From patchwork Mon Aug 20 02:39: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: 10569837 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 C511E920 for ; Mon, 20 Aug 2018 02:39:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A537228F7B for ; Mon, 20 Aug 2018 02:39:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81C2428F8F; Mon, 20 Aug 2018 02:39:32 +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 EB17928F7B for ; Mon, 20 Aug 2018 02:39:31 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 8EC747A1438; Sun, 19 Aug 2018 19:39: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 B0B017A13DC for ; Sun, 19 Aug 2018 19:39:28 -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 6E94F10050EE; Sun, 19 Aug 2018 22:39:27 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 66436369; Sun, 19 Aug 2018 22:39:27 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 19 Aug 2018 22:39:25 -0400 Message-Id: <1534732765-22828-1-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 Subject: [lustre-devel] [PATCH v2 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 ldebugfs_[un]register_mountpoint() to ll_debugfs_[un]register_super(). This first aligns the functions name with the major of the llite function prototypes by starting with the ll_* prefix. The use of mountpoint is not the best way to describe the functions who's name are being changed. Since this is managed by struct ll_sb_info, which is the lustre private instance for struct super_block, so rename to *_super() instead. 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 Changelog) v1) Initial patch v2) Improved changelog message --- 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 Mon Aug 20 02:39:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10569839 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 AD95C5A4 for ; Mon, 20 Aug 2018 02:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C46928F7B for ; Mon, 20 Aug 2018 02:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F8E628F8F; Mon, 20 Aug 2018 02:39:54 +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 2A85228F7B for ; Mon, 20 Aug 2018 02:39:54 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6F91D7A168F; Sun, 19 Aug 2018 19:39: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 74DDD21F7C8 for ; Sun, 19 Aug 2018 19:39: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 3819F10050EE; Sun, 19 Aug 2018 22:39:51 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 360E7369; Sun, 19 Aug 2018 22:39:51 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 19 Aug 2018 22:39:49 -0400 Message-Id: <1534732789-22934-1-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 Subject: [lustre-devel] [PATCH v2 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 WC-bug-id: https://jira.whamcloud.com/browse/LU-10824 Reviewed-on: https://review.whamcloud.com/33025 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog) v1) initial patch v2) Remove use of ll_mnt in fstype sysfs file 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 | 5 +---- 3 files changed, 3 insertions(+), 9 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..858d276 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -212,10 +212,7 @@ static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, 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); - - return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); + return sprintf(buf, "lustre\n"); } LUSTRE_RO_ATTR(fstype); From patchwork Mon Aug 20 02:40: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: 10569841 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 4219B5A4 for ; Mon, 20 Aug 2018 02:40:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E193291D1 for ; Mon, 20 Aug 2018 02:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C49C291DB; Mon, 20 Aug 2018 02:40:17 +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 5E5B8291AF for ; Mon, 20 Aug 2018 02:40:16 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1111821F8B4; Sun, 19 Aug 2018 19:40:16 -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 35CF821F3CF for ; Sun, 19 Aug 2018 19:40:14 -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 284D910050EE; Sun, 19 Aug 2018 22:40:13 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 25285369; Sun, 19 Aug 2018 22:40:13 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 19 Aug 2018 22:40:11 -0400 Message-Id: <1534732811-23048-1-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 Subject: [lustre-devel] [PATCH v2 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 --- Changelog) v1) Initial patch v2) fstype no longer needs to use kobject .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 112 +++++++++++++-------- 2 files changed, 71 insertions(+), 43 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 858d276..f43fc99 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -39,22 +39,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; @@ -62,7 +82,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; @@ -77,7 +98,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; @@ -95,7 +116,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; @@ -120,7 +141,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; @@ -145,7 +166,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; @@ -170,7 +191,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; @@ -188,7 +209,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; @@ -220,7 +241,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); } @@ -243,7 +264,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; @@ -261,7 +282,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; @@ -290,7 +311,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; @@ -308,7 +329,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; @@ -335,7 +356,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; @@ -353,7 +374,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; @@ -518,7 +539,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); } @@ -529,7 +550,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; @@ -560,7 +581,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); @@ -575,7 +596,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; @@ -644,7 +665,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); } @@ -655,7 +676,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; @@ -678,7 +699,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); } @@ -689,7 +710,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; @@ -730,7 +751,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); } @@ -741,7 +762,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; @@ -765,7 +786,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; @@ -794,7 +815,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; @@ -827,7 +848,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; @@ -873,7 +894,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); } @@ -884,7 +905,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; @@ -909,7 +930,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)); } @@ -920,7 +941,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; @@ -1106,7 +1127,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); } @@ -1281,17 +1302,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; @@ -1299,7 +1325,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) { @@ -1313,8 +1339,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 Mon Aug 20 02:40: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: 10569843 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 3B3075A4 for ; Mon, 20 Aug 2018 02:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29B40291B7 for ; Mon, 20 Aug 2018 02:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2894E291B5; Mon, 20 Aug 2018 02:40:29 +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 CFC41291B7 for ; Mon, 20 Aug 2018 02:40:28 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2F0347A1693; Sun, 19 Aug 2018 19:40:28 -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 C6C2E7A109E for ; Sun, 19 Aug 2018 19:40:25 -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 C893910050EF; Sun, 19 Aug 2018 22:40:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C69C0369; Sun, 19 Aug 2018 22:40:24 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Sun, 19 Aug 2018 22:40:23 -0400 Message-Id: <1534732823-23115-1-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 Subject: [lustre-devel] [PATCH v2 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 --- Changelog) v1) Initial patch v2) remove unneeded spin lock for max_rpcs_in_flight_show 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 @@ -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);