Skip to contentSkip to conversation

lustre: fixes for sysfs handling

PATCH Superseded James Simmons 3 participants 53 messages Aug 17, 2018 – Aug 20, 2018 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover lustre: fixes for sysfs handling

The port to sysfs upstream was done in haste and without any support in the utilies to even test it. Now the user land tools do work with the sysfs / debugfs port and many problems were exposed. This patch series fixes some of the largest holes which brings back some basic lustre functionality for the users. One special note to users you need to add the following udev rule to allowing tuning to work automatically with testing.

SUBSYSTEM=="lustre", ACTION=="change", ENV{PARAM}=="?*", RUN+="/usr/sbin/lctl set_param '$env{PARAM}=$env{SETTING}'"

Andreas Dilger (1):
lustre: llite: add newline to llite.*.offset_stats

Bruno Faccini (1):
lustre: osc: enhance end to end bulk cksum error report

Emoly Liu (1):
lustre: llite: register mountpoint before process llog

James Simmons (33):
lustre: llite: rename ldebugfs_[un]register_mountpoint
lustre: llite: change ll_statfs_internal to use struct ll_sb_info
lustre: llite: move llite_root and llite_kset to lproc_llite.c
lustre: llite: remove ll_sb
lustre: llite: change top kobject for llite into a kset
lustre: llite: rename llite_sb_release
lustre: llite: move lmd_profile handling
lustre: llite: add proper error handling for
ll_debugfs_register_super()
lustre: llite: use C99 for struct lprocfs_llite_obd_vars
lustre: llite: don't handle success case for blocksize sysfs code
lustre: llite: don't handle success case for kbyte* sysfs code
lustre: llite: don't handle success case for file* sysfs code
lustre: llite: user kstrtobool for some sysfs handling
lustre: obd: embedded struct lprocfs_vars in obd device
lustre: obdclass: swap obd device attrs and default_attrs
lustre: obdclass: embedded attributes in struct obd_device
lustre: obdclass: add light weight obd_def_uuid_attrs
lustre: obd: migrate to ksets
lustre: obd: create class_setup_tunables() function
lustre: obd: create conn_uuid sysfs file
lustre: obd: enhance print_lustre_cfg()
lustre: obd: merge both top lustre sysfs attributes
lustre: obd: resolve config log sysfs issues
lustre: obd: move ioctl handling to class_obd.c
lustre: llite: replace ll_process_config with class_modify_config
lustre: mgc: update sysfs handling
lustre: osc: fixup kstrto* for sysfs handling
lustre: osc: restore cl_loi_list_lock
lustre: osc: make unstable_stats a debugfs file
lustre: osc: update sysfs handling
lustre: lmv: update sysfs handling
lustre: lov: update sysfs handling
lustre: mdc: update sysfs handling

Steve Guminski (2):
lustre: llite: create ll_stats_pid_write()
lustre: llite: improve sysfs file text in lproc_llite.c

 drivers/staging/lustre/lnet/libcfs/debug.c         |   1 +
 .../staging/lustre/lustre/include/lprocfs_status.h |  12 +-
 .../staging/lustre/lustre/include/lustre_disk.h    |   2 +
 drivers/staging/lustre/lustre/include/obd.h        |  17 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |  10 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |   2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |  21 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    | 137 ++++---
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 442 +++++++++++----------
 drivers/staging/lustre/lustre/llite/super25.c      |  28 +-
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |   4 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |  26 +-
 drivers/staging/lustre/lustre/lmv/lproc_lmv.c      |  58 +--
 drivers/staging/lustre/lustre/lov/lov_internal.h   |   3 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c        |  51 +--
 drivers/staging/lustre/lustre/lov/lproc_lov.c      | 219 +++++-----
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c      |  94 +++--
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |  37 +-
 drivers/staging/lustre/lustre/mgc/lproc_mgc.c      |  45 ++-
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |  11 +-
 drivers/staging/lustre/lustre/obdclass/Makefile    |   2 +-
 drivers/staging/lustre/lustre/obdclass/class_obd.c | 209 +++++++++-
 drivers/staging/lustre/lustre/obdclass/genops.c    |  47 ++-
 drivers/staging/lustre/lustre/obdclass/llog_swab.c |  12 +-
 .../lustre/lustre/obdclass/lprocfs_status.c        | 111 ++++--
 .../staging/lustre/lustre/obdclass/obd_config.c    | 213 +++++++---
 .../lustre/obdclass/{module.c => obd_sysfs.c}      | 293 +++++---------
 drivers/staging/lustre/lustre/obdclass/sysctl.c    | 162 --------
 drivers/staging/lustre/lustre/osc/lproc_osc.c      | 252 ++++++++----
 drivers/staging/lustre/lustre/osc/osc_internal.h   |   3 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    | 174 +++++---
 33 files changed, 1503 insertions(+), 1199 deletions(-)
 rename drivers/staging/lustre/lustre/obdclass/{module.c => obd_sysfs.c} (57%)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/sysctl.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/38 lustre: llite: rename ldebugfs_[un]register_mountpoint

Rename from ldebugfs_[un]register_mountpoint() to ll_debugfs_[un]register_super().

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +3 -3
index 6ed7034..b2cdf75 100644
@@ -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,
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -2
index fb3bc16..50ea5fb 100644
@@ -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);
drivers/staging/lustre/lustre/llite/lproc_llite.c +3 -3
index 617aabb..996703d 100644
@@ -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);
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/38 lustre: llite: rename ldebugfs_[un]register_mountpoint

Quoted 2 lines · James Simmons

Rename from ldebugfs_[un]register_mountpoint() to
ll_debugfs_[un]register_super().

I really helps with review if I am told *why* something is happening.

I can guess, but being told means I'm less concerned that I might have missed something.

I can see that "mountpoint" is an inappropriate name, though I'm not entired sure that "super" is a better now. Surely this code is registering an filesystem (instance) with debugfs.... maybe a "super" is exactly a "filesystem instance"....

Why is ll_debugfs better than ldebugfs? More typing doesn't usually thrill me.

I don't really care about this particular change - it seems innocuous. I do really care about good change logs.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/81ed97d5/attachment-0001.sig>

#3 lore raw

PATCH 1/38 lustre: llite: rename ldebugfs_[un]register_mountpoint

Quoted 11 lines · James Simmons
Quoted 3 lines

Rename from ldebugfs_[un]register_mountpoint() to
ll_debugfs_[un]register_super().

I really helps with review if I am told *why* something is happening.

I can guess, but being told means I'm less concerned that I might have missed something.

Quoted 7 lines

I can see that "mountpoint" is an inappropriate name, though I'm not entired sure that "super" is a better now. Surely this code is registering an filesystem (instance) with debugfs.... maybe a "super" is exactly a "filesystem instance"....

Why is ll_debugfs better than ldebugfs? More typing doesn't usually thrill me.

This was a request by John Hammond, the lustre style enforcer :-) Same for the ll_*() function naming. The idea here is all llite function begin with ll_ prefix. How about this changelog.

--------------------------------------------------------------------------

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

#4 lore raw

PATCH 2/38 lustre: llite: change ll_statfs_internal to use struct ll_sb_info

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +2 -2
index b2cdf75..4053314 100644
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +4 -5
index 50ea5fb..437f4cc 100644
@@ -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)
drivers/staging/lustre/lustre/llite/lproc_llite.c +6 -6
index 996703d..cae483f 100644
@@ -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)
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 3/38 lustre: llite: move llite_root and llite_kset to lproc_llite.c

In reply to James Simmons

Move llite_root and llite_kset to lproc_llite.c so that all the sysfs and debugfs code is together.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 .../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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +3 -4
index 4053314..2719bc53 100644
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +5 -9
index 437f4cc..d16f5d1 100644
@@ -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;
drivers/staging/lustre/lustre/llite/lproc_llite.c +31 -3
index cae483f..a9ad328 100644
@@ -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,
drivers/staging/lustre/lustre/llite/super25.c +6 -18
index a3bc57d..2f4306e 100644
@@ -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);
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 4/38 lustre: llite: remove ll_sb

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +0 -1
index 2719bc53..92dc05d 100644
@@ -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;
 };
 
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -4
index d16f5d1..d352287 100644
@@ -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);
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -1
index a9ad328..8e418ba 100644
@@ -33,6 +33,7 @@
 #define DEBUG_SUBSYSTEM S_LLITE
 
 #include <lprocfs_status.h>
+#include <linux/mount.h>
 #include <linux/seq_file.h>
 #include <obd_support.h>
 
@@ -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);
 
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 4/38 lustre: llite: remove ll_sb

Quoted 6 lines · James Simmons

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.

....

drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, · line 219

Quoted 6 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
@@ -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);

ll_mnt ??? What is that, why is it a better thing to keep than ll_sb. (looks at code).

The code takes a copy of a vfsmnt and a dentry (a path) without increasing the refcount on either??? Why did someone think that was a sane thing to do?
Have you plans to get rid of ll_mnt too (I hope)??

Thanks,
NeilBrown

Quoted 5 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +0 -0
 }
 LUSTRE_RO_ATTR(fstype);
 
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/1375c9bf/attachment.sig>

#8 lore raw

PATCH 4/38 lustre: llite: remove ll_sb

Quoted 15 lines · James Simmons
Quoted 7 lines

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.

....

Quoted 4 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +0 -0
@@ -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);
 
Quoted 5 lines

drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, · line 219

Quoted 2 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
-	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);

ll_mnt ??? What is that, why is it a better thing to keep than ll_sb. (looks at code).

At first I was thinking that the name was of the format $FSNAME-$UUID but now that I look at what its requesting that is not the case. The 'name' returned looks to be always "lustre". Yet for some reason its does this long winded way to get this info. Andreas or Oleg is their a reason for this?

Quoted 4 lines

The code takes a copy of a vfsmnt and a dentry (a path) without increasing the refcount on either??? Why did someone think that was a sane thing to do?
Have you plans to get rid of ll_mnt too (I hope)??

That would be Rahul. The patch is :

http://review.whamcloud.com/20061

and the details are at https://jira.whamcloud.com/browse/LU-1882.

Some time ago Al Viro and Oleg discussed this. That is under ticket
https://jira.whamcloud.com/browse/LU-10824

So the answer is yes their are plans but no one has looked at fixing this.

#9 lore raw

PATCH 4/38 lustre: llite: remove ll_sb

Quoted 22 lines · James Simmons
Quoted 16 lines · James Simmons
Quoted 7 lines

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.

....

Quoted 4 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +0 -0
@@ -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);
 
Quoted 5 lines

drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, · line 219

Quoted 2 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
-	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);

ll_mnt ??? What is that, why is it a better thing to keep than ll_sb. (looks at code).

Quoted 5 lines

At first I was thinking that the name was of the format $FSNAME-$UUID but now that I look at what its requesting that is not the case. The 'name' returned looks to be always "lustre". Yet for some reason its does this long winded way to get this info. Andreas or Oleg is their a reason for this?

In the ancient past the filesystem type was named either "llite" or "lustre", so this was used to print the filesystem type consistently. It has been "lustre" for quite a while now. I recently discussed with you about changing the server-side mounts to use "lustre-mdt" and "lustre-ost", but I don't think this applies to this code here.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180818/8981e77d/attachment-0001.sig>

#10 lore raw

PATCH 5/38 lustre: llite: change top kobject for llite into a kset

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 .../staging/lustre/lustre/llite/llite_internal.h   |   2 +-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 114 +++++++++++++--------
 2 files changed, 72 insertions(+), 44 deletions(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +1 -1
index 92dc05d..5577407 100644
@@ -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;
 };
 
drivers/staging/lustre/lustre/llite/lproc_llite.c +71 -43

356 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#11 lore raw

PATCH 6/38 lustre: llite: rename llite_sb_release

In reply to James Simmons

Since we are freeing a kobject rename llite_sb_release() to llite_kobj_release().

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -2
index 8af6636..90140b0 100644
@@ -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 {
Signature · 1 line
1.8.3.1
#12 lore raw

PATCH 6/38 lustre: llite: rename llite_sb_release

Quoted 2 lines · James Simmons

Since we are freeing a kobject rename llite_sb_release() to llite_kobj_release().

Thank you! You told me *why*. Easy to review!
:-)

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/4d812b77/attachment.sig>

#13 lore raw

PATCH 7/38 lustre: llite: register mountpoint before process llog

In reply to James Simmons

From: Emoly Liu <[email protected]>

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9399
Reviewed-on: https://review.whamcloud.com/27241

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/#/c/32516

---
 .../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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +4 -1
index 5577407..9e60c5e 100644
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +54 -21

160 lines not on this page · raw message

drivers/staging/lustre/lustre/llite/lproc_llite.c +10 -20
index 90140b0..868c9b0 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#14 lore raw

PATCH 7/38 lustre: llite: register mountpoint before process llog

Quoted 36 lines · James Simmons

From: Emoly Liu <[email protected]>

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9399
Reviewed-on: https://review.whamcloud.com/27241

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/#/c/32516

---
 .../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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +0 -0
index 5577407..9e60c5e 100644
@@ -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;

drivers/staging/lustre/lustre/llite/llite_internal.h struct ll_sb_info { · line 473

Quoted 10 lines
drivers/staging/lustre/lustre/llite/llite_internal.h +3 -0
+	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;

Bit fields are dangerous in a shared data structures. You need locking for updates as the compiler produces a read-modify-write on the whole 32bit word.
I note that no locking is used... I don't think there is a real risk of anything going wrong, but it is poor practice.

I also note ll_umounting is never tested - should be removed.

There is room for improvement here.

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/49838d23/attachment.sig>

#15 lore raw

PATCH 8/38 lustre: llite: move lmd_profile handling

In reply to James Simmons

The function ll_debugfs_register_super() should only handling sysfs related things so move the lmd_profile parsing out of that function.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 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(-)
drivers/staging/lustre/lustre/llite/llite_internal.h +1 -1
index 9e60c5e..1130ea3 100644
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +16 -1
index 95568b7..ce072da 100644
@@ -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);
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -16
index 868c9b0..4186a8d 100644
@@ -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;
 
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH 9/38 lustre: llite: add proper error handling for ll_debugfs_register_super()

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/24031

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 34 +++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +22 -12
index 4186a8d..5530156 100644
@@ -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;
 }
 
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 10/38 lustre: llite: use C99 for struct lprocfs_llite_obd_vars

In reply to James Simmons

Remove mntpt_path and filegroups since they don't even exit. Migrate the rest to C99 structure initialization.

WC-bug-id: https://jira.whamcloud.com/browse/LU-3319
Reviewed-on: http://review.whamcloud.com/7290

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +13 -10
index 5530156..0dc4d00 100644
@@ -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 }
 };
 
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 11/38 lustre: llite: create ll_stats_pid_write()

In reply to James Simmons

From: Steve Guminski <[email protected]>

Several repeated code blocks are consolidated into a new function, ll_stats_pid_write(), to reduce duplication.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8767
Reviewed-on: https://review.whamcloud.com/23942

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 90 +++++++++++------------
 1 file changed, 41 insertions(+), 49 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +41 -49
index 0dc4d00..f57ad15 100644
@@ -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;
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 12/38 lustre: llite: improve sysfs file text in lproc_llite.c

In reply to James Simmons

From: Steve Guminski <[email protected]>

Improves the instructions displayed when reading from the stats files.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8767
Reviewed-on: https://review.whamcloud.com/23942

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +6 -6
index f57ad15..2a76c01 100644
@@ -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);
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 13/38 lustre: llite: don't handle success case for blocksize sysfs code

In reply to James Simmons

The proper thing to due is return on failure so reverse the logic to conform to kernel standards.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/32496

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +3 -3
index 2a76c01..7bd557b 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 14/38 lustre: llite: don't handle success case for kbyte* sysfs code

In reply to James Simmons

The proper thing to due is return on failure so reverse the logic to conform to kernel standards.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/32497

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 51 ++++++++++++-----------
 1 file changed, 27 insertions(+), 24 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +27 -24
index 7bd557b..72a8f8d 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH 14/38 lustre: llite: don't handle success case for kbyte* sysfs code

Quoted 34 lines · James Simmons

The proper thing to due is return on failure so reverse the logic to conform to kernel standards.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/32497

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 51 ++++++++++++-----------
 1 file changed, 27 insertions(+), 24 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +4 -3
index 7bd557b..72a8f8d 100644
@@ -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;

drivers/staging/lustre/lustre/llite/lproc_llite.c static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, · line 171

Quoted 10 lines
drivers/staging/lustre/lustre/llite/lproc_llite.c +4 -4
 
-		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;

I had to think 2 or 3 times to be sure this code was correct. I think it is, but it is odd.
I assume blk_size is always a power of 2?
So why not
result *= blk_size;
??
It is obvious what that does.
This is for printing out a sysfs file, so speed does not trump readability.
If it might not be a power of 2, then
result <<= log2(blk_size);

it fairly obvious..

(I know you didn't introduce this strange code, I just felt the need to comment)

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/33aed3a6/attachment.sig>

#23 lore raw

PATCH 15/38 lustre: llite: don't handle success case for file* sysfs code

In reply to James Simmons

The proper thing to due is return on failure so reverse the logic to conform to kernel standards.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/32497

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +6 -6
index 72a8f8d..02a09e7 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#24 lore raw

PATCH 16/38 lustre: llite: user kstrtobool for some sysfs handling

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/30539

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 33 ++++++++++++-----------
 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +17 -16
index 02a09e7..e35b3ea 100644
@@ -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;
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH 17/38 lustre: llite: add newline to llite.*.offset_stats

In reply to James Simmons

From: Andreas Dilger <[email protected]>

The llite.*.offset_stats file is missing a newline in the output.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11147
Reviewed-on: https://review.whamcloud.com/32817

---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -2
index e35b3ea..c2d27d7 100644
@@ -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,
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH 18/38 lustre: obd: embedded struct lprocfs_vars in obd device

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-3319
Reviewed-on: https://review.whamcloud.com/7135

---
 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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +1 -1
index 495e6f5..ca4cd9a 100644
@@ -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);
 
drivers/staging/lustre/lustre/include/obd.h +1 -0
index 3c0dbb6..0b071e3 100644
@@ -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 */
drivers/staging/lustre/lustre/lmv/lmv_internal.h +2 -1
index 68a9917..3157ab9 100644
@@ -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;
 
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -5
index 55db904..1867f6a 100644
@@ -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;
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +3 -2
index 30727b7..bc6e13c 100644
@@ -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;
 }
drivers/staging/lustre/lustre/lov/lov_internal.h +2 -1
index 47042f2..e93dfd4 100644
@@ -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;
drivers/staging/lustre/lustre/lov/lov_obd.c +3 -8
index 07f6b1b..05d097e 100644
@@ -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);
drivers/staging/lustre/lustre/lov/lproc_lov.c +3 -2
index 721440f..317c154 100644
@@ -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 = {
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +3 -2
index 6cce324..bf92893 100644
@@ -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;
 }
drivers/staging/lustre/lustre/mdc/mdc_internal.h +2 -2
index f19b0ce..20be240 100644
@@ -36,8 +36,8 @@
 
 #include <lustre_mdc.h>
 
-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,
drivers/staging/lustre/lustre/mdc/mdc_request.c +3 -8
index a759da2..8a90dab 100644
@@ -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);
 }
drivers/staging/lustre/lustre/mgc/lproc_mgc.c +3 -2
index 6367706..e92787d 100644
@@ -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;
 }
drivers/staging/lustre/lustre/mgc/mgc_internal.h +2 -1
index 9541892..400d52c 100644
@@ -39,7 +39,8 @@
 #include <lustre_log.h>
 #include <lustre_export.h>
 
-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);
drivers/staging/lustre/lustre/mgc/mgc_request.c +2 -2
index 833e6a0..6c769c6 100644
@@ -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) {
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2 -2
index 3776447..c032458 100644
@@ -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;
 }
drivers/staging/lustre/lustre/osc/lproc_osc.c +3 -2
index 54a303e..1492ad9 100644
@@ -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;
 }
drivers/staging/lustre/lustre/osc/osc_internal.h +2 -1
index 02e8318..a762d31 100644
@@ -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;
 
drivers/staging/lustre/lustre/osc/osc_request.c +4 -9
index b2b55a7..9c226f0 100644
@@ -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;
Signature · 1 line
1.8.3.1
#27 lore raw

PATCH 19/38 lustre: obdclass: swap obd device attrs and default_attrs

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28948

---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +8 -8
index c032458..d370fbb 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH 20/38 lustre: obdclass: embedded attributes in struct obd_device

In reply to James Simmons

We can further simplify lprocfs_obd_setup() by embedding the obd devices attributes in struct obd_device.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28948
Reviewed-on: https://review.whamcloud.com/32377

---
 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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +1 -2
index ca4cd9a..358ace3 100644
@@ -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 */
drivers/staging/lustre/lustre/include/obd.h +2 -0
index 0b071e3..55aa035 100644
@@ -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;
 };
 
drivers/staging/lustre/lustre/lmv/lmv_internal.h +1 -2
index 3157ab9..1b51dfb 100644
@@ -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;
 
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -3
index 1867f6a..212ca31 100644
@@ -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,
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +2 -7
index bc6e13c..c54227d 100644
@@ -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;
 }
drivers/staging/lustre/lustre/lov/lov_internal.h +1 -2
index e93dfd4..7e0b9ac 100644
@@ -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;
drivers/staging/lustre/lustre/lov/lov_obd.c +2 -3
index 05d097e..43ebec6 100644
@@ -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);
drivers/staging/lustre/lustre/lov/lproc_lov.c +2 -3
index 317c154..ca86f16 100644
@@ -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 = {
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +2 -7
index bf92893..fc5f3a3 100644
@@ -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;
 }
drivers/staging/lustre/lustre/mdc/mdc_internal.h +1 -2
index 20be240..d66663f 100644
@@ -36,8 +36,7 @@
 
 #include <lustre_mdc.h>
 
-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,
drivers/staging/lustre/lustre/mdc/mdc_request.c +2 -3
index 8a90dab..a3c0461f 100644
@@ -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);
 
drivers/staging/lustre/lustre/mgc/lproc_mgc.c +2 -3
index e92787d..7951ec6 100644
@@ -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;
 }
drivers/staging/lustre/lustre/mgc/mgc_internal.h +1 -2
index 400d52c..5385d91 100644
@@ -39,8 +39,7 @@
 #include <lustre_log.h>
 #include <lustre_export.h>
 
-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);
drivers/staging/lustre/lustre/mgc/mgc_request.c +2 -3
index 6c769c6..46b1e36 100644
@@ -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) {
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +6 -10
index d370fbb..a5676ff 100644
@@ -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)
drivers/staging/lustre/lustre/osc/lproc_osc.c +2 -7
index 1492ad9..3bcb36b 100644
@@ -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;
 }
drivers/staging/lustre/lustre/osc/osc_internal.h +1 -2
index a762d31..6caabdb 100644
@@ -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;
 
drivers/staging/lustre/lustre/osc/osc_request.c +2 -3
index 9c226f0..0472165 100644
@@ -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);
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH 21/38 lustre: obdclass: add light weight obd_def_uuid_attrs

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/26020

---
 .../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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +1 -1
index 358ace3..f428ce0 100644
@@ -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 */
drivers/staging/lustre/lustre/lmv/lmv_obd.c +1 -1
index 212ca31..c36ecb7 100644
@@ -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,
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -1
index 43ebec6..751bf64 100644
@@ -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);
drivers/staging/lustre/lustre/mdc/mdc_request.c +1 -1
index a3c0461f..fcba599 100644
@@ -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);
 
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
index 46b1e36..50da9cf 100644
@@ -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) {
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +16 -3
index a5676ff..91d37fc 100644
@@ -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);
drivers/staging/lustre/lustre/osc/osc_request.c +1 -1
index 0472165..4f57a8e 100644
@@ -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);
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH 22/38 lustre: obd: migrate to ksets

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28948

---
 .../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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +2 -1
index f428ce0..3863fff 100644
@@ -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)
 
drivers/staging/lustre/lustre/include/obd.h +6 -3
index 55aa035..36f6c10 100644
@@ -34,7 +34,9 @@
 #ifndef __OBD_H
 #define __OBD_H
 
+#include <linux/kobject.h>
 #include <linux/spinlock.h>
+#include <linux/sysfs.h>
 
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lustre_lib.h>
@@ -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);
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -1
index 0ee4798..adc96b6 100644
@@ -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;
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -2
index ce072da..7765060 100644
@@ -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",
drivers/staging/lustre/lustre/llite/lproc_llite.c +2 -1
index c2d27d7..ab2f102 100644
@@ -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;
drivers/staging/lustre/lustre/lmv/lmv_obd.c +3 -2
index c36ecb7..7d5d03b 100644
@@ -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;
 }
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +2 -2
index c54227d..6aae298 100644
@@ -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;
drivers/staging/lustre/lustre/lov/lov_obd.c +3 -2
index 751bf64..28b7d91 100644
@@ -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];
drivers/staging/lustre/lustre/lov/lproc_lov.c +2 -2
index ca86f16..9c5d6fc 100644
@@ -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;
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +7 -7
index fc5f3a3..47f23d6 100644
@@ -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);
drivers/staging/lustre/lustre/obdclass/genops.c +25 -10
index 532418e..bf182e5 100644
@@ -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);
 
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +26 -15

116 lines not on this page · raw message

drivers/staging/lustre/lustre/obdclass/module.c +9 -8
index 9c80058..0ce2617 100644
@@ -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;
 }
drivers/staging/lustre/lustre/obdclass/sysctl.c +1 -1
index e5e8687..f8760b2 100644
@@ -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);
 }
drivers/staging/lustre/lustre/osc/lproc_osc.c +25 -25

200 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#31 lore raw

PATCH 23/38 lustre: obd: create class_setup_tunables() function

In reply to James Simmons

Creat class_setup_tunables() so sysfs kobject creation is handled for both obd_devices and llite.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28108

---
 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(-)
drivers/staging/lustre/lustre/include/obd.h +1 -2
index 36f6c10..385a88d 100644
@@ -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 {
drivers/staging/lustre/lustre/include/obd_class.h +2 -0
index fd9d99b..e994c968 100644
@@ -33,6 +33,7 @@
 #ifndef __CLASS_OBD_H
 #define __CLASS_OBD_H
 
+#include <linux/kobject.h>
 #include <obd_support.h>
 #include <lustre_import.h>
 #include <lustre_net.h>
@@ -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);
drivers/staging/lustre/lustre/llite/lproc_llite.c +5 -25
index ab2f102..30873fc 100644
@@ -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;
drivers/staging/lustre/lustre/obdclass/genops.c +27 -13
index bf182e5..29ed498 100644
@@ -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);
 
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -1
index b3ba554..f889fb8 100644
@@ -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);
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH 24/38 lustre: obd: create conn_uuid sysfs file

In reply to James Simmons

Change conn_uuid from a debugfs file to sysfs file.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28108

---
 .../staging/lustre/lustre/include/lprocfs_status.h |  1 +
 .../lustre/lustre/obdclass/lprocfs_status.c        | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/staging/lustre/lustre/include/lprocfs_status.h +1 -0
index 3863fff..bc7a390 100644
@@ -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);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +23 -0
index f889fb8..3fbf10b 100644
@@ -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", "<none>");
+
+	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;
Signature · 1 line
1.8.3.1
#33 lore raw

PATCH 25/38 lustre: obd: enhance print_lustre_cfg()

In reply to James Simmons

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.

WC-id: https://jira.whamcloud.com/browse/LU-7004
Reviewed-on: https://review.whamcloud.com/28590

---
 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(-)
drivers/staging/lustre/lustre/include/obd_class.h +1 -0
index e994c968..e250bc3 100644
@@ -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);
drivers/staging/lustre/lustre/obdclass/llog_swab.c +8 -4
index b431c34..3803056 100644
@@ -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)
 {
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH 26/38 lustre: obd: merge both top lustre sysfs attributes

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9431
Reviewed-on: https://review.whamcloud.com/30143

---
 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
drivers/staging/lustre/lustre/include/obd_class.h +0 -3
index e250bc3..02a3f97 100644
@@ -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);
drivers/staging/lustre/lustre/obdclass/Makefile +1 -1
index 686bd54..5d050f0 100644
@@ -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 \
drivers/staging/lustre/lustre/obdclass/class_obd.c +0 -4
index 8100184..bbffede 100644
@@ -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;
drivers/staging/lustre/lustre/obdclass/module.c +97 -0

109 lines not on this page · raw message

drivers/staging/lustre/lustre/obdclass/sysctl.c deleted +0 -162

162 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#35 lore raw

PATCH 27/38 lustre: obd: resolve config log sysfs issues

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9431
Reviewed-on: https://review.whamcloud.com/30143

---
 .../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(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +5 -0
index bc7a390..c841aba 100644
@@ -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;
drivers/staging/lustre/lustre/include/obd_class.h +3 -0
index 02a3f97..1925bda 100644
@@ -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);
 
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +6 -4
index 3fbf10b..84e5a8c 100644
@@ -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,
drivers/staging/lustre/lustre/obdclass/module.c +18 -0
index 27b3849..eab9820 100644
@@ -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;
drivers/staging/lustre/lustre/obdclass/obd_config.c +120 -52

204 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#36 lore raw

PATCH 27/38 lustre: obd: resolve config log sysfs issues

Quoted 14 lines · James Simmons

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.

..

drivers/staging/lustre/lustre/obdclass/obd_config.c int class_process_config(struct lustre_cfg *lcfg) · line 1152

Quoted 2 lines
drivers/staging/lustre/lustre/obdclass/obd_config.c +2 -0
+EXPORT_SYMBOL(class_modify_config);
+

Unfortunately EXPORTed symbols are global - there is no namespace control.
So it is good practice to choose names that are not overly generic. I would be nice of all exported symbols from lustre started with "lustre_". Having "lnet_" as well is OK. This isn't necessarily a strict requirement.
But "class_" looks particularly bad.
I'm not saying you have to change this now, but it is something that we really need to clean up.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/e05f3135/attachment.sig>

#37 lore raw

PATCH 28/38 lustre: obd: move ioctl handling to class_obd.c

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8837
Reviewed-on: https://review.whamcloud.com/32100

---
 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%)
drivers/staging/lustre/lustre/include/obd_class.h +0 -1
index 1925bda..33c0b87 100644
@@ -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);
 
drivers/staging/lustre/lustre/obdclass/Makefile +1 -1
index 5d050f0..19c8bd9 100644
@@ -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 \
drivers/staging/lustre/lustre/obdclass/class_obd.c +205 -0

217 lines not on this page · raw message

drivers/staging/lustre/lustre/obdclass/obd_sysfs.c renamed from drivers/staging/lustre/lustre/obdclass/module.c +0 -207

213 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#38 lore raw

PATCH 29/38 lustre: llite: replace ll_process_config with class_modify_config

In reply to James Simmons

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/32722

---
 .../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(-)
drivers/staging/lustre/lustre/include/lustre_disk.h +2 -0
index 6bed07a..7b6421d 100644
@@ -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];
drivers/staging/lustre/lustre/llite/llite_internal.h +1 -3
index 1130ea3..bf679c9 100644
@@ -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,
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -34
index 7765060..f0fe21f 100644
@@ -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,
drivers/staging/lustre/lustre/llite/lproc_llite.c +9 -6
index 30873fc..1492d70 100644
@@ -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;
-}
drivers/staging/lustre/lustre/llite/super25.c +0 -4
index 2f4306e..562bf329 100644
@@ -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();
drivers/staging/lustre/lustre/obdclass/obd_config.c +29 -12

58 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#39 lore raw

PATCH 30/38 lustre: mgc: update sysfs handling

In reply to James Simmons

Move mgc to using the new sysfs conn_uuid. Move all sysfs/debugfs handling to lprocfs_mgc.c and implement proper error handling.

WC-bug-id: https://jira.hpdd.intel.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/29250

---
 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(-)
drivers/staging/lustre/lustre/mgc/lproc_mgc.c +33 -10
index 7951ec6..574233e 100644
@@ -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);
 }
drivers/staging/lustre/lustre/mgc/mgc_internal.h +1 -1
index 5385d91..0a91624 100644
@@ -39,7 +39,7 @@
 #include <lustre_log.h>
 #include <lustre_export.h>
 
-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);
drivers/staging/lustre/lustre/mgc/mgc_request.c +6 -4
index 50da9cf..4552cc5 100644
@@ -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:
Signature · 1 line
1.8.3.1
#40 lore raw

PATCH 31/38 lustre: osc: fixup kstrto* for sysfs handling

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Reviewed-on: https://review.whamcloud.com/30539

---
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 43 ++++++++++++---------------
 1 file changed, 19 insertions(+), 24 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +19 -24
index 4ed289b..3c31e98 100644
@@ -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;
 
Signature · 1 line
1.8.3.1
#41 lore raw

PATCH 32/38 lustre: osc: restore cl_loi_list_lock

In reply to James Simmons

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.

---
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +31 -5
index 3c31e98..5fb7a16 100644
@@ -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);
 
Signature · 1 line
1.8.3.1
#42 lore raw

PATCH 32/38 lustre: osc: restore cl_loi_list_lock

Quoted 14 lines · James Simmons

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.

---
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +0 -0
index 3c31e98..5fb7a16 100644

drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, · line 87

Quoted 9 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +4 -1
@@ -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);

Why do you think a spinlock is needed here? How could you even end up with an incorrect value?

NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180817/6be5aed0/attachment.sig>

#43 lore raw

PATCH 32/38 lustre: osc: restore cl_loi_list_lock

Quoted 20 lines
Quoted 20 lines

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.

---
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +1 -0
index 3c31e98..5fb7a16 100644
@@ -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;
 
Quoted 7 lines

drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, · line 87

Quoted 4 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +3 -1
-	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);

Why do you think a spinlock is needed here? How could you even end up with an incorrect value?

I see both mdc sysfs and the osc sysfs layer being able to modify cl_max_rpcs_in_flight. Andreas is the struct client_obd shared between both the osc and mdc layer or does each subsystem contain a unique cli in struct obd_device?

#44 lore raw

PATCH 32/38 lustre: osc: restore cl_loi_list_lock

Quoted 29 lines · James Simmons
Quoted 21 lines
Quoted 21 lines

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.

---
drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++----

1 file changed, 31 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +1 -0
index 3c31e98..5fb7a16 100644
@@ -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;
 
Quoted 7 lines

drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, · line 87

Quoted 4 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +3 -1
-	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);

Why do you think a spinlock is needed here? How could you even end up with an incorrect value?

Quoted 4 lines

I see both mdc sysfs and the osc sysfs layer being able to modify cl_max_rpcs_in_flight. Andreas is the struct client_obd shared between both the osc and mdc layer or does each subsystem contain a unique cli in struct obd_device?

Each OBD device (OSC, MDC, MGC, etc) has its own struct obd_device with an embedded struct client_obd, so it is not shared between the OSC and MDC. These tunables could potentially be set differently for each filesystem, or even for each target within a single filesystem (e.g. if some flash OSTs need more RPCs in flight to keep busy than HDD-based OSTs).

Since this is just printing the value, it doesn't make sense to have locking in any case. At worst the cl_max_rpcs_in_flight value used may ne nanoseconds out of date when accessed, and microseconds old when printed. That race exists whether the locking is here or not (i.e. the value could be changed immediately after it is printed into the buffer and the lock is dropped).

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180818/7a46220c/attachment.sig>

#45 lore raw

PATCH 32/38 lustre: osc: restore cl_loi_list_lock

Quoted 44 lines · Andreas Dilger

Signed PGP part

Quoted 29 lines · James Simmons
Quoted 21 lines
Quoted 21 lines

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.

---
drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++----

1 file changed, 31 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +1 -0
index 3c31e98..5fb7a16 100644
@@ -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;
 
Quoted 7 lines

drivers/staging/lustre/lustre/osc/lproc_osc.c static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, · line 87

Quoted 4 lines
drivers/staging/lustre/lustre/osc/lproc_osc.c +3 -1
-	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);

Why do you think a spinlock is needed here? How could you even end up with an incorrect value?

Quoted 4 lines

I see both mdc sysfs and the osc sysfs layer being able to modify cl_max_rpcs_in_flight. Andreas is the struct client_obd shared between both the osc and mdc layer or does each subsystem contain a unique cli in struct obd_device?

Each OBD device (OSC, MDC, MGC, etc) has its own struct obd_device with an embedded struct client_obd, so it is not shared between the OSC and MDC. These tunables could potentially be set differently for each filesystem, or even for each target within a single filesystem (e.g. if some flash OSTs need more RPCs in flight to keep busy than HDD-based OSTs).

Quoted 6 lines

Since this is just printing the value, it doesn't make sense to have locking in any case. At worst the cl_max_rpcs_in_flight value used may ne nanoseconds out of date when accessed, and microseconds old when printed. That race exists whether the locking is here or not (i.e. the value could be changed immediately after it is printed into the buffer and the lock is dropped).

The only reason to keep this locking might be to make static code analysis tools happy, so that they always see cl_max_rpcs_in_flight access protected by a spinlock, instead of inconsistent locking.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180818/7cda47b1/attachment.sig>

#46 lore raw

PATCH 33/38 lustre: osc: make unstable_stats a debugfs file

In reply to James Simmons

The sysfs attribute unstable_stats breaks the one item per file rule. Make it a debugfs file instead.

---
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +11 -9
index 5fb7a16..79a30b3 100644
@@ -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,
 };
 
Signature · 1 line
1.8.3.1
#47 lore raw

PATCH 34/38 lustre: osc: enhance end to end bulk cksum error report

In reply to James Simmons

From: Bruno Faccini <[email protected]>

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8376
Reviewed-on: https://review.whamcloud.com/23960

---
 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(-)
drivers/staging/lustre/lnet/libcfs/debug.c +1 -0
index 0289f24..dd06a4c 100644
@@ -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;
drivers/staging/lustre/lustre/include/obd.h +4 -2
index 385a88d..329bae9 100644
@@ -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
 	 */
drivers/staging/lustre/lustre/osc/lproc_osc.c +31 -0
index 79a30b3..89dadba 100644
@@ -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,
drivers/staging/lustre/lustre/osc/osc_request.c +111 -29

189 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#48 lore raw

PATCH 35/38 lustre: osc: update sysfs handling

In reply to James Simmons

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/30962

---
 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(-)
drivers/staging/lustre/lustre/osc/lproc_osc.c +47 -21
index 89dadba..284ceed 100644
@@ -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;
 }
drivers/staging/lustre/lustre/osc/osc_internal.h +1 -2
index 6caabdb..55054d7 100644
@@ -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;
 
drivers/staging/lustre/lustre/osc/osc_request.c +8 -18
index a7a4a53..7c91c4b 100644
@@ -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)
Signature · 1 line
1.8.3.1
#49 lore raw

PATCH 36/38 lustre: lmv: update sysfs handling

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28460

---
 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(-)
drivers/staging/lustre/lustre/lmv/lmv_internal.h +1 -3
index 1b51dfb..f2c41c7 100644
@@ -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
drivers/staging/lustre/lustre/lmv/lmv_obd.c +9 -8
index 7d5d03b..cf2a4c6 100644
@@ -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)
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +27 -21

84 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#50 lore raw

PATCH 37/38 lustre: lov: update sysfs handling

In reply to James Simmons

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.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/30960

---
 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(-)
drivers/staging/lustre/lustre/lov/lov_internal.h +1 -2
index 7e0b9ac..dbb79d4 100644
@@ -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;
drivers/staging/lustre/lustre/lov/lov_obd.c +24 -16
index 28b7d91..3483f9b 100644
@@ -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:
drivers/staging/lustre/lustre/lov/lproc_lov.c +106 -107

294 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#51 lore raw

PATCH 38/38 lustre: mdc: update sysfs handling

In reply to James Simmons

Move all the sysfs/debugfs handling to lproc_mdc.c. Properly handle failure cases for sysfs/debugfs bring up.

WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/30961

---
 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(-)
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +41 -31
index 47f23d6..3bff8b5 100644
@@ -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;
 }
drivers/staging/lustre/lustre/mdc/mdc_internal.h +2 -1
index d66663f..941a896 100644
@@ -36,7 +36,8 @@
 
 #include <lustre_mdc.h>
 
-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,
drivers/staging/lustre/lustre/mdc/mdc_request.c +12 -19
index fcba599..f3c0722 100644
@@ -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 = {
Signature · 1 line
1.8.3.1
#52 lore raw

cover lustre: fixes for sysfs handling

In reply to James Simmons
Quoted 7 lines · James Simmons

The port to sysfs upstream was done in haste and without any support in the utilies to even test it. Now the user land tools do work with the sysfs / debugfs port and many problems were exposed. This patch series fixes some of the largest holes which brings back some basic lustre functionality for the users. One special note to users you need to add the following udev rule to allowing tuning to work automatically with testing.

Thanks,
I've applied all of these, after replacing 3 with updates, and discarding one as it added unnecessary locking.

Thanks,
NeilBrown

Quoted 80 lines

SUBSYSTEM=="lustre", ACTION=="change", ENV{PARAM}=="?*", RUN+="/usr/sbin/lctl set_param '$env{PARAM}=$env{SETTING}'"

Andreas Dilger (1):
lustre: llite: add newline to llite.*.offset_stats

Bruno Faccini (1):
lustre: osc: enhance end to end bulk cksum error report

Emoly Liu (1):
lustre: llite: register mountpoint before process llog

James Simmons (33):
lustre: llite: rename ldebugfs_[un]register_mountpoint
lustre: llite: change ll_statfs_internal to use struct ll_sb_info
lustre: llite: move llite_root and llite_kset to lproc_llite.c
lustre: llite: remove ll_sb
lustre: llite: change top kobject for llite into a kset
lustre: llite: rename llite_sb_release
lustre: llite: move lmd_profile handling
lustre: llite: add proper error handling for
ll_debugfs_register_super()
lustre: llite: use C99 for struct lprocfs_llite_obd_vars
lustre: llite: don't handle success case for blocksize sysfs code
lustre: llite: don't handle success case for kbyte* sysfs code
lustre: llite: don't handle success case for file* sysfs code
lustre: llite: user kstrtobool for some sysfs handling
lustre: obd: embedded struct lprocfs_vars in obd device
lustre: obdclass: swap obd device attrs and default_attrs
lustre: obdclass: embedded attributes in struct obd_device
lustre: obdclass: add light weight obd_def_uuid_attrs
lustre: obd: migrate to ksets
lustre: obd: create class_setup_tunables() function
lustre: obd: create conn_uuid sysfs file
lustre: obd: enhance print_lustre_cfg()
lustre: obd: merge both top lustre sysfs attributes
lustre: obd: resolve config log sysfs issues
lustre: obd: move ioctl handling to class_obd.c
lustre: llite: replace ll_process_config with class_modify_config
lustre: mgc: update sysfs handling
lustre: osc: fixup kstrto* for sysfs handling
lustre: osc: restore cl_loi_list_lock
lustre: osc: make unstable_stats a debugfs file
lustre: osc: update sysfs handling
lustre: lmv: update sysfs handling
lustre: lov: update sysfs handling
lustre: mdc: update sysfs handling

Steve Guminski (2):
lustre: llite: create ll_stats_pid_write()
lustre: llite: improve sysfs file text in lproc_llite.c

 drivers/staging/lustre/lnet/libcfs/debug.c         |   1 +
 .../staging/lustre/lustre/include/lprocfs_status.h |  12 +-
 .../staging/lustre/lustre/include/lustre_disk.h    |   2 +
 drivers/staging/lustre/lustre/include/obd.h        |  17 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |  10 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |   2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |  21 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    | 137 ++++---
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 442 +++++++++++----------
 drivers/staging/lustre/lustre/llite/super25.c      |  28 +-
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |   4 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |  26 +-
 drivers/staging/lustre/lustre/lmv/lproc_lmv.c      |  58 +--
 drivers/staging/lustre/lustre/lov/lov_internal.h   |   3 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c        |  51 +--
 drivers/staging/lustre/lustre/lov/lproc_lov.c      | 219 +++++-----
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c      |  94 +++--
 drivers/staging/lustre/lustre/mdc/mdc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |  37 +-
 drivers/staging/lustre/lustre/mgc/lproc_mgc.c      |  45 ++-
 drivers/staging/lustre/lustre/mgc/mgc_internal.h   |   2 +-
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |  11 +-
 drivers/staging/lustre/lustre/obdclass/Makefile    |   2 +-
 drivers/staging/lustre/lustre/obdclass/class_obd.c | 209 +++++++++-
 drivers/staging/lustre/lustre/obdclass/genops.c    |  47 ++-
 drivers/staging/lustre/lustre/obdclass/llog_swab.c |  12 +-
 .../lustre/lustre/obdclass/lprocfs_status.c        | 111 ++++--
 .../staging/lustre/lustre/obdclass/obd_config.c    | 213 +++++++---
Quoted 11 lines
 .../lustre/obdclass/{module.c => obd_sysfs.c}      | 293 +++++---------
 drivers/staging/lustre/lustre/obdclass/sysctl.c    | 162 --------
 drivers/staging/lustre/lustre/osc/lproc_osc.c      | 252 ++++++++----
 drivers/staging/lustre/lustre/osc/osc_internal.h   |   3 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    | 174 +++++---
 33 files changed, 1503 insertions(+), 1199 deletions(-)
 rename drivers/staging/lustre/lustre/obdclass/{module.c => obd_sysfs.c} (57%)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/sysctl.c
Signature · 1 line
1.8.3.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180820/43b25537/attachment.sig>