From f957caaa9b2afa4777bf7dbb573354421811681a Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 12 Mar 2012 14:45:13 -0500 Subject: [PATCH] LU-673 llite: Add some metadata stats, fix some file stats. Add LPROC_LL_CREATE, LPROC_LL_LINK, LPROC_LL_UNLINK, LPROC_LL_SYMLINK, LPROC_LL_MKDIR, LPROC_LL_RMDIR, LPROC_LL_MKNOD, and LPROC_LL_RENAME for successful calls to the corresponding directory inode operations. Add LPROC_LL_READDIR for successful calls to ll_readdir(). Tally LPROC_LL_OPEN if and only if the call succeeds. Under the previous behavior, opens of a file that was already open locally with the same flags were not tallied. Do not tally LPROC_LL_SETATTR when the setattr is from truncate() or truncate from open(). Tally LPROC_LL_TRUNC when appropriate in ll_setattr_raw(), but remove tallies in ll_truncate() and vvp_io_init(). Under the previous behavior, a single call to truncate() caused LPROC_LL_TRUNC to be tallied 3 times (and similarly for truncate from open()). Remove the unused stats LPROC_LL_WB_WRITEPAGE, LPROC_LL_WB_PRESSURE, LPROC_LL_WB_OK, LPROC_LL_WB_FAIL, LPROC_LL_LOCKLESS_TRUNC, LPROC_LL_DIRECT_READ, LPROC_LL_DIRECT_WRITE, LPROC_LL_LOCKLESS_READ, and LPROC_LL_LOCKLESS_WRITE. Change-Id: Id286a6eb986088ea109da2e6c6e31b9d21a34562 Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/1360 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/include/linux/lustre_lite.h | 46 ++++++++------------------------------ lustre/llite/dir.c | 6 ++++- lustre/llite/file.c | 5 ++--- lustre/llite/llite_lib.c | 12 +++++++--- lustre/llite/lproc_llite.c | 29 +++++++++--------------- lustre/llite/namei.c | 22 +++++++++++++++++- lustre/llite/rw.c | 2 -- lustre/llite/vvp_io.c | 7 +----- 8 files changed, 57 insertions(+), 72 deletions(-) diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index 6087969..0c1d8e8 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -59,42 +59,10 @@ #include #include -#ifdef HAVE_PERCPU_COUNTER -#include - -typedef struct percpu_counter lcounter_t; - -#define lcounter_read(counter) (int)percpu_counter_read(counter) -#define lcounter_inc(counter) percpu_counter_inc(counter) -#define lcounter_dec(counter) percpu_counter_dec(counter) - -#ifdef HAVE_PERCPU_2ND_ARG -# define lcounter_init(counter) percpu_counter_init(counter, 0) -#else -# define lcounter_init(counter) percpu_counter_init(counter) -#endif - -#define lcounter_destroy(counter) percpu_counter_destroy(counter) - -#else -typedef struct { cfs_atomic_t count; } lcounter_t; - -#define lcounter_read(counter) cfs_atomic_read(&counter->count) -#define lcounter_inc(counter) cfs_atomic_inc(&counter->count) -#define lcounter_dec(counter) cfs_atomic_dec(&counter->count) -#define lcounter_init(counter) cfs_atomic_set(&counter->count, 0) -#define lcounter_destroy(counter) - -#endif /* if defined HAVE_PERCPU_COUNTER */ - /* lprocfs.c */ enum { LPROC_LL_DIRTY_HITS = 0, LPROC_LL_DIRTY_MISSES, - LPROC_LL_WB_WRITEPAGE, - LPROC_LL_WB_PRESSURE, - LPROC_LL_WB_OK, - LPROC_LL_WB_FAIL, LPROC_LL_READ_BYTES, LPROC_LL_WRITE_BYTES, LPROC_LL_BRW_READ, @@ -107,11 +75,19 @@ enum { LPROC_LL_MAP, LPROC_LL_LLSEEK, LPROC_LL_FSYNC, + LPROC_LL_READDIR, LPROC_LL_SETATTR, LPROC_LL_TRUNC, - LPROC_LL_LOCKLESS_TRUNC, LPROC_LL_FLOCK, LPROC_LL_GETATTR, + LPROC_LL_CREATE, + LPROC_LL_LINK, + LPROC_LL_UNLINK, + LPROC_LL_SYMLINK, + LPROC_LL_MKDIR, + LPROC_LL_RMDIR, + LPROC_LL_MKNOD, + LPROC_LL_RENAME, LPROC_LL_STAFS, LPROC_LL_ALLOC_INODE, LPROC_LL_SETXATTR, @@ -119,10 +95,6 @@ enum { LPROC_LL_LISTXATTR, LPROC_LL_REMOVEXATTR, LPROC_LL_INODE_PERM, - LPROC_LL_DIRECT_READ, - LPROC_LL_DIRECT_WRITE, - LPROC_LL_LOCKLESS_READ, - LPROC_LL_LOCKLESS_WRITE, LPROC_LL_FILE_OPCODES }; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 2718683..0e0258a 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -525,7 +525,7 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) /* * end-of-file. */ - RETURN(0); + GOTO(out, rc = 0); rc = 0; done = 0; @@ -644,6 +644,10 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) ll_dir_chain_fini(&chain); +out: + if (!rc) + ll_stats_ops_tally(sbi, LPROC_LL_READDIR, 1); + RETURN(rc); } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index c458bb4..4282d49 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -587,8 +587,6 @@ restart: } ll_release_openhandle(file->f_dentry, it); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, - LPROC_LL_OPEN); } (*och_usecount)++; @@ -632,7 +630,6 @@ restart: LASSERT(it_disposition(it, DISP_ENQ_OPEN_REF)); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1); rc = ll_local_open(file, it, fd, *och_p); if (rc) GOTO(out_och_free, rc); @@ -678,6 +675,8 @@ out_openerr: ll_stop_statahead(inode, lli->lli_opendir_key); if (fd != NULL) ll_file_data_put(fd); + } else { + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1); } return rc; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 8a2d3fb..76bc5d0 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1321,7 +1321,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu valid %x\n", inode->i_ino, attr->ia_valid); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETATTR, 1); if (ia_valid & ATTR_SIZE) { /* Check new size against VFS/VM file size limit and rlimit */ @@ -1422,13 +1421,20 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) EXIT; out: if (op_data) { - if (op_data->op_ioepoch) + if (op_data->op_ioepoch) { rc1 = ll_setattr_done_writing(inode, op_data, mod); + if (!rc) + rc = rc1; + } ll_finish_md_op_data(op_data); } if (!S_ISDIR(inode->i_mode)) cfs_up_write(&lli->lli_trunc_sem); - return rc ? rc : rc1; + + ll_stats_ops_tally(ll_i2sbi(inode), (ia_valid & ATTR_SIZE) ? + LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1); + + return rc; } int ll_setattr(struct dentry *de, struct iattr *attr) diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 0c65339..b4f28e5 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -695,14 +695,6 @@ struct llite_file_opcode { /* file operation */ { LPROC_LL_DIRTY_HITS, LPROCFS_TYPE_REGS, "dirty_pages_hits" }, { LPROC_LL_DIRTY_MISSES, LPROCFS_TYPE_REGS, "dirty_pages_misses" }, - { LPROC_LL_WB_WRITEPAGE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "writeback_from_writepage" }, - { LPROC_LL_WB_PRESSURE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "writeback_from_pressure" }, - { LPROC_LL_WB_OK, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "writeback_ok_pages" }, - { LPROC_LL_WB_FAIL, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "writeback_failed_pages" }, { LPROC_LL_READ_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES, "read_bytes" }, { LPROC_LL_WRITE_BYTES, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES, @@ -715,19 +707,27 @@ struct llite_file_opcode { "osc_read" }, { LPROC_LL_OSC_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES, "osc_write" }, - { LPROC_LL_IOCTL, LPROCFS_TYPE_REGS, "ioctl" }, { LPROC_LL_OPEN, LPROCFS_TYPE_REGS, "open" }, { LPROC_LL_RELEASE, LPROCFS_TYPE_REGS, "close" }, { LPROC_LL_MAP, LPROCFS_TYPE_REGS, "mmap" }, { LPROC_LL_LLSEEK, LPROCFS_TYPE_REGS, "seek" }, { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" }, + { LPROC_LL_READDIR, LPROCFS_TYPE_REGS, "readdir" }, /* inode operation */ { LPROC_LL_SETATTR, LPROCFS_TYPE_REGS, "setattr" }, { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "truncate" }, - { LPROC_LL_LOCKLESS_TRUNC, LPROCFS_TYPE_REGS, "lockless_truncate"}, { LPROC_LL_FLOCK, LPROCFS_TYPE_REGS, "flock" }, { LPROC_LL_GETATTR, LPROCFS_TYPE_REGS, "getattr" }, + /* dir inode operation */ + { LPROC_LL_CREATE, LPROCFS_TYPE_REGS, "create" }, + { LPROC_LL_LINK, LPROCFS_TYPE_REGS, "link" }, + { LPROC_LL_UNLINK, LPROCFS_TYPE_REGS, "unlink" }, + { LPROC_LL_SYMLINK, LPROCFS_TYPE_REGS, "symlink" }, + { LPROC_LL_MKDIR, LPROCFS_TYPE_REGS, "mkdir" }, + { LPROC_LL_RMDIR, LPROCFS_TYPE_REGS, "rmdir" }, + { LPROC_LL_MKNOD, LPROCFS_TYPE_REGS, "mknod" }, + { LPROC_LL_RENAME, LPROCFS_TYPE_REGS, "rename" }, /* special inode operation */ { LPROC_LL_STAFS, LPROCFS_TYPE_REGS, "statfs" }, { LPROC_LL_ALLOC_INODE, LPROCFS_TYPE_REGS, "alloc_inode" }, @@ -736,15 +736,6 @@ struct llite_file_opcode { { LPROC_LL_LISTXATTR, LPROCFS_TYPE_REGS, "listxattr" }, { LPROC_LL_REMOVEXATTR, LPROCFS_TYPE_REGS, "removexattr" }, { LPROC_LL_INODE_PERM, LPROCFS_TYPE_REGS, "inode_permission" }, - { LPROC_LL_DIRECT_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "direct_read" }, - { LPROC_LL_DIRECT_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_PAGES, - "direct_write" }, - { LPROC_LL_LOCKLESS_READ, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES, - "lockless_read_bytes" }, - { LPROC_LL_LOCKLESS_WRITE, LPROCFS_CNTR_AVGMINMAX|LPROCFS_TYPE_BYTES, - "lockless_write_bytes" }, - }; void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 0d32bf7..06a4a67 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -898,6 +898,10 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, default: err = -EINVAL; } + + if (!err) + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1); + RETURN(err); } @@ -932,6 +936,9 @@ out: ll_intent_release(it); OBD_FREE(it, sizeof(*it)); + if (!rc) + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_CREATE, 1); + return rc; } @@ -947,6 +954,10 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, err = ll_new_node(dir, name, (char *)tgt, S_IFLNK | S_IRWXUGO, 0, dchild, LUSTRE_OPC_SYMLINK); + + if (!err) + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_SYMLINK, 1); + RETURN(err); } @@ -977,6 +988,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, d_drop(dchild); ll_update_times(request, dir); + ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); EXIT; out: ptlrpc_req_finished(request); @@ -996,6 +1008,9 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, mode = (mode & (S_IRWXUGO|S_ISVTX) & ~cfs_curproc_umask()) | S_IFDIR; err = ll_new_node(dir, name, NULL, mode, 0, dchild, LUSTRE_OPC_MKDIR); + if (!err) + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKDIR, 1); + RETURN(err); } @@ -1037,8 +1052,11 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, ll_get_child_fid(dir, name, &op_data->op_fid3); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); - if (rc == 0) + if (rc == 0) { ll_update_times(request, dir); + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_RMDIR, 1); + } + ptlrpc_req_finished(request); RETURN(rc); } @@ -1152,6 +1170,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, GOTO(out, rc); ll_update_times(request, dir); + ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1); rc = ll_objects_destroy(request, dir); out: @@ -1192,6 +1211,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, if (!err) { ll_update_times(request, src); ll_update_times(request, tgt); + ll_stats_ops_tally(sbi, LPROC_LL_RENAME, 1); err = ll_objects_destroy(request, src); } diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index fee99b3..2a546c8 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -80,8 +80,6 @@ void ll_truncate(struct inode *inode) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %llu\n", inode->i_ino, inode->i_generation, inode, i_size_read(inode)); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_TRUNC, 1); - EXIT; return; } /* ll_truncate */ diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 253d13a..1647399 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1108,8 +1108,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, { struct vvp_io *vio = vvp_env_io(env); struct ccc_io *cio = ccc_env_io(env); - struct inode *inode = ccc_object_inode(obj); - struct ll_sb_info *sbi = ll_i2sbi(inode); int result; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); @@ -1132,10 +1130,7 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, cio->cui_tot_nrsegs = 0; } } else if (io->ci_type == CIT_SETATTR) { - if (cl_io_is_trunc(io)) - /* lockless truncate? */ - ll_stats_ops_tally(sbi, LPROC_LL_TRUNC, 1); - else + if (!cl_io_is_trunc(io)) io->ci_lockreq = CILR_MANDATORY; } RETURN(result); -- 1.8.3.1