diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index 9e09a069bb0725981f8f31c8cfcaccecb19016fe..dacc1bc071e4e13c07eeffd85bb3ebea009803bd 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -50,6 +50,7 @@ enum { LPROC_LL_FSYNC, LPROC_LL_SETATTR, LPROC_LL_TRUNC, + LPROC_LL_FLOCK, #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) LPROC_LL_GETATTR, @@ -60,7 +61,9 @@ enum { LPROC_LL_ALLOC_INODE, LPROC_LL_SETXATTR, LPROC_LL_GETXATTR, - + LPROC_LL_LISTXATTR, + LPROC_LL_REMOVEXATTR, + LPROC_LL_INODE_PERM, LPROC_LL_DIRECT_READ, LPROC_LL_DIRECT_WRITE, LPROC_LL_FILE_OPCODES diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index a6895d7a8439e6dcbad2e6975aee59b54fb596a0..34d2c7dc1da22f9f97b07e671219ce303a0cbabf 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -491,7 +491,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (_IOC_TYPE(cmd) == 'T' || _IOC_TYPE(cmd) == 't') /* tty ioctls */ return -ENOTTY; - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_IOCTL, 1); switch(cmd) { case EXT3_IOC_GETFLAGS: case EXT3_IOC_SETFLAGS: diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 0db3cb4c635cb2603e30211b3e5f5c145d5a0fd9..1bf51df59d6918a173c793db6dbad639d6fd3add 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -234,14 +234,12 @@ int ll_file_release(struct inode *inode, struct file *file) ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - ll_vfs_ops_tally(sbi, VFS_OPS_RELEASE); /* don't do anything for / */ if (inode->i_sb->s_root == file->f_dentry) RETURN(0); - lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_RELEASE); - + ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1); fd = LUSTRE_FPRIVATE(file); LASSERT(fd != NULL); @@ -385,7 +383,6 @@ int ll_file_open(struct inode *inode, struct file *file) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_OPEN); /* don't do anything for / */ if (inode->i_sb->s_root == file->f_dentry) @@ -494,7 +491,7 @@ int ll_file_open(struct inode *inode, struct file *file) GOTO(out_och_free, rc); } - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_OPEN); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_OPEN, 1); rc = ll_local_open(file, it, fd, *och_p); LASSERTF(rc == 0, "rc = %d\n", rc); } @@ -1162,14 +1159,12 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),size="LPSZ",offset=%Ld\n", inode->i_ino, inode->i_generation, inode, count, *ppos); - ll_vfs_ops_tally(sbi, VFS_OPS_READ); - /* "If nbyte is 0, read() will return 0 and have no other results." * -- Single Unix Spec */ if (count == 0) RETURN(0); - lprocfs_counter_add(sbi->ll_stats, LPROC_LL_READ_BYTES, count); + ll_stats_ops_tally(sbi, LPROC_LL_READ_BYTES, count); if (!lsm) { /* Read on file with no objects should return zero-filled @@ -1287,7 +1282,7 @@ repeat: /* BUG: 5972 */ file_accessed(file); retval = generic_file_read(file, buf, chunk, ppos); - ll_rw_stats_tally(ll_i2sbi(inode), current->pid, file, count, 0); + ll_rw_stats_tally(sbi, current->pid, file, count, 0); ll_tree_unlock(&tree); @@ -1325,7 +1320,6 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),size="LPSZ",offset=%Ld\n", inode->i_ino, inode->i_generation, inode, count, *ppos); - ll_vfs_ops_tally(sbi, VFS_OPS_WRITE); SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */ @@ -1417,8 +1411,8 @@ out: up(&ll_i2info(inode)->lli_write_sem); retval = (sum > 0) ? sum : retval; - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, LPROC_LL_WRITE_BYTES, - retval > 0 ? retval : 0); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_WRITE_BYTES, + retval > 0 ? retval : 0); RETURN(retval); } @@ -1448,9 +1442,7 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count, if (count == 0) RETURN(0); - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, LPROC_LL_READ_BYTES, - count); - + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_READ_BYTES, count); /* turn off the kernel's read-ahead */ in_file->f_ra.ra_pages = 0; @@ -2065,13 +2057,12 @@ int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd, CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),cmd=%x\n", inode->i_ino, inode->i_generation, inode, cmd); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_IOCTL); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_IOCTL, 1); /* asm-ppc{,64} declares TCGETS, et. al. as type 't' not 'T' */ if (_IOC_TYPE(cmd) == 'T' || _IOC_TYPE(cmd) == 't') /* tty ioctls */ RETURN(-ENOTTY); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_IOCTL); switch(cmd) { case LL_IOC_GETFLAGS: /* Get the current value of the file flags */ @@ -2154,8 +2145,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%Lu=%#Lx(%s)\n", inode->i_ino, inode->i_generation, inode, retval, retval, origin == 2 ? "SEEK_END": origin == 1 ? "SEEK_CUR" : "SEEK_SET"); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_SEEK); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_LLSEEK); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LLSEEK, 1); if (origin == 2) { /* SEEK_END */ int nonblock = 0, rc; @@ -2202,8 +2192,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_FSYNC); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_FSYNC); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1); /* fsync's caller has already called _fdata{sync,write}, we want * that IO to finish before calling the osc and mdc sync methods */ @@ -2264,7 +2253,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n", inode->i_ino, file_lock); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_FLOCK); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FLOCK, 1); if (file_lock->fl_flags & FL_FLOCK) { LASSERT((cmd == F_SETLKW) || (cmd == F_SETLK)); @@ -2415,7 +2404,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%s\n", inode->i_ino, inode->i_generation, inode, dentry->d_name.name); #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)) - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_REVALIDATE); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REVALIDATE, 1); #endif exp = ll_i2mdcexp(inode); @@ -2501,7 +2490,7 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, int res = 0; res = ll_inode_revalidate_it(de, it); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_GETATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETATTR, 1); if (res) return res; @@ -2533,7 +2522,6 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat) { struct lookup_intent it = { .it_op = IT_GETATTR }; - ll_vfs_ops_tally(ll_i2sbi(de->d_inode), VFS_OPS_GETATTR); return ll_getattr_it(mnt, de, &it, stat); } #endif @@ -2569,7 +2557,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), mask %o\n", inode->i_ino, inode->i_generation, inode, mask); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_INODE_PERMISSION); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); return generic_permission(inode, mask, lustre_check_acl); } #else @@ -2584,7 +2572,7 @@ int ll_inode_permission(struct inode *inode, int mask) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), mask %o\n", inode->i_ino, inode->i_generation, inode, mask); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_INODE_PERMISSION); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); if ((mask & MAY_WRITE) && IS_RDONLY(inode) && (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 07e5646c649705180751abd9685af40ba9e87ef0..71b8115059adde58735de4ae42833f5cc1114599 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -190,33 +190,13 @@ struct ll_rw_process_info { struct file *rw_last_file; }; -enum vfs_ops_list { - VFS_OPS_READ = 0, - VFS_OPS_WRITE, - VFS_OPS_IOCTL, - VFS_OPS_OPEN, - VFS_OPS_RELEASE, - VFS_OPS_MMAP, - VFS_OPS_SEEK, - VFS_OPS_FSYNC, - VFS_OPS_FLOCK, - VFS_OPS_SETATTR, - VFS_OPS_GETATTR, - VFS_OPS_SETXATTR, - VFS_OPS_GETXATTR, - VFS_OPS_LISTXATTR, - VFS_OPS_REMOVEXATTR, - VFS_OPS_TRUNCATE, - VFS_OPS_INODE_PERMISSION, - VFS_OPS_LAST, -}; -enum vfs_track_type { - VFS_TRACK_ALL = 0, /* track all processes */ - VFS_TRACK_PID, /* track process with this pid */ - VFS_TRACK_PPID, /* track processes with this ppid */ - VFS_TRACK_GID, /* track processes with this gid */ - VFS_TRACK_LAST, +enum stats_track_type { + STATS_TRACK_ALL = 0, /* track all processes */ + STATS_TRACK_PID, /* track process with this pid */ + STATS_TRACK_PPID, /* track processes with this ppid */ + STATS_TRACK_GID, /* track processes with this gid */ + STATS_TRACK_LAST, }; /* flags for sbi->ll_flags */ @@ -233,6 +213,8 @@ struct ll_sb_info { /* this protects pglist and ra_info. It isn't safe to * grab from interrupt contexts */ spinlock_t ll_lock; + spinlock_t ll_pp_extent_lock; /* Lock for pp_extent entries */ + spinlock_t ll_process_lock; /* Lock for ll_rw_process_info */ struct obd_uuid ll_sb_uuid; struct obd_export *ll_mdc_exp; struct obd_export *ll_osc_exp; @@ -272,9 +254,9 @@ struct ll_sb_info { unsigned int ll_offset_process_count; struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX]; unsigned int ll_rw_offset_entry_count; - struct lprocfs_stats *ll_vfs_ops_stats; - enum vfs_track_type ll_vfs_track_type; - int ll_vfs_track_id; + enum stats_track_type ll_stats_track_type; + int ll_stats_track_id; + int ll_rw_stats_on; }; #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) @@ -436,12 +418,12 @@ struct ll_ra_read *ll_ra_read_get(struct file *f); int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct super_block *sb, char *osc, char *mdc); void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); -void ll_vfs_ops_tally(struct ll_sb_info *sbi, int op); +void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); #else static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct super_block *sb, char *osc, char *mdc){return 0;} static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {} -static void ll_vfs_ops_tally(struct ll_sb_info *sbi, int op) {} +static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} #endif diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index fbe0526ee3d74cad667db1c356ee54c0f8bee261..7d5fe8e8605f6c35656f584c88d3f1a0039bfbb0 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -62,6 +62,9 @@ static struct ll_sb_info *ll_init_sbi(void) spin_lock_init(&sbi->ll_lock); spin_lock_init(&sbi->ll_lco.lco_lock); + spin_lock_init(&sbi->ll_pp_extent_lock); + spin_lock_init(&sbi->ll_process_lock); + sbi->ll_rw_stats_on = 0; INIT_LIST_HEAD(&sbi->ll_pglist); if (num_physpages >> (20 - CFS_PAGE_SHIFT) < 512) sbi->ll_async_page_max = num_physpages / 2; @@ -1198,7 +1201,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu valid %x\n", inode->i_ino, attr->ia_valid); - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETATTR, 1); if (ia_valid & ATTR_SIZE) { if (attr->ia_size > ll_file_maxbytes(inode)) { @@ -1373,8 +1376,6 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) int ll_setattr(struct dentry *de, struct iattr *attr) { - ll_vfs_ops_tally(ll_i2sbi(de->d_inode), VFS_OPS_SETATTR); - if ((attr->ia_valid & (ATTR_CTIME|ATTR_SIZE|ATTR_MODE)) == (ATTR_CTIME|ATTR_SIZE|ATTR_MODE)) attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; @@ -1440,7 +1441,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) int rc; CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64()); - lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS); + ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); /* For now we will always get up-to-date statfs values, but in the * future we may allow some amount of caching on the client (e.g. diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index f1ff91a6407a20eed07cb45f8f95d39f3a099c8c..bba41b43020f152303412cb23f98f7c2acfa525d 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -628,7 +628,7 @@ int ll_file_mmap(struct file * file, struct vm_area_struct * vma) int rc; ENTRY; - ll_vfs_ops_tally(ll_i2sbi(file->f_dentry->d_inode), VFS_OPS_MMAP); + ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode), LPROC_LL_MAP, 1); rc = generic_file_mmap(file, vma); if (rc == 0) { #if !defined(HAVE_FILEMAP_POPULATE) && \ diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 23841d645c42def017236e0cbfc1f5f11c4c79d6..53591ec0c3ae2ebaa152c77a1f50ba19662cf72e 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -368,15 +368,15 @@ static int ll_wr_max_rw_chunk(struct file *file, const char *buffer, } static int ll_rd_track_id(char *page, int count, void *data, - enum vfs_track_type type) + enum stats_track_type type) { struct super_block *sb = data; - if (ll_s2sbi(sb)->ll_vfs_track_type == type) { + if (ll_s2sbi(sb)->ll_stats_track_type == type) { return snprintf(page, count, "%d\n", - ll_s2sbi(sb)->ll_vfs_track_id); + ll_s2sbi(sb)->ll_stats_track_id); - } else if (ll_s2sbi(sb)->ll_vfs_track_type == VFS_TRACK_ALL) { + } else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL) { return snprintf(page, count, "0 (all)\n"); } else { return snprintf(page, count, "untracked\n"); @@ -384,7 +384,7 @@ static int ll_rd_track_id(char *page, int count, void *data, } static int ll_wr_track_id(const char *buffer, unsigned long count, void *data, - enum vfs_track_type type) + enum stats_track_type type) { struct super_block *sb = data; int rc, pid; @@ -392,49 +392,49 @@ static int ll_wr_track_id(const char *buffer, unsigned long count, void *data, rc = lprocfs_write_helper(buffer, count, &pid); if (rc) return rc; - ll_s2sbi(sb)->ll_vfs_track_id = pid; + ll_s2sbi(sb)->ll_stats_track_id = pid; if (pid == 0) - ll_s2sbi(sb)->ll_vfs_track_type = VFS_TRACK_ALL; + ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL; else - ll_s2sbi(sb)->ll_vfs_track_type = type; - lprocfs_clear_stats(ll_s2sbi(sb)->ll_vfs_ops_stats); + ll_s2sbi(sb)->ll_stats_track_type = type; + lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats); return count; } static int ll_rd_track_pid(char *page, char **start, off_t off, int count, int *eof, void *data) { - return (ll_rd_track_id(page, count, data, VFS_TRACK_PID)); + return (ll_rd_track_id(page, count, data, STATS_TRACK_PID)); } static int ll_wr_track_pid(struct file *file, const char *buffer, unsigned long count, void *data) { - return (ll_wr_track_id(buffer, count, data, VFS_TRACK_PID)); + return (ll_wr_track_id(buffer, count, data, STATS_TRACK_PID)); } static int ll_rd_track_ppid(char *page, char **start, off_t off, int count, int *eof, void *data) { - return (ll_rd_track_id(page, count, data, VFS_TRACK_PPID)); + return (ll_rd_track_id(page, count, data, STATS_TRACK_PPID)); } static int ll_wr_track_ppid(struct file *file, const char *buffer, unsigned long count, void *data) { - return (ll_wr_track_id(buffer, count, data, VFS_TRACK_PPID)); + return (ll_wr_track_id(buffer, count, data, STATS_TRACK_PPID)); } static int ll_rd_track_gid(char *page, char **start, off_t off, int count, int *eof, void *data) { - return (ll_rd_track_id(page, count, data, VFS_TRACK_GID)); + return (ll_rd_track_id(page, count, data, STATS_TRACK_GID)); } static int ll_wr_track_gid(struct file *file, const char *buffer, unsigned long count, void *data) { - return (ll_wr_track_id(buffer, count, data, VFS_TRACK_GID)); + return (ll_wr_track_id(buffer, count, data, STATS_TRACK_GID)); } static struct lprocfs_vars lprocfs_obd_vars[] = { @@ -455,9 +455,9 @@ static struct lprocfs_vars lprocfs_obd_vars[] = { { "max_cached_mb", ll_rd_max_cached_mb, ll_wr_max_cached_mb, 0 }, { "checksum_pages", ll_rd_checksum, ll_wr_checksum, 0 }, { "max_rw_chunk", ll_rd_max_rw_chunk, ll_wr_max_rw_chunk, 0 }, - { "vfs_track_pid", ll_rd_track_pid, ll_wr_track_pid, 0 }, - { "vfs_track_ppid", ll_rd_track_ppid, ll_wr_track_ppid, 0 }, - { "vfs_track_gid", ll_rd_track_gid, ll_wr_track_gid, 0 }, + { "stats_track_pid", ll_rd_track_pid, ll_wr_track_pid, 0 }, + { "stats_track_ppid", ll_rd_track_ppid, ll_wr_track_ppid, 0 }, + { "stats_track_gid", ll_rd_track_gid, ll_wr_track_gid, 0 }, { 0 } }; @@ -496,7 +496,8 @@ struct llite_file_opcode { { LPROC_LL_FSYNC, LPROCFS_TYPE_REGS, "fsync" }, /* inode operation */ { LPROC_LL_SETATTR, LPROCFS_TYPE_REGS, "setattr" }, - { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "punch" }, + { LPROC_LL_TRUNC, LPROCFS_TYPE_REGS, "truncate" }, + { LPROC_LL_FLOCK, LPROCFS_TYPE_REGS, "flock" }, #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) { LPROC_LL_GETATTR, LPROCFS_TYPE_REGS, "getattr" }, #else @@ -507,6 +508,9 @@ struct llite_file_opcode { { LPROC_LL_ALLOC_INODE, LPROCFS_TYPE_REGS, "alloc_inode" }, { LPROC_LL_SETXATTR, LPROCFS_TYPE_REGS, "setxattr" }, { LPROC_LL_GETXATTR, LPROCFS_TYPE_REGS, "getxattr" }, + { 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, @@ -514,19 +518,21 @@ struct llite_file_opcode { }; -void ll_vfs_ops_tally(struct ll_sb_info *sbi, int op) +void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) { - if (sbi->ll_vfs_ops_stats && sbi->ll_vfs_track_type == VFS_TRACK_ALL) - lprocfs_counter_incr(sbi->ll_vfs_ops_stats, op); - else if (sbi->ll_vfs_track_type == VFS_TRACK_PID && - sbi->ll_vfs_track_id == current->pid) - lprocfs_counter_incr(sbi->ll_vfs_ops_stats, op); - else if (sbi->ll_vfs_track_type == VFS_TRACK_PPID && - sbi->ll_vfs_track_id == current->p_pptr->pid) - lprocfs_counter_incr(sbi->ll_vfs_ops_stats, op); - else if (sbi->ll_vfs_track_type == VFS_TRACK_GID && - sbi->ll_vfs_track_id == current->gid) - lprocfs_counter_incr(sbi->ll_vfs_ops_stats, op); + if (!sbi->ll_stats) + return; + if (sbi->ll_stats_track_type == STATS_TRACK_ALL) + lprocfs_counter_add(sbi->ll_stats, op, count); + else if (sbi->ll_stats_track_type == STATS_TRACK_PID && + sbi->ll_stats_track_id == current->pid) + lprocfs_counter_add(sbi->ll_stats, op, count); + else if (sbi->ll_stats_track_type == STATS_TRACK_PPID && + sbi->ll_stats_track_id == current->p_pptr->pid) + lprocfs_counter_add(sbi->ll_stats, op, count); + else if (sbi->ll_stats_track_type == STATS_TRACK_GID && + sbi->ll_stats_track_id == current->gid) + lprocfs_counter_add(sbi->ll_stats, op, count); } int lprocfs_register_mountpoint(struct proc_dir_entry *parent, @@ -538,7 +544,6 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct obd_device *obd; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len; - struct lprocfs_stats *vfs_ops_stats = NULL; struct proc_dir_entry *entry; ENTRY; @@ -626,44 +631,6 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, if (err) GOTO(out, err); - /* VFS operations stats */ - vfs_ops_stats = sbi->ll_vfs_ops_stats = - lprocfs_alloc_stats(VFS_OPS_LAST); - if (vfs_ops_stats == NULL) - GOTO(out, err = -ENOMEM); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_READ, 0, "read", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_WRITE, 0, "write", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_IOCTL, 0, "ioctl", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_OPEN, 0, "open", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_RELEASE, 0, "release", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_MMAP, 0, "mmap", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_SEEK, 0, "seek", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_FSYNC, 0, "fsync", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_FLOCK, 0, "flock", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_SETATTR, 0, "setattr", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_GETATTR, 0, "getattr", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_SETXATTR, 0, "setxattr", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_GETXATTR, 0, "getxattr", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_LISTXATTR, 0, "listxattr", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_REMOVEXATTR, 0, - "removexattr", "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_TRUNCATE, 0, "truncate", - "reqs"); - lprocfs_counter_init(vfs_ops_stats, VFS_OPS_INODE_PERMISSION, 0, - "inode_permission", "reqs"); - - err = lprocfs_register_stats(sbi->ll_proc_root, "vfs_ops_stats", - vfs_ops_stats); - if (err) - GOTO(out, err); - - /* Static configuration info */ err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb); if (err) GOTO(out, err); @@ -709,7 +676,6 @@ out: if (err) { lprocfs_remove(&sbi->ll_proc_root); lprocfs_free_stats(&sbi->ll_stats); - lprocfs_free_stats(&sbi->ll_vfs_ops_stats); } RETURN(err); } @@ -719,7 +685,6 @@ void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) if (sbi->ll_proc_root) { lprocfs_remove(&sbi->ll_proc_root); lprocfs_free_stats(&sbi->ll_stats); - lprocfs_free_stats(&sbi->ll_vfs_ops_stats); } } #undef MAX_STRING_SIZE @@ -1013,14 +978,18 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) do_gettimeofday(&now); + if (!sbi->ll_rw_stats_on) { + seq_printf(seq, "Disabled\n" + "Write anything in this file to activate\n"); + return 0; + } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", now.tv_sec, now.tv_usec); seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write"); seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", "extents", "calls", "%", "cum%", "calls", "%", "cum%"); - - spin_lock(&sbi->ll_lock); + spin_lock(&sbi->ll_pp_extent_lock); for(k = 0; k < LL_PROCESS_HIST_MAX; k++) { if(io_extents->pp_extents[k].pid != 0) { seq_printf(seq, "\nPID: %d\n", @@ -1028,8 +997,7 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) ll_display_extents_info(io_extents, seq, k); } } - spin_unlock(&sbi->ll_lock); - + spin_unlock(&sbi->ll_pp_extent_lock); return 0; } @@ -1042,13 +1010,14 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int i; - spin_lock(&sbi->ll_lock); + sbi->ll_rw_stats_on = 1; + spin_lock(&sbi->ll_pp_extent_lock); for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { io_extents->pp_extents[i].pid = 0; lprocfs_oh_clear(&io_extents->pp_extents[i].pp_r_hist); lprocfs_oh_clear(&io_extents->pp_extents[i].pp_w_hist); } - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_pp_extent_lock); return len; } @@ -1062,6 +1031,11 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) do_gettimeofday(&now); + if (!sbi->ll_rw_stats_on) { + seq_printf(seq, "Disabled\n" + "Write anything in this file to activate\n"); + return 0; + } seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", now.tv_sec, now.tv_usec); @@ -1069,7 +1043,6 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", "extents", "calls", "%", "cum%", "calls", "%", "cum%"); - spin_lock(&sbi->ll_lock); ll_display_extents_info(io_extents, seq, LL_PROCESS_HIST_MAX); spin_unlock(&sbi->ll_lock); @@ -1083,9 +1056,17 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf, struct seq_file *seq = file->private_data; struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; + int i; - lprocfs_oh_clear(&io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_r_hist); - lprocfs_oh_clear(&io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_w_hist); + sbi->ll_rw_stats_on = 1; + spin_lock(&sbi->ll_pp_extent_lock); + for(i = 0; i <= LL_PROCESS_HIST_MAX; i++) + { + io_extents->pp_extents[i].pid = 0; + lprocfs_oh_clear(&io_extents->pp_extents[i].pp_r_hist); + lprocfs_oh_clear(&io_extents->pp_extents[i].pp_w_hist); + } + spin_unlock(&sbi->ll_pp_extent_lock); return len; } @@ -1102,10 +1083,12 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file int *process_count = &sbi->ll_offset_process_count; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; + if(!sbi->ll_rw_stats_on) + return; process = sbi->ll_rw_process_info; offset = sbi->ll_rw_offset_info; - spin_lock(&sbi->ll_lock); + spin_lock(&sbi->ll_pp_extent_lock); /* Extent statistics */ for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { if(io_extents->pp_extents[i].pid == pid) { @@ -1133,7 +1116,9 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file io_extents->pp_extents[cur].pp_w_hist.oh_buckets[i]++; io_extents->pp_extents[LL_PROCESS_HIST_MAX].pp_w_hist.oh_buckets[i]++; } + spin_unlock(&sbi->ll_pp_extent_lock); + spin_lock(&sbi->ll_process_lock); /* Offset statistics */ for (i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid == pid) { @@ -1145,7 +1130,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file process[i].rw_largest_extent = count; process[i].rw_offset = 0; process[i].rw_last_file = file; - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_process_lock); return; } if (process[i].rw_last_file_pos != file->f_pos) { @@ -1175,7 +1160,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file if(process[i].rw_largest_extent < count) process[i].rw_largest_extent = count; process[i].rw_last_file_pos = file->f_pos + count; - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_process_lock); return; } } @@ -1188,7 +1173,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file process[*process_count].rw_largest_extent = count; process[*process_count].rw_offset = 0; process[*process_count].rw_last_file = file; - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_process_lock); } char lpszt[] = LPSZ; @@ -1204,14 +1189,19 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) do_gettimeofday(&now); - spin_lock(&sbi->ll_lock); + if (!sbi->ll_rw_stats_on) { + seq_printf(seq, "Disabled\n" + "Write anything in this file to activate\n"); + return 0; + } + spin_lock(&sbi->ll_process_lock); seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", now.tv_sec, now.tv_usec); seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n", "R/W", "PID", "RANGE START", "RANGE END", "SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET"); - sprintf(format, "%s%s%s%s%s\n", + sprintf(format, "%s%s%s%s%s\n", "%3c %10d %14Lu %14Lu %17", lpszt+1, " %17", lpszt+1, " %14Ld"); /* We stored the discontiguous offsets here; print them first */ for(i = 0; i < LL_OFFSET_HIST_MAX; i++) { @@ -1238,7 +1228,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) process[i].rw_largest_extent, process[i].rw_offset); } - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_process_lock); return 0; } @@ -1251,14 +1241,16 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf, struct ll_rw_process_info *process_info = sbi->ll_rw_process_info; struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info; - spin_lock(&sbi->ll_lock); + sbi->ll_rw_stats_on = 1; + + spin_lock(&sbi->ll_process_lock); sbi->ll_offset_process_count = 0; sbi->ll_rw_offset_entry_count = 0; memset(process_info, 0, sizeof(struct ll_rw_process_info) * LL_PROCESS_HIST_MAX); memset(offset_info, 0, sizeof(struct ll_rw_process_info) * LL_OFFSET_HIST_MAX); - spin_unlock(&sbi->ll_lock); + spin_unlock(&sbi->ll_process_lock); return len; } diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 17a696f0bd5c1cac3e49a0f3434ef5aa17ee70a5..7d4ad4ca9d4ac9ceb69a0f9122d5746a8e7dfa1b 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -89,11 +89,11 @@ static int ll_brw(int cmd, struct inode *inode, struct obdo *oa, pg.flag = flags; if (cmd & OBD_BRW_WRITE) - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_BRW_WRITE, pg.count); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_BRW_WRITE, + pg.count); else - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_BRW_READ, pg.count); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_BRW_READ, + pg.count); oinfo.oi_oa = oa; oinfo.oi_md = lsm; rc = obd_brw(cmd, ll_i2obdexp(inode), &oinfo, 1, &pg, NULL); @@ -121,7 +121,7 @@ void ll_truncate(struct inode *inode) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %Lu=%#Lx\n",inode->i_ino, inode->i_generation, inode, inode->i_size, inode->i_size); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_TRUNCATE); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_TRUNC, 1); if (lli->lli_size_sem_owner != current) { EXIT; return; @@ -771,15 +771,13 @@ int ll_commit_write(struct file *file, struct page *page, unsigned from, /* queue a write for some time in the future the first time we * dirty the page */ if (!PageDirty(page)) { - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRTY_MISSES); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRTY_MISSES, 1); rc = queue_or_sync_write(exp, inode, llap, to, 0); if (rc) GOTO(out, rc); } else { - lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRTY_HITS); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRTY_HITS, 1); } /* put the page in the page cache, from now on ll_removepage is diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c index 508636bd08f6416b2a69b2a1e8e1a41625dffde2..151e00b59403cf4d8f3c2581bb2e0a958dc760c4 100644 --- a/lustre/llite/rw24.c +++ b/lustre/llite/rw24.c @@ -106,11 +106,9 @@ static int ll_direct_IO_24(int rw, ll_inode_fill_obdo(inode, rw, &oa); if (rw == OBD_BRW_WRITE) - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRECT_WRITE, iobuf->length); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_WRITE, iobuf->length); else - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRECT_READ, iobuf->length); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_READ, iobuf->length); rc = obd_brw_rqset(rw, ll_i2obdexp(inode), &oa, lsm, iobuf->nr_pages, pga, NULL); if (rc == 0) { diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 4fb767f00cf43a880c3a2e85fe4380be63f6ed98..0c50dcf1fd67f9185d2993692ecfe45b36894386 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -211,11 +211,9 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, MAX_DIO_SIZE >> CFS_PAGE_SHIFT); if (rw == WRITE) - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRECT_WRITE, count); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_WRITE, count); else - lprocfs_counter_add(ll_i2sbi(inode)->ll_stats, - LPROC_LL_DIRECT_READ, count); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_READ, count); /* Check that all user buffers are aligned as well */ for (seg = 0; seg < nr_segs; seg++) { diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 14c191e4c4575e04b2c23d98f04611c28898d1f1..6323817d54348c67a772a1a31869537157f562aa 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -40,7 +40,7 @@ static kmem_cache_t *ll_inode_cachep; static struct inode *ll_alloc_inode(struct super_block *sb) { struct ll_inode_info *lli; - lprocfs_counter_incr((ll_s2sbi(sb))->ll_stats, LPROC_LL_ALLOC_INODE); + ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); OBD_SLAB_ALLOC(lli, ll_inode_cachep, GFP_KERNEL, sizeof *lli); if (lli == NULL) return NULL; diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 63322d63a41adca990f750811dfe611d2d0e2f8f..d123ba144504c0193f35854f14b8e5cb891ebf1b 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -110,7 +110,6 @@ int ll_setxattr_common(struct inode *inode, const char *name, int xattr_type, rc; ENTRY; - lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_SETXATTR); xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); @@ -148,7 +147,7 @@ int ll_setxattr(struct dentry *dentry, const char *name, CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), xattr %s\n", inode->i_ino, inode->i_generation, inode, name); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_SETXATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1); if (strncmp(name, XATTR_TRUSTED_PREFIX, 8) == 0 && strcmp(name + 8, "lov") == 0) { @@ -185,7 +184,7 @@ int ll_removexattr(struct dentry *dentry, const char *name) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), xattr %s\n", inode->i_ino, inode->i_generation, inode, name); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_REMOVEXATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1); return ll_setxattr_common(inode, name, NULL, 0, 0, OBD_MD_FLXATTRRM); } @@ -205,7 +204,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_GETXATTR); /* listxattr have slightly different behavior from of ext3: * without 'user_xattr' ext3 will list all xattr names but @@ -305,7 +303,7 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), xattr %s\n", inode->i_ino, inode->i_generation, inode, name); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_GETXATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1); if (strncmp(name, XATTR_TRUSTED_PREFIX, 8) == 0 && strcmp(name + 8, "lov") == 0) { @@ -355,7 +353,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - ll_vfs_ops_tally(ll_i2sbi(inode), VFS_OPS_LISTXATTR); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR, 1); rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);