Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243030
b: refs/heads/master
c: 99bdc38
h: refs/heads/master
v: v3
  • Loading branch information
Joel Becker committed Mar 28, 2011
1 parent e6bad32 commit 580dff8
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 87 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b4e1b7e88b2c87c358c2a88bec0c76d25accc604
refs/heads/master: 99bdc3880c611c7f2061fbd5372ef81b40217e26
10 changes: 5 additions & 5 deletions trunk/fs/ocfs2/cluster/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ static inline void o2net_set_func_stop_time(struct o2net_sock_container *sc)
sc->sc_tv_func_stop = ktime_get();
}

static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc)
{
return ktime_sub(sc->sc_tv_func_stop, sc->sc_tv_func_start);
}
#else /* CONFIG_DEBUG_FS */
# define o2net_init_nst(a, b, c, d, e)
# define o2net_set_nst_sock_time(a)
Expand All @@ -227,10 +223,14 @@ static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc)
# define o2net_set_advance_stop_time(a)
# define o2net_set_func_start_time(a)
# define o2net_set_func_stop_time(a)
# define o2net_get_func_run_time(a) (ktime_t)0
#endif /* CONFIG_DEBUG_FS */

#ifdef CONFIG_OCFS2_FS_STATS
static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc)
{
return ktime_sub(sc->sc_tv_func_stop, sc->sc_tv_func_start);
}

static void o2net_update_send_stats(struct o2net_send_tracking *nst,
struct o2net_sock_container *sc)
{
Expand Down
12 changes: 7 additions & 5 deletions trunk/fs/ocfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,23 @@ static int ocfs2_check_dir_entry(struct inode * dir,
const char *error_msg = NULL;
const int rlen = le16_to_cpu(de->rec_len);

if (rlen < OCFS2_DIR_REC_LEN(1))
if (unlikely(rlen < OCFS2_DIR_REC_LEN(1)))
error_msg = "rec_len is smaller than minimal";
else if (rlen % 4 != 0)
else if (unlikely(rlen % 4 != 0))
error_msg = "rec_len % 4 != 0";
else if (rlen < OCFS2_DIR_REC_LEN(de->name_len))
else if (unlikely(rlen < OCFS2_DIR_REC_LEN(de->name_len)))
error_msg = "rec_len is too small for name_len";
else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)
else if (unlikely(
((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize))
error_msg = "directory entry across blocks";

if (error_msg != NULL)
if (unlikely(error_msg != NULL))
mlog(ML_ERROR, "bad entry in directory #%llu: %s - "
"offset=%lu, inode=%llu, rec_len=%d, name_len=%d\n",
(unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg,
offset, (unsigned long long)le64_to_cpu(de->inode), rlen,
de->name_len);

return error_msg == NULL ? 1 : 0;
}

Expand Down
28 changes: 16 additions & 12 deletions trunk/fs/ocfs2/dlm/dlmdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,10 @@ static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data,
}

static int dlm_match_regions(struct dlm_ctxt *dlm,
struct dlm_query_region *qr)
struct dlm_query_region *qr,
char *local, int locallen)
{
char *local = NULL, *remote = qr->qr_regions;
char *remote = qr->qr_regions;
char *l, *r;
int localnr, i, j, foundit;
int status = 0;
Expand Down Expand Up @@ -957,13 +958,8 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,
r += O2HB_MAX_REGION_NAME_LEN;
}

local = kmalloc(sizeof(qr->qr_regions), GFP_ATOMIC);
if (!local) {
status = -ENOMEM;
goto bail;
}

localnr = o2hb_get_all_regions(local, O2NM_MAX_REGIONS);
localnr = min(O2NM_MAX_REGIONS, locallen/O2HB_MAX_REGION_NAME_LEN);
localnr = o2hb_get_all_regions(local, (u8)localnr);

/* compare local regions with remote */
l = local;
Expand Down Expand Up @@ -1012,8 +1008,6 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,
}

bail:
kfree(local);

return status;
}

Expand Down Expand Up @@ -1075,6 +1069,7 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len,
{
struct dlm_query_region *qr;
struct dlm_ctxt *dlm = NULL;
char *local = NULL;
int status = 0;
int locked = 0;

Expand All @@ -1083,6 +1078,13 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len,
mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node,
qr->qr_domain);

/* buffer used in dlm_mast_regions() */
local = kmalloc(sizeof(qr->qr_regions), GFP_KERNEL);
if (!local) {
status = -ENOMEM;
goto bail;
}

status = -EINVAL;

spin_lock(&dlm_domain_lock);
Expand Down Expand Up @@ -1112,13 +1114,15 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len,
goto bail;
}

status = dlm_match_regions(dlm, qr);
status = dlm_match_regions(dlm, qr, local, sizeof(qr->qr_regions));

bail:
if (locked)
spin_unlock(&dlm->spinlock);
spin_unlock(&dlm_domain_lock);

kfree(local);

return status;
}

Expand Down
97 changes: 50 additions & 47 deletions trunk/fs/ocfs2/dlmglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct ocfs2_mask_waiter {
unsigned long mw_mask;
unsigned long mw_goal;
#ifdef CONFIG_OCFS2_FS_STATS
unsigned long long mw_lock_start;
ktime_t mw_lock_start;
#endif
};

Expand Down Expand Up @@ -431,44 +431,41 @@ static void ocfs2_remove_lockres_tracking(struct ocfs2_lock_res *res)
#ifdef CONFIG_OCFS2_FS_STATS
static void ocfs2_init_lock_stats(struct ocfs2_lock_res *res)
{
res->l_lock_num_prmode = 0;
res->l_lock_num_prmode_failed = 0;
res->l_lock_total_prmode = 0;
res->l_lock_max_prmode = 0;
res->l_lock_num_exmode = 0;
res->l_lock_num_exmode_failed = 0;
res->l_lock_total_exmode = 0;
res->l_lock_max_exmode = 0;
res->l_lock_refresh = 0;
memset(&res->l_lock_prmode, 0, sizeof(struct ocfs2_lock_stats));
memset(&res->l_lock_exmode, 0, sizeof(struct ocfs2_lock_stats));
}

static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level,
struct ocfs2_mask_waiter *mw, int ret)
{
unsigned long long *num, *sum;
unsigned int *max, *failed;
struct timespec ts = current_kernel_time();
unsigned long long time = timespec_to_ns(&ts) - mw->mw_lock_start;

if (level == LKM_PRMODE) {
num = &res->l_lock_num_prmode;
sum = &res->l_lock_total_prmode;
max = &res->l_lock_max_prmode;
failed = &res->l_lock_num_prmode_failed;
} else if (level == LKM_EXMODE) {
num = &res->l_lock_num_exmode;
sum = &res->l_lock_total_exmode;
max = &res->l_lock_max_exmode;
failed = &res->l_lock_num_exmode_failed;
} else
u32 usec;
ktime_t kt;
struct ocfs2_lock_stats *stats;

if (level == LKM_PRMODE)
stats = &res->l_lock_prmode;
else if (level == LKM_EXMODE)
stats = &res->l_lock_exmode;
else
return;

(*num)++;
(*sum) += time;
if (time > *max)
*max = time;
kt = ktime_sub(ktime_get(), mw->mw_lock_start);
usec = ktime_to_us(kt);

stats->ls_gets++;
stats->ls_total += ktime_to_ns(kt);
/* overflow */
if (unlikely(stats->ls_gets) == 0) {
stats->ls_gets++;
stats->ls_total = ktime_to_ns(kt);
}

if (stats->ls_max < usec)
stats->ls_max = usec;

if (ret)
(*failed)++;
stats->ls_fail++;
}

static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres)
Expand All @@ -478,8 +475,7 @@ static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres)

static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw)
{
struct timespec ts = current_kernel_time();
mw->mw_lock_start = timespec_to_ns(&ts);
mw->mw_lock_start = ktime_get();
}
#else
static inline void ocfs2_init_lock_stats(struct ocfs2_lock_res *res)
Expand Down Expand Up @@ -2774,8 +2770,15 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
return iter;
}

/* So that debugfs.ocfs2 can determine which format is being used */
#define OCFS2_DLM_DEBUG_STR_VERSION 2
/*
* Version is used by debugfs.ocfs2 to determine the format being used
*
* New in version 2
* - Lock stats printed
* New in version 3
* - Max time in lock stats is in usecs (instead of nsecs)
*/
#define OCFS2_DLM_DEBUG_STR_VERSION 3
static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
{
int i;
Expand Down Expand Up @@ -2817,18 +2820,18 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
seq_printf(m, "0x%x\t", lvb[i]);

#ifdef CONFIG_OCFS2_FS_STATS
# define lock_num_prmode(_l) (_l)->l_lock_num_prmode
# define lock_num_exmode(_l) (_l)->l_lock_num_exmode
# define lock_num_prmode_failed(_l) (_l)->l_lock_num_prmode_failed
# define lock_num_exmode_failed(_l) (_l)->l_lock_num_exmode_failed
# define lock_total_prmode(_l) (_l)->l_lock_total_prmode
# define lock_total_exmode(_l) (_l)->l_lock_total_exmode
# define lock_max_prmode(_l) (_l)->l_lock_max_prmode
# define lock_max_exmode(_l) (_l)->l_lock_max_exmode
# define lock_refresh(_l) (_l)->l_lock_refresh
# define lock_num_prmode(_l) ((_l)->l_lock_prmode.ls_gets)
# define lock_num_exmode(_l) ((_l)->l_lock_exmode.ls_gets)
# define lock_num_prmode_failed(_l) ((_l)->l_lock_prmode.ls_fail)
# define lock_num_exmode_failed(_l) ((_l)->l_lock_exmode.ls_fail)
# define lock_total_prmode(_l) ((_l)->l_lock_prmode.ls_total)
# define lock_total_exmode(_l) ((_l)->l_lock_exmode.ls_total)
# define lock_max_prmode(_l) ((_l)->l_lock_prmode.ls_max)
# define lock_max_exmode(_l) ((_l)->l_lock_exmode.ls_max)
# define lock_refresh(_l) ((_l)->l_lock_refresh)
#else
# define lock_num_prmode(_l) (0ULL)
# define lock_num_exmode(_l) (0ULL)
# define lock_num_prmode(_l) (0)
# define lock_num_exmode(_l) (0)
# define lock_num_prmode_failed(_l) (0)
# define lock_num_exmode_failed(_l) (0)
# define lock_total_prmode(_l) (0ULL)
Expand All @@ -2838,8 +2841,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v)
# define lock_refresh(_l) (0)
#endif
/* The following seq_print was added in version 2 of this output */
seq_printf(m, "%llu\t"
"%llu\t"
seq_printf(m, "%u\t"
"%u\t"
"%u\t"
"%u\t"
"%llu\t"
Expand Down
38 changes: 30 additions & 8 deletions trunk/fs/ocfs2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ static inline void __o2info_set_request_error(struct ocfs2_info_request *kreq,
#define o2info_set_request_error(a, b) \
__o2info_set_request_error((struct ocfs2_info_request *)&(a), b)

static inline void __o2info_set_request_filled(struct ocfs2_info_request *req)
{
req->ir_flags |= OCFS2_INFO_FL_FILLED;
}

#define o2info_set_request_filled(a) \
__o2info_set_request_filled((struct ocfs2_info_request *)&(a))

static inline void __o2info_clear_request_filled(struct ocfs2_info_request *req)
{
req->ir_flags &= ~OCFS2_INFO_FL_FILLED;
}

#define o2info_clear_request_filled(a) \
__o2info_clear_request_filled((struct ocfs2_info_request *)&(a))

static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags)
{
int status;
Expand Down Expand Up @@ -136,7 +152,8 @@ int ocfs2_info_handle_blocksize(struct inode *inode,
goto bail;

oib.ib_blocksize = inode->i_sb->s_blocksize;
oib.ib_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oib);

if (o2info_to_user(oib, req))
goto bail;
Expand All @@ -160,7 +177,8 @@ int ocfs2_info_handle_clustersize(struct inode *inode,
goto bail;

oic.ic_clustersize = osb->s_clustersize;
oic.ic_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oic);

if (o2info_to_user(oic, req))
goto bail;
Expand All @@ -184,7 +202,8 @@ int ocfs2_info_handle_maxslots(struct inode *inode,
goto bail;

oim.im_max_slots = osb->max_slots;
oim.im_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oim);

if (o2info_to_user(oim, req))
goto bail;
Expand All @@ -208,7 +227,8 @@ int ocfs2_info_handle_label(struct inode *inode,
goto bail;

memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN);
oil.il_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oil);

if (o2info_to_user(oil, req))
goto bail;
Expand All @@ -232,7 +252,8 @@ int ocfs2_info_handle_uuid(struct inode *inode,
goto bail;

memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1);
oiu.iu_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oiu);

if (o2info_to_user(oiu, req))
goto bail;
Expand All @@ -258,7 +279,8 @@ int ocfs2_info_handle_fs_features(struct inode *inode,
oif.if_compat_features = osb->s_feature_compat;
oif.if_incompat_features = osb->s_feature_incompat;
oif.if_ro_compat_features = osb->s_feature_ro_compat;
oif.if_req.ir_flags |= OCFS2_INFO_FL_FILLED;

o2info_set_request_filled(oif);

if (o2info_to_user(oif, req))
goto bail;
Expand All @@ -283,7 +305,7 @@ int ocfs2_info_handle_journal_size(struct inode *inode,

oij.ij_journal_size = osb->journal->j_inode->i_size;

oij.ij_req.ir_flags |= OCFS2_INFO_FL_FILLED;
o2info_set_request_filled(oij);

if (o2info_to_user(oij, req))
goto bail;
Expand All @@ -305,7 +327,7 @@ int ocfs2_info_handle_unknown(struct inode *inode,
if (o2info_from_user(oir, req))
goto bail;

oir.ir_flags &= ~OCFS2_INFO_FL_FILLED;
o2info_clear_request_filled(oir);

if (o2info_to_user(oir, req))
goto bail;
Expand Down
Loading

0 comments on commit 580dff8

Please sign in to comment.