From patchwork Fri Aug 17 03:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A45113B6 for ; Fri, 17 Aug 2018 03:10:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E4D32B124 for ; Fri, 17 Aug 2018 03:10:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 122BB2B18D; Fri, 17 Aug 2018 03:10:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 784B12B157 for ; Fri, 17 Aug 2018 03:10:49 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C0D414E1A9E; Thu, 16 Aug 2018 20:10:48 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B511821FFA8 for ; Thu, 16 Aug 2018 20:10:47 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id BEE561005364; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id B814639B; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:04 -0400 Message-Id: <1534475441-15543-2-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Rename from ldebugfs_[un]register_mountpoint() to ll_debugfs_[un]register_super(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 6 +++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 6ed7034..b2cdf75 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -675,9 +675,9 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc); -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index fb3bc16..50ea5fb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -573,7 +573,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(osfs); if (llite_root) { - err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); + err = ll_debugfs_register_super(llite_root, sb, dt, md); if (err < 0) { CERROR("%s: could not register mount in debugfs: " "rc = %d\n", ll_get_fsname(sb, NULL, 0), err); @@ -679,7 +679,7 @@ static void client_common_put_super(struct super_block *sb) obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - ldebugfs_unregister_mountpoint(sbi); + ll_debugfs_unregister_super(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 617aabb..996703d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1175,8 +1175,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1285,7 +1285,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent, return err; } -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); kobject_put(&sbi->ll_kobj); From patchwork Fri Aug 17 03:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E70914BD for ; Fri, 17 Aug 2018 03:11:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B2DC2B124 for ; Fri, 17 Aug 2018 03:11:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E86C2B157; Fri, 17 Aug 2018 03:11:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E76B22B124 for ; Fri, 17 Aug 2018 03:11:02 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6C0CE4E1DDD; Thu, 16 Aug 2018 20:10:55 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7A61E21FFA8 for ; Thu, 16 Aug 2018 20:10:48 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id C45B8100536B; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id BADE8463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:05 -0400 Message-Id: <1534475441-15543-3-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 02/38] lustre: llite: change ll_statfs_internal to use struct ll_sb_info X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The only reason ll_statfs_internal() needs struct super_block is for the super block magic. We can use LL_SUPER_MAGIC directly thus removing the need to pass in struct super_block. This will help to remove ll_sb in struct ll_sb_info. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 4 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 9 ++++----- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index b2cdf75..4053314 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -832,8 +832,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, unsigned int xvalid, bool hsm_import); int ll_setattr(struct dentry *de, struct iattr *attr); int ll_statfs(struct dentry *de, struct kstatfs *sfs); -int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags); +int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, + u64 max_age, u32 flags); int ll_update_inode(struct inode *inode, struct lustre_md *md); int ll_read_inode2(struct inode *inode, void *opaque); void ll_delete_inode(struct inode *inode); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 50ea5fb..437f4cc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1643,10 +1643,9 @@ int ll_setattr(struct dentry *de, struct iattr *attr) return ll_setattr_raw(de, attr, xvalid, false); } -int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags) +int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, + u64 max_age, u32 flags) { - struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; int rc; @@ -1656,7 +1655,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, return rc; } - osfs->os_type = sb->s_magic; + osfs->os_type = LL_SUPER_MAGIC; CDEBUG(D_SUPER, "MDC blocks %llu/%llu objects %llu/%llu\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree, @@ -1703,7 +1702,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); /* Some amount of caching on the client is allowed */ - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(ll_s2sbi(sb), &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, 0); if (rc) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 996703d..cae483f 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -52,7 +52,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) @@ -70,7 +70,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -95,7 +95,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -120,7 +120,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -145,7 +145,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) @@ -163,7 +163,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) From patchwork Fri Aug 17 03:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BA8A14BD for ; Fri, 17 Aug 2018 03:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 684822B124 for ; Fri, 17 Aug 2018 03:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C6222B157; Fri, 17 Aug 2018 03:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C541F2B124 for ; Fri, 17 Aug 2018 03:11:27 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1CF5B4E1F92; Thu, 16 Aug 2018 20:11:08 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 24ACF21FFA8 for ; Thu, 16 Aug 2018 20:10:48 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id C23671005367; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id BCCA3464; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:06 -0400 Message-Id: <1534475441-15543-4-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 03/38] lustre: llite: move llite_root and llite_kset to lproc_llite.c X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move llite_root and llite_kset to lproc_llite.c so that all the sysfs and debugfs code is together. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 7 ++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 14 ++++----- drivers/staging/lustre/lustre/llite/lproc_llite.c | 34 ++++++++++++++++++++-- drivers/staging/lustre/lustre/llite/super25.c | 24 ++++----------- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 4053314..2719bc53 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -636,8 +636,8 @@ struct ll_file_data { struct list_head fd_lccs; /* list of ll_cl_context */ }; -extern struct dentry *llite_root; -extern struct kset *llite_kset; +void llite_tunables_unregister(void); +int llite_tunables_register(void); static inline struct inode *ll_info2i(struct ll_inode_info *lli) { @@ -675,8 +675,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc); +int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 437f4cc..d16f5d1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -57,8 +57,6 @@ #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; -struct dentry *llite_root; -struct kset *llite_kset; #ifndef log2 #define log2(n) ffz(~(n)) @@ -572,13 +570,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(data); kfree(osfs); - if (llite_root) { - err = ll_debugfs_register_super(llite_root, sb, dt, md); - if (err < 0) { - CERROR("%s: could not register mount in debugfs: " - "rc = %d\n", ll_get_fsname(sb, NULL, 0), err); - err = 0; - } + err = ll_debugfs_register_super(sb, dt, md); + if (err < 0) { + CERROR("%s: could not register mount in debugfs: rc = %d\n", + ll_get_fsname(sb, NULL, 0), err); + err = 0; } return err; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index cae483f..a9ad328 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -39,6 +39,35 @@ #include "llite_internal.h" #include "vvp_internal.h" +static struct dentry *llite_root; +static struct kset *llite_kset; + +int llite_tunables_register(void) +{ + int rc = 0; + + llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); + if (!llite_kset) + return -ENOMEM; + + llite_root = debugfs_create_dir("llite", debugfs_lustre_root); + if (IS_ERR_OR_NULL(llite_root)) { + rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; + llite_root = NULL; + kset_unregister(llite_kset); + } + + return rc; +} + +void llite_tunables_unregister(void) +{ + kset_unregister(llite_kset); + + debugfs_remove(llite_root); + llite_root = NULL; +} + /* debugfs llite mount point registration */ static const struct file_operations ll_rw_extents_stats_fops; static const struct file_operations ll_rw_extents_stats_pp_fops; @@ -1175,8 +1204,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1201,7 +1229,7 @@ int ll_debugfs_register_super(struct dentry *parent, snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, lsi->lsi_lmd->lmd_profile, sb); - dir = debugfs_create_dir(name, parent); + dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; debugfs_create_file("dump_page_cache", 0444, dir, sbi, diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index a3bc57d..2f4306e 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -228,22 +228,13 @@ static int __init lustre_init(void) if (!ll_file_data_slab) goto out_cache; - llite_root = debugfs_create_dir("llite", debugfs_lustre_root); - if (IS_ERR_OR_NULL(llite_root)) { - rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; - llite_root = NULL; + rc = llite_tunables_register(); + if (rc) goto out_cache; - } - - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); - if (!llite_kset) { - rc = -ENOMEM; - goto out_debugfs; - } rc = vvp_global_init(); if (rc != 0) - goto out_sysfs; + goto out_tunables; cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck, LCT_REMEMBER | LCT_NOREF); @@ -270,10 +261,8 @@ static int __init lustre_init(void) cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); out_vvp: vvp_global_fini(); -out_sysfs: - kset_unregister(llite_kset); -out_debugfs: - debugfs_remove(llite_root); +out_tunables: + llite_tunables_unregister(); out_cache: kmem_cache_destroy(ll_inode_cachep); kmem_cache_destroy(ll_file_data_slab); @@ -286,8 +275,7 @@ static void __exit lustre_exit(void) lustre_register_client_process_config(NULL); - debugfs_remove(llite_root); - kset_unregister(llite_kset); + llite_tunables_unregister(); ll_xattr_fini(); cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); From patchwork Fri Aug 17 03:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AB7B13B6 for ; Fri, 17 Aug 2018 03:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E522886F for ; Fri, 17 Aug 2018 03:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC754288D0; Fri, 17 Aug 2018 03:12:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9377F2886F for ; Fri, 17 Aug 2018 03:12:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D20404E20B6; Thu, 16 Aug 2018 20:11:45 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D05754E1AA4 for ; Thu, 16 Aug 2018 20:10:48 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id C591A100536C; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C2C28465; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:07 -0400 Message-Id: <1534475441-15543-5-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The only user of ll_sb in struct ll_sb_info is used to query the name locate in the file_system_type. We can get that information from using the super block located in struct path instead. This enables us to use struct ll_sb_info directly for every sysfs or debugfs entry. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 1 - drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- drivers/staging/lustre/lustre/llite/lproc_llite.c | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 2719bc53..92dc05d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -524,7 +524,6 @@ struct ll_sb_info { __kernel_fsid_t ll_fsid; struct kobject ll_kobj; /* sysfs object */ - struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d16f5d1..d352287 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -62,7 +62,7 @@ #define log2(n) ffz(~(n)) #endif -static struct ll_sb_info *ll_init_sbi(struct super_block *sb) +static struct ll_sb_info *ll_init_sbi(void) { struct ll_sb_info *sbi = NULL; unsigned long pages; @@ -129,8 +129,6 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids); init_rwsem(&sbi->ll_squash.rsi_sem); - sbi->ll_sb = sb; - return sbi; } @@ -912,7 +910,7 @@ int ll_fill_super(struct super_block *sb) try_module_get(THIS_MODULE); /* client additional sb info */ - sbi = ll_init_sbi(sb); + sbi = ll_init_sbi(); lsi->lsi_llsbi = sbi; if (!sbi) { module_put(THIS_MODULE); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a9ad328..8e418ba 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -33,6 +33,7 @@ #define DEBUG_SUBSYSTEM S_LLITE #include +#include #include #include @@ -215,7 +216,7 @@ static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kobj); - return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); + return sprintf(buf, "%s\n", sbi->ll_mnt.mnt->mnt_sb->s_type->name); } LUSTRE_RO_ATTR(fstype); From patchwork Fri Aug 17 03:10:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12E8B15E2 for ; Fri, 17 Aug 2018 03:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1F2C2B124 for ; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E479B2B157; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 305582B144 for ; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 616694E1D2E; Thu, 16 Aug 2018 20:10:52 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1E6484E1AF9 for ; Thu, 16 Aug 2018 20:10:49 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id CABAE100536D; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C7958463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:08 -0400 Message-Id: <1534475441-15543-6-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 05/38] lustre: llite: change top kobject for llite into a kset X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the top of the sysfs tree for llite is represented by a kobject and each mount instance a kset. Change the top object into a kset and each mount instance into a kobject instead. The reason for this change is in the future lustre_kobj will be changed into a kset and you can't layer two ksets. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 114 +++++++++++++-------- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 92dc05d..5577407 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -523,7 +523,7 @@ struct ll_sb_info { struct path ll_mnt; __kernel_fsid_t ll_fsid; - struct kobject ll_kobj; /* sysfs object */ + struct kset ll_kset; /* sysfs object */ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8e418ba..8af6636 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -40,22 +40,42 @@ #include "llite_internal.h" #include "vvp_internal.h" +static struct kobject *llite_kobj; static struct dentry *llite_root; -static struct kset *llite_kset; + +static void class_sysfs_release(struct kobject *kobj) +{ + kfree(kobj); +} + +static struct kobj_type class_ktype = { + .sysfs_ops = &lustre_sysfs_ops, + .release = class_sysfs_release, +}; int llite_tunables_register(void) { + const char *name = "llite"; + struct kobject *kobj; int rc = 0; - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); - if (!llite_kset) + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return -ENOMEM; + + kobject_init(kobj, &class_ktype); + rc = kobject_add(kobj, lustre_kobj, "%s", name); + if (rc) { + kobject_put(kobj); return -ENOMEM; + } + llite_kobj = kobj; llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; llite_root = NULL; - kset_unregister(llite_kset); + kobject_put(kobj); } return rc; @@ -63,7 +83,8 @@ int llite_tunables_register(void) void llite_tunables_unregister(void) { - kset_unregister(llite_kset); + kobject_put(llite_kobj); + llite_kobj = NULL; debugfs_remove(llite_root); llite_root = NULL; @@ -78,7 +99,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -96,7 +117,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -121,7 +142,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -146,7 +167,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -171,7 +192,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -189,7 +210,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -214,7 +235,7 @@ static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%s\n", sbi->ll_mnt.mnt->mnt_sb->s_type->name); } @@ -224,7 +245,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid); } @@ -247,7 +268,7 @@ static ssize_t max_read_ahead_mb_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -265,7 +286,7 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -294,7 +315,7 @@ static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -312,7 +333,7 @@ static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -339,7 +360,7 @@ static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -357,7 +378,7 @@ static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -522,7 +543,7 @@ static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } @@ -533,7 +554,7 @@ static ssize_t checksum_pages_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -564,7 +585,7 @@ static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); if (sbi->ll_stats_track_type == type) return sprintf(buf, "%d\n", sbi->ll_stats_track_id); @@ -579,7 +600,7 @@ static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pid; @@ -648,7 +669,7 @@ static ssize_t statahead_max_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_sa_max); } @@ -659,7 +680,7 @@ static ssize_t statahead_max_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -682,7 +703,7 @@ static ssize_t statahead_agl_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } @@ -693,7 +714,7 @@ static ssize_t statahead_agl_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -734,7 +755,7 @@ static ssize_t lazystatfs_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); } @@ -745,7 +766,7 @@ static ssize_t lazystatfs_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -769,7 +790,7 @@ static ssize_t max_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -798,7 +819,7 @@ static ssize_t default_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -831,7 +852,7 @@ static ssize_t default_easize_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned long val; int rc; @@ -877,7 +898,7 @@ static ssize_t xattr_cache_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled); } @@ -888,7 +909,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -913,7 +934,7 @@ static ssize_t fast_read_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", !!(sbi->ll_flags & LL_SBI_FAST_READ)); } @@ -924,7 +945,7 @@ static ssize_t fast_read_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); bool val; int rc; @@ -1110,7 +1131,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, static void llite_sb_release(struct kobject *kobj) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); complete(&sbi->ll_kobj_unregister); } @@ -1285,17 +1306,22 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); - sbi->ll_kobj.kset = llite_kset; + /* Yes we also register sysfs mount kset here as well */ + sbi->ll_kset.kobj.parent = llite_kobj; + sbi->ll_kset.kobj.ktype = &llite_ktype; init_completion(&sbi->ll_kobj_unregister); - err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL, - "%s", name); + err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name); + if (err) + goto out; + + err = kset_register(&sbi->ll_kset); if (err) goto out; /* MDC info */ obd = class_name2obd(mdc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); if (err) goto out; @@ -1303,7 +1329,7 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) /* OSC */ obd = class_name2obd(osc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); out: if (err) { @@ -1317,8 +1343,10 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); - kobject_put(&sbi->ll_kobj); + + kset_unregister(&sbi->ll_kset); wait_for_completion(&sbi->ll_kobj_unregister); + lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } From patchwork Fri Aug 17 03:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A087113B6 for ; Fri, 17 Aug 2018 03:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E7DA2B176 for ; Fri, 17 Aug 2018 03:12:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82ACB2B1A7; Fri, 17 Aug 2018 03:12:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D0272B176 for ; Fri, 17 Aug 2018 03:12:25 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7CCF44E1D13; Thu, 16 Aug 2018 20:11:32 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 746CC4E1AF9 for ; Thu, 16 Aug 2018 20:10:49 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id CF25B100536E; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id CC20B464; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:09 -0400 Message-Id: <1534475441-15543-7-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 06/38] lustre: llite: rename llite_sb_release X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since we are freeing a kobject rename llite_sb_release() to llite_kobj_release(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8af6636..90140b0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1128,7 +1128,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, NULL, }; -static void llite_sb_release(struct kobject *kobj) +static void llite_kobj_release(struct kobject *kobj) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); @@ -1138,7 +1138,7 @@ static void llite_sb_release(struct kobject *kobj) static struct kobj_type llite_ktype = { .default_attrs = llite_attrs, .sysfs_ops = &lustre_sysfs_ops, - .release = llite_sb_release, + .release = llite_kobj_release, }; static const struct llite_file_opcode { From patchwork Fri Aug 17 03:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A360713B6 for ; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 902C72B124 for ; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 849842B176; Fri, 17 Aug 2018 03:10:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D0A672B124 for ; Fri, 17 Aug 2018 03:10:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3B8754E1D27; Thu, 16 Aug 2018 20:10:52 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B56BA4E1C1A for ; Thu, 16 Aug 2018 20:10:49 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id D506F100536F; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id D1022463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:10 -0400 Message-Id: <1534475441-15543-8-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 07/38] lustre: llite: register mountpoint before process llog X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emoly Liu In ll_fill_super(), ll_debugfs_register_super() should be called before lustre_process_log(), otherwise the directory /sys/fs/lustre/llite/* can't be created in time and the params "llite.*.*" won't be set correctly. Also, this patch adds sbi->ll_xattr_cache_set to mark the flag LL_SBI_XATTR_CACHE already set during lustre_process_log(), in case that it will be overwritten in client_common_fill_super(). Signed-off-by: Emoly Liu WC-bug-id: https://jira.whamcloud.com/browse/LU-9399 Reviewed-on: https://review.whamcloud.com/27241 Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/#/c/32516 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 5 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 75 ++++++++++++++++------ drivers/staging/lustre/lustre/llite/lproc_llite.c | 30 +++------ 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5577407..9e60c5e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -461,12 +461,15 @@ struct ll_sb_info { struct obd_uuid ll_sb_uuid; struct obd_export *ll_md_exp; struct obd_export *ll_dt_exp; + struct obd_device *ll_md_obd; + struct obd_device *ll_dt_obd; struct dentry *ll_debugfs_entry; struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; unsigned int ll_umounting:1, ll_xattr_cache_enabled:1, + ll_xattr_cache_set:1, /* already set to 0/1 */ ll_client_common_fill_super_succeeded:1; struct lustre_client_ocd ll_lco; @@ -674,7 +677,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc); +int ll_debugfs_register_super(struct super_block *sb); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d352287..95568b7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -156,7 +156,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) { struct inode *root = NULL; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct obd_device *obd; struct obd_statfs *osfs = NULL; struct ptlrpc_request *request = NULL; struct obd_connect_data *data = NULL; @@ -166,8 +165,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) u64 valid; int size, err, checksum; - obd = class_name2obd(md); - if (!obd) { + sbi->ll_md_obd = class_name2obd(md); + if (!sbi->ll_md_obd) { CERROR("MD %s: not setup or attached\n", md); return -EINVAL; } @@ -247,8 +246,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) data->ocd_brw_size = MD_MAX_BRW_SIZE; - err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, - data, NULL); + err = obd_connect(NULL, &sbi->ll_md_exp, sbi->ll_md_obd, + &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", @@ -360,14 +359,19 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) LCONSOLE_INFO( "%s: disabling xattr cache due to unknown maximum xattr size.\n", dt); - } else { + } else if (!sbi->ll_xattr_cache_set) { + /* If xattr_cache is already set (no matter 0 or 1) + * during processing llog, it won't be enabled here. + */ + spin_lock(&sbi->ll_lock); sbi->ll_flags |= LL_SBI_XATTR_CACHE; + spin_unlock(&sbi->ll_lock); sbi->ll_xattr_cache_enabled = 1; } } - obd = class_name2obd(dt); - if (!obd) { + sbi->ll_dt_obd = class_name2obd(dt); + if (!sbi->ll_dt_obd) { CERROR("DT %s: not setup or attached\n", dt); err = -ENODEV; goto out_md_fid; @@ -414,13 +418,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) data->ocd_connect_flags, data->ocd_version, data->ocd_grant); - obd->obd_upcall.onu_owner = &sbi->ll_lco; - obd->obd_upcall.onu_upcall = cl_ocd_update; + sbi->ll_dt_obd->obd_upcall.onu_owner = &sbi->ll_lco; + sbi->ll_dt_obd->obd_upcall.onu_upcall = cl_ocd_update; data->ocd_brw_size = DT_MAX_BRW_SIZE; - err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, - NULL); + err = obd_connect(NULL, &sbi->ll_dt_exp, sbi->ll_dt_obd, + &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", @@ -568,11 +572,26 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(data); kfree(osfs); - err = ll_debugfs_register_super(sb, dt, md); - if (err < 0) { - CERROR("%s: could not register mount in debugfs: rc = %d\n", - ll_get_fsname(sb, NULL, 0), err); - err = 0; + if (sbi->ll_dt_obd) { + err = sysfs_create_link(&sbi->ll_kset.kobj, + &sbi->ll_dt_obd->obd_kobj, + sbi->ll_dt_obd->obd_type->typ_name); + if (err < 0) { + CERROR("%s: could not register %s in llite: rc = %d\n", + dt, ll_get_fsname(sb, NULL, 0), err); + err = 0; + } + } + + if (sbi->ll_md_obd) { + err = sysfs_create_link(&sbi->ll_kset.kobj, + &sbi->ll_md_obd->obd_kobj, + sbi->ll_md_obd->obd_type->typ_name); + if (err < 0) { + CERROR("%s: could not register %s in llite: rc = %d\n", + md, ll_get_fsname(sb, NULL, 0), err); + err = 0; + } } return err; @@ -583,6 +602,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) out_dt: obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; + sbi->ll_dt_obd = NULL; out_md_fid: obd_fid_fini(sbi->ll_md_exp->exp_obd); out_md: @@ -931,6 +951,16 @@ int ll_fill_super(struct super_block *sb) /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ sb->s_d_op = &ll_d_ops; + /* Call ll_debugsfs_register_super() before lustre_process_log() + * so that "llite.*.*" params can be processed correctly. + */ + err = ll_debugfs_register_super(sb); + if (err < 0) { + CERROR("%s: could not register mountpoint in llite: rc = %d\n", + ll_get_fsname(sb, NULL, 0), err); + err = 0; + } + /* Generate a string unique to this super, in case some joker tries * to mount the same fs at two mount points. * Use the address of the super itself. @@ -942,7 +972,7 @@ int ll_fill_super(struct super_block *sb) /* set up client obds */ err = lustre_process_log(sb, profilenm, cfg); if (err < 0) - goto out_free; + goto out_debugfs; /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ lprof = class_get_profile(profilenm); @@ -951,7 +981,7 @@ int ll_fill_super(struct super_block *sb) "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n", profilenm); err = -EINVAL; - goto out_free; + goto out_debugfs; } CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, lprof->lp_md, lprof->lp_dt); @@ -959,13 +989,13 @@ int ll_fill_super(struct super_block *sb) dt = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_dt, cfg->cfg_instance); if (!dt) { err = -ENOMEM; - goto out_free; + goto out_debugfs; } md = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_md, cfg->cfg_instance); if (!md) { err = -ENOMEM; - goto out_free; + goto out_debugfs; } /* connections, registrations, sb setup */ @@ -973,6 +1003,9 @@ int ll_fill_super(struct super_block *sb) if (!err) sbi->ll_client_common_fill_super_succeeded = 1; +out_debugfs: + if (err < 0) + ll_debugfs_unregister_super(sbi); out_free: kfree(md); kfree(dt); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 90140b0..868c9b0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -924,6 +924,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, return -ENOTSUPP; sbi->ll_xattr_cache_enabled = val; + sbi->ll_xattr_cache_set = 1; return count; } @@ -1226,11 +1227,10 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); - struct obd_device *obd; struct dentry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len; @@ -1238,8 +1238,6 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) name[MAX_STRING_SIZE] = '\0'; LASSERT(sbi); - LASSERT(mdc); - LASSERT(osc); /* Get fsname */ len = strlen(lsi->lsi_lmd->lmd_profile); @@ -1315,22 +1313,6 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) goto out; err = kset_register(&sbi->ll_kset); - if (err) - goto out; - - /* MDC info */ - obd = class_name2obd(mdc); - - err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, - obd->obd_type->typ_name); - if (err) - goto out; - - /* OSC */ - obd = class_name2obd(osc); - - err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, - obd->obd_type->typ_name); out: if (err) { debugfs_remove_recursive(sbi->ll_debugfs_entry); @@ -1344,6 +1326,14 @@ void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); + if (sbi->ll_dt_obd) + sysfs_remove_link(&sbi->ll_kset.kobj, + sbi->ll_dt_obd->obd_type->typ_name); + + if (sbi->ll_md_obd) + sysfs_remove_link(&sbi->ll_kset.kobj, + sbi->ll_md_obd->obd_type->typ_name); + kset_unregister(&sbi->ll_kset); wait_for_completion(&sbi->ll_kobj_unregister); From patchwork Fri Aug 17 03:10:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FCD013B6 for ; Fri, 17 Aug 2018 03:11:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CAEC2B124 for ; Fri, 17 Aug 2018 03:11:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214462B157; Fri, 17 Aug 2018 03:11:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B615C2B124 for ; Fri, 17 Aug 2018 03:11:09 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5983A4E1C85; Thu, 16 Aug 2018 20:10:59 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 16B4F4E1C1A for ; Thu, 16 Aug 2018 20:10:50 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id DA3131005370; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id D4992464; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:11 -0400 Message-Id: <1534475441-15543-9-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 08/38] lustre: llite: move lmd_profile handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function ll_debugfs_register_super() should only handling sysfs related things so move the lmd_profile parsing out of that function. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 17 ++++++++++++++++- drivers/staging/lustre/lustre/llite/lproc_llite.c | 18 ++---------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 9e60c5e..1130ea3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -677,7 +677,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct super_block *sb); +int ll_debugfs_register_super(struct super_block *sb, const char *name); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 95568b7..ce072da 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -909,6 +909,8 @@ void ll_lli_init(struct ll_inode_info *lli) memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); } +#define MAX_STRING_SIZE 128 + int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof = NULL; @@ -917,6 +919,9 @@ int ll_fill_super(struct super_block *sb) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; + char name[MAX_STRING_SIZE]; + char *ptr; + int len; int err; static atomic_t ll_bdi_num = ATOMIC_INIT(0); @@ -951,10 +956,20 @@ int ll_fill_super(struct super_block *sb) /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ sb->s_d_op = &ll_d_ops; + /* Get fsname */ + len = strlen(lsi->lsi_lmd->lmd_profile); + ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); + if (ptr && (strcmp(ptr, "-client") == 0)) + len -= 7; + + /* Mount info */ + snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, + lsi->lsi_lmd->lmd_profile, sb); + /* Call ll_debugsfs_register_super() before lustre_process_log() * so that "llite.*.*" params can be processed correctly. */ - err = ll_debugfs_register_super(sb); + err = ll_debugfs_register_super(sb, name); if (err < 0) { CERROR("%s: could not register mountpoint in llite: rc = %d\n", ll_get_fsname(sb, NULL, 0), err); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 868c9b0..4186a8d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1227,28 +1227,14 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct super_block *sb) +int ll_debugfs_register_super(struct super_block *sb, const char *name) { - struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct dentry *dir; - char name[MAX_STRING_SIZE + 1], *ptr; - int err, id, len; - - name[MAX_STRING_SIZE] = '\0'; + int err, id; LASSERT(sbi); - /* Get fsname */ - len = strlen(lsi->lsi_lmd->lmd_profile); - ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); - if (ptr && (strcmp(ptr, "-client") == 0)) - len -= 7; - - /* Mount info */ - snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, - lsi->lsi_lmd->lmd_profile, sb); - dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; From patchwork Fri Aug 17 03:10:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 441A713B6 for ; Fri, 17 Aug 2018 03:11:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31F8A2B124 for ; Fri, 17 Aug 2018 03:11:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24EBA2B157; Fri, 17 Aug 2018 03:11:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BFEC22B124 for ; Fri, 17 Aug 2018 03:11:13 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 39BB24E1DA6; Thu, 16 Aug 2018 20:11:02 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6DBDC4E189F for ; Thu, 16 Aug 2018 20:10:50 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id DD5BE1005371; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id D918D463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:12 -0400 Message-Id: <1534475441-15543-10-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 09/38] lustre: llite: add proper error handling for ll_debugfs_register_super() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Having the single out label that cleans up everything is not proper kernel style and can create more bugs. Instead just cleanup the items we created only by introducing multiple goto label that handle specific cleanups. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 4186a8d..5530156 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1235,9 +1235,14 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LASSERT(sbi); + if (IS_ERR_OR_NULL(llite_root)) + goto out_ll_kset; + dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; + ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); + debugfs_create_file("dump_page_cache", 0444, dir, sbi, &vvp_dump_pgcache_file_ops); debugfs_create_file("extents_stats", 0644, dir, sbi, @@ -1252,8 +1257,9 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LPROCFS_STATS_FLAG_NONE); if (!sbi->ll_stats) { err = -ENOMEM; - goto out; + goto out_debugfs; } + /* do counter init */ for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) { __u32 type = llite_opcode_table[id].type; @@ -1278,7 +1284,7 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LPROCFS_STATS_FLAG_NONE); if (!sbi->ll_ra_stats) { err = -ENOMEM; - goto out; + goto out_stats; } for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) @@ -1287,24 +1293,28 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry, sbi->ll_ra_stats, &lprocfs_stats_seq_fops); - - ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); - +out_ll_kset: /* Yes we also register sysfs mount kset here as well */ sbi->ll_kset.kobj.parent = llite_kobj; sbi->ll_kset.kobj.ktype = &llite_ktype; init_completion(&sbi->ll_kobj_unregister); err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name); if (err) - goto out; + goto out_ra_stats; err = kset_register(&sbi->ll_kset); -out: - if (err) { - debugfs_remove_recursive(sbi->ll_debugfs_entry); - lprocfs_free_stats(&sbi->ll_ra_stats); - lprocfs_free_stats(&sbi->ll_stats); - } + if (err) + goto out_ra_stats; + + return 0; + +out_ra_stats: + lprocfs_free_stats(&sbi->ll_ra_stats); +out_stats: + lprocfs_free_stats(&sbi->ll_stats); +out_debugfs: + debugfs_remove_recursive(sbi->ll_debugfs_entry); + return err; } From patchwork Fri Aug 17 03:10:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC78314BD for ; Fri, 17 Aug 2018 03:12:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA0F02B176 for ; Fri, 17 Aug 2018 03:12:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE9A72B1A7; Fri, 17 Aug 2018 03:12:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 65DEF2B176 for ; Fri, 17 Aug 2018 03:12:31 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B0F2A4E2432; Thu, 16 Aug 2018 20:11:35 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C77B74E1CB4 for ; Thu, 16 Aug 2018 20:10:50 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id E03591005372; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id DD837465; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:13 -0400 Message-Id: <1534475441-15543-11-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 10/38] lustre: llite: use C99 for struct lprocfs_llite_obd_vars X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Remove mntpt_path and filegroups since they don't even exit. Migrate the rest to C99 structure initialization. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-3319 Reviewed-on: http://review.whamcloud.com/7290 Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 5530156..0dc4d00 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1086,17 +1086,20 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, LPROC_SEQ_FOPS(ll_nosquash_nids); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { - /* { "mntpt_path", ll_rd_path, 0, 0 }, */ - { "site", &ll_site_stats_fops, NULL, 0 }, - /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "unstable_stats", &ll_unstable_stats_fops, NULL }, - { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, - { .name = "root_squash", + { .name = "site", + .fops = &ll_site_stats_fops }, + { .name = "max_cached_mb", + .fops = &ll_max_cached_mb_fops }, + { .name = "statahead_stats", + .fops = &ll_statahead_stats_fops }, + { .name = "unstable_stats", + .fops = &ll_unstable_stats_fops }, + { .name = "sbi_flags", + .fops = &ll_sbi_flags_fops }, + { .name = "root_squash", .fops = &ll_root_squash_fops }, - { .name = "nosquash_nids", - .fops = &ll_nosquash_nids_fops }, + { .name = "nosquash_nids", + .fops = &ll_nosquash_nids_fops }, { NULL } }; From patchwork Fri Aug 17 03:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E2BB13B6 for ; Fri, 17 Aug 2018 03:11:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A5AC2B124 for ; Fri, 17 Aug 2018 03:11:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E6AA2B157; Fri, 17 Aug 2018 03:11:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E0C662B124 for ; Fri, 17 Aug 2018 03:11:19 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 183494E1F46; Thu, 16 Aug 2018 20:11:05 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1441C4E1CB4 for ; Thu, 16 Aug 2018 20:10:51 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id E626F1005373; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E28DC463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:14 -0400 Message-Id: <1534475441-15543-12-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 11/38] lustre: llite: create ll_stats_pid_write() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Steve Guminski , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Guminski Several repeated code blocks are consolidated into a new function, ll_stats_pid_write(), to reduce duplication. Signed-off-by: Steve Guminski WC-bug-id: https://jira.whamcloud.com/browse/LU-8767 Reviewed-on: https://review.whamcloud.com/23942 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 90 +++++++++++------------ 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 0dc4d00..f57ad15 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -95,6 +95,41 @@ void llite_tunables_unregister(void) static const struct file_operations ll_rw_extents_stats_pp_fops; static const struct file_operations ll_rw_offset_stats_fops; +/** + * ll_stats_pid_write() - Determine if stats collection should be enabled + * @buf: Buffer containing the data written + * @len: Number of bytes in the buffer + * + * Several proc files begin collecting stats when a value is written, and stop + * collecting when either '0' or 'disable' is written. This function checks the + * written value to see if collection should be enabled or disabled. + * + * Return: If '0' or 'disable' is provided, 0 is returned. If the text + * equivalent of a number is written, that number is returned. Otherwise, + * 1 is returned. Non-zero return values indicate collection should be enabled. + */ +static s64 ll_stats_pid_write(const char __user *buf, size_t len) +{ + unsigned long long value = 1; + char kernbuf[16]; + int rc; + + rc = kstrtoull_from_user(buf, len, 0, &value); + if (rc < 0 && len < sizeof(kernbuf)) { + if (copy_from_user(kernbuf, buf, len)) + return -EFAULT; + kernbuf[len] = 0; + + if (kernbuf[len - 1] == '\n') + kernbuf[len - 1] = 0; + + if (strncasecmp(kernbuf, "disable", 7) == 0) + value = 0; + } + + return value; +} + static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -1425,26 +1460,12 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int i; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; @@ -1498,26 +1519,12 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int i; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; @@ -1702,27 +1709,12 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_process_info *process_info = sbi->ll_rw_process_info; struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; From patchwork Fri Aug 17 03:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 291F515E2 for ; Fri, 17 Aug 2018 03:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15F932B124 for ; Fri, 17 Aug 2018 03:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A8152B157; Fri, 17 Aug 2018 03:11:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A57532B124 for ; Fri, 17 Aug 2018 03:11:03 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D201B4E1E03; Thu, 16 Aug 2018 20:10:55 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6A00F4E1CB4 for ; Thu, 16 Aug 2018 20:10:51 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id E97161005374; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E69B7464; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:15 -0400 Message-Id: <1534475441-15543-13-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 12/38] lustre: llite: improve sysfs file text in lproc_llite.c X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Steve Guminski , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Guminski Improves the instructions displayed when reading from the stats files. Signed-off-by: Steve Guminski WC-bug-id: https://jira.whamcloud.com/browse/LU-8767 Reviewed-on: https://review.whamcloud.com/23942 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f57ad15..2a76c01 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1429,8 +1429,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then '0' or 'disabled' to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", @@ -1493,8 +1493,8 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then '0' or 'disabled' to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", @@ -1659,8 +1659,8 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); return 0; } spin_lock(&sbi->ll_process_lock); From patchwork Fri Aug 17 03:10:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 723E014BD for ; Fri, 17 Aug 2018 03:13:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FB2B2886F for ; Fri, 17 Aug 2018 03:13:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54427288D0; Fri, 17 Aug 2018 03:13:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17F562886F for ; Fri, 17 Aug 2018 03:13:00 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2D05C4E1F80; Thu, 16 Aug 2018 20:11:49 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id AE9304E1CF5 for ; Thu, 16 Aug 2018 20:10:51 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id EDC611005377; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id EAECC463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:16 -0400 Message-Id: <1534475441-15543-14-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 13/38] lustre: llite: don't handle success case for blocksize sysfs code X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32496 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 2a76c01..7bd557b 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -141,10 +141,10 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%u\n", osfs.os_bsize); + if (rc) + return rc; - return rc; + return sprintf(buf, "%u\n", osfs.os_bsize); } LUSTRE_RO_ATTR(blocksize); From patchwork Fri Aug 17 03:10:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E1E414BD for ; Fri, 17 Aug 2018 03:11:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 890112B124 for ; Fri, 17 Aug 2018 03:11:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D4092B157; Fri, 17 Aug 2018 03:11:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2BEB02B124 for ; Fri, 17 Aug 2018 03:11:21 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BAAE74E1AC0; Thu, 16 Aug 2018 20:11:05 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id F15964E1CF5 for ; Thu, 16 Aug 2018 20:10:51 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id F2B4B1005378; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id F0747463; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:17 -0400 Message-Id: <1534475441-15543-15-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 14/38] lustre: llite: don't handle success case for kbyte* sysfs code X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32497 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 7bd557b..72a8f8d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -154,22 +154,23 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_blocks; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_blocks; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytestotal); @@ -179,22 +180,23 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_bfree; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_bfree; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesfree); @@ -204,22 +206,23 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_bavail; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_bavail; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesavail); From patchwork Fri Aug 17 03:10:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5BF614BD for ; Fri, 17 Aug 2018 03:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42992886F for ; Fri, 17 Aug 2018 03:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8AE2288D0; Fri, 17 Aug 2018 03:13:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 881EC2886F for ; Fri, 17 Aug 2018 03:13:03 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 7EAD64E26D8; Thu, 16 Aug 2018 20:11:51 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 52F1D4E1D2C for ; Thu, 16 Aug 2018 20:10:52 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 046AA100537A; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 003BD464; Thu, 16 Aug 2018 23:10:45 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:18 -0400 Message-Id: <1534475441-15543-16-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 15/38] lustre: llite: don't handle success case for file* sysfs code X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32497 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 72a8f8d..02a09e7 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -237,10 +237,10 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%llu\n", osfs.os_files); + if (rc) + return rc; - return rc; + return sprintf(buf, "%llu\n", osfs.os_files); } LUSTRE_RO_ATTR(filestotal); @@ -255,10 +255,10 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%llu\n", osfs.os_ffree); + if (rc) + return rc; - return rc; + return sprintf(buf, "%llu\n", osfs.os_ffree); } LUSTRE_RO_ATTR(filesfree); From patchwork Fri Aug 17 03:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E882C13B6 for ; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D69D42B124 for ; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAEAD2B157; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FF332B124 for ; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 585D24E2037; Thu, 16 Aug 2018 20:11:12 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 939824E1AA4 for ; Thu, 16 Aug 2018 20:10:52 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 084D71005382; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 04913463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:19 -0400 Message-Id: <1534475441-15543-17-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 16/38] lustre: llite: user kstrtobool for some sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some of the llite sysfs files only allow 1 or 0 which was retrieved with kstrtoul(). A much better fit would be to use kstrtobool(). This adds 'Y' or 'N' as valid options as well. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9325 Reviewed-on: https://review.whamcloud.com/30539 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 02a09e7..e35b3ea 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -593,25 +593,28 @@ static ssize_t checksum_pages_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; + int tmp; int rc; - unsigned long val; if (!sbi->ll_dt_exp) /* Not set up yet */ return -EAGAIN; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; + spin_lock(&sbi->ll_lock); if (val) sbi->ll_flags |= LL_SBI_CHECKSUM; else sbi->ll_flags &= ~LL_SBI_CHECKSUM; spin_unlock(&sbi->ll_lock); + tmp = val; rc = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CHECKSUM), - KEY_CHECKSUM, sizeof(val), &val, NULL); + KEY_CHECKSUM, sizeof(tmp), &tmp, NULL); if (rc) CWARN("Failed to set OSC checksum flags: %d\n", rc); @@ -753,10 +756,10 @@ static ssize_t statahead_agl_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; @@ -805,10 +808,10 @@ static ssize_t lazystatfs_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; @@ -948,17 +951,14 @@ static ssize_t xattr_cache_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val != 0 && val != 1) - return -ERANGE; - - if (val == 1 && !(sbi->ll_flags & LL_SBI_XATTR_CACHE)) + if (val && !(sbi->ll_flags & LL_SBI_XATTR_CACHE)) return -ENOTSUPP; sbi->ll_xattr_cache_enabled = val; @@ -1030,7 +1030,8 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); char kernbuf[128]; - int val, rc; + bool val; + int rc; if (!count) return 0; @@ -1043,13 +1044,13 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, buffer += lprocfs_find_named_value(kernbuf, "unstable_check:", &count) - kernbuf; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtobool_from_user(buffer, count, &val); if (rc < 0) return rc; /* borrow lru lock to set the value */ spin_lock(&sbi->ll_cache->ccc_lru_lock); - sbi->ll_cache->ccc_unstable_check = !!val; + sbi->ll_cache->ccc_unstable_check = val; spin_unlock(&sbi->ll_cache->ccc_lru_lock); return count; From patchwork Fri Aug 17 03:10:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AEF414BD for ; Fri, 17 Aug 2018 03:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284BF2B144 for ; Fri, 17 Aug 2018 03:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 191E52B176; Fri, 17 Aug 2018 03:11:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C9B252B144 for ; Fri, 17 Aug 2018 03:11:43 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 708CC4E1E78; Thu, 16 Aug 2018 20:11:15 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id F17A74E1AA4 for ; Thu, 16 Aug 2018 20:10:52 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 0A9C11005383; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 08A68464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:20 -0400 Message-Id: <1534475441-15543-18-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 17/38] lustre: llite: add newline to llite.*.offset_stats X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andreas Dilger The llite.*.offset_stats file is missing a newline in the output. Signed-off-by: Andreas Dilger WC-bug-id: https://jira.whamcloud.com/browse/LU-11147 Reviewed-on: https://review.whamcloud.com/32817 Reviewed-by: James Simmons Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index e35b3ea..c2d27d7 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1678,7 +1678,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < LL_OFFSET_HIST_MAX; i++) { if (offset[i].rw_pid != 0) seq_printf(seq, - "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + "%3c %10d %14llu %14llu %17lu %17lu %14llu\n", offset[i].rw_op == READ ? 'R' : 'W', offset[i].rw_pid, offset[i].rw_range_start, @@ -1691,7 +1691,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid != 0) seq_printf(seq, - "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + "%3c %10d %14llu %14llu %17lu %17lu %14llu\n", process[i].rw_op == READ ? 'R' : 'W', process[i].rw_pid, process[i].rw_range_start, From patchwork Fri Aug 17 03:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5188713B6 for ; Fri, 17 Aug 2018 03:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC682B157 for ; Fri, 17 Aug 2018 03:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320EC2B176; Fri, 17 Aug 2018 03:11:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 40AE62B192 for ; Fri, 17 Aug 2018 03:11:51 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 608524E1C67; Thu, 16 Aug 2018 20:11:18 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 413BD4E1AA4 for ; Thu, 16 Aug 2018 20:10:53 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 120F61005384; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0E12A463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:21 -0400 Message-Id: <1534475441-15543-19-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 18/38] lustre: obd: embedded struct lprocfs_vars in obd device X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently struct lprocfs_vars is initialized by the function lprocfs_xxx_init_var() in many places. By initializing and caching the obd_vars inside of the obd device we can simplify the code greatly. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-3319 Reviewed-on: https://review.whamcloud.com/7135 Reviewed-by: Bob Glossman Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 1 + drivers/staging/lustre/lustre/lmv/lmv_internal.h | 3 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 7 ++----- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 5 +++-- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 ++- drivers/staging/lustre/lustre/lov/lov_obd.c | 11 +++-------- drivers/staging/lustre/lustre/lov/lproc_lov.c | 5 +++-- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 5 +++-- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++-------- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 5 +++-- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 3 ++- drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ++-- drivers/staging/lustre/lustre/osc/lproc_osc.c | 5 +++-- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 ++- drivers/staging/lustre/lustre/osc/osc_request.c | 13 ++++--------- 18 files changed, 43 insertions(+), 51 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 495e6f5..ca4cd9a 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,7 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, +int lprocfs_obd_setup(struct obd_device *obd, const struct attribute_group *attrs); int lprocfs_obd_cleanup(struct obd_device *obd); diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 3c0dbb6..0b071e3 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -602,6 +602,7 @@ struct obd_device { struct dentry *obd_debugfs_entry; struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; + struct lprocfs_vars *obd_vars; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; struct list_head obd_evict_list; /* protected with pet_lock */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 68a9917..3157ab9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,7 +157,8 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_lmv_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); extern const struct file_operations lmv_proc_target_fops; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 55db904..1867f6a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1254,9 +1254,9 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(&lvars); + lprocfs_lmv_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, @@ -3098,11 +3098,8 @@ static int lmv_merge_attr(struct obd_export *exp, static int __init lmv_init(void) { - struct lprocfs_static_vars lvars; int rc; - lprocfs_lmv_init_vars(&lvars); - rc = libcfs_setup(); if (rc) return rc; diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 30727b7..bc6e13c 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -166,8 +166,9 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) .attrs = lmv_attrs, }; -void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_lmv_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_lmv_obd_vars; lvars->sysfs_vars = &lmv_attr_group; - lvars->obd_vars = lprocfs_lmv_obd_vars; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 47042f2..e93dfd4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -241,7 +241,8 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, /* lproc_lov.c */ extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_lov_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 07f6b1b..05d097e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -769,8 +769,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) goto out; - lprocfs_lov_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_lov_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); @@ -872,7 +872,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, goto out; } case LCFG_PARAM: { - struct lprocfs_static_vars lvars = { NULL }; struct lov_desc *desc = &obd->u.lov.desc; if (!desc) { @@ -880,9 +879,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, goto out; } - lprocfs_lov_init_vars(&lvars); - - rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars, + rc = class_process_proc_param(PARAM_LOV, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -1356,7 +1353,6 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, static int __init lov_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; /* print an address of _any_ initialized kernel symbol from this @@ -1380,7 +1376,6 @@ static int __init lov_init(void) lu_kmem_fini(lov_caches); return -ENOMEM; } - lprocfs_lov_init_vars(&lvars); rc = class_register_type(&lov_obd_ops, NULL, LUSTRE_LOV_NAME, &lov_device_type); diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 721440f..317c154 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -284,10 +284,11 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) .attrs = lov_attrs, }; -void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_lov_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_lov_obd_vars; lvars->sysfs_vars = &lov_attr_group; - lvars->obd_vars = lprocfs_lov_obd_vars; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 6cce324..bf92893 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -224,8 +224,9 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, .attrs = mdc_attrs, }; -void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_mdc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_mdc_obd_vars; lvars->sysfs_vars = &mdc_attr_group; - lvars->obd_vars = lprocfs_mdc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index f19b0ce..20be240 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,8 +36,8 @@ #include -void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); - +void lprocfs_mdc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index a759da2..8a90dab 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2648,8 +2648,8 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_mdc_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -2716,13 +2716,11 @@ static int mdc_cleanup(struct obd_device *obd) static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) { struct lustre_cfg *lcfg = buf; - struct lprocfs_static_vars lvars = { NULL }; int rc = 0; - lprocfs_mdc_init_vars(&lvars); switch (lcfg->lcfg_command) { default: - rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars, + rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -2784,15 +2782,12 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) static int __init mdc_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; rc = libcfs_setup(); if (rc) return rc; - lprocfs_mdc_init_vars(&lvars); - return class_register_type(&mdc_obd_ops, &mdc_md_ops, LUSTRE_MDC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 6367706..e92787d 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -63,7 +63,8 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { NULL } }; -void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_mgc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { - lvars->obd_vars = lprocfs_mgc_obd_vars; + obd->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 9541892..400d52c 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,7 +39,8 @@ #include #include -void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_mgc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 833e6a0..6c769c6 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -748,8 +748,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_mgc_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3776447..c032458 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1014,7 +1014,7 @@ static void obd_sysfs_release(struct kobject *kobj) .release = obd_sysfs_release, }; -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, +int lprocfs_obd_setup(struct obd_device *obd, const struct attribute_group *attrs) { int rc = 0; @@ -1036,7 +1036,7 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name, obd->obd_type->typ_debugfs_entry); - ldebugfs_add_vars(obd->obd_debugfs_entry, list, obd); + ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_vars, obd); return rc; } diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 54a303e..1492ad9 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -824,8 +824,9 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) .attrs = osc_attrs, }; -void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_osc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { lvars->sysfs_vars = &osc_attr_group; - lvars->obd_vars = lprocfs_osc_obd_vars; + obd->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 02e8318..a762d31 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -146,7 +146,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_osc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index b2b55a7..9c226f0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2803,8 +2803,9 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out_ptlrpcd_work; cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(&lvars); - if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) { + + lprocfs_osc_init_vars(obd, &lvars); + if (lprocfs_obd_setup(obd, lvars.sysfs_vars) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -2911,14 +2912,11 @@ static int osc_cleanup(struct obd_device *obd) int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; int rc = 0; - lprocfs_osc_init_vars(&lvars); - switch (lcfg->lcfg_command) { default: - rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars, + rc = class_process_proc_param(PARAM_OSC, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -2967,7 +2965,6 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) static int __init osc_init(void) { - struct lprocfs_static_vars lvars = { NULL }; unsigned int reqpool_size; unsigned int reqsize; int rc; @@ -2986,8 +2983,6 @@ static int __init osc_init(void) if (rc) return rc; - lprocfs_osc_init_vars(&lvars); - rc = register_shrinker(&osc_cache_shrinker); if (rc) goto err; From patchwork Fri Aug 17 03:10:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01BE813B6 for ; Fri, 17 Aug 2018 03:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E34972B157 for ; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D81672B18D; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 860EE2B157 for ; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id D64BF4E2215; Thu, 16 Aug 2018 20:11:21 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 996A34E1D85 for ; Thu, 16 Aug 2018 20:10:53 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1640E1005385; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 11E1E464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:22 -0400 Message-Id: <1534475441-15543-20-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 19/38] lustre: obdclass: swap obd device attrs and default_attrs X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the obd_ktype sets its default_attr field to the universal obd_def_attr and attaches additional attributes. Reverse this by making obd device specific attributes the default and add obd_def_attr as the extra. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index c032458..d370fbb 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -989,7 +989,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); -static struct attribute *obd_def_attrs[] = { +static const struct attribute *obd_def_attrs[] = { &lustre_attr_blocksize.attr, &lustre_attr_kbytestotal.attr, &lustre_attr_kbytesfree.attr, @@ -1009,7 +1009,6 @@ static void obd_sysfs_release(struct kobject *kobj) } static struct kobj_type obd_ktype = { - .default_attrs = obd_def_attrs, .sysfs_ops = &lustre_sysfs_ops, .release = obd_sysfs_release, }; @@ -1019,6 +1018,7 @@ int lprocfs_obd_setup(struct obd_device *obd, { int rc = 0; + obd_ktype.default_attrs = attrs->attrs; init_completion(&obd->obd_kobj_unregister); rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, obd->obd_type->typ_kobj, @@ -1026,12 +1026,10 @@ int lprocfs_obd_setup(struct obd_device *obd, if (rc) return rc; - if (attrs) { - rc = sysfs_create_group(&obd->obd_kobj, attrs); - if (rc) { - kobject_put(&obd->obd_kobj); - return rc; - } + rc = sysfs_create_files(&obd->obd_kobj, obd_def_attrs); + if (rc) { + kobject_put(&obd->obd_kobj); + return rc; } obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name, @@ -1049,6 +1047,8 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); + sysfs_remove_files(&obd->obd_kobj, obd_def_attrs); + kobject_put(&obd->obd_kobj); wait_for_completion(&obd->obd_kobj_unregister); From patchwork Fri Aug 17 03:10:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 790DC14BD for ; Fri, 17 Aug 2018 03:12:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63C752B157 for ; Fri, 17 Aug 2018 03:12:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56B572B18D; Fri, 17 Aug 2018 03:12:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7938E2B157 for ; Fri, 17 Aug 2018 03:12:05 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id AAE374E1F01; Thu, 16 Aug 2018 20:11:24 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DABFD4E1DA1 for ; Thu, 16 Aug 2018 20:10:53 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1A2091005386; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 1630E463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:23 -0400 Message-Id: <1534475441-15543-21-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 20/38] lustre: obdclass: embedded attributes in struct obd_device X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can further simplify lprocfs_obd_setup() by embedding the obd devices attributes in struct obd_device. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-on: https://review.whamcloud.com/32377 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 3 +-- drivers/staging/lustre/lustre/include/obd.h | 2 ++ drivers/staging/lustre/lustre/lmv/lmv_internal.h | 3 +-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++--- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 9 ++------- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 +-- drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++--- drivers/staging/lustre/lustre/lov/lproc_lov.c | 5 ++--- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 9 ++------- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 3 +-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 5 ++--- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 5 ++--- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 3 +-- drivers/staging/lustre/lustre/mgc/mgc_request.c | 5 ++--- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 16 ++++++---------- drivers/staging/lustre/lustre/osc/lproc_osc.c | 9 ++------- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +-- drivers/staging/lustre/lustre/osc/osc_request.c | 5 ++--- 18 files changed, 34 insertions(+), 64 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index ca4cd9a..358ace3 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,8 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd, - const struct attribute_group *attrs); +int lprocfs_obd_setup(struct obd_device *obd); int lprocfs_obd_cleanup(struct obd_device *obd); /* Generic callbacks */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0b071e3..55aa035 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -602,6 +602,7 @@ struct obd_device { struct dentry *obd_debugfs_entry; struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; + const struct attribute **obd_attrs; struct lprocfs_vars *obd_vars; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; @@ -623,6 +624,7 @@ struct obd_device { struct lu_ref obd_reference; struct kobject obd_kobj; /* sysfs object */ + struct kobj_type obd_ktype; struct completion obd_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 3157ab9..1b51dfb 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,8 +157,7 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_lmv_init_vars(struct obd_device *obd); extern const struct file_operations lmv_proc_target_fops; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1867f6a..212ca31 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1224,7 +1224,6 @@ int lmv_fid_alloc(const struct lu_env *env, struct obd_export *exp, static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lmv_obd *lmv = &obd->u.lmv; - struct lprocfs_static_vars lvars = { NULL }; struct lmv_desc *desc; int rc; @@ -1254,9 +1253,9 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(obd, &lvars); + lprocfs_lmv_init_vars(obd); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_obd_setup(obd); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index bc6e13c..c54227d 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -162,13 +162,8 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) NULL, }; -static const struct attribute_group lmv_attr_group = { - .attrs = lmv_attrs, -}; - -void lprocfs_lmv_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_lmv_init_vars(struct obd_device *obd) { obd->obd_vars = lprocfs_lmv_obd_vars; - lvars->sysfs_vars = &lmv_attr_group; + obd->obd_ktype.default_attrs = lmv_attrs; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index e93dfd4..7e0b9ac 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -241,8 +241,7 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, /* lproc_lov.c */ extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_lov_init_vars(struct obd_device *obd); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 05d097e..43ebec6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -718,7 +718,6 @@ void lov_fix_desc(struct lov_desc *desc) int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct lov_desc *desc; struct lov_obd *lov = &obd->u.lov; int rc; @@ -769,8 +768,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) goto out; - lprocfs_lov_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_lov_init_vars(obd); + lprocfs_obd_setup(obd); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 317c154..ca86f16 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -284,11 +284,10 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) .attrs = lov_attrs, }; -void lprocfs_lov_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_lov_init_vars(struct obd_device *obd) { obd->obd_vars = lprocfs_lov_obd_vars; - lvars->sysfs_vars = &lov_attr_group; + obd->obd_ktype.default_attrs = lov_attrs; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index bf92893..fc5f3a3 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -220,13 +220,8 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, NULL, }; -static const struct attribute_group mdc_attr_group = { - .attrs = mdc_attrs, -}; - -void lprocfs_mdc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_mdc_init_vars(struct obd_device *obd) { + obd->obd_ktype.default_attrs = mdc_attrs; obd->obd_vars = lprocfs_mdc_obd_vars; - lvars->sysfs_vars = &mdc_attr_group; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 20be240..d66663f 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,8 +36,7 @@ #include -void lprocfs_mdc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_mdc_init_vars(struct obd_device *obd); void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 8a90dab..a3c0461f 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2637,7 +2637,6 @@ static void mdc_llog_finish(struct obd_device *obd) static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) { - struct lprocfs_static_vars lvars = { NULL }; int rc; rc = ptlrpcd_addref(); @@ -2648,8 +2647,8 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_mdc_init_vars(obd); + lprocfs_obd_setup(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index e92787d..7951ec6 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -63,8 +63,7 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { NULL } }; -void lprocfs_mgc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_mgc_init_vars(struct obd_device *obd) { - obd->obd_vars = lprocfs_mgc_obd_vars; + obd->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 400d52c..5385d91 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,8 +39,7 @@ #include #include -void lprocfs_mgc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_mgc_init_vars(struct obd_device *obd); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 6c769c6..46b1e36 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -730,7 +730,6 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct task_struct *task; int rc; @@ -748,8 +747,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_mgc_init_vars(obd); + lprocfs_obd_setup(obd); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index d370fbb..a5676ff 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1008,19 +1008,15 @@ static void obd_sysfs_release(struct kobject *kobj) complete(&obd->obd_kobj_unregister); } -static struct kobj_type obd_ktype = { - .sysfs_ops = &lustre_sysfs_ops, - .release = obd_sysfs_release, -}; - -int lprocfs_obd_setup(struct obd_device *obd, - const struct attribute_group *attrs) +int lprocfs_obd_setup(struct obd_device *obd) { - int rc = 0; + int rc; + + obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; + obd->obd_ktype.release = obd_sysfs_release; - obd_ktype.default_attrs = attrs->attrs; init_completion(&obd->obd_kobj_unregister); - rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, + rc = kobject_init_and_add(&obd->obd_kobj, &obd->obd_ktype, obd->obd_type->typ_kobj, "%s", obd->obd_name); if (rc) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 1492ad9..3bcb36b 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -820,13 +820,8 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) NULL, }; -static const struct attribute_group osc_attr_group = { - .attrs = osc_attrs, -}; - -void lprocfs_osc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_osc_init_vars(struct obd_device *obd) { - lvars->sysfs_vars = &osc_attr_group; + obd->obd_ktype.default_attrs = osc_attrs; obd->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index a762d31..6caabdb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -146,8 +146,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_osc_init_vars(struct obd_device *obd); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 9c226f0..0472165 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2767,7 +2767,6 @@ static int brw_queue_work(const struct lu_env *env, void *data) int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct client_obd *cli = &obd->u.cli; void *handler; int rc; @@ -2804,8 +2803,8 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(obd, &lvars); - if (lprocfs_obd_setup(obd, lvars.sysfs_vars) == 0) { + lprocfs_osc_init_vars(obd); + if (lprocfs_obd_setup(obd) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); From patchwork Fri Aug 17 03:10:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 173D913B6 for ; Fri, 17 Aug 2018 03:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 032D72B124 for ; Fri, 17 Aug 2018 03:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB7542B144; Fri, 17 Aug 2018 03:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 77F602B176 for ; Fri, 17 Aug 2018 03:11:28 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BCF9F4E1C83; Thu, 16 Aug 2018 20:11:08 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 3C05621FFA8 for ; Thu, 16 Aug 2018 20:10:54 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 1EBDF1005387; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 1A8F2464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:24 -0400 Message-Id: <1534475441-15543-22-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 21/38] lustre: obdclass: add light weight obd_def_uuid_attrs X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP It was assumed that all obd devices supported every attribute in obd_def_attrs but that is not true. Several obd devices only have a uuid sysfs file. Add an option to lprocfs_obd_setup() to select the proper obd_def_attrs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/26020 Reviewed-by: John L. Hammond Reviewed-by: Niu Yawei Reviewed-by: Fan Yong Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- .../staging/lustre/lustre/obdclass/lprocfs_status.c | 19 ++++++++++++++++--- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 358ace3..f428ce0 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,7 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd); +int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only); int lprocfs_obd_cleanup(struct obd_device *obd); /* Generic callbacks */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 212ca31..c36ecb7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1255,7 +1255,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, true); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 43ebec6..751bf64 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -769,7 +769,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out; lprocfs_lov_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, false); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index a3c0461f..fcba599 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2648,7 +2648,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) goto err_ptlrpcd_decref; lprocfs_mdc_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, false); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 46b1e36..50da9cf 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -748,7 +748,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } lprocfs_mgc_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, true); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a5676ff..91d37fc 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -989,6 +989,11 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); +static const struct attribute *obd_def_uuid_attrs[] = { + &lustre_attr_uuid.attr, + NULL, +}; + static const struct attribute *obd_def_attrs[] = { &lustre_attr_blocksize.attr, &lustre_attr_kbytestotal.attr, @@ -1008,7 +1013,7 @@ static void obd_sysfs_release(struct kobject *kobj) complete(&obd->obd_kobj_unregister); } -int lprocfs_obd_setup(struct obd_device *obd) +int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) { int rc; @@ -1022,7 +1027,12 @@ int lprocfs_obd_setup(struct obd_device *obd) if (rc) return rc; - rc = sysfs_create_files(&obd->obd_kobj, obd_def_attrs); + if (uuid_only) + obd->obd_attrs = obd_def_uuid_attrs; + else + obd->obd_attrs = obd_def_attrs; + + rc = sysfs_create_files(&obd->obd_kobj, obd->obd_attrs); if (rc) { kobject_put(&obd->obd_kobj); return rc; @@ -1043,7 +1053,10 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); - sysfs_remove_files(&obd->obd_kobj, obd_def_attrs); + if (obd->obd_attrs) { + sysfs_remove_files(&obd->obd_kobj, obd->obd_attrs); + obd->obd_attrs = NULL; + } kobject_put(&obd->obd_kobj); wait_for_completion(&obd->obd_kobj_unregister); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 0472165..4f57a8e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2804,7 +2804,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(obd); - if (lprocfs_obd_setup(obd) == 0) { + if (lprocfs_obd_setup(obd, false) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); From patchwork Fri Aug 17 03:10:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E93DF14BD for ; Fri, 17 Aug 2018 03:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A9C2B124 for ; Fri, 17 Aug 2018 03:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4CB22B18D; Fri, 17 Aug 2018 03:11:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6164F2B124 for ; Fri, 17 Aug 2018 03:11:14 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B50C14E1DB6; Thu, 16 Aug 2018 20:11:02 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 914E321FFA8 for ; Thu, 16 Aug 2018 20:10:54 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 22FD01005388; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 1EF43463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:25 -0400 Message-Id: <1534475441-15543-23-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 22/38] lustre: obd: migrate to ksets X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Lustre's obd_device sysfs only uses kobjects but with the introduction of ksets we can use functionality like kset_find_kobj() and uevents. Currently lustre is layered as lustre_kobj -> class -> obd device. This patch changes the obd devices and the top level lustre_kobj into ksets. The class level is kept as kobjects but are bound to the top level lustre kset so they searchable and uevents can be created for them. Also much of the class functionality can be replaced with what ksets can do. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 3 +- drivers/staging/lustre/lustre/include/obd.h | 9 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 4 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++- drivers/staging/lustre/lustre/lov/lproc_lov.c | 4 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 14 +++--- drivers/staging/lustre/lustre/obdclass/genops.c | 35 ++++++++++----- .../lustre/lustre/obdclass/lprocfs_status.c | 41 +++++++++++------- drivers/staging/lustre/lustre/obdclass/module.c | 17 ++++---- drivers/staging/lustre/lustre/obdclass/sysctl.c | 2 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 50 +++++++++++----------- 15 files changed, 116 insertions(+), 82 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index f428ce0..3863fff 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -339,7 +339,7 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ extern struct dentry *debugfs_lustre_root; -extern struct kobject *lustre_kobj; +extern struct kset *lustre_kset; struct obd_device; struct obd_histogram; @@ -572,6 +572,7 @@ struct lustre_attr { #define LUSTRE_ATTR(name, mode, show, store) \ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) +#define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store) #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 55aa035..36f6c10 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -34,7 +34,9 @@ #ifndef __OBD_H #define __OBD_H +#include #include +#include #include #include @@ -109,7 +111,8 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; - struct kobject *typ_kobj; + struct kobject typ_kobj; + struct completion typ_kobj_unregister; }; struct brw_page { @@ -623,9 +626,9 @@ struct obd_device { */ struct lu_ref obd_reference; - struct kobject obd_kobj; /* sysfs object */ + struct kset obd_kset; /* sysfs object collection */ struct kobj_type obd_ktype; - struct completion obd_kobj_unregister; + struct completion obd_kobj_unregister; }; int obd_uuid_add(struct obd_device *obd, struct obd_export *export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 0ee4798..adc96b6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -956,7 +956,7 @@ static int ldlm_setup(void) if (!ldlm_state) return -ENOMEM; - ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); + ldlm_kobj = kobject_create_and_add("ldlm", &lustre_kset->kobj); if (!ldlm_kobj) { rc = -ENOMEM; goto out; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index ce072da..7765060 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -574,7 +574,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) if (sbi->ll_dt_obd) { err = sysfs_create_link(&sbi->ll_kset.kobj, - &sbi->ll_dt_obd->obd_kobj, + &sbi->ll_dt_obd->obd_kset.kobj, sbi->ll_dt_obd->obd_type->typ_name); if (err < 0) { CERROR("%s: could not register %s in llite: rc = %d\n", @@ -585,7 +585,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) if (sbi->ll_md_obd) { err = sysfs_create_link(&sbi->ll_kset.kobj, - &sbi->ll_md_obd->obd_kobj, + &sbi->ll_md_obd->obd_kset.kobj, sbi->ll_md_obd->obd_type->typ_name); if (err < 0) { CERROR("%s: could not register %s in llite: rc = %d\n", diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index c2d27d7..ab2f102 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -63,8 +63,9 @@ int llite_tunables_register(void) if (!kobj) return -ENOMEM; + kobj->kset = lustre_kset; kobject_init(kobj, &class_ktype); - rc = kobject_add(kobj, lustre_kobj, "%s", name); + rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); if (rc) { kobject_put(kobj); return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index c36ecb7..7d5d03b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -210,7 +210,7 @@ static int lmv_connect(const struct lu_env *env, lmv->conn_data = *data; lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", - &obd->obd_kobj); + &obd->obd_kset.kobj); rc = lmv_check_connect(obd); if (rc) goto out_sysfs; @@ -349,7 +349,8 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) if (lmv->lmv_tgts_kobj) /* Even if we failed to create the link, that's fine */ - rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj, + rc = sysfs_create_link(lmv->lmv_tgts_kobj, + &mdc_obd->obd_kset.kobj, mdc_obd->obd_name); return 0; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index c54227d..6aae298 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -43,7 +43,7 @@ static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lmv_desc *desc; desc = &dev->u.lmv.desc; @@ -55,7 +55,7 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lmv_desc *desc; desc = &dev->u.lmv.desc; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 751bf64..28b7d91 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -191,7 +191,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (lov->lov_tgts_kobj) /* Even if we failed, that's ok */ - rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj, + rc = sysfs_create_link(lov->lov_tgts_kobj, + &tgt_obd->obd_kset.kobj, tgt_obd->obd_name); return 0; @@ -226,7 +227,7 @@ static int lov_connect(const struct lu_env *env, obd_getref(obd); lov->lov_tgts_kobj = kobject_create_and_add("target_obds", - &obd->obd_kobj); + &obd->obd_kset.kobj); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index ca86f16..9c5d6fc 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -171,7 +171,7 @@ static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lov_desc *desc; desc = &dev->u.lov.desc; @@ -183,7 +183,7 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lov_desc *desc; desc = &dev->u.lov.desc; diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index fc5f3a3..47f23d6 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -41,7 +41,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", !dev->u.cli.cl_import->imp_deactive); } @@ -50,7 +50,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); unsigned long val; int rc; @@ -79,7 +79,7 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, { int len; struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); __u32 max; max = obd_get_max_rpcs_in_flight(&dev->u.cli); @@ -94,7 +94,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -115,7 +115,7 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); u16 max; int len; @@ -131,7 +131,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); u16 val; int rc; @@ -187,7 +187,7 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 532418e..bf182e5 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -133,6 +133,19 @@ void class_put_type(struct obd_type *type) spin_unlock(&type->obd_type_lock); } +static void class_sysfs_release(struct kobject *kobj) +{ + struct obd_type *type = container_of(kobj, struct obd_type, + typ_kobj); + + complete(&type->typ_kobj_unregister); +} + +static struct kobj_type class_ktype = { + .sysfs_ops = &lustre_sysfs_ops, + .release = class_sysfs_release, +}; + #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, @@ -174,17 +187,21 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); - type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj); - if (!type->typ_kobj) { - rc = -ENOMEM; + type->typ_kobj.kset = lustre_kset; + init_completion(&type->typ_kobj_unregister); + rc = kobject_init_and_add(&type->typ_kobj, &class_ktype, + &lustre_kset->kobj, "%s", type->typ_name); + if (rc) goto failed; - } + if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); - if (rc != 0) + if (rc != 0) { + kobject_put(&type->typ_kobj); goto failed; + } } spin_lock(&obd_types_lock); @@ -193,9 +210,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; - failed: - if (type->typ_kobj) - kobject_put(type->typ_kobj); +failed: kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); @@ -222,8 +237,8 @@ int class_unregister_type(const char *name) return -EBUSY; } - if (type->typ_kobj) - kobject_put(type->typ_kobj); + kobject_put(&type->typ_kobj); + wait_for_completion(&type->typ_kobj_unregister); debugfs_remove_recursive(type->typ_debugfs_entry); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 91d37fc..b3ba554 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -353,7 +353,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%s\n", obd->obd_uuid.uuid); } @@ -363,7 +363,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -379,7 +379,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -402,7 +402,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -425,7 +425,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -448,7 +448,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -464,7 +464,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -1008,7 +1008,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) static void obd_sysfs_release(struct kobject *kobj) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); complete(&obd->obd_kobj_unregister); } @@ -1017,13 +1017,20 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) { int rc; + if (!obd || obd->obd_magic != OBD_DEVICE_MAGIC) + return -ENODEV; + + rc = kobject_set_name(&obd->obd_kset.kobj, "%s", obd->obd_name); + if (rc) + return rc; + obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; obd->obd_ktype.release = obd_sysfs_release; + obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj; + obd->obd_kset.kobj.ktype = &obd->obd_ktype; init_completion(&obd->obd_kobj_unregister); - rc = kobject_init_and_add(&obd->obd_kobj, &obd->obd_ktype, - obd->obd_type->typ_kobj, - "%s", obd->obd_name); + rc = kset_register(&obd->obd_kset); if (rc) return rc; @@ -1032,9 +1039,9 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) else obd->obd_attrs = obd_def_attrs; - rc = sysfs_create_files(&obd->obd_kobj, obd->obd_attrs); + rc = sysfs_create_files(&obd->obd_kset.kobj, obd->obd_attrs); if (rc) { - kobject_put(&obd->obd_kobj); + kset_unregister(&obd->obd_kset); return rc; } @@ -1053,12 +1060,16 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); + /* obd device never allocated a kset */ + if (!obd->obd_kset.kobj.state_initialized) + return 0; + if (obd->obd_attrs) { - sysfs_remove_files(&obd->obd_kobj, obd->obd_attrs); + sysfs_remove_files(&obd->obd_kset.kobj, obd->obd_attrs); obd->obd_attrs = NULL; } - kobject_put(&obd->obd_kobj); + kset_unregister(&obd->obd_kset); wait_for_completion(&obd->obd_kobj_unregister); return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 9c80058..0ce2617 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -471,8 +471,8 @@ static int obd_device_list_open(struct inode *inode, struct file *file) .release = seq_release, }; -struct kobject *lustre_kobj; -EXPORT_SYMBOL_GPL(lustre_kobj); +struct kset *lustre_kset; +EXPORT_SYMBOL_GPL(lustre_kset); static const struct attribute_group lustre_attr_group = { .attrs = lustre_attrs, @@ -482,14 +482,14 @@ int class_procfs_init(void) { int rc = -ENOMEM; - lustre_kobj = kobject_create_and_add("lustre", fs_kobj); - if (!lustre_kobj) + lustre_kset = kset_create_and_add("lustre", NULL, fs_kobj); + if (!lustre_kset) goto out; /* Create the files associated with this kobject */ - rc = sysfs_create_group(lustre_kobj, &lustre_attr_group); + rc = sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); if (rc) { - kobject_put(lustre_kobj); + kset_unregister(lustre_kset); goto out; } @@ -507,8 +507,9 @@ int class_procfs_clean(void) debugfs_lustre_root = NULL; - sysfs_remove_group(lustre_kobj, &lustre_attr_group); - kobject_put(lustre_kobj); + sysfs_remove_group(&lustre_kset->kobj, &lustre_attr_group); + + kset_unregister(lustre_kset); return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/sysctl.c b/drivers/staging/lustre/lustre/obdclass/sysctl.c index e5e8687..f8760b2 100644 --- a/drivers/staging/lustre/lustre/obdclass/sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/sysctl.c @@ -158,5 +158,5 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, int obd_sysctl_init(void) { - return sysfs_create_group(lustre_kobj, &lustre_attr_group); + return sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); } diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3bcb36b..4ed289b 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -44,7 +44,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); } @@ -54,7 +54,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -80,7 +80,7 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); @@ -92,7 +92,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; int rc; unsigned long val; @@ -133,7 +133,7 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; long val; int mult; @@ -149,7 +149,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; int rc; unsigned long pages_number; @@ -247,7 +247,7 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); @@ -260,7 +260,7 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_avail_grant); @@ -272,7 +272,7 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &obd->u.cli; int rc; unsigned long long val; @@ -298,7 +298,7 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_lost_grant); @@ -310,7 +310,7 @@ static ssize_t cur_dirty_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_dirty_grant); @@ -322,7 +322,7 @@ static ssize_t grant_shrink_interval_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval); } @@ -333,7 +333,7 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -355,7 +355,7 @@ static ssize_t checksums_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); } @@ -366,7 +366,7 @@ static ssize_t checksums_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -442,7 +442,7 @@ static ssize_t resend_count_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } @@ -453,7 +453,7 @@ static ssize_t resend_count_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -472,7 +472,7 @@ static ssize_t contention_seconds_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); return sprintf(buf, "%u\n", od->od_contention_time); @@ -484,7 +484,7 @@ static ssize_t contention_seconds_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); int rc; int val; @@ -507,7 +507,7 @@ static ssize_t lockless_truncate_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); return sprintf(buf, "%u\n", od->od_lockless_truncate); @@ -519,7 +519,7 @@ static ssize_t lockless_truncate_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); int rc; unsigned int val; @@ -539,7 +539,7 @@ static ssize_t destroys_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight)); @@ -551,7 +551,7 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); @@ -563,7 +563,7 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; @@ -598,7 +598,7 @@ static ssize_t unstable_stats_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; long pages; int mb; From patchwork Fri Aug 17 03:10:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B9C113B6 for ; Fri, 17 Aug 2018 03:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 771DA2886F for ; Fri, 17 Aug 2018 03:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A647289B3; Fri, 17 Aug 2018 03:13:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D23462886F for ; Fri, 17 Aug 2018 03:13:06 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 005E24E2727; Thu, 16 Aug 2018 20:11:53 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E70474E1C1E for ; Thu, 16 Aug 2018 20:10:54 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2754D1005389; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 235F9464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:26 -0400 Message-Id: <1534475441-15543-24-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 23/38] lustre: obd: create class_setup_tunables() function X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Creat class_setup_tunables() so sysfs kobject creation is handled for both obd_devices and llite. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28108 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd.h | 3 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 ++ drivers/staging/lustre/lustre/llite/lproc_llite.c | 30 +++------------- drivers/staging/lustre/lustre/obdclass/genops.c | 40 +++++++++++++++------- .../lustre/lustre/obdclass/lprocfs_status.c | 2 +- 5 files changed, 36 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 36f6c10..385a88d 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -111,8 +111,7 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; - struct kobject typ_kobj; - struct completion typ_kobj_unregister; + struct kobject *typ_kobj; }; struct brw_page { diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index fd9d99b..e994c968 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -33,6 +33,7 @@ #ifndef __CLASS_OBD_H #define __CLASS_OBD_H +#include #include #include #include @@ -59,6 +60,7 @@ /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *conn); +struct kobject *class_setup_tunables(const char *name); int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, const char *name, struct lu_device_type *ldt); int class_unregister_type(const char *name); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index ab2f102..30873fc 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -43,40 +43,20 @@ static struct kobject *llite_kobj; static struct dentry *llite_root; -static void class_sysfs_release(struct kobject *kobj) -{ - kfree(kobj); -} - -static struct kobj_type class_ktype = { - .sysfs_ops = &lustre_sysfs_ops, - .release = class_sysfs_release, -}; - int llite_tunables_register(void) { - const char *name = "llite"; - struct kobject *kobj; int rc = 0; - kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); - if (!kobj) - return -ENOMEM; - - kobj->kset = lustre_kset; - kobject_init(kobj, &class_ktype); - rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); - if (rc) { - kobject_put(kobj); - return -ENOMEM; - } - llite_kobj = kobj; + llite_kobj = class_setup_tunables("llite"); + if (IS_ERR(llite_kobj)) + return PTR_ERR(llite_kobj); llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; llite_root = NULL; - kobject_put(kobj); + kobject_put(llite_kobj); + llite_kobj = NULL; } return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index bf182e5..29ed498 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -135,10 +135,7 @@ void class_put_type(struct obd_type *type) static void class_sysfs_release(struct kobject *kobj) { - struct obd_type *type = container_of(kobj, struct obd_type, - typ_kobj); - - complete(&type->typ_kobj_unregister); + kfree(kobj); } static struct kobj_type class_ktype = { @@ -146,6 +143,26 @@ static void class_sysfs_release(struct kobject *kobj) .release = class_sysfs_release, }; +struct kobject *class_setup_tunables(const char *name) +{ + struct kobject *kobj; + int rc; + + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return ERR_PTR(-ENOMEM); + + kobj->kset = lustre_kset; + kobject_init(kobj, &class_ktype); + rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); + if (rc) { + kobject_put(kobj); + return ERR_PTR(rc); + } + return kobj; +} +EXPORT_SYMBOL(class_setup_tunables); + #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, @@ -187,19 +204,17 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); - type->typ_kobj.kset = lustre_kset; - init_completion(&type->typ_kobj_unregister); - rc = kobject_init_and_add(&type->typ_kobj, &class_ktype, - &lustre_kset->kobj, "%s", type->typ_name); - if (rc) + type->typ_kobj = class_setup_tunables(type->typ_name); + if (IS_ERR(type->typ_kobj)) { + rc = PTR_ERR(type->typ_kobj); goto failed; - + } if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); if (rc != 0) { - kobject_put(&type->typ_kobj); + kobject_put(type->typ_kobj); goto failed; } } @@ -237,8 +252,7 @@ int class_unregister_type(const char *name) return -EBUSY; } - kobject_put(&type->typ_kobj); - wait_for_completion(&type->typ_kobj_unregister); + kobject_put(type->typ_kobj); debugfs_remove_recursive(type->typ_debugfs_entry); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index b3ba554..f889fb8 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1027,7 +1027,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; obd->obd_ktype.release = obd_sysfs_release; - obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj; + obd->obd_kset.kobj.parent = obd->obd_type->typ_kobj; obd->obd_kset.kobj.ktype = &obd->obd_ktype; init_completion(&obd->obd_kobj_unregister); rc = kset_register(&obd->obd_kset); From patchwork Fri Aug 17 03:10:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 323CE14BD for ; Fri, 17 Aug 2018 03:12:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F6B02B176 for ; Fri, 17 Aug 2018 03:12:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13EEB2B1A7; Fri, 17 Aug 2018 03:12:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE2B12B176 for ; Fri, 17 Aug 2018 03:12:37 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 9A3004E1E62; Thu, 16 Aug 2018 20:11:38 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 483FE4E1C8B for ; Thu, 16 Aug 2018 20:10:55 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2BA9B100538A; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 27C08463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:27 -0400 Message-Id: <1534475441-15543-25-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 24/38] lustre: obd: create conn_uuid sysfs file X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change conn_uuid from a debugfs file to sysfs file. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28108 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 1 + .../lustre/lustre/obdclass/lprocfs_status.c | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 3863fff..bc7a390 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -463,6 +463,7 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer, unsigned long count, void *data); int lprocfs_rd_server_uuid(struct seq_file *m, void *data); int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); +ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf); int lprocfs_rd_import(struct seq_file *m, void *data); int lprocfs_rd_state(struct seq_file *m, void *data); int lprocfs_rd_connect_flags(struct seq_file *m, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index f889fb8..3fbf10b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -476,6 +476,29 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(filesfree); +ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct ptlrpc_connection *conn; + ssize_t count; + int rc; + + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + + conn = obd->u.cli.cl_import->imp_connection; + if (conn && obd->u.cli.cl_import) + count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid); + else + count = sprintf(buf, "%s\n", ""); + + up_read(&obd->u.cli.cl_sem); + return count; +} +EXPORT_SYMBOL(conn_uuid_show); + int lprocfs_rd_server_uuid(struct seq_file *m, void *data) { struct obd_device *obd = data; From patchwork Fri Aug 17 03:10:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F82914BD for ; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7DE2B124 for ; Fri, 17 Aug 2018 03:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3E812B157; Fri, 17 Aug 2018 03:11:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4E7A2B124 for ; Fri, 17 Aug 2018 03:11:35 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id EA0B54E1FE3; Thu, 16 Aug 2018 20:11:11 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 892FF4E1D00 for ; Thu, 16 Aug 2018 20:10:55 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 2FFCE100538B; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2BFFA464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:28 -0400 Message-Id: <1534475441-15543-26-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 25/38] lustre: obd: enhance print_lustre_cfg() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make the function print_lustre_cfg() exportables so we can provide details when debugging other parts of the stack that handle lustre_cfg processing. We currently report the index of the buffer in struct lustre_cfg as well as the buffers length. We don't report the actually string so lets add that info as well. Signed-off-by: James Simmons WC-id: https://jira.whamcloud.com/browse/LU-7004 Reviewed-on: https://review.whamcloud.com/28590 Reviewed-by: Fan Yong Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 1 + drivers/staging/lustre/lustre/obdclass/llog_swab.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e994c968..e250bc3 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -106,6 +106,7 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, /* obd_config.c */ char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); +void print_lustre_cfg(struct lustre_cfg *lcfg); int class_process_config(struct lustre_cfg *lcfg); int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index b431c34..3803056 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -308,12 +308,13 @@ void lustre_swab_llog_hdr(struct llog_log_hdr *h) } EXPORT_SYMBOL(lustre_swab_llog_hdr); -static void print_lustre_cfg(struct lustre_cfg *lcfg) +void print_lustre_cfg(struct lustre_cfg *lcfg) { int i; if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */ return; + CDEBUG(D_OTHER, "lustre_cfg: %p\n", lcfg); CDEBUG(D_OTHER, "\tlcfg->lcfg_version: %#x\n", lcfg->lcfg_version); @@ -324,10 +325,13 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) CDEBUG(D_OTHER, "\tlcfg->lcfg_bufcount: %d\n", lcfg->lcfg_bufcount); if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT) - for (i = 0; i < lcfg->lcfg_bufcount; i++) - CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d\n", - i, lcfg->lcfg_buflens[i]); + for (i = 0; i < lcfg->lcfg_bufcount; i++) { + CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d %s\n", + i, lcfg->lcfg_buflens[i], + lustre_cfg_string(lcfg, i)); + } } +EXPORT_SYMBOL(print_lustre_cfg); void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) { From patchwork Fri Aug 17 03:10:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16FF414BD for ; Fri, 17 Aug 2018 03:12:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0421D2B176 for ; Fri, 17 Aug 2018 03:12:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC6262B192; Fri, 17 Aug 2018 03:12:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 31DAB2B176 for ; Fri, 17 Aug 2018 03:12:12 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 666F94E22D4; Thu, 16 Aug 2018 20:11:27 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id CBD6E4E1DF5 for ; Thu, 16 Aug 2018 20:10:55 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 34B0F100538C; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 30815463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:29 -0400 Message-Id: <1534475441-15543-27-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 26/38] lustre: obd: merge both top lustre sysfs attributes X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The top of the lustre sysfs tree is handled by two sets of attributes, one in sysctl.c and the other in modules.c. Worst is the the sysfs attributes in sysctl.c are never cleaned up. So merge all the sysfs handling in sysctl.c into the one managed in modules.c. Additionally now all the top level attributes will be cleaned up. This eliminates the sysctl.c file as well. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9431 Reviewed-on: https://review.whamcloud.com/30143 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 3 - drivers/staging/lustre/lustre/obdclass/Makefile | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 - drivers/staging/lustre/lustre/obdclass/module.c | 97 ++++++++++++ drivers/staging/lustre/lustre/obdclass/sysctl.c | 162 --------------------- 5 files changed, 98 insertions(+), 170 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/sysctl.c diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e250bc3..02a3f97 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1553,9 +1553,6 @@ struct lwp_register_item { int lustre_register_fs(void); int lustre_check_exclusion(struct super_block *sb, char *svname); -/* sysctl.c */ -int obd_sysctl_init(void); - /* uuid.c */ typedef __u8 class_uuid_t[16]; void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 686bd54..5d050f0 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := module.o sysctl.o \ +obdclass-y := module.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 8100184..bbffede 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -494,10 +494,6 @@ static int __init obdclass_init(void) if (err) goto cleanup_caches; - err = obd_sysctl_init(); - if (err) - goto cleanup_class_procfs; - err = lu_global_init(); if (err) goto cleanup_class_procfs; diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 0ce2617..27b3849 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -274,6 +274,93 @@ struct miscdevice obd_psdev = { .fops = &obd_psdev_fops, }; +struct static_lustre_uintvalue_attr { + struct { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + } u; + int *value; +}; + +static ssize_t static_uintvalue_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct static_lustre_uintvalue_attr *lattr = (void *)attr; + + return sprintf(buf, "%d\n", *lattr->value); +} + +static ssize_t static_uintvalue_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, size_t count) +{ + struct static_lustre_uintvalue_attr *lattr = (void *)attr; + unsigned int val; + int rc; + + rc = kstrtouint(buffer, 10, &val); + if (rc) + return rc; + + *lattr->value = val; + + return count; +} + +#define LUSTRE_STATIC_UINT_ATTR(name, value) \ +static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ + { __ATTR(name, 0644, static_uintvalue_show, \ + static_uintvalue_store), value } + +LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout); +LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout); +LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout); +LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction); +LUSTRE_STATIC_UINT_ATTR(at_min, &at_min); +LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); +LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); +LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); +LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); + +static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%lu\n", + obd_max_dirty_pages / (1 << (20 - PAGE_SHIFT))); +} + +static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) +{ + unsigned long val; + int rc; + + rc = kstrtoul(buffer, 10, &val); + if (rc) + return rc; + + val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */ + + if (val > ((totalram_pages / 10) * 9)) { + /* Somebody wants to assign too much memory to dirty pages */ + return -EINVAL; + } + + if (val < 4 << (20 - PAGE_SHIFT)) { + /* Less than 4 Mb for dirty cache is also bad */ + return -EINVAL; + } + + obd_max_dirty_pages = val; + + return count; +} +LUSTRE_RW_ATTR(max_dirty_mb); + static ssize_t version_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -390,6 +477,16 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, &lustre_attr_health_check.attr, &lustre_attr_jobid_name.attr, &lustre_attr_jobid_var.attr, + &lustre_sattr_timeout.u.attr, + &lustre_attr_max_dirty_mb.attr, + &lustre_sattr_debug_peer_on_timeout.u.attr, + &lustre_sattr_dump_on_timeout.u.attr, + &lustre_sattr_dump_on_eviction.u.attr, + &lustre_sattr_at_min.u.attr, + &lustre_sattr_at_max.u.attr, + &lustre_sattr_at_extra.u.attr, + &lustre_sattr_at_early_margin.u.attr, + &lustre_sattr_at_history.u.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/obdclass/sysctl.c b/drivers/staging/lustre/lustre/obdclass/sysctl.c deleted file mode 100644 index f8760b2..0000000 --- a/drivers/staging/lustre/lustre/obdclass/sysctl.c +++ /dev/null @@ -1,162 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2015, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include -#include - -struct static_lustre_uintvalue_attr { - struct { - struct attribute attr; - ssize_t (*show)(struct kobject *kobj, struct attribute *attr, - char *buf); - ssize_t (*store)(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len); - } u; - int *value; -}; - -static ssize_t static_uintvalue_show(struct kobject *kobj, - struct attribute *attr, - char *buf) -{ - struct static_lustre_uintvalue_attr *lattr = (void *)attr; - - return sprintf(buf, "%d\n", *lattr->value); -} - -static ssize_t static_uintvalue_store(struct kobject *kobj, - struct attribute *attr, - const char *buffer, size_t count) -{ - struct static_lustre_uintvalue_attr *lattr = (void *)attr; - int rc; - unsigned int val; - - rc = kstrtouint(buffer, 10, &val); - if (rc) - return rc; - - *lattr->value = val; - - return count; -} - -#define LUSTRE_STATIC_UINT_ATTR(name, value) \ -static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ - {__ATTR(name, 0644, \ - static_uintvalue_show, \ - static_uintvalue_store),\ - value } - -LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout); - -static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", - obd_max_dirty_pages / (1 << (20 - PAGE_SHIFT))); -} - -static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) -{ - int rc; - unsigned long val; - - rc = kstrtoul(buffer, 10, &val); - if (rc) - return rc; - - val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */ - - if (val > ((totalram_pages / 10) * 9)) { - /* Somebody wants to assign too much memory to dirty pages */ - return -EINVAL; - } - - if (val < 4 << (20 - PAGE_SHIFT)) { - /* Less than 4 Mb for dirty cache is also bad */ - return -EINVAL; - } - - obd_max_dirty_pages = val; - - return count; -} -LUSTRE_RW_ATTR(max_dirty_mb); - -LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout); -LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout); -LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction); -LUSTRE_STATIC_UINT_ATTR(at_min, &at_min); -LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); -LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); -LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); -LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); - -static struct attribute *lustre_attrs[] = { - &lustre_sattr_timeout.u.attr, - &lustre_attr_max_dirty_mb.attr, - &lustre_sattr_debug_peer_on_timeout.u.attr, - &lustre_sattr_dump_on_timeout.u.attr, - &lustre_sattr_dump_on_eviction.u.attr, - &lustre_sattr_at_min.u.attr, - &lustre_sattr_at_max.u.attr, - &lustre_sattr_at_extra.u.attr, - &lustre_sattr_at_early_margin.u.attr, - &lustre_sattr_at_history.u.attr, - NULL, -}; - -static const struct attribute_group lustre_attr_group = { - .attrs = lustre_attrs, -}; - -int obd_sysctl_init(void) -{ - return sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); -} From patchwork Fri Aug 17 03:10:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8EB713B6 for ; Fri, 17 Aug 2018 03:11:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4EA92B157 for ; Fri, 17 Aug 2018 03:11:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C83FA2B176; Fri, 17 Aug 2018 03:11:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B4D22B144 for ; Fri, 17 Aug 2018 03:11:43 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 0BC364E1E50; Thu, 16 Aug 2018 20:11:15 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 311834E1A98 for ; Thu, 16 Aug 2018 20:10:56 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 3C1A2100538D; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 35280464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:30 -0400 Message-Id: <1534475441-15543-28-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 27/38] lustre: obd: resolve config log sysfs issues X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP This resolves long standing issues with modifying sysfs settings on multiple nodes simultaneously by running a single command on the backend MGS server. Their are two ways to change the settings, LCFG_PARAM and LCFG_SET_PARAM. For the LCFG_PARAM case we create a new function class_modify_config() that grabs the attributes from the passed in kobject. We can use those attributes to modify the sysfs settings. If we can't find the attribute then send a uevent to let userland resolve the change. For the LCFG_SET_PARAM case we handle two class of settings. The function class_set_global() was modifiy to handle the top lustre sysfs files since they are not searchable with kset_find_obj. If we can find a kobject with kset_find_obj then we can send a uevent so userland change manage the change. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9431 Reviewed-on: https://review.whamcloud.com/30143 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 5 + drivers/staging/lustre/lustre/include/obd_class.h | 3 + .../lustre/lustre/obdclass/lprocfs_status.c | 10 +- drivers/staging/lustre/lustre/obdclass/module.c | 18 +++ .../staging/lustre/lustre/obdclass/obd_config.c | 172 ++++++++++++++------- 5 files changed, 152 insertions(+), 56 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index bc7a390..c841aba 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -577,6 +577,11 @@ struct lustre_attr { #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) +ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf); +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + extern const struct sysfs_ops lustre_sysfs_ops; struct root_squash_info; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 02a3f97..1925bda 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -108,6 +108,9 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); void print_lustre_cfg(struct lustre_cfg *lcfg); int class_process_config(struct lustre_cfg *lcfg); +ssize_t class_set_global(const char *param); +ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, + struct kobject *kobj); int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3fbf10b..84e5a8c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1762,21 +1762,23 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, } EXPORT_SYMBOL(lprocfs_wr_nosquash_nids); -static ssize_t lustre_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf) +ssize_t lustre_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) { struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); return a->show ? a->show(kobj, attr, buf) : 0; } +EXPORT_SYMBOL_GPL(lustre_attr_show); -static ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len) +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len) { struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); return a->store ? a->store(kobj, attr, buf, len) : len; } +EXPORT_SYMBOL_GPL(lustre_attr_store); const struct sysfs_ops lustre_sysfs_ops = { .show = lustre_attr_show, diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 27b3849..eab9820 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -575,6 +575,24 @@ static int obd_device_list_open(struct inode *inode, struct file *file) .attrs = lustre_attrs, }; +ssize_t class_set_global(const char *param) +{ + const char *value = strchr(param, '=') + 1; + size_t off = value - param - 1; + ssize_t count = -ENOENT; + int i; + + for (i = 0; lustre_attrs[i]; i++) { + if (!strncmp(lustre_attrs[i]->name, param, off)) { + count = lustre_attr_store(&lustre_kset->kobj, + lustre_attrs[i], value, + strlen(value)); + break; + } + } + return count; +} + int class_procfs_init(void) { int rc = -ENOMEM; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index d962f0c..823ddb0 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -814,28 +814,6 @@ void class_del_profiles(void) } EXPORT_SYMBOL(class_del_profiles); -static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) -{ - if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) - at_min = val; - else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) - at_max = val; - else if (class_match_param(ptr, PARAM_AT_EXTRA, NULL) == 0) - at_extra = val; - else if (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, NULL) == 0) - at_early_margin = val; - else if (class_match_param(ptr, PARAM_AT_HISTORY, NULL) == 0) - at_history = val; - else if (class_match_param(ptr, PARAM_JOBID_VAR, NULL) == 0) - strlcpy(obd_jobid_var, lustre_cfg_string(lcfg, 2), - JOBSTATS_JOBID_VAR_MAX_LEN + 1); - else - return -EINVAL; - - CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); - return 0; -} - /* We can't call ll_process_config or lquota_process_config directly because * it lives in a module that must be loaded after this one. */ @@ -851,38 +829,44 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)) static int process_param2_config(struct lustre_cfg *lcfg) { char *param = lustre_cfg_string(lcfg, 1); - char *upcall = lustre_cfg_string(lcfg, 2); - char *argv[] = { - [0] = "/usr/sbin/lctl", - [1] = "set_param", - [2] = param, - [3] = NULL - }; - ktime_t start; - ktime_t end; - int rc; + struct kobject *kobj = NULL; + const char *subsys = param; + char *envp[3]; + char *value; + size_t len; + int rc; + int i; - /* Add upcall processing here. Now only lctl is supported */ - if (strcmp(upcall, LCTL_UPCALL) != 0) { - CERROR("Unsupported upcall %s\n", upcall); + print_lustre_cfg(lcfg); + + len = strcspn(param, ".="); + if (!len) return -EINVAL; - } - start = ktime_get(); - rc = call_usermodehelper(argv[0], argv, NULL, UMH_WAIT_PROC); - end = ktime_get(); + /* If we find '=' then its the top level sysfs directory */ + if (param[len] == '=') + return class_set_global(param); - if (rc < 0) { - CERROR( - "lctl: error invoking upcall %s %s %s: rc = %d; time %ldus\n", - argv[0], argv[1], argv[2], rc, - (long)ktime_us_delta(end, start)); - } else { - CDEBUG(D_HA, "lctl: invoked upcall %s %s %s, time %ldus\n", - argv[0], argv[1], argv[2], - (long)ktime_us_delta(end, start)); - rc = 0; - } + subsys = kstrndup(param, len, GFP_KERNEL); + if (!subsys) + return -ENOMEM; + + kobj = kset_find_obj(lustre_kset, subsys); + kfree(subsys); + if (!kobj) + return -ENODEV; + + value = param; + param = strsep(&value, "="); + envp[0] = kasprintf(GFP_KERNEL, "PARAM=%s", param); + envp[1] = kasprintf(GFP_KERNEL, "SETTING=%s", value); + envp[2] = NULL; + + rc = kobject_uevent_env(kobj, KOBJ_CHANGE, envp); + for (i = 0; i < ARRAY_SIZE(envp); i++) + kfree(envp[i]); + + kobject_put(kobj); return rc; } @@ -983,12 +967,12 @@ int class_process_config(struct lustre_cfg *lcfg) } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { /* Global param settings */ - err = class_set_global(tmp, lcfg->lcfg_num, lcfg); + err = class_set_global(tmp); /* * Client or server should not fail to mount if * it hits an unknown configuration parameter. */ - if (err != 0) + if (err < 0) CWARN("Ignoring unknown param %s\n", tmp); err = 0; @@ -1082,6 +1066,90 @@ int class_process_config(struct lustre_cfg *lcfg) } EXPORT_SYMBOL(class_process_config); +ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, + struct kobject *kobj) +{ + struct kobj_type *typ; + ssize_t count = 0; + int i; + + if (lcfg->lcfg_command != LCFG_PARAM) { + CERROR("Unknown command: %d\n", lcfg->lcfg_command); + return -EINVAL; + } + + typ = get_ktype(kobj); + if (!typ || !typ->default_attrs) + return -ENODEV; + + print_lustre_cfg(lcfg); + + /* + * e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt + * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar + * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 + */ + for (i = 1; i < lcfg->lcfg_bufcount; i++) { + struct attribute *attr; + size_t keylen; + char *value; + char *key; + int j; + + key = lustre_cfg_buf(lcfg, i); + /* Strip off prefix */ + if (class_match_param(key, prefix, &key)) + /* If the prefix doesn't match, return error so we + * can pass it down the stack + */ + return -EINVAL; + + value = strchr(key, '='); + if (!value || *(value + 1) == 0) { + CERROR("%s: can't parse param '%s' (missing '=')\n", + lustre_cfg_string(lcfg, 0), + lustre_cfg_string(lcfg, i)); + /* continue parsing other params */ + continue; + } + keylen = value - key; + value++; + + attr = NULL; + for (j = 0; typ->default_attrs[j]; j++) { + if (!strncmp(typ->default_attrs[j]->name, key, + keylen)) { + attr = typ->default_attrs[j]; + break; + } + } + + if (!attr) { + char *envp[3]; + + envp[0] = kasprintf(GFP_KERNEL, "PARAM=%s.%s.%.*s", + kobject_name(kobj->parent), + kobject_name(kobj), + (int)keylen, key); + envp[1] = kasprintf(GFP_KERNEL, "SETTING=%s", value); + envp[2] = NULL; + + if (kobject_uevent_env(kobj, KOBJ_CHANGE, envp)) { + CERROR("%s: failed to send uevent %s\n", + kobject_name(kobj), key); + } + + for (i = 0; i < ARRAY_SIZE(envp); i++) + kfree(envp[i]); + } else { + count += lustre_attr_store(kobj, attr, value, + strlen(value)); + } + } + return count; +} +EXPORT_SYMBOL(class_modify_config); + int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data) { From patchwork Fri Aug 17 03:10:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7501A13B6 for ; Fri, 17 Aug 2018 03:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6018F2B176 for ; Fri, 17 Aug 2018 03:12:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541242B1A7; Fri, 17 Aug 2018 03:12:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85F482B176 for ; Fri, 17 Aug 2018 03:12:19 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1FF194E236D; Thu, 16 Aug 2018 20:11:30 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8C6F14E1A98 for ; Thu, 16 Aug 2018 20:10:56 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 3E097100538E; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 3A510463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:31 -0400 Message-Id: <1534475441-15543-29-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 28/38] lustre: obd: move ioctl handling to class_obd.c X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move the ioctl handling in module.c to class_obd.c and rename module.c to obd_sysfs.c since it only contains sysfs/debugfs code. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8837 Reviewed-on: https://review.whamcloud.com/32100 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 1 - drivers/staging/lustre/lustre/obdclass/Makefile | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 205 ++++++++++++++++++++ .../lustre/obdclass/{module.c => obd_sysfs.c} | 207 --------------------- 4 files changed, 206 insertions(+), 209 deletions(-) rename drivers/staging/lustre/lustre/obdclass/{module.c => obd_sysfs.c} (67%) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 1925bda..33c0b87 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1568,7 +1568,6 @@ struct lwp_register_item { /* class_obd.c */ extern char obd_jobid_node[]; -extern struct miscdevice obd_psdev; int class_procfs_init(void); int class_procfs_clean(void); diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 5d050f0..19c8bd9 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := module.o \ +obdclass-y := obd_sysfs.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index bbffede..eabaafe 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -153,6 +153,168 @@ static int class_resolve_dev_name(__u32 len, const char *name) return rc; } +#define OBD_MAX_IOCTL_BUFFER 8192 + +static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) +{ + if (data->ioc_len > BIT(30)) { + CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen1 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen2 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen3 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen4 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) { + CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) { + CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf3 && data->ioc_inllen3 == 0) { + CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf4 && data->ioc_inllen4 == 0) { + CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf1 && data->ioc_plen1 == 0) { + CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf2 && data->ioc_plen2 == 0) { + CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); + return 1; + } + + if (!data->ioc_pbuf1 && data->ioc_plen1 != 0) { + CERROR("OBD ioctl: plen1 set but NULL pointer\n"); + return 1; + } + + if (!data->ioc_pbuf2 && data->ioc_plen2 != 0) { + CERROR("OBD ioctl: plen2 set but NULL pointer\n"); + return 1; + } + + if (obd_ioctl_packlen(data) > data->ioc_len) { + CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", + obd_ioctl_packlen(data), data->ioc_len); + return 1; + } + + return 0; +} + +/* buffer MUST be at least the size of obd_ioctl_hdr */ +int obd_ioctl_getdata(char **buf, int *len, void __user *arg) +{ + struct obd_ioctl_data *data; + struct obd_ioctl_hdr hdr; + int offset = 0; + int err; + + if (copy_from_user(&hdr, arg, sizeof(hdr))) + return -EFAULT; + + if (hdr.ioc_version != OBD_IOCTL_VERSION) { + CERROR("Version mismatch kernel (%x) vs application (%x)\n", + OBD_IOCTL_VERSION, hdr.ioc_version); + return -EINVAL; + } + + if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { + CERROR("User buffer len %d exceeds %d max buffer\n", + hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); + return -EINVAL; + } + + if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { + CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); + return -EINVAL; + } + + /* When there are lots of processes calling vmalloc on multi-core + * system, the high lock contention will hurt performance badly, + * obdfilter-survey is an example, which relies on ioctl. So we'd + * better avoid vmalloc on ioctl path. LU-66 + */ + *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); + if (!*buf) { + CERROR("Cannot allocate control buffer of len %d\n", + hdr.ioc_len); + return -EINVAL; + } + *len = hdr.ioc_len; + data = (struct obd_ioctl_data *)*buf; + + if (copy_from_user(*buf, arg, hdr.ioc_len)) { + err = -EFAULT; + goto free_buf; + } + + if (hdr.ioc_len != data->ioc_len) { + err = -EINVAL; + goto free_buf; + } + + if (obd_ioctl_is_invalid(data)) { + CERROR("ioctl not correctly formatted\n"); + err = -EINVAL; + goto free_buf; + } + + if (data->ioc_inllen1) { + data->ioc_inlbuf1 = &data->ioc_bulk[0]; + offset += cfs_size_round(data->ioc_inllen1); + } + + if (data->ioc_inllen2) { + data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; + offset += cfs_size_round(data->ioc_inllen2); + } + + if (data->ioc_inllen3) { + data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; + offset += cfs_size_round(data->ioc_inllen3); + } + + if (data->ioc_inllen4) + data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; + + return 0; + +free_buf: + kvfree(*buf); + return err; +} +EXPORT_SYMBOL(obd_ioctl_getdata); + int class_handle_ioctl(unsigned int cmd, unsigned long arg) { char *buf = NULL; @@ -379,6 +541,49 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) return err; } /* class_handle_ioctl */ +/* opening /dev/obd */ +static int obd_class_open(struct inode *inode, struct file *file) +{ + try_module_get(THIS_MODULE); + return 0; +} + +/* closing /dev/obd */ +static int obd_class_release(struct inode *inode, struct file *file) +{ + module_put(THIS_MODULE); + return 0; +} + +/* to control /dev/obd */ +static long obd_class_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) +{ + /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ + if (!capable(CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) + return -EACCES; + + if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ + return -ENOTTY; + + return class_handle_ioctl(cmd, (unsigned long)arg); +} + +/* declare character device */ +static const struct file_operations obd_psdev_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ + .open = obd_class_open, /* open */ + .release = obd_class_release, /* release */ +}; + +/* modules setup */ +static struct miscdevice obd_psdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = OBD_DEV_NAME, + .fops = &obd_psdev_fops, +}; + #define OBD_INIT_CHECK static int obd_init_checks(void) { diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c similarity index 67% rename from drivers/staging/lustre/lustre/obdclass/module.c rename to drivers/staging/lustre/lustre/obdclass/obd_sysfs.c index eab9820..6669c23 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c @@ -67,213 +67,6 @@ #include #include -#define OBD_MAX_IOCTL_BUFFER 8192 - -static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) -{ - if (data->ioc_len > BIT(30)) { - CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen1 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen2 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen3 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen4 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) { - CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) { - CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf3 && data->ioc_inllen3 == 0) { - CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf4 && data->ioc_inllen4 == 0) { - CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_pbuf1 && data->ioc_plen1 == 0) { - CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_pbuf2 && data->ioc_plen2 == 0) { - CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); - return 1; - } - - if (!data->ioc_pbuf1 && data->ioc_plen1 != 0) { - CERROR("OBD ioctl: plen1 set but NULL pointer\n"); - return 1; - } - - if (!data->ioc_pbuf2 && data->ioc_plen2 != 0) { - CERROR("OBD ioctl: plen2 set but NULL pointer\n"); - return 1; - } - - if (obd_ioctl_packlen(data) > data->ioc_len) { - CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", - obd_ioctl_packlen(data), data->ioc_len); - return 1; - } - - return 0; -} - -/* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) -{ - struct obd_ioctl_hdr hdr; - struct obd_ioctl_data *data; - int err; - int offset = 0; - - if (copy_from_user(&hdr, arg, sizeof(hdr))) - return -EFAULT; - - if (hdr.ioc_version != OBD_IOCTL_VERSION) { - CERROR("Version mismatch kernel (%x) vs application (%x)\n", - OBD_IOCTL_VERSION, hdr.ioc_version); - return -EINVAL; - } - - if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { - CERROR("User buffer len %d exceeds %d max buffer\n", - hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); - return -EINVAL; - } - - if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { - CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); - return -EINVAL; - } - - /* When there are lots of processes calling vmalloc on multi-core - * system, the high lock contention will hurt performance badly, - * obdfilter-survey is an example, which relies on ioctl. So we'd - * better avoid vmalloc on ioctl path. LU-66 - */ - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); - if (!*buf) { - CERROR("Cannot allocate control buffer of len %d\n", - hdr.ioc_len); - return -EINVAL; - } - *len = hdr.ioc_len; - data = (struct obd_ioctl_data *)*buf; - - if (copy_from_user(*buf, arg, hdr.ioc_len)) { - err = -EFAULT; - goto free_buf; - } - if (hdr.ioc_len != data->ioc_len) { - err = -EINVAL; - goto free_buf; - } - - if (obd_ioctl_is_invalid(data)) { - CERROR("ioctl not correctly formatted\n"); - err = -EINVAL; - goto free_buf; - } - - if (data->ioc_inllen1) { - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - offset += cfs_size_round(data->ioc_inllen1); - } - - if (data->ioc_inllen2) { - data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen2); - } - - if (data->ioc_inllen3) { - data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen3); - } - - if (data->ioc_inllen4) - data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; - - return 0; - -free_buf: - kvfree(*buf); - return err; -} -EXPORT_SYMBOL(obd_ioctl_getdata); - -/* opening /dev/obd */ -static int obd_class_open(struct inode *inode, struct file *file) -{ - try_module_get(THIS_MODULE); - return 0; -} - -/* closing /dev/obd */ -static int obd_class_release(struct inode *inode, struct file *file) -{ - module_put(THIS_MODULE); - return 0; -} - -/* to control /dev/obd */ -static long obd_class_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - int err = 0; - - /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ - if (!capable(CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) - return err = -EACCES; - if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ - return err = -ENOTTY; - - err = class_handle_ioctl(cmd, (unsigned long)arg); - - return err; -} - -/* declare character device */ -static const struct file_operations obd_psdev_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ - .open = obd_class_open, /* open */ - .release = obd_class_release, /* release */ -}; - -/* modules setup */ -struct miscdevice obd_psdev = { - .minor = MISC_DYNAMIC_MINOR, - .name = OBD_DEV_NAME, - .fops = &obd_psdev_fops, -}; - struct static_lustre_uintvalue_attr { struct { struct attribute attr; From patchwork Fri Aug 17 03:10:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4745214BD for ; Fri, 17 Aug 2018 03:11:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 330CD2B157 for ; Fri, 17 Aug 2018 03:11:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 274DA2B18D; Fri, 17 Aug 2018 03:11:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 88CAB2B157 for ; Fri, 17 Aug 2018 03:11:50 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 0E4AC4E21B9; Thu, 16 Aug 2018 20:11:18 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E385C4E1C83 for ; Thu, 16 Aug 2018 20:10:56 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 403B5100538F; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 3C437465; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:32 -0400 Message-Id: <1534475441-15543-30-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 29/38] lustre: llite: replace ll_process_config with class_modify_config X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current method of handling tunables with ll_process_config can not work with sysfs. So replace ll_process_config handling with class_modify_config() which can handle both sysfs and debugfs. This is just to make llite work but eventually the code will be updated to pass in a kobject to class_process_config(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32722 Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lustre_disk.h | 2 ++ .../staging/lustre/lustre/llite/llite_internal.h | 4 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 36 ++----------------- drivers/staging/lustre/lustre/llite/lproc_llite.c | 15 ++++---- drivers/staging/lustre/lustre/llite/super25.c | 4 --- .../staging/lustre/lustre/obdclass/obd_config.c | 41 +++++++++++++++------- 6 files changed, 43 insertions(+), 59 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 6bed07a..7b6421d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -114,6 +114,7 @@ struct lustre_mount_data { /****************** superblock additional info *********************/ struct ll_sb_info; +struct kobject; struct lustre_sb_info { int lsi_flags; @@ -122,6 +123,7 @@ struct lustre_sb_info { struct ll_sb_info *lsi_llsbi; /* add'l client sbi info */ struct dt_device *lsi_dt_dev; /* dt device to access disk fs*/ atomic_t lsi_mounts; /* references to the srv_mnt */ + struct kobject *lsi_kobj; char lsi_svname[MTI_NAME_MAXLEN]; char lsi_osd_obdname[64]; char lsi_osd_uuid[64]; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 1130ea3..bf679c9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -678,9 +678,8 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, /* llite/lproc_llite.c */ int ll_debugfs_register_super(struct super_block *sb, const char *name); -void ll_debugfs_unregister_super(struct ll_sb_info *sbi); +void ll_debugfs_unregister_super(struct super_block *sb); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); -void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); @@ -851,7 +850,6 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize); -int ll_process_config(struct lustre_cfg *lcfg); enum { LUSTRE_OPC_MKDIR = 0, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 7765060..f0fe21f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -693,7 +693,7 @@ static void client_common_put_super(struct super_block *sb) obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - ll_debugfs_unregister_super(sbi); + ll_debugfs_unregister_super(sb); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); @@ -1020,7 +1020,7 @@ int ll_fill_super(struct super_block *sb) out_debugfs: if (err < 0) - ll_debugfs_unregister_super(sbi); + ll_debugfs_unregister_super(sb); out_free: kfree(md); kfree(dt); @@ -2319,38 +2319,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) return rc; } -int ll_process_config(struct lustre_cfg *lcfg) -{ - char *ptr; - void *sb; - struct lprocfs_static_vars lvars; - unsigned long x; - int rc = 0; - - lprocfs_llite_init_vars(&lvars); - - /* The instance name contains the sb: lustre-client-aacfe000 */ - ptr = strrchr(lustre_cfg_string(lcfg, 0), '-'); - if (!ptr || !*(++ptr)) - return -EINVAL; - rc = kstrtoul(ptr, 16, &x); - if (rc != 0) - return -EINVAL; - sb = (void *)x; - /* This better be a real Lustre superblock! */ - LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == - LMD_MAGIC); - - /* Note we have not called client_common_fill_super yet, so - * proc fns must be able to handle that! - */ - rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars, - lcfg, sb); - if (rc > 0) - rc = 0; - return rc; -} - /* this function prepares md_op_data hint for passing ot down to MD stack. */ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 30873fc..1492d70 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1252,6 +1252,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) int ll_debugfs_register_super(struct super_block *sb, const char *name) { + struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct dentry *dir; int err, id; @@ -1329,6 +1330,8 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) if (err) goto out_ra_stats; + lsi->lsi_kobj = kobject_get(&sbi->ll_kset.kobj); + return 0; out_ra_stats: @@ -1341,8 +1344,13 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) return err; } -void ll_debugfs_unregister_super(struct ll_sb_info *sbi) +void ll_debugfs_unregister_super(struct super_block *sb) { + struct lustre_sb_info *lsi = s2lsi(sb); + struct ll_sb_info *sbi = ll_s2sbi(sb); + + kobject_put(lsi->lsi_kobj); + debugfs_remove_recursive(sbi->ll_debugfs_entry); if (sbi->ll_dt_obd) @@ -1719,8 +1727,3 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, } LPROC_SEQ_FOPS(ll_rw_offset_stats); - -void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) -{ - lvars->obd_vars = lprocfs_llite_obd_vars; -} diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 2f4306e..562bf329 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -253,8 +253,6 @@ static int __init lustre_init(void) if (rc) goto out_inode_fini_env; - lustre_register_client_process_config(ll_process_config); - return 0; out_inode_fini_env: @@ -273,8 +271,6 @@ static void __exit lustre_exit(void) { lustre_unregister_fs(); - lustre_register_client_process_config(NULL); - llite_tunables_unregister(); ll_xattr_fini(); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 823ddb0..9e46eb2 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -814,18 +814,11 @@ void class_del_profiles(void) } EXPORT_SYMBOL(class_del_profiles); -/* We can't call ll_process_config or lquota_process_config directly because +/* We can't call lquota_process_config directly because * it lives in a module that must be loaded after this one. */ -static int (*client_process_config)(struct lustre_cfg *lcfg); static int (*quota_process_config)(struct lustre_cfg *lcfg); -void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)) -{ - client_process_config = cpc; -} -EXPORT_SYMBOL(lustre_register_client_process_config); - static int process_param2_config(struct lustre_cfg *lcfg) { char *param = lustre_cfg_string(lcfg, 1); @@ -958,11 +951,35 @@ int class_process_config(struct lustre_cfg *lcfg) } case LCFG_PARAM: { char *tmp; + /* llite has no obd */ - if ((class_match_param(lustre_cfg_string(lcfg, 1), - PARAM_LLITE, NULL) == 0) && - client_process_config) { - err = (*client_process_config)(lcfg); + if (class_match_param(lustre_cfg_string(lcfg, 1), + PARAM_LLITE, NULL) == 0) { + struct lustre_sb_info *lsi; + unsigned long addr; + ssize_t count; + + /* The instance name contains the sb: + * lustre-client-aacfe000 + */ + tmp = strrchr(lustre_cfg_string(lcfg, 0), '-'); + if (!tmp || !*(++tmp)) { + err = -EINVAL; + goto out; + } + + if (sscanf(tmp, "%lx", &addr) != 1) { + err = -EINVAL; + goto out; + } + + lsi = s2lsi((struct super_block *)addr); + /* This better be a real Lustre superblock! */ + LASSERT(lsi->lsi_lmd->lmd_magic == LMD_MAGIC); + + count = class_modify_config(lcfg, PARAM_LLITE, + lsi->lsi_kobj); + err = count < 0 ? count : 0; goto out; } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { From patchwork Fri Aug 17 03:10:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19EE914BD for ; Fri, 17 Aug 2018 03:12:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 061942B176 for ; Fri, 17 Aug 2018 03:12:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE99D2B1C4; Fri, 17 Aug 2018 03:12:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E25C2B176 for ; Fri, 17 Aug 2018 03:12:26 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 398FC4E1F8B; Thu, 16 Aug 2018 20:11:33 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 4AEC84E1C16 for ; Thu, 16 Aug 2018 20:10:57 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 425EC1005390; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 3F288464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:33 -0400 Message-Id: <1534475441-15543-31-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 30/38] lustre: mgc: update sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move mgc to using the new sysfs conn_uuid. Move all sysfs/debugfs handling to lprocfs_mgc.c and implement proper error handling. Signed-off-by: James Simmons WC-bug-id: https://jira.hpdd.intel.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/29250 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 43 ++++++++++++++++++------ drivers/staging/lustre/lustre/mgc/mgc_internal.h | 2 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 10 +++--- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 7951ec6..574233e 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -38,9 +38,11 @@ #include "mgc_internal.h" LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); + LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid); + LPROC_SEQ_FOPS_RO_TYPE(mgc, import); + LPROC_SEQ_FOPS_RO_TYPE(mgc, state); LPROC_SEQ_FOPS_WR_ONLY(mgc, ping); @@ -52,18 +54,39 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO(mgc_ir_state); -static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { - { "ping", &mgc_ping_fops, NULL, 0222 }, - { "connect_flags", &mgc_connect_flags_fops, NULL, 0 }, - { "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 }, - { "mgs_conn_uuid", &mgc_conn_uuid_fops, NULL, 0 }, - { "import", &mgc_import_fops, NULL, 0 }, - { "state", &mgc_state_fops, NULL, 0 }, - { "ir_state", &mgc_ir_state_fops, NULL, 0 }, +struct lprocfs_vars lprocfs_mgc_obd_vars[] = { + { .name = "ping", + .fops = &mgc_ping_fops }, + { .name = "connect_flags", + .fops = &mgc_connect_flags_fops }, + { .name = "mgs_server_uuid", + .fops = &mgc_server_uuid_fops }, + { .name = "import", + .fops = &mgc_import_fops }, + { .name = "state", + .fops = &mgc_state_fops }, + { .name = "ir_state", + .fops = &mgc_ir_state_fops }, { NULL } }; -void lprocfs_mgc_init_vars(struct obd_device *obd) +#define mgs_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(mgs_conn_uuid); + +static struct attribute *mgc_attrs[] = { + &lustre_attr_mgs_conn_uuid.attr, + NULL, +}; + +int mgc_tunables_init(struct obd_device *obd) { + int rc; + + obd->obd_ktype.default_attrs = mgc_attrs; obd->obd_vars = lprocfs_mgc_obd_vars; + rc = lprocfs_obd_setup(obd, true); + if (rc) + return rc; + + return sptlrpc_lprocfs_cliobd_attach(obd); } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 5385d91..0a91624 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,7 +39,7 @@ #include #include -void lprocfs_mgc_init_vars(struct obd_device *obd); +int mgc_tunables_init(struct obd_device *obd); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 50da9cf..4552cc5 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -747,9 +747,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(obd); - lprocfs_obd_setup(obd, true); - sptlrpc_lprocfs_cliobd_attach(obd); + rc = mgc_tunables_init(obd); + if (rc) + goto err_sysfs; if (atomic_inc_return(&mgc_count) == 1) { rq_state = 0; @@ -761,7 +761,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = PTR_ERR(task); CERROR("%s: cannot start requeue thread: rc = %d; no more log updates\n", obd->obd_name, rc); - goto err_cleanup; + goto err_sysfs; } /* rc is the task_struct pointer of mgc_requeue_thread. */ rc = 0; @@ -770,6 +770,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return rc; +err_sysfs: + lprocfs_obd_cleanup(obd); err_cleanup: client_obd_cleanup(obd); err_decref: From patchwork Fri Aug 17 03:10:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B737A13B6 for ; Fri, 17 Aug 2018 03:12:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CB62B176 for ; Fri, 17 Aug 2018 03:12:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98EAA2B1A7; Fri, 17 Aug 2018 03:12:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3079E2B176 for ; Fri, 17 Aug 2018 03:12:33 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B20324E246E; Thu, 16 Aug 2018 20:11:36 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A90974E1E32 for ; Thu, 16 Aug 2018 20:10:57 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 488001005391; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 448D6463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:34 -0400 Message-Id: <1534475441-15543-32-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 31/38] lustre: osc: fixup kstrto* for sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some of the osc sysfs files only allow 1 or 0 which was retrieved with kstrtoul(). A much better fit would be to use kstrtobool(). This adds 'Y' or 'N' as valid options as well. Instead of using kstrtoull() for everything with additional range checking we can change to a different kstrtoxxx() so the range checking can be removed. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9325 Reviewed-on: https://review.whamcloud.com/30539 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 43 ++++++++++++--------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 4ed289b..3c31e98 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -55,20 +55,18 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val > 1) - return -ERANGE; /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else - CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n", + CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n", val); return count; @@ -94,15 +92,15 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; - int rc; - unsigned long val; int adding, added, req_count; + unsigned int val; + int rc; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val < 1 || val > OSC_MAX_RIF_MAX) + if (val == 0 || val > OSC_MAX_RIF_MAX) return -ERANGE; adding = val - cli->cl_max_rpcs_in_flight; @@ -334,14 +332,14 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val <= 0) + if (val == 0) return -ERANGE; obd->u.cli.cl_grant_shrink_interval = val; @@ -367,14 +365,14 @@ static ssize_t checksums_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - obd->u.cli.cl_checksum = (val ? 1 : 0); + obd->u.cli.cl_checksum = val; return count; } @@ -454,10 +452,10 @@ static ssize_t resend_count_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; @@ -486,16 +484,13 @@ static ssize_t contention_seconds_store(struct kobject *kobj, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); + unsigned int val; int rc; - int val; - rc = kstrtoint(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val < 0) - return -EINVAL; - od->od_contention_time = val; return count; @@ -521,10 +516,10 @@ static ssize_t lockless_truncate_store(struct kobject *kobj, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); + bool val; int rc; - unsigned int val; - rc = kstrtouint(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; From patchwork Fri Aug 17 03:10:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB70913B6 for ; Fri, 17 Aug 2018 03:12:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F052B176 for ; Fri, 17 Aug 2018 03:12:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D77F2B1A7; Fri, 17 Aug 2018 03:12:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4ECA52B176 for ; Fri, 17 Aug 2018 03:12:40 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B93C44E24E2; Thu, 16 Aug 2018 20:11:39 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 0EC744E1D03 for ; Thu, 16 Aug 2018 20:10:58 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 49D871005392; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 482E6464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:35 -0400 Message-Id: <1534475441-15543-33-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Access to struct client_obd should be protected with the spinlock cl_loi_list_lock. This was dropped during the port to sysfs so restore the proper locking. Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3c31e98..5fb7a16 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, @@ -136,7 +141,10 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, long val; int mult; + spin_lock(&cli->cl_loi_list_lock); val = cli->cl_dirty_max_pages; + spin_unlock(&cli->cl_loi_list_lock); + mult = 1 << (20 - PAGE_SHIFT); return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } @@ -247,9 +255,13 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_unlock(&cli->cl_loi_list_lock); + return len; } LUSTRE_RO_ATTR(cur_dirty_bytes); @@ -260,8 +272,13 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t cur_grant_bytes_store(struct kobject *kobj, @@ -280,8 +297,12 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, return rc; /* this is only for shrinking grant */ - if (val >= cli->cl_avail_grant) + spin_lock(&cli->cl_loi_list_lock); + if (val >= cli->cl_avail_grant) { + spin_unlock(&cli->cl_loi_list_lock); return -EINVAL; + } + spin_unlock(&cli->cl_loi_list_lock); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); @@ -298,8 +319,13 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } LUSTRE_RO_ATTR(cur_lost_grant_bytes); From patchwork Fri Aug 17 03:10:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFB7F13B6 for ; Fri, 17 Aug 2018 03:12:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DB6B2B176 for ; Fri, 17 Aug 2018 03:12:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91D9C2B1A7; Fri, 17 Aug 2018 03:12:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FAC52B176 for ; Fri, 17 Aug 2018 03:12:44 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 4CEDA4E2523; Thu, 16 Aug 2018 20:11:41 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 66A874E1D03 for ; Thu, 16 Aug 2018 20:10:58 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 4F3EE1005393; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 4CB8D463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:36 -0400 Message-Id: <1534475441-15543-34-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 33/38] lustre: osc: make unstable_stats a debugfs file X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP The sysfs attribute unstable_stats breaks the one item per file rule. Make it a debugfs file instead. Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 5fb7a16..79a30b3 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -614,12 +614,9 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_pages_per_rpc); -static ssize_t unstable_stats_show(struct kobject *kobj, - struct attribute *attr, - char *buf) +static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) { - struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kset.kobj); + struct obd_device *dev = m->private; struct client_obd *cli = &dev->u.cli; long pages; int mb; @@ -627,10 +624,14 @@ static ssize_t unstable_stats_show(struct kobject *kobj, pages = atomic_long_read(&cli->cl_unstable_count); mb = (pages * PAGE_SIZE) >> 20; - return sprintf(buf, "unstable_pages: %20ld\n" - "unstable_mb: %10d\n", pages, mb); + seq_printf(m, + "unstable_pages: %20ld\n" + "unstable_mb: %10d\n", + pages, mb); + return 0; } -LUSTRE_RO_ATTR(unstable_stats); + +LPROC_SEQ_FOPS_RO(osc_unstable_stats); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); @@ -655,6 +656,8 @@ static ssize_t unstable_stats_show(struct kobject *kobj, { "import", &osc_import_fops, NULL }, { "state", &osc_state_fops, NULL, 0 }, { "pinger_recov", &osc_pinger_recov_fops, NULL }, + { .name = "unstable_stats", + .fops = &osc_unstable_stats_fops }, { NULL } }; @@ -837,7 +840,6 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_resend_count.attr, - &lustre_attr_unstable_stats.attr, NULL, }; From patchwork Fri Aug 17 03:10:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 039BA15E2 for ; Fri, 17 Aug 2018 03:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E36612B176 for ; Fri, 17 Aug 2018 03:12:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D73A82B1A7; Fri, 17 Aug 2018 03:12:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 216BA2B192 for ; Fri, 17 Aug 2018 03:12:47 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6B1334E1FDC; Thu, 16 Aug 2018 20:11:42 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A717C4E1D03 for ; Thu, 16 Aug 2018 20:10:58 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 545021005394; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 5114E463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:37 -0400 Message-Id: <1534475441-15543-35-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 34/38] lustre: osc: enhance end to end bulk cksum error report X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Bruno Faccini Some sites have experienced spurious checksum errors upon bulk xfers where it is very difficult to determine the source of the corruption. With this patch, upon cksum error, full dump of all pages in a bulk xfer is now possible (enabled via a /sysfs tunable) on both Client and OSS sides, to allow easier root cause identification. Signed-off-by: Bruno Faccini WC-bug-id: https://jira.whamcloud.com/browse/LU-8376 Reviewed-on: https://review.whamcloud.com/23960 Reviewed-by: Nathaniel Clark Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lnet/libcfs/debug.c | 1 + drivers/staging/lustre/lustre/include/obd.h | 6 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 31 ++++++ drivers/staging/lustre/lustre/osc/osc_request.c | 140 +++++++++++++++++++----- 4 files changed, 147 insertions(+), 31 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index 0289f24..dd06a4c 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -219,6 +219,7 @@ static int param_set_uintpos(const char *val, const struct kernel_param *kp) static wait_queue_head_t debug_ctlwq; char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT; +EXPORT_SYMBOL(libcfs_debug_file_path_arr); /* We need to pass a pointer here, but elsewhere this must be a const */ static char *libcfs_debug_file_path; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 385a88d..329bae9 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -324,7 +324,8 @@ struct client_obd { struct obd_export *cl_mgc_mgsexp; /* checksumming for data sent over the network */ - unsigned int cl_checksum:1; /* 0 = disabled, 1 = enabled */ + unsigned int cl_checksum:1, /* 0 = disabled, 1 = enabled */ + cl_checksum_dump:1; /* same */ /* supported checksum types that are worked out at connect time */ __u32 cl_supp_cksum_types; /* checksum algorithm to be used */ @@ -557,7 +558,8 @@ struct obd_device { * (for sysfs status only!!) */ obd_no_ir:1, /* no imperative recovery. */ - obd_process_conf:1; /* device is processing mgs config */ + obd_process_conf:1, /* device is processing mgs config */ + obd_checksum_dump:1; /* dump pages upon cksum error */ /* use separate field as it is set in interrupt to don't mess with * protection of other bits using _bh lock */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 79a30b3..89dadba 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -491,6 +491,36 @@ static ssize_t resend_count_store(struct kobject *kobj, } LUSTRE_RW_ATTR(resend_count); +static ssize_t checksum_dump_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + + return sprintf(buf, "%d\n", obd->u.cli.cl_checksum_dump ? 1 : 0); +} + +static ssize_t checksum_dump_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + bool val; + int rc; + + rc = kstrtobool(buffer, &val); + if (rc) + return rc; + + obd->u.cli.cl_checksum_dump = val; + + return count; +} +LUSTRE_RW_ATTR(checksum_dump); + static ssize_t contention_seconds_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -828,6 +858,7 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) static struct attribute *osc_attrs[] = { &lustre_attr_active.attr, &lustre_attr_checksums.attr, + &lustre_attr_checksum_dump.attr, &lustre_attr_contention_seconds.attr, &lustre_attr_cur_dirty_bytes.attr, &lustre_attr_cur_grant_bytes.attr, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 4f57a8e..a7a4a53 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1306,6 +1306,12 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, body->oa.o_flags |= cksum_type_pack(cli->cl_cksum_type); body->oa.o_valid |= OBD_MD_FLCKSUM | OBD_MD_FLFLAGS; } + + /* Client cksum has been already copied to wire obdo in previous + * lustre_set_wire_obdo(), and in the case a bulk-read is being + * resent due to cksum error, this will allow Server to + * check+dump pages on its side + */ } ptlrpc_request_set_replen(req); @@ -1333,11 +1339,73 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, return rc; } +char dbgcksum_file_name[PATH_MAX]; + +static void dump_all_bulk_pages(struct obdo *oa, u32 page_count, + struct brw_page **pga, u32 server_cksum, + u32 client_cksum) +{ + struct file *filp; + unsigned int len; + int rc, i; + char *buf; + + /* will only keep dump of pages on first error for the same range in + * file/fid, not during the resends/retries. + */ + snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name), + "%s-checksum_dump-osc-" DFID ":[%llu-%llu]-%x-%x", + (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 ? + libcfs_debug_file_path_arr : + LIBCFS_DEBUG_FILE_PATH_DEFAULT), + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : 0ULL, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, + pga[0]->off, + pga[page_count - 1]->off + pga[page_count - 1]->count - 1, + client_cksum, server_cksum); + filp = filp_open(dbgcksum_file_name, + O_CREAT | O_EXCL | O_WRONLY | O_LARGEFILE, 0600); + if (IS_ERR(filp)) { + rc = PTR_ERR(filp); + if (rc == -EEXIST) + CDEBUG(D_INFO, + "%s: can't open to dump pages with checksum error: rc = %d\n", + dbgcksum_file_name, rc); + else + CERROR("%s: can't open to dump pages with checksum error: rc = %d\n", + dbgcksum_file_name, rc); + return; + } + + for (i = 0; i < page_count; i++) { + len = pga[i]->count; + buf = kmap(pga[i]->pg); + while (len != 0) { + rc = kernel_write(filp, buf, len, &filp->f_pos); + if (rc < 0) { + CERROR("%s: wanted to write %u but got %d error\n", + dbgcksum_file_name, len, rc); + break; + } + len -= rc; + buf += rc; + CDEBUG(D_INFO, "%s: wrote %d bytes\n", + dbgcksum_file_name, rc); + } + kunmap(pga[i]->pg); + } + + rc = vfs_fsync_range(filp, 0, LLONG_MAX, 1); + if (rc) + CERROR("%s: sync returns %d\n", dbgcksum_file_name, rc); + filp_close(filp, NULL); +} + static int check_write_checksum(struct obdo *oa, const struct lnet_process_id *peer, - __u32 client_cksum, __u32 server_cksum, int nob, - u32 page_count, struct brw_page **pga, - enum cksum_type client_cksum_type) + u32 client_cksum, u32 server_cksum, + struct osc_brw_async_args *aa) { __u32 new_cksum; char *msg; @@ -1348,12 +1416,16 @@ static int check_write_checksum(struct obdo *oa, return 0; } + if (aa->aa_cli->cl_checksum_dump) + dump_all_bulk_pages(oa, aa->aa_page_count, aa->aa_ppga, + server_cksum, client_cksum); + cksum_type = cksum_type_unpack(oa->o_valid & OBD_MD_FLFLAGS ? oa->o_flags : 0); - new_cksum = osc_checksum_bulk(nob, page_count, pga, OST_WRITE, - cksum_type); + new_cksum = osc_checksum_bulk(aa->aa_requested_nob, aa->aa_page_count, + aa->aa_ppga, OST_WRITE, cksum_type); - if (cksum_type != client_cksum_type) + if (cksum_type != cksum_type_unpack(aa->aa_oa->o_flags)) msg = "the server did not use the checksum type specified in the original request - likely a protocol problem" ; else if (new_cksum == server_cksum) @@ -1365,17 +1437,19 @@ static int check_write_checksum(struct obdo *oa, msg = "changed in transit AND doesn't match the original - likely false positive due to mmap IO (bug 11742)" ; - LCONSOLE_ERROR_MSG(0x132, "BAD WRITE CHECKSUM: %s: from %s inode " DFID " object " DOSTID " extent [%llu-%llu]\n", + LCONSOLE_ERROR_MSG(0x132, + "%s: BAD WRITE CHECKSUM: %s: from %s inode " DFID " object " DOSTID " extent [%llu-%llu], original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", + aa->aa_cli->cl_import->imp_obd->obd_name, msg, libcfs_nid2str(peer->nid), - oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (__u64)0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (u64)0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, - POSTID(&oa->o_oi), pga[0]->off, - pga[page_count - 1]->off + - pga[page_count - 1]->count - 1); - CERROR("original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", - client_cksum, client_cksum_type, - server_cksum, cksum_type, new_cksum); + POSTID(&oa->o_oi), aa->aa_ppga[0]->off, + aa->aa_ppga[aa->aa_page_count - 1]->off + + aa->aa_ppga[aa->aa_page_count - 1]->count - 1, + client_cksum, cksum_type_unpack(aa->aa_oa->o_flags), + server_cksum, cksum_type, new_cksum); + return 1; } @@ -1432,9 +1506,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if ((aa->aa_oa->o_valid & OBD_MD_FLCKSUM) && client_cksum && check_write_checksum(&body->oa, peer, client_cksum, - body->oa.o_cksum, aa->aa_requested_nob, - aa->aa_page_count, aa->aa_ppga, - cksum_type_unpack(aa->aa_oa->o_flags))) + body->oa.o_cksum, aa)) return -EAGAIN; rc = check_write_rcs(req, aa->aa_requested_nob, @@ -1487,23 +1559,33 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } if (server_cksum != client_cksum) { - LCONSOLE_ERROR_MSG(0x133, "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu]\n", + u32 page_count = aa->aa_page_count; + struct ost_body *clbody; + + clbody = req_capsule_client_get(&req->rq_pill, + &RMF_OST_BODY); + if (cli->cl_checksum_dump) + dump_all_bulk_pages(&clbody->oa, page_count, + aa->aa_ppga, server_cksum, + client_cksum); + + LCONSOLE_ERROR_MSG(0x133, + "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu], client %x, server %x, cksum_type %x\n", req->rq_import->imp_obd->obd_name, libcfs_nid2str(peer->nid), via, router, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_seq : (__u64)0, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_oid : 0, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_ver : 0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_seq : (u64)0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_oid : 0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_ver : 0, POSTID(&body->oa.o_oi), aa->aa_ppga[0]->off, - aa->aa_ppga[aa->aa_page_count-1]->off + - aa->aa_ppga[aa->aa_page_count-1]->count - - 1); - CERROR("client %x, server %x, cksum_type %x\n", - client_cksum, server_cksum, cksum_type); + aa->aa_ppga[page_count - 1]->off + + aa->aa_ppga[page_count - 1]->count - 1, + client_cksum, server_cksum, + cksum_type); cksum_counter = 0; aa->aa_oa->o_cksum = client_cksum; rc = -EAGAIN; From patchwork Fri Aug 17 03:10:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AC6513B6 for ; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27CDB2B157 for ; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C5D62B18D; Fri, 17 Aug 2018 03:11:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 887892B157 for ; Fri, 17 Aug 2018 03:11:57 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DF6E74E21FB; Thu, 16 Aug 2018 20:11:20 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 086D04E1CAE for ; Thu, 16 Aug 2018 20:10:59 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 581C21005395; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 54F9E464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:38 -0400 Message-Id: <1534475441-15543-36-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 35/38] lustre: osc: update sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move sysfs/debugfs handling to lproc_osc.c. Do proper cleanup if any of the sysfs handling code fails. Fix up the style issues. Move to class_modify_params(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30962 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 68 ++++++++++++++++-------- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +- drivers/staging/lustre/lustre/osc/osc_request.c | 26 +++------ 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 89dadba..284ceed 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -50,8 +50,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, } static ssize_t active_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, - size_t count) + const char *buffer, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); @@ -157,8 +156,8 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; - int rc; unsigned long pages_number; + int rc; rc = kstrtoul(buffer, 10, &pages_number); if (rc) @@ -180,6 +179,9 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_dirty_mb); +#define ost_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(ost_conn_uuid); + static int osc_cached_mb_seq_show(struct seq_file *m, void *v) { struct obd_device *dev = m->private; @@ -407,9 +409,8 @@ static ssize_t checksums_store(struct kobject *kobj, static int osc_checksum_type_seq_show(struct seq_file *m, void *v) { struct obd_device *obd = m->private; - int i; - DECLARE_CKSUM_NAME; + int i; if (!obd) return 0; @@ -431,10 +432,9 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int i; - DECLARE_CKSUM_NAME; char kernbuf[10]; + int i; if (!obd) return 0; @@ -665,7 +665,6 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(osc, state); @@ -675,17 +674,24 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); static struct lprocfs_vars lprocfs_osc_obd_vars[] = { - { "ping", &osc_ping_fops, NULL, 0222 }, - { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, - { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, - { "osc_cached_mb", &osc_cached_mb_fops, NULL }, - { "checksum_type", &osc_checksum_type_fops, NULL }, - { "timeouts", &osc_timeouts_fops, NULL, 0 }, - { "import", &osc_import_fops, NULL }, - { "state", &osc_state_fops, NULL, 0 }, - { "pinger_recov", &osc_pinger_recov_fops, NULL }, + { .name = "ping", + .fops = &osc_ping_fops }, + { .name = "connect_flags", + .fops = &osc_connect_flags_fops }, + { .name = "ost_server_uuid", + .fops = &osc_server_uuid_fops }, + { .name = "osc_cached_mb", + .fops = &osc_cached_mb_fops }, + { .name = "checksum_type", + .fops = &osc_checksum_type_fops }, + { .name = "timeouts", + .fops = &osc_timeouts_fops }, + { .name = "import", + .fops = &osc_import_fops }, + { .name = "state", + .fops = &osc_state_fops }, + { .name = "pinger_recov", + .fops = &osc_pinger_recov_fops }, { .name = "unstable_stats", .fops = &osc_unstable_stats_fops }, { NULL } @@ -871,11 +877,31 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_resend_count.attr, + &lustre_attr_ost_conn_uuid.attr, NULL, }; -void lprocfs_osc_init_vars(struct obd_device *obd) +int osc_tunables_init(struct obd_device *obd) { - obd->obd_ktype.default_attrs = osc_attrs; + int rc; + obd->obd_vars = lprocfs_osc_obd_vars; + obd->obd_ktype.default_attrs = osc_attrs; + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; + + rc = sptlrpc_lprocfs_cliobd_attach(obd); + if (rc) { + lprocfs_obd_cleanup(obd); + return rc; + } + + debugfs_create_file("osc_stats", 0644, obd->obd_debugfs_entry, obd, + &osc_stats_fops); + debugfs_create_file("rpc_stats", 0644, obd->obd_debugfs_entry, obd, + &osc_rpc_stats_fops); + + ptlrpc_lprocfs_register_obd(obd); + return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 6caabdb..55054d7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -145,8 +145,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct obd_device *obd); +int osc_tunables_init(struct obd_device *obd); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index a7a4a53..7c91c4b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2885,12 +2885,9 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(obd); - if (lprocfs_obd_setup(obd, false) == 0) { - lproc_osc_attach_seqstat(obd); - sptlrpc_lprocfs_cliobd_attach(obd); - ptlrpc_lprocfs_register_obd(obd); - } + rc = osc_tunables_init(obd); + if (rc) + goto out_quota; /* * We try to control the total number of requests with a upper limit @@ -2916,6 +2913,8 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return rc; +out_quota: + osc_quota_cleanup(obd); out_ptlrpcd_work: if (cli->cl_writeback_work) { ptlrpcd_destroy_work(cli->cl_writeback_work); @@ -2993,18 +2992,9 @@ static int osc_cleanup(struct obd_device *obd) int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) { - int rc = 0; - - switch (lcfg->lcfg_command) { - default: - rc = class_process_proc_param(PARAM_OSC, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; - break; - } - - return rc; + ssize_t count = class_modify_config(lcfg, PARAM_OSC, + &obd->obd_kset.kobj); + return count > 0 ? 0 : count; } static int osc_process_config(struct obd_device *obd, u32 len, void *buf) From patchwork Fri Aug 17 03:10:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87C5314BD for ; Fri, 17 Aug 2018 03:12:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 740032B157 for ; Fri, 17 Aug 2018 03:12:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65FAB2B18D; Fri, 17 Aug 2018 03:12:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA6892B157 for ; Fri, 17 Aug 2018 03:12:03 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1D42A4E2273; Thu, 16 Aug 2018 20:11:24 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5E0B64E1CAE for ; Thu, 16 Aug 2018 20:10:59 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 5D8A51005396; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 59702463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:39 -0400 Message-Id: <1534475441-15543-37-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 36/38] lustre: lmv: update sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move all the sysfs/debugfs handling to lproc_lmv.c. Properly handle failure cases for sysfs/debugfs bring up. Change desc_uuid into a sysfs files since its a simple one item file so we don't clutter debugfs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28460 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lmv/lmv_internal.h | 4 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 17 +++++---- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 48 +++++++++++++----------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 1b51dfb..f2c41c7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,8 +157,6 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct obd_device *obd); - -extern const struct file_operations lmv_proc_target_fops; +int lmv_tunables_init(struct obd_device *obd); #endif diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 7d5d03b..cf2a4c6 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -211,6 +211,10 @@ static int lmv_connect(const struct lu_env *env, lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", &obd->obd_kset.kobj); + if (!lmv->lmv_tgts_kobj) + CERROR("%s: cannot create /sys/fs/lustre/%s/%s/target_obds\n", + obd->obd_name, obd->obd_type->typ_name, obd->obd_name); + rc = lmv_check_connect(obd); if (rc) goto out_sysfs; @@ -1254,22 +1258,19 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(obd); + rc = lmv_tunables_init(obd); + if (rc) + CWARN("%s: error adding LMV sysfs/debugfs files: rc = %d\n", + obd->obd_name, rc); - lprocfs_obd_setup(obd, true); - debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, - &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, LUSTRE_CLI_FLD_HASH_DHT); if (rc) { CERROR("Can't init FLD, err %d\n", rc); - goto out; + return rc; } return 0; - -out: - return rc; } static int lmv_cleanup(struct obd_device *obd) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 6aae298..efc12ad 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -37,6 +37,7 @@ #include #include #include + #include "lmv_internal.h" static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, @@ -63,18 +64,17 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(activeobd); -static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lmv_desc *desc; - LASSERT(dev); - lmv = &dev->u.lmv; - seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid); - return 0; + desc = &dev->u.lmv.desc; + return sprintf(buf, "%s\n", desc->ld_uuid.uuid); } - -LPROC_SEQ_FOPS_RO(lmv_desc_uuid); +LUSTRE_RO_ATTR(desc_uuid); static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos) { @@ -115,6 +115,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) if (!tgt) return 0; + seq_printf(p, "%u: %s %sACTIVE\n", tgt->ltd_idx, tgt->ltd_uuid.uuid, tgt->ltd_active ? "" : "IN"); @@ -143,27 +144,32 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) return 0; } -static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, - { NULL } -}; - -const struct file_operations lmv_proc_target_fops = { +static const struct file_operations lmv_debugfs_target_fops = { .owner = THIS_MODULE, - .open = lmv_target_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, + .open = lmv_target_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static struct attribute *lmv_attrs[] = { &lustre_attr_activeobd.attr, + &lustre_attr_desc_uuid.attr, &lustre_attr_numobd.attr, NULL, }; -void lprocfs_lmv_init_vars(struct obd_device *obd) +int lmv_tunables_init(struct obd_device *obd) { - obd->obd_vars = lprocfs_lmv_obd_vars; + int rc; + obd->obd_ktype.default_attrs = lmv_attrs; + rc = lprocfs_obd_setup(obd, true); + if (rc) + return rc; + + debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, + &lmv_debugfs_target_fops); + + return 0; } From patchwork Fri Aug 17 03:10:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEFAD13B6 for ; Fri, 17 Aug 2018 03:12:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A92BC2B157 for ; Fri, 17 Aug 2018 03:12:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D4322B18D; Fri, 17 Aug 2018 03:12:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD8462B157 for ; Fri, 17 Aug 2018 03:12:10 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C27464E22CA; Thu, 16 Aug 2018 20:11:26 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id B38BE4E1C6A for ; Thu, 16 Aug 2018 20:10:59 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 61F261005397; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 5D66E464; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:40 -0400 Message-Id: <1534475441-15543-38-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 37/38] lustre: lov: update sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move all the sysfs/debugfs handling to lproc_lov.c. Properly handle failure cases for sysfs/debugfs bring up. Migrate all the debugfs files to sys so we don't clutter debugfs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30960 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 40 +++-- drivers/staging/lustre/lustre/lov/lproc_lov.c | 213 +++++++++++------------ 3 files changed, 131 insertions(+), 125 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 7e0b9ac..dbb79d4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -240,8 +240,7 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); /* lproc_lov.c */ -extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct obd_device *obd); +int lov_tunables_init(struct obd_device *obd); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 28b7d91..3483f9b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -189,12 +189,19 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); - if (lov->lov_tgts_kobj) + if (lov->lov_tgts_kobj) { /* Even if we failed, that's ok */ rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kset.kobj, tgt_obd->obd_name); - + if (rc) { + CERROR("%s: can't register LOV target /sys/fs/lustre/%s/%s/target_obds/%s : rc = %d\n", + obd->obd_name, obd->obd_type->typ_name, + obd->obd_name, + lov->lov_tgts[index]->ltd_exp->exp_obd->obd_name, + rc); + } + } return 0; } @@ -764,22 +771,23 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lov->lov_pool_count = 0; rc = lov_pool_hash_init(&lov->lov_pools_hash_body); if (rc) - goto out; + goto out_hash; + rc = lov_ost_pool_init(&lov->lov_packed, 0); if (rc) - goto out; - - lprocfs_lov_init_vars(obd); - lprocfs_obd_setup(obd, false); + goto out_pool; - debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, - &lov_proc_target_fops); + rc = lov_tunables_init(obd); + if (rc) + goto out_tunables; - lov->lov_pool_debugfs_entry = debugfs_create_dir("pools", - obd->obd_debugfs_entry); return 0; -out: +out_tunables: + lov_ost_pool_free(&lov->lov_packed); +out_pool: + lov_pool_hash_destroy(&lov->lov_pools_hash_body); +out_hash: return rc; } @@ -873,16 +881,16 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, } case LCFG_PARAM: { struct lov_desc *desc = &obd->u.lov.desc; + ssize_t count; if (!desc) { rc = -EINVAL; goto out; } - rc = class_process_proc_param(PARAM_LOV, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; + count = class_modify_config(lcfg, PARAM_LOV, + &obd->obd_kset.kobj); + rc = count < 0 ? count : 0; goto out; } case LCFG_POOL_NEW: diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 9c5d6fc..771c6f8 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -38,134 +38,131 @@ #include #include "lov_internal.h" -static int lov_stripesize_seq_show(struct seq_file *m, void *v) +static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%llu\n", desc->ld_default_stripe_size); - return 0; + return sprintf(buf, "%llu\n", desc->ld_default_stripe_size); } -static ssize_t lov_stripesize_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - __u64 val; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + u64 val; int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buf, 10, &val); if (rc) return rc; lov_fix_desc_stripe_size(&val); desc->ld_default_stripe_size = val; + return count; } +LUSTRE_RW_ATTR(stripesize); -LPROC_SEQ_FOPS(lov_stripesize); - -static int lov_stripeoffset_seq_show(struct seq_file *m, void *v) +static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%llu\n", desc->ld_default_stripe_offset); - return 0; + return sprintf(buf, "%llu\n", desc->ld_default_stripe_offset); } -static ssize_t lov_stripeoffset_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripeoffset_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - __u64 val; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + long val; int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtol(buf, 0, &val); if (rc) return rc; + if (val < -1 || val > LOV_MAX_STRIPE_COUNT) + return -ERANGE; + desc->ld_default_stripe_offset = val; + return count; } +LUSTRE_RW_ATTR(stripeoffset); -LPROC_SEQ_FOPS(lov_stripeoffset); - -static int lov_stripetype_seq_show(struct seq_file *m, void *v) +static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_pattern); - return 0; + return sprintf(buf, "%u\n", desc->ld_pattern); } -static ssize_t lov_stripetype_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripetype_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + u32 pattern; + int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &pattern); if (rc) return rc; - lov_fix_desc_pattern(&val); - desc->ld_pattern = val; + lov_fix_desc_pattern(&pattern); + desc->ld_pattern = pattern; + return count; } +LUSTRE_RW_ATTR(stripetype); -LPROC_SEQ_FOPS(lov_stripetype); - -static int lov_stripecount_seq_show(struct seq_file *m, void *v) +static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%d\n", (__s16)(desc->ld_default_stripe_count + 1) - 1); - return 0; + return sprintf(buf, "%d\n", + (s16)(desc->ld_default_stripe_count + 1) - 1); } -static ssize_t lov_stripecount_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripecount_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + int stripe_count; + int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoint(buffer, 0, &stripe_count); if (rc) return rc; - lov_fix_desc_stripe_count(&val); - desc->ld_default_stripe_count = val; + if (stripe_count < -1) + return -ERANGE; + + lov_fix_desc_stripe_count(&stripe_count); + desc->ld_default_stripe_count = stripe_count; + return count; } - -LPROC_SEQ_FOPS(lov_stripecount); +LUSTRE_RW_ATTR(stripecount); static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -191,18 +188,16 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(activeobd); -static int lov_desc_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_obd *lov; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - lov = &dev->u.lov; - seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", desc->ld_uuid.uuid); } - -LPROC_SEQ_FOPS_RO(lov_desc_uuid); +LUSTRE_RO_ATTR(desc_uuid); static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos) { @@ -264,36 +259,40 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) return 0; } -static struct lprocfs_vars lprocfs_lov_obd_vars[] = { - { "stripesize", &lov_stripesize_fops, NULL }, - { "stripeoffset", &lov_stripeoffset_fops, NULL }, - { "stripecount", &lov_stripecount_fops, NULL }, - { "stripetype", &lov_stripetype_fops, NULL }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 }, - { NULL } +static const struct file_operations lov_debugfs_target_fops = { + .owner = THIS_MODULE, + .open = lov_target_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = lprocfs_seq_release, }; static struct attribute *lov_attrs[] = { &lustre_attr_activeobd.attr, &lustre_attr_numobd.attr, + &lustre_attr_desc_uuid.attr, + &lustre_attr_stripesize.attr, + &lustre_attr_stripeoffset.attr, + &lustre_attr_stripetype.attr, + &lustre_attr_stripecount.attr, NULL, }; -static const struct attribute_group lov_attr_group = { - .attrs = lov_attrs, -}; - -void lprocfs_lov_init_vars(struct obd_device *obd) +int lov_tunables_init(struct obd_device *obd) { - obd->obd_vars = lprocfs_lov_obd_vars; + struct lov_obd *lov = &obd->u.lov; + int rc; + obd->obd_ktype.default_attrs = lov_attrs; -} + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; -const struct file_operations lov_proc_target_fops = { - .owner = THIS_MODULE, - .open = lov_target_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = lprocfs_seq_release, -}; + debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, + &lov_debugfs_target_fops); + + lov->lov_pool_debugfs_entry = debugfs_create_dir("pools", + obd->obd_debugfs_entry); + + return 0; +} From patchwork Fri Aug 17 03:10:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10568389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A431414BD for ; Fri, 17 Aug 2018 03:12:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914222B176 for ; Fri, 17 Aug 2018 03:12:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 855682B1A7; Fri, 17 Aug 2018 03:12:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F2D3D2B176 for ; Fri, 17 Aug 2018 03:12:17 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6D7954E1EA4; Thu, 16 Aug 2018 20:11:29 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 151A64E1C6A for ; Thu, 16 Aug 2018 20:11:00 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 63C9C1005398; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 615A2463; Thu, 16 Aug 2018 23:10:46 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 16 Aug 2018 23:10:41 -0400 Message-Id: <1534475441-15543-39-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 38/38] lustre: mdc: update sysfs handling X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move all the sysfs/debugfs handling to lproc_mdc.c. Properly handle failure cases for sysfs/debugfs bring up. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30961 Reviewed-by: Dmitry Eremin Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 72 ++++++++++++++---------- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 3 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 31 ++++------ 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 47f23d6..3bff8b5 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -51,23 +51,20 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - unsigned long val; + bool val; int rc; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val > 1) - return -ERANGE; - /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) { rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); if (rc) count = rc; } else { - CDEBUG(D_CONFIG, "activate %lu: ignoring repeat request\n", val); + CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n", val); } return count; } @@ -77,15 +74,10 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, struct attribute *attr, char *buf) { - int len; struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - __u32 max; - - max = obd_get_max_rpcs_in_flight(&dev->u.cli); - len = sprintf(buf, "%u\n", max); - return len; + return sprintf(buf, "%u\n", obd_get_max_rpcs_in_flight(&dev->u.cli)); } static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, @@ -95,10 +87,10 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; @@ -116,13 +108,8 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - u16 max; - int len; - - max = dev->u.cli.cl_max_mod_rpcs_in_flight; - len = sprintf(buf, "%hu\n", max); - return len; + return sprintf(buf, "%hu\n", dev->u.cli.cl_max_mod_rpcs_in_flight); } static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, @@ -147,6 +134,9 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_mod_rpcs_in_flight); +#define mdc_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(mdc_conn_uuid); + static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) { struct obd_device *dev = seq->private; @@ -172,7 +162,6 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file, LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(mdc, state); @@ -198,15 +187,20 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { - { "ping", &mdc_ping_fops, NULL, 0222 }, - { "connect_flags", &mdc_connect_flags_fops, NULL, 0 }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, - { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, - { "timeouts", &mdc_timeouts_fops, NULL, 0 }, - { "import", &mdc_import_fops, NULL, 0 }, - { "state", &mdc_state_fops, NULL, 0 }, - { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 }, + { .name = "ping", + .fops = &mdc_ping_fops }, + { .name = "connect_flags", + .fops = &mdc_connect_flags_fops }, + { .name = "mds_server_uuid", + .fops = &mdc_server_uuid_fops, }, + { .name = "timeouts", + .fops = &mdc_timeouts_fops }, + { .name = "import", + .fops = &mdc_import_fops }, + { .name = "state", + .fops = &mdc_state_fops }, + { .name = "pinger_recov", + .fops = &mdc_pinger_recov_fops }, { .name = "rpc_stats", .fops = &mdc_rpc_stats_fops }, { NULL } @@ -217,11 +211,27 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_max_mod_rpcs_in_flight.attr, &lustre_attr_max_pages_per_rpc.attr, + &lustre_attr_mdc_conn_uuid.attr, NULL, }; -void lprocfs_mdc_init_vars(struct obd_device *obd) +int mdc_tunables_init(struct obd_device *obd) { + int rc; + obd->obd_ktype.default_attrs = mdc_attrs; obd->obd_vars = lprocfs_mdc_obd_vars; + + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; + + rc = sptlrpc_lprocfs_cliobd_attach(obd); + if (rc) { + lprocfs_obd_cleanup(obd); + return rc; + } + ptlrpc_lprocfs_register_obd(obd); + + return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index d66663f..941a896 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,7 +36,8 @@ #include -void lprocfs_mdc_init_vars(struct obd_device *obd); +int mdc_tunables_init(struct obd_device *obd); + void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index fcba599..f3c0722 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -60,8 +60,6 @@ #define REQUEST_MINOR 244 -static int mdc_cleanup(struct obd_device *obd); - static inline int mdc_queue_wait(struct ptlrpc_request *req) { struct client_obd *cli = &req->rq_import->imp_obd->u.cli; @@ -2647,10 +2645,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(obd); - lprocfs_obd_setup(obd, false); - sptlrpc_lprocfs_cliobd_attach(obd); - ptlrpc_lprocfs_register_obd(obd); + rc = mdc_tunables_init(obd); + if (rc) + goto err_osc_cleanup; ns_register_cancel(obd->obd_namespace, mdc_cancel_weight); @@ -2658,13 +2655,16 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) rc = mdc_llog_init(obd); if (rc) { - mdc_cleanup(obd); CERROR("failed to setup llogging subsystems\n"); - return rc; + goto err_llog_cleanup; } - return rc; + return 0; +err_llog_cleanup: + ptlrpc_lprocfs_unregister_obd(obd); +err_osc_cleanup: + client_obd_cleanup(obd); err_ptlrpcd_decref: ptlrpcd_decref(); return rc; @@ -2715,17 +2715,10 @@ static int mdc_cleanup(struct obd_device *obd) static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) { struct lustre_cfg *lcfg = buf; - int rc = 0; + size_t count = class_modify_config(lcfg, PARAM_MDC, + &obd->obd_kset.kobj); - switch (lcfg->lcfg_command) { - default: - rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; - break; - } - return rc; + return count > 0 ? 0 : count; } static struct obd_ops mdc_obd_ops = {