From adilger at whamcloud.com Wed Aug 1 00:13:43 2018 From: adilger at whamcloud.com (Andreas Dilger) Date: Wed, 1 Aug 2018 00:13:43 +0000 Subject: [lustre-devel] [PATCH 2/3] lustre: llite: handle registering file system In-Reply-To: <1532992594-2576-3-git-send-email-jsimmons@infradead.org> References: <1532992594-2576-1-git-send-email-jsimmons@infradead.org> <1532992594-2576-3-git-send-email-jsimmons@infradead.org> Message-ID: <8045D39A-57C7-4FA3-867E-AB20722BFC04@whamcloud.com> On Jul 30, 2018, at 17:16, James Simmons wrote: > > Move the code that registers struct file_system_type for lustre > with the VFS layer to the llite layer where it belongs. This > removes the ugly function pointer passing between obdclass and > llite. One potential issue here is that "mount -t lustre" may get confused because the mount(8) binary (or kernel, I forget where it is these days) will modprobe "lustre" when trying to mount the filesystem. This can fail if some odd combinations of modules are loaded, since obdclass used to register the "lustre" filesystem type, but the client needs "llite" loaded to actually mount, while the server does not. This might end up causing "llite" to always be loaded on the server if this patch were included into master. One option that I've through for a while is to change the servers to mount with "-t mdt" and "-t ost", or "-t lustre_mdt" or maybe just "-t lustre_server" or something similar. I don't have a great love for any of these options, so I'm open for suggestions. Doing this sooner rather than later will ease the transition at some point in the future. We would add this as an additional filesystem type for the modules, and still allow "-t lustre" for some time for compatibility reasons. I like the "lustre_mdt" and "lustre_ost" filesystem types, but using just "mdt" and "ost" might be the best options, since this would result in the "mdt.ko" and "ost.ko" modules being auto-loaded at mount time. Cheers, Andreas > Signed-off-by: James Simmons > --- > .../staging/lustre/lustre/include/lustre_disk.h | 3 - > drivers/staging/lustre/lustre/llite/super25.c | 34 +++++++++++- > drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 -- > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 64 ---------------------- > 4 files changed, 31 insertions(+), 76 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h > index 772ecc9..d5fadde 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_disk.h > +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h > @@ -145,9 +145,6 @@ struct lustre_sb_info { > int lustre_put_lsi(struct super_block *sb); > int lmd_parse(char *options, struct lustre_mount_data *lmd); > int lustre_start_mgc(struct super_block *sb); > -void lustre_register_super_ops(int (*cfs)(struct super_block *sb, void *data, > - int silent), > - void (*ksc)(struct super_block *sb)); > int lustre_common_put_super(struct super_block *sb); > > int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type); > diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c > index de43d58..ac8f6f1 100644 > --- a/drivers/staging/lustre/lustre/llite/super25.c > +++ b/drivers/staging/lustre/lustre/llite/super25.c > @@ -81,7 +81,6 @@ struct super_operations lustre_super_operations = { > .remount_fs = ll_remount_fs, > .show_options = ll_show_options, > }; > -MODULE_ALIAS_FS("lustre"); > > /** This is the entry point for the mount call into Lustre. > * This is called when a server or client is mounted, > @@ -162,6 +161,30 @@ int lustre_fill_super(struct super_block *sb, void *lmd2_data, int silent) > return rc; > } > > +/***************** FS registration ******************/ > +static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, > + const char *devname, void *data) > +{ > + return mount_nodev(fs_type, flags, data, lustre_fill_super); > +} > + > +static void lustre_kill_super(struct super_block *sb) > +{ > + ll_kill_super(sb); > + kill_anon_super(sb); > +} > + > +/** Register the "lustre" fs type > + */ > +static struct file_system_type lustre_fs_type = { > + .owner = THIS_MODULE, > + .name = "lustre", > + .mount = lustre_mount, > + .kill_sb = lustre_kill_super, > + .fs_flags = FS_RENAME_DOES_D_MOVE, > +}; > +MODULE_ALIAS_FS("lustre"); > + > static int __init lustre_init(void) > { > int rc; > @@ -224,11 +247,16 @@ static int __init lustre_init(void) > if (rc != 0) > goto out_inode_fini_env; > > - lustre_register_super_ops(lustre_fill_super, ll_kill_super); > + rc = register_filesystem(&lustre_fs_type); > + if (rc) > + goto out_xattr_cache; > + > lustre_register_client_process_config(ll_process_config); > > return 0; > > +out_xattr_cache: > + ll_xattr_fini(); > out_inode_fini_env: > cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); > out_vvp: > @@ -245,8 +273,8 @@ static int __init lustre_init(void) > > static void __exit lustre_exit(void) > { > - lustre_register_super_ops(NULL, NULL); > lustre_register_client_process_config(NULL); > + unregister_filesystem(&lustre_fs_type); > > debugfs_remove(llite_root); > kset_unregister(llite_kset); > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index 81a4c66..cdaf729 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -510,18 +510,12 @@ static int __init obdclass_init(void) > return err; > > err = llog_info_init(); > - if (err) > - return err; > - > - err = lustre_register_fs(); > > return err; > } > > static void obdclass_exit(void) > { > - lustre_unregister_fs(); > - > misc_deregister(&obd_psdev); > llog_info_fini(); > cl_global_fini(); > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > index ac841f4..b84bca4 100644 > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > @@ -49,11 +49,6 @@ > #include > #include > > -static DEFINE_SPINLOCK(client_lock); > -static int (*client_fill_super)(struct super_block *sb, void *data, > - int silent); > -static void (*kill_super_cb)(struct super_block *sb); > - > /**************** config llog ********************/ > > /** Get a config log from the MGS and process it. > @@ -1225,62 +1220,3 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd) > return -EINVAL; > } > EXPORT_SYMBOL(lmd_parse); > - > -/* We can't call ll_fill_super by name because it lives in a module that > - * must be loaded after this one. > - */ > -void lustre_register_super_ops(int (*cfs)(struct super_block *sb, void *data, > - int silent), > - void (*ksc)(struct super_block *sb)) > -{ > - spin_lock(&client_lock); > - client_fill_super = cfs; > - kill_super_cb = ksc; > - spin_unlock(&client_lock); > -} > -EXPORT_SYMBOL(lustre_register_super_ops); > - > -/***************** FS registration ******************/ > -static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, > - const char *devname, void *data) > -{ > - struct dentry *root; > - > - spin_lock(&client_lock); > - if (!client_fill_super) > - request_module("lustre"); > - root = mount_nodev(fs_type, flags, data, client_fill_super); > - spin_unlock(&client_lock); > - return root; > -} > - > -static void lustre_kill_super(struct super_block *sb) > -{ > - struct lustre_sb_info *lsi = s2lsi(sb); > - > - if (kill_super_cb && lsi) > - (*kill_super_cb)(sb); > - > - kill_anon_super(sb); > -} > - > -/** Register the "lustre" fs type > - */ > -static struct file_system_type lustre_fs_type = { > - .owner = THIS_MODULE, > - .name = "lustre", > - .mount = lustre_mount, > - .kill_sb = lustre_kill_super, > - .fs_flags = FS_RENAME_DOES_D_MOVE, > -}; > -MODULE_ALIAS_FS("lustre"); > - > -int lustre_register_fs(void) > -{ > - return register_filesystem(&lustre_fs_type); > -} > - > -int lustre_unregister_fs(void) > -{ > - return unregister_filesystem(&lustre_fs_type); > -} > -- > 1.8.3.1 > Cheers, Andreas --- Andreas Dilger CTO 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: From neilb at suse.com Wed Aug 1 00:23:21 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 10:23:21 +1000 Subject: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h In-Reply-To: References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-26-git-send-email-jsimmons@infradead.org> <871sbjrpj3.fsf@notabene.neil.brown.name> Message-ID: <87va8vq6iu.fsf@notabene.neil.brown.name> On Tue, Jul 31 2018, Patrick Farrell wrote: > Neil, > > Do you have an objection to the concept, or just because this one's not used? > Having a MAX makes it easy to write things like < MYENUM_MAX as sanity checking code, and then if the enum is added to, it still works. Seems useful to me. I object to the name. "MAX" is short for "MAXIMUM" which means the highest value that is actually used. When comparing something to the maximum it makes sense to say if (foo <= maximum) but it rarely makes sense to say if (foo < maximum) If you want a count of the number of values, use MYENUM_CNT or MYENUM_NUM. This can sensibly be one more than the maximum value. But if you have MYSENUM_MAX, make sure it is the maximum meaningful value for the enum. Thanks, NeilBrown > > - Patrick > ________________________________ > From: lustre-devel on behalf of NeilBrown > Sent: Tuesday, July 31, 2018 5:47:28 PM > To: James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h > > On Mon, Jul 30 2018, James Simmons wrote: > >> From: Niu Yawei >> >> Move config type values CONFIG_T_XXX into lustre_idl.h since they >> will be put on wire when reading config logs. >> >> Add missing wire checks for mgs_nidtbl_entry, mgs_config_body and >> mgs_config_res. >> >> Redefine CONFIG_SUB_XXX for the sub clds attached on config log. >> >> Signed-off-by: Niu Yawei >> WC-id: https://jira.whamcloud.com/browse/LU-9216 >> Reviewed-on: https://review.whamcloud.com/26022 >> Reviewed-by: Fan Yong >> Reviewed-by: John L. Hammond >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> .../lustre/include/uapi/linux/lustre/lustre_idl.h | 10 ++- >> drivers/staging/lustre/lustre/include/obd_class.h | 12 +-- >> drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +- >> drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 85 ++++++++++++++++++++++ >> 4 files changed, 103 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> index c9b32ef..bd3b45a 100644 >> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> @@ -2111,11 +2111,19 @@ struct mgs_nidtbl_entry { >> } u; >> }; >> >> +enum { >> + CONFIG_T_CONFIG = 0, >> + CONFIG_T_SPTLRPC = 1, >> + CONFIG_T_RECOVER = 2, >> + CONFIG_T_PARAMS = 3, >> + CONFIG_T_MAX > > Arrrgggh. It's back. I thought we had killed CONFIG_T_MAX (which isn't > a MAX). > It's never used, so it'll have to go. > > NeilBrown > > >> +}; >> + >> struct mgs_config_body { >> char mcb_name[MTI_NAME_MAXLEN]; /* logname */ >> __u64 mcb_offset; /* next index of config log to request */ >> __u16 mcb_type; /* type of log: CONFIG_T_[CONFIG|RECOVER] */ >> - __u8 mcb_reserved; >> + __u8 mcb_nm_cur_pass; >> __u8 mcb_bits; /* bits unit size of config log */ >> __u32 mcb_units; /* # of units for bulk transfer */ >> }; >> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h >> index 184da99..647cc22 100644 >> --- a/drivers/staging/lustre/lustre/include/obd_class.h >> +++ b/drivers/staging/lustre/lustre/include/obd_class.h >> @@ -156,16 +156,16 @@ struct config_llog_instance { >> int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, >> char *name, struct config_llog_instance *cfg); >> >> -#define CONFIG_T_CONFIG BIT(0) >> -#define CONFIG_T_SPTLRPC BIT(1) >> -#define CONFIG_T_RECOVER BIT(2) >> -#define CONFIG_T_PARAMS BIT(3) >> +#define CONFIG_SUB_CONFIG BIT(0) >> +#define CONFIG_SUB_SPTLRPC BIT(1) >> +#define CONFIG_SUB_RECOVER BIT(2) >> +#define CONFIG_SUB_PARAMS BIT(3) >> >> /* Sub clds should be attached to the config_llog_data when processing >> * config log for client or server target. >> */ >> -#define CONFIG_SUB_CLIENT (CONFIG_T_SPTLRPC | CONFIG_T_RECOVER | \ >> - CONFIG_T_PARAMS) >> +#define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \ >> + CONFIG_SUB_PARAMS) >> >> #define PARAMS_FILENAME "params" >> #define LCTL_UPCALL "lctl" >> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c >> index 06fcc7e..833e6a0 100644 >> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c >> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c >> @@ -315,7 +315,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> memcpy(seclogname, logname, ptr - logname); >> strcpy(seclogname + (ptr - logname), "-sptlrpc"); >> >> - if (cfg->cfg_sub_clds & CONFIG_T_SPTLRPC) { >> + if (cfg->cfg_sub_clds & CONFIG_SUB_SPTLRPC) { >> sptlrpc_cld = config_log_find_or_add(obd, seclogname, NULL, >> CONFIG_T_SPTLRPC, cfg); >> if (IS_ERR(sptlrpc_cld)) { >> @@ -325,7 +325,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> } >> } >> >> - if (cfg->cfg_sub_clds & CONFIG_T_PARAMS) { >> + if (cfg->cfg_sub_clds & CONFIG_SUB_PARAMS) { >> params_cld = config_log_find_or_add(obd, PARAMS_FILENAME, sb, >> CONFIG_T_PARAMS, cfg); >> if (IS_ERR(params_cld)) { >> @@ -345,7 +345,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> >> LASSERT(lsi->lsi_lmd); >> if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) && >> - cfg->cfg_sub_clds & CONFIG_T_RECOVER) { >> + cfg->cfg_sub_clds & CONFIG_SUB_RECOVER) { >> ptr = strrchr(seclogname, '-'); >> if (ptr) { >> *ptr = 0; >> diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> index 2f081ed..09b1298 100644 >> --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> @@ -3629,6 +3629,91 @@ void lustre_assert_wire_constants(void) >> LASSERTF((int)sizeof(((struct mgs_target_info *)0)->mti_params) == 4096, "found %lld\n", >> (long long)(int)sizeof(((struct mgs_target_info *)0)->mti_params)); >> >> + /* Checks for struct mgs_nidtbl_entry */ >> + LASSERTF((int)sizeof(struct mgs_nidtbl_entry) == 24, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_nidtbl_entry)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_version) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_version)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_instance) == 8, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_instance)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_index) == 12, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_index)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_length) == 16, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_length)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_type) == 20, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_type)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_type) == 21, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_type)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_size) == 22, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_size)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_count) == 23, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_count)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, u.nids[0]) == 24, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, u.nids[0])); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0]) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0])); >> + >> + /* Checks for struct mgs_config_body */ >> + LASSERTF((int)sizeof(struct mgs_config_body) == 80, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_config_body)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_name) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_name)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_name) == 64, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_name)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_offset) == 64, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_offset)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_offset) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_offset)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_type) == 72, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_type)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_type) == 2, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_type)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_nm_cur_pass) == 74, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_nm_cur_pass)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_bits) == 75, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_bits)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_bits) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_bits)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_units) == 76, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_units)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_units) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_units)); >> + >> + BUILD_BUG_ON(CONFIG_T_CONFIG != 0); >> + BUILD_BUG_ON(CONFIG_T_SPTLRPC != 1); >> + BUILD_BUG_ON(CONFIG_T_RECOVER != 2); >> + BUILD_BUG_ON(CONFIG_T_PARAMS != 3); >> + >> + /* Checks for struct mgs_config_res */ >> + LASSERTF((int)sizeof(struct mgs_config_res) == 16, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_config_res)); >> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_offset) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_res, mcr_offset)); >> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_offset) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_offset)); >> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_size) == 8, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_res, mcr_size)); >> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_size) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_size)); >> + >> /* Checks for struct lustre_capa */ >> LASSERTF((int)sizeof(struct lustre_capa) == 120, "found %lld\n", >> (long long)(int)sizeof(struct lustre_capa)); >> -- >> 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: From neilb at suse.com Wed Aug 1 00:32:47 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 10:32:47 +1000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> Message-ID: <87sh3zq634.fsf@notabene.neil.brown.name> Hi Amir, thanks for the background. I had to chuckle at "0 being the highest", though I know that this distortion is not something specific to lustre. Your description seems to suggest that "-1" means "unknown" with an implication that the number of hops might be high, and best not to take the risk. Your point about compatability with scripts has some validity, though it is annoying to have to support such ugly interfaces indefinitely. Are there really likely to be dependencies? lustre has only been printing -1 since Feb last year when this patch went upstream. That was presumably an abi change as it would have printed MAXINT-1 previously. Did that cause any problems? Thanks, NeilBrown On Tue, Jul 31 2018, Amir Shehata wrote: > The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. > > In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. > > Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. > > thanks > amir > ________________________________________ > From: NeilBrown [neilb at suse.com] > Sent: Tuesday, July 31, 2018 3:38 PM > To: James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List; Amir Shehata; James Simmons > Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print > > On Mon, Jul 30 2018, James Simmons wrote: > >> From: Amir Shehata >> >> The default number of hops for a route is -1. This is >> currently being printed as %u. Change that to %d to >> make it print out properly. > > -1 hops??? I wish I could hop -1 times - it would be a good party > trick!! > > What does -1 mean? Unlimited (just a guess). If so, could we print > "unlimited"?? > > I'm fine with having magic numbers in the code, but I don't like them to > leak out. > > NeilBrown > >> >> Signed-off-by: Amir Shehata >> WC-id: https://jira.whamcloud.com/browse/LU-9078 >> Reviewed-on: https://review.whamcloud.com/25250 >> Reviewed-by: Olaf Weber >> Reviewed-by: Doug Oucharek >> Reviewed-by: James Simmons >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >> index 8856798..aa98ce5 100644 >> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >> int alive = lnet_is_route_alive(route); >> >> s += snprintf(s, tmpstr + tmpsiz - s, >> - "%-8s %4u %8u %7s %s\n", >> + "%-8s %4d %8u %7s %s\n", >> libcfs_net2str(net), hops, >> priority, >> alive ? "up" : "down", >> -- >> 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: From paf at cray.com Wed Aug 1 00:40:23 2018 From: paf at cray.com (Patrick Farrell) Date: Wed, 1 Aug 2018 00:40:23 +0000 Subject: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h In-Reply-To: <87va8vq6iu.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-26-git-send-email-jsimmons@infradead.org> <871sbjrpj3.fsf@notabene.neil.brown.name> , <87va8vq6iu.fsf@notabene.neil.brown.name> Message-ID: Huh. I see your point, and the logic of it is obviously sound, but I'm curious - I don't think I've ever seen names like those you gave used. I've only seen MAX. Am I wrong about that, or is MAX indeed the dominant choice? I also think in context, used in caps, MAX is clearly a special value without other meaning. ________________________________ From: NeilBrown Sent: Tuesday, July 31, 2018 7:23:21 PM To: Patrick Farrell; James Simmons; Andreas Dilger; Oleg Drokin Cc: Lustre Development List Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h On Tue, Jul 31 2018, Patrick Farrell wrote: > Neil, > > Do you have an objection to the concept, or just because this one's not used? > Having a MAX makes it easy to write things like < MYENUM_MAX as sanity checking code, and then if the enum is added to, it still works. Seems useful to me. I object to the name. "MAX" is short for "MAXIMUM" which means the highest value that is actually used. When comparing something to the maximum it makes sense to say if (foo <= maximum) but it rarely makes sense to say if (foo < maximum) If you want a count of the number of values, use MYENUM_CNT or MYENUM_NUM. This can sensibly be one more than the maximum value. But if you have MYSENUM_MAX, make sure it is the maximum meaningful value for the enum. Thanks, NeilBrown > > - Patrick > ________________________________ > From: lustre-devel on behalf of NeilBrown > Sent: Tuesday, July 31, 2018 5:47:28 PM > To: James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h > > On Mon, Jul 30 2018, James Simmons wrote: > >> From: Niu Yawei >> >> Move config type values CONFIG_T_XXX into lustre_idl.h since they >> will be put on wire when reading config logs. >> >> Add missing wire checks for mgs_nidtbl_entry, mgs_config_body and >> mgs_config_res. >> >> Redefine CONFIG_SUB_XXX for the sub clds attached on config log. >> >> Signed-off-by: Niu Yawei >> WC-id: https://jira.whamcloud.com/browse/LU-9216 >> Reviewed-on: https://review.whamcloud.com/26022 >> Reviewed-by: Fan Yong >> Reviewed-by: John L. Hammond >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> .../lustre/include/uapi/linux/lustre/lustre_idl.h | 10 ++- >> drivers/staging/lustre/lustre/include/obd_class.h | 12 +-- >> drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +- >> drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 85 ++++++++++++++++++++++ >> 4 files changed, 103 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> index c9b32ef..bd3b45a 100644 >> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >> @@ -2111,11 +2111,19 @@ struct mgs_nidtbl_entry { >> } u; >> }; >> >> +enum { >> + CONFIG_T_CONFIG = 0, >> + CONFIG_T_SPTLRPC = 1, >> + CONFIG_T_RECOVER = 2, >> + CONFIG_T_PARAMS = 3, >> + CONFIG_T_MAX > > Arrrgggh. It's back. I thought we had killed CONFIG_T_MAX (which isn't > a MAX). > It's never used, so it'll have to go. > > NeilBrown > > >> +}; >> + >> struct mgs_config_body { >> char mcb_name[MTI_NAME_MAXLEN]; /* logname */ >> __u64 mcb_offset; /* next index of config log to request */ >> __u16 mcb_type; /* type of log: CONFIG_T_[CONFIG|RECOVER] */ >> - __u8 mcb_reserved; >> + __u8 mcb_nm_cur_pass; >> __u8 mcb_bits; /* bits unit size of config log */ >> __u32 mcb_units; /* # of units for bulk transfer */ >> }; >> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h >> index 184da99..647cc22 100644 >> --- a/drivers/staging/lustre/lustre/include/obd_class.h >> +++ b/drivers/staging/lustre/lustre/include/obd_class.h >> @@ -156,16 +156,16 @@ struct config_llog_instance { >> int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, >> char *name, struct config_llog_instance *cfg); >> >> -#define CONFIG_T_CONFIG BIT(0) >> -#define CONFIG_T_SPTLRPC BIT(1) >> -#define CONFIG_T_RECOVER BIT(2) >> -#define CONFIG_T_PARAMS BIT(3) >> +#define CONFIG_SUB_CONFIG BIT(0) >> +#define CONFIG_SUB_SPTLRPC BIT(1) >> +#define CONFIG_SUB_RECOVER BIT(2) >> +#define CONFIG_SUB_PARAMS BIT(3) >> >> /* Sub clds should be attached to the config_llog_data when processing >> * config log for client or server target. >> */ >> -#define CONFIG_SUB_CLIENT (CONFIG_T_SPTLRPC | CONFIG_T_RECOVER | \ >> - CONFIG_T_PARAMS) >> +#define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \ >> + CONFIG_SUB_PARAMS) >> >> #define PARAMS_FILENAME "params" >> #define LCTL_UPCALL "lctl" >> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c >> index 06fcc7e..833e6a0 100644 >> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c >> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c >> @@ -315,7 +315,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> memcpy(seclogname, logname, ptr - logname); >> strcpy(seclogname + (ptr - logname), "-sptlrpc"); >> >> - if (cfg->cfg_sub_clds & CONFIG_T_SPTLRPC) { >> + if (cfg->cfg_sub_clds & CONFIG_SUB_SPTLRPC) { >> sptlrpc_cld = config_log_find_or_add(obd, seclogname, NULL, >> CONFIG_T_SPTLRPC, cfg); >> if (IS_ERR(sptlrpc_cld)) { >> @@ -325,7 +325,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> } >> } >> >> - if (cfg->cfg_sub_clds & CONFIG_T_PARAMS) { >> + if (cfg->cfg_sub_clds & CONFIG_SUB_PARAMS) { >> params_cld = config_log_find_or_add(obd, PARAMS_FILENAME, sb, >> CONFIG_T_PARAMS, cfg); >> if (IS_ERR(params_cld)) { >> @@ -345,7 +345,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >> >> LASSERT(lsi->lsi_lmd); >> if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) && >> - cfg->cfg_sub_clds & CONFIG_T_RECOVER) { >> + cfg->cfg_sub_clds & CONFIG_SUB_RECOVER) { >> ptr = strrchr(seclogname, '-'); >> if (ptr) { >> *ptr = 0; >> diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> index 2f081ed..09b1298 100644 >> --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >> @@ -3629,6 +3629,91 @@ void lustre_assert_wire_constants(void) >> LASSERTF((int)sizeof(((struct mgs_target_info *)0)->mti_params) == 4096, "found %lld\n", >> (long long)(int)sizeof(((struct mgs_target_info *)0)->mti_params)); >> >> + /* Checks for struct mgs_nidtbl_entry */ >> + LASSERTF((int)sizeof(struct mgs_nidtbl_entry) == 24, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_nidtbl_entry)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_version) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_version)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_instance) == 8, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_instance)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_index) == 12, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_index)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_length) == 16, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_length)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_type) == 20, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_type)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_type) == 21, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_type)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_size) == 22, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_size)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_count) == 23, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_count)); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count)); >> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, u.nids[0]) == 24, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_nidtbl_entry, u.nids[0])); >> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0]) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0])); >> + >> + /* Checks for struct mgs_config_body */ >> + LASSERTF((int)sizeof(struct mgs_config_body) == 80, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_config_body)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_name) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_name)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_name) == 64, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_name)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_offset) == 64, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_offset)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_offset) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_offset)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_type) == 72, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_type)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_type) == 2, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_type)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_nm_cur_pass) == 74, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_nm_cur_pass)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_bits) == 75, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_bits)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_bits) == 1, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_bits)); >> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_units) == 76, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_body, mcb_units)); >> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_units) == 4, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_units)); >> + >> + BUILD_BUG_ON(CONFIG_T_CONFIG != 0); >> + BUILD_BUG_ON(CONFIG_T_SPTLRPC != 1); >> + BUILD_BUG_ON(CONFIG_T_RECOVER != 2); >> + BUILD_BUG_ON(CONFIG_T_PARAMS != 3); >> + >> + /* Checks for struct mgs_config_res */ >> + LASSERTF((int)sizeof(struct mgs_config_res) == 16, "found %lld\n", >> + (long long)(int)sizeof(struct mgs_config_res)); >> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_offset) == 0, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_res, mcr_offset)); >> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_offset) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_offset)); >> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_size) == 8, "found %lld\n", >> + (long long)(int)offsetof(struct mgs_config_res, mcr_size)); >> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_size) == 8, "found %lld\n", >> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_size)); >> + >> /* Checks for struct lustre_capa */ >> LASSERTF((int)sizeof(struct lustre_capa) == 120, "found %lld\n", >> (long long)(int)sizeof(struct lustre_capa)); >> -- >> 1.8.3.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Wed Aug 1 01:14:27 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 11:14:27 +1000 Subject: [lustre-devel] [PATCH 2/3] lustre: llite: handle registering file system In-Reply-To: <8045D39A-57C7-4FA3-867E-AB20722BFC04@whamcloud.com> References: <1532992594-2576-1-git-send-email-jsimmons@infradead.org> <1532992594-2576-3-git-send-email-jsimmons@infradead.org> <8045D39A-57C7-4FA3-867E-AB20722BFC04@whamcloud.com> Message-ID: <87h8keriq4.fsf@notabene.neil.brown.name> On Wed, Aug 01 2018, Andreas Dilger wrote: > On Jul 30, 2018, at 17:16, James Simmons wrote: >> >> Move the code that registers struct file_system_type for lustre >> with the VFS layer to the llite layer where it belongs. This >> removes the ugly function pointer passing between obdclass and >> llite. > > One potential issue here is that "mount -t lustre" may get confused > because the mount(8) binary (or kernel, I forget where it is these days) > will modprobe "lustre" when trying to mount the filesystem. This > can fail if some odd combinations of modules are loaded, since obdclass > used to register the "lustre" filesystem type, but the client needs > "llite" loaded to actually mount, while the server does not. This > might end up causing "llite" to always be loaded on the server if this > patch were included into master. > > One option that I've through for a while is to change the servers to > mount with "-t mdt" and "-t ost", or "-t lustre_mdt" or maybe just > "-t lustre_server" or something similar. I don't have a great love > for any of these options, so I'm open for suggestions. Doing this sooner > rather than later will ease the transition at some point in the future. > > We would add this as an additional filesystem type for the modules, and > still allow "-t lustre" for some time for compatibility reasons. I like > the "lustre_mdt" and "lustre_ost" filesystem types, but using just "mdt" > and "ost" might be the best options, since this would result in the > "mdt.ko" and "ost.ko" modules being auto-loaded at mount time. I think that having the same filesystem type "lustre" be used both to mount on a client and to activate a server is a particularly unfortunate aspect of the lustre design. I really think it needs to change, and I'm glad you seem to think so too. I'm not keen on using "mdt" or "ost" as they are meaningless to people outside of lustre (and I still have to think twice to decode ... metadata target and object storage target..). I think "lustre_mdt" and "lustre_ost" are good suggestions. Creating module aliases is trivial. I think it would be really good if upstream lustre could start accepting these for server-side mounts soon. When the server code eventually lands in Linux, I expect it to only support (something like) lustre_mdt and lustre_ost for server-side mounts. Thanks, NeilBrown > > Cheers, Andreas > > >> Signed-off-by: James Simmons >> --- >> .../staging/lustre/lustre/include/lustre_disk.h | 3 - >> drivers/staging/lustre/lustre/llite/super25.c | 34 +++++++++++- >> drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 -- >> drivers/staging/lustre/lustre/obdclass/obd_mount.c | 64 ---------------------- >> 4 files changed, 31 insertions(+), 76 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h >> index 772ecc9..d5fadde 100644 >> --- a/drivers/staging/lustre/lustre/include/lustre_disk.h >> +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h >> @@ -145,9 +145,6 @@ struct lustre_sb_info { >> int lustre_put_lsi(struct super_block *sb); >> int lmd_parse(char *options, struct lustre_mount_data *lmd); >> int lustre_start_mgc(struct super_block *sb); >> -void lustre_register_super_ops(int (*cfs)(struct super_block *sb, void *data, >> - int silent), >> - void (*ksc)(struct super_block *sb)); >> int lustre_common_put_super(struct super_block *sb); >> >> int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type); >> diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c >> index de43d58..ac8f6f1 100644 >> --- a/drivers/staging/lustre/lustre/llite/super25.c >> +++ b/drivers/staging/lustre/lustre/llite/super25.c >> @@ -81,7 +81,6 @@ struct super_operations lustre_super_operations = { >> .remount_fs = ll_remount_fs, >> .show_options = ll_show_options, >> }; >> -MODULE_ALIAS_FS("lustre"); >> >> /** This is the entry point for the mount call into Lustre. >> * This is called when a server or client is mounted, >> @@ -162,6 +161,30 @@ int lustre_fill_super(struct super_block *sb, void *lmd2_data, int silent) >> return rc; >> } >> >> +/***************** FS registration ******************/ >> +static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, >> + const char *devname, void *data) >> +{ >> + return mount_nodev(fs_type, flags, data, lustre_fill_super); >> +} >> + >> +static void lustre_kill_super(struct super_block *sb) >> +{ >> + ll_kill_super(sb); >> + kill_anon_super(sb); >> +} >> + >> +/** Register the "lustre" fs type >> + */ >> +static struct file_system_type lustre_fs_type = { >> + .owner = THIS_MODULE, >> + .name = "lustre", >> + .mount = lustre_mount, >> + .kill_sb = lustre_kill_super, >> + .fs_flags = FS_RENAME_DOES_D_MOVE, >> +}; >> +MODULE_ALIAS_FS("lustre"); >> + >> static int __init lustre_init(void) >> { >> int rc; >> @@ -224,11 +247,16 @@ static int __init lustre_init(void) >> if (rc != 0) >> goto out_inode_fini_env; >> >> - lustre_register_super_ops(lustre_fill_super, ll_kill_super); >> + rc = register_filesystem(&lustre_fs_type); >> + if (rc) >> + goto out_xattr_cache; >> + >> lustre_register_client_process_config(ll_process_config); >> >> return 0; >> >> +out_xattr_cache: >> + ll_xattr_fini(); >> out_inode_fini_env: >> cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); >> out_vvp: >> @@ -245,8 +273,8 @@ static int __init lustre_init(void) >> >> static void __exit lustre_exit(void) >> { >> - lustre_register_super_ops(NULL, NULL); >> lustre_register_client_process_config(NULL); >> + unregister_filesystem(&lustre_fs_type); >> >> debugfs_remove(llite_root); >> kset_unregister(llite_kset); >> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c >> index 81a4c66..cdaf729 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c >> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c >> @@ -510,18 +510,12 @@ static int __init obdclass_init(void) >> return err; >> >> err = llog_info_init(); >> - if (err) >> - return err; >> - >> - err = lustre_register_fs(); >> >> return err; >> } >> >> static void obdclass_exit(void) >> { >> - lustre_unregister_fs(); >> - >> misc_deregister(&obd_psdev); >> llog_info_fini(); >> cl_global_fini(); >> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c >> index ac841f4..b84bca4 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c >> +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c >> @@ -49,11 +49,6 @@ >> #include >> #include >> >> -static DEFINE_SPINLOCK(client_lock); >> -static int (*client_fill_super)(struct super_block *sb, void *data, >> - int silent); >> -static void (*kill_super_cb)(struct super_block *sb); >> - >> /**************** config llog ********************/ >> >> /** Get a config log from the MGS and process it. >> @@ -1225,62 +1220,3 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd) >> return -EINVAL; >> } >> EXPORT_SYMBOL(lmd_parse); >> - >> -/* We can't call ll_fill_super by name because it lives in a module that >> - * must be loaded after this one. >> - */ >> -void lustre_register_super_ops(int (*cfs)(struct super_block *sb, void *data, >> - int silent), >> - void (*ksc)(struct super_block *sb)) >> -{ >> - spin_lock(&client_lock); >> - client_fill_super = cfs; >> - kill_super_cb = ksc; >> - spin_unlock(&client_lock); >> -} >> -EXPORT_SYMBOL(lustre_register_super_ops); >> - >> -/***************** FS registration ******************/ >> -static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, >> - const char *devname, void *data) >> -{ >> - struct dentry *root; >> - >> - spin_lock(&client_lock); >> - if (!client_fill_super) >> - request_module("lustre"); >> - root = mount_nodev(fs_type, flags, data, client_fill_super); >> - spin_unlock(&client_lock); >> - return root; >> -} >> - >> -static void lustre_kill_super(struct super_block *sb) >> -{ >> - struct lustre_sb_info *lsi = s2lsi(sb); >> - >> - if (kill_super_cb && lsi) >> - (*kill_super_cb)(sb); >> - >> - kill_anon_super(sb); >> -} >> - >> -/** Register the "lustre" fs type >> - */ >> -static struct file_system_type lustre_fs_type = { >> - .owner = THIS_MODULE, >> - .name = "lustre", >> - .mount = lustre_mount, >> - .kill_sb = lustre_kill_super, >> - .fs_flags = FS_RENAME_DOES_D_MOVE, >> -}; >> -MODULE_ALIAS_FS("lustre"); >> - >> -int lustre_register_fs(void) >> -{ >> - return register_filesystem(&lustre_fs_type); >> -} >> - >> -int lustre_unregister_fs(void) >> -{ >> - return unregister_filesystem(&lustre_fs_type); >> -} >> -- >> 1.8.3.1 >> > > Cheers, Andreas > --- > Andreas Dilger > CTO Whamcloud -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Aug 1 02:10:46 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 12:10:46 +1000 Subject: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h In-Reply-To: References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-26-git-send-email-jsimmons@infradead.org> <871sbjrpj3.fsf@notabene.neil.brown.name> <87va8vq6iu.fsf@notabene.neil.brown.name> Message-ID: <87bmamrg49.fsf@notabene.neil.brown.name> On Wed, Aug 01 2018, Patrick Farrell wrote: > Huh. I see your point, and the logic of it is obviously sound, but I'm curious - I don't think I've ever seen names like those you gave used. I've only seen MAX. uses "count": enum acpi_bus_device_type include/linux/acpi.h enum cgroup_subsys_id uses "reserved" as in "this number as larger are reserved" include/apci/actbl* enum bh_state_bits (uses "BH_PrivateStart, which is similar) uses "last" (just as bad as max) enum amd_asic_type enum req_opf include/linux/ccp.h uses "max" include/drm/bridge/dw_hdmi.h enum drm_color_encoding enum drm_color_range enum drm_sched_priority enum wb_reason enum backlight_type enum rdmacg_resource_type include/linux/clk/ti.h include/linux/crypto.h uses "size" (as good as 'num' or 'count') include/drm/bridge/mhl.h uses "num" enum drm_global_types enum ttm_ref_type ans1_ber_bytecode.h (actually 'nr' not 'num') enum wb_stat_item (actually uses "NR" prefix) enum bcm963xx_nvram_nand_part (__..._NR_PARTS) enum blkg_rwstat_type enum req_flag_bits I was looking at all matches of "git grep -w 'enum.*{' include/" and gave up when I had done include/[a-k]* and include/linux/[a-c]*. about 55 of the way.l Clearly havin a name to represent the number of names in the enum is a common need. There are several alternatives people use. "max" might be a little more common than "num", but I don't think it is a clear winner. Count, cnt, size, reserved, private, num, nr are all good and meaningful. max and last are wrong - unless the number actually is the max or the last, which it usually isn't. > > Am I wrong about that, or is MAX indeed the dominant choice? > > I also think in context, used in caps, MAX is clearly a special value > without other meaning. "clearly" except where it isn't clear. Not that long ago: http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-May/120870.html The code *looked* right - it is an error if the id number is larger than the MAX. That makes sense. But it was wrong, because the MAX wasn't the maximum, it was one more. NeilBrown > ________________________________ > From: NeilBrown > Sent: Tuesday, July 31, 2018 7:23:21 PM > To: Patrick Farrell; James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h > > On Tue, Jul 31 2018, Patrick Farrell wrote: > >> Neil, >> >> Do you have an objection to the concept, or just because this one's not used? >> Having a MAX makes it easy to write things like < MYENUM_MAX as sanity checking code, and then if the enum is added to, it still works. Seems useful to me. > > I object to the name. "MAX" is short for "MAXIMUM" which means the > highest value that is actually used. When comparing something to the > maximum it makes sense to say > if (foo <= maximum) > > but it rarely makes sense to say > if (foo < maximum) > > If you want a count of the number of values, use MYENUM_CNT or > MYENUM_NUM. This can sensibly be one more than the maximum value. > But if you have MYSENUM_MAX, make sure it is the maximum meaningful > value for the enum. > > > Thanks, > NeilBrown > > >> >> - Patrick >> ________________________________ >> From: lustre-devel on behalf of NeilBrown >> Sent: Tuesday, July 31, 2018 5:47:28 PM >> To: James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List >> Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h >> >> On Mon, Jul 30 2018, James Simmons wrote: >> >>> From: Niu Yawei >>> >>> Move config type values CONFIG_T_XXX into lustre_idl.h since they >>> will be put on wire when reading config logs. >>> >>> Add missing wire checks for mgs_nidtbl_entry, mgs_config_body and >>> mgs_config_res. >>> >>> Redefine CONFIG_SUB_XXX for the sub clds attached on config log. >>> >>> Signed-off-by: Niu Yawei >>> WC-id: https://jira.whamcloud.com/browse/LU-9216 >>> Reviewed-on: https://review.whamcloud.com/26022 >>> Reviewed-by: Fan Yong >>> Reviewed-by: John L. Hammond >>> Reviewed-by: Oleg Drokin >>> Signed-off-by: James Simmons >>> --- >>> .../lustre/include/uapi/linux/lustre/lustre_idl.h | 10 ++- >>> drivers/staging/lustre/lustre/include/obd_class.h | 12 +-- >>> drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +- >>> drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 85 ++++++++++++++++++++++ >>> 4 files changed, 103 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> index c9b32ef..bd3b45a 100644 >>> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> @@ -2111,11 +2111,19 @@ struct mgs_nidtbl_entry { >>> } u; >>> }; >>> >>> +enum { >>> + CONFIG_T_CONFIG = 0, >>> + CONFIG_T_SPTLRPC = 1, >>> + CONFIG_T_RECOVER = 2, >>> + CONFIG_T_PARAMS = 3, >>> + CONFIG_T_MAX >> >> Arrrgggh. It's back. I thought we had killed CONFIG_T_MAX (which isn't >> a MAX). >> It's never used, so it'll have to go. >> >> NeilBrown >> >> >>> +}; >>> + >>> struct mgs_config_body { >>> char mcb_name[MTI_NAME_MAXLEN]; /* logname */ >>> __u64 mcb_offset; /* next index of config log to request */ >>> __u16 mcb_type; /* type of log: CONFIG_T_[CONFIG|RECOVER] */ >>> - __u8 mcb_reserved; >>> + __u8 mcb_nm_cur_pass; >>> __u8 mcb_bits; /* bits unit size of config log */ >>> __u32 mcb_units; /* # of units for bulk transfer */ >>> }; >>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h >>> index 184da99..647cc22 100644 >>> --- a/drivers/staging/lustre/lustre/include/obd_class.h >>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h >>> @@ -156,16 +156,16 @@ struct config_llog_instance { >>> int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, >>> char *name, struct config_llog_instance *cfg); >>> >>> -#define CONFIG_T_CONFIG BIT(0) >>> -#define CONFIG_T_SPTLRPC BIT(1) >>> -#define CONFIG_T_RECOVER BIT(2) >>> -#define CONFIG_T_PARAMS BIT(3) >>> +#define CONFIG_SUB_CONFIG BIT(0) >>> +#define CONFIG_SUB_SPTLRPC BIT(1) >>> +#define CONFIG_SUB_RECOVER BIT(2) >>> +#define CONFIG_SUB_PARAMS BIT(3) >>> >>> /* Sub clds should be attached to the config_llog_data when processing >>> * config log for client or server target. >>> */ >>> -#define CONFIG_SUB_CLIENT (CONFIG_T_SPTLRPC | CONFIG_T_RECOVER | \ >>> - CONFIG_T_PARAMS) >>> +#define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \ >>> + CONFIG_SUB_PARAMS) >>> >>> #define PARAMS_FILENAME "params" >>> #define LCTL_UPCALL "lctl" >>> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> index 06fcc7e..833e6a0 100644 >>> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> @@ -315,7 +315,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> memcpy(seclogname, logname, ptr - logname); >>> strcpy(seclogname + (ptr - logname), "-sptlrpc"); >>> >>> - if (cfg->cfg_sub_clds & CONFIG_T_SPTLRPC) { >>> + if (cfg->cfg_sub_clds & CONFIG_SUB_SPTLRPC) { >>> sptlrpc_cld = config_log_find_or_add(obd, seclogname, NULL, >>> CONFIG_T_SPTLRPC, cfg); >>> if (IS_ERR(sptlrpc_cld)) { >>> @@ -325,7 +325,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> } >>> } >>> >>> - if (cfg->cfg_sub_clds & CONFIG_T_PARAMS) { >>> + if (cfg->cfg_sub_clds & CONFIG_SUB_PARAMS) { >>> params_cld = config_log_find_or_add(obd, PARAMS_FILENAME, sb, >>> CONFIG_T_PARAMS, cfg); >>> if (IS_ERR(params_cld)) { >>> @@ -345,7 +345,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> >>> LASSERT(lsi->lsi_lmd); >>> if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) && >>> - cfg->cfg_sub_clds & CONFIG_T_RECOVER) { >>> + cfg->cfg_sub_clds & CONFIG_SUB_RECOVER) { >>> ptr = strrchr(seclogname, '-'); >>> if (ptr) { >>> *ptr = 0; >>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> index 2f081ed..09b1298 100644 >>> --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> @@ -3629,6 +3629,91 @@ void lustre_assert_wire_constants(void) >>> LASSERTF((int)sizeof(((struct mgs_target_info *)0)->mti_params) == 4096, "found %lld\n", >>> (long long)(int)sizeof(((struct mgs_target_info *)0)->mti_params)); >>> >>> + /* Checks for struct mgs_nidtbl_entry */ >>> + LASSERTF((int)sizeof(struct mgs_nidtbl_entry) == 24, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_nidtbl_entry)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_version) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_version)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_instance) == 8, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_instance)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_index) == 12, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_index)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_length) == 16, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_length)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_type) == 20, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_type)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_type) == 21, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_type)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_size) == 22, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_size)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_count) == 23, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_count)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, u.nids[0]) == 24, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, u.nids[0])); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0]) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0])); >>> + >>> + /* Checks for struct mgs_config_body */ >>> + LASSERTF((int)sizeof(struct mgs_config_body) == 80, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_config_body)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_name) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_name)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_name) == 64, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_name)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_offset) == 64, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_offset)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_offset) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_offset)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_type) == 72, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_type)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_type) == 2, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_type)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_nm_cur_pass) == 74, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_nm_cur_pass)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_bits) == 75, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_bits)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_bits) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_bits)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_units) == 76, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_units)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_units) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_units)); >>> + >>> + BUILD_BUG_ON(CONFIG_T_CONFIG != 0); >>> + BUILD_BUG_ON(CONFIG_T_SPTLRPC != 1); >>> + BUILD_BUG_ON(CONFIG_T_RECOVER != 2); >>> + BUILD_BUG_ON(CONFIG_T_PARAMS != 3); >>> + >>> + /* Checks for struct mgs_config_res */ >>> + LASSERTF((int)sizeof(struct mgs_config_res) == 16, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_config_res)); >>> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_offset) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_res, mcr_offset)); >>> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_offset) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_offset)); >>> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_size) == 8, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_res, mcr_size)); >>> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_size) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_size)); >>> + >>> /* Checks for struct lustre_capa */ >>> LASSERTF((int)sizeof(struct lustre_capa) == 120, "found %lld\n", >>> (long long)(int)sizeof(struct lustre_capa)); >>> -- >>> 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: From neilb at suse.com Wed Aug 1 02:50:29 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 12:50:29 +1000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> <87sh3zq634.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> Message-ID: <878t5qrea2.fsf@notabene.neil.brown.name> Hi Amir, I think I'm happy to let this slide. I don't like magic numbers, but this one isn't important enough to justify the problems that might be caused by changing it. To answer your broader question: > The code bases are already diverging significantly between the > upstream client and the master repo, which makes porting features from > master to upstream a difficult task. Do we have a strategy on how to > deal with this? The long term strategy is just to get the work done so that the client code - and then all the kernel code - can be deleted from the master repo and can live solely in Linux. I know that is still quite a way away. Shorter term, there are no magic answers. Yes it is difficult but it is far from impossible. My plan has always been to get the code that is already in drivers/staging into a reasonable state, then start forward-porting patches from master. If other people do some of the forward-porting, that just makes me happier. If you think there is too much churn in my lustre tree, then just provide patches based on some old commit - I'm quite happy to receive patches based on fairly old code, and to do the final steps of forward-porting/conflict resolution myself (I have lots of practice). NeilBrown On Wed, Aug 01 2018, Amir Shehata wrote: > Hi Neil, > > This issue actually came up because of LU-6060, which changed the behavior for LLNL. The behavior then was changed again by LU-6851: https://jira.whamcloud.com/browse/LU-6851 (if you'd like more background) > > As a result of LU-6851 we were printing the unsigned value of -1. That's why we ended up printing it as -1, which is more bearable than just printing a large unsigned value. > > I'm not disagreeing that it'll be better to print a clearer value, "unknown" does sound like it relays the correct meaning. However, I've sometimes run into issues where changing user facing interfaces caused problems to user scripts. Would this be the case here, I'm not 100% sure. We can always make the change and then wait for tickets to be opened. > > However, I think of more concern to me is that if we make changes like this to the upstreamed client, it's probably a good idea to also make them to the whamcloud repo as well, so as not to diverge the client and server (LNet is common between them). This particular case, might not be very significant, but other issues might come up that are of more significance. > > The code bases are already diverging significantly between the upstream client and the master repo, which makes porting features from master to upstream a difficult task. Do we have a strategy on how to deal with this? > > thanks > amir > ________________________________________ > From: NeilBrown [neilb at suse.com] > Sent: Tuesday, July 31, 2018 5:32 PM > To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print > > Hi Amir, > thanks for the background. > > I had to chuckle at "0 being the highest", though I know that this > distortion is not something specific to lustre. > > Your description seems to suggest that "-1" means "unknown" with an > implication that the number of hops might be high, and best not to take > the risk. > > Your point about compatability with scripts has some validity, though > it is annoying to have to support such ugly interfaces indefinitely. > Are there really likely to be dependencies? lustre has only been > printing -1 since Feb last year when this patch went upstream. > That was presumably an abi change as it would have printed MAXINT-1 > previously. Did that cause any problems? > > Thanks, > NeilBrown > > > On Tue, Jul 31 2018, Amir Shehata wrote: > >> The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. >> >> In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. >> >> Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. >> >> thanks >> amir >> ________________________________________ >> From: NeilBrown [neilb at suse.com] >> Sent: Tuesday, July 31, 2018 3:38 PM >> To: James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List; Amir Shehata; James Simmons >> Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print >> >> On Mon, Jul 30 2018, James Simmons wrote: >> >>> From: Amir Shehata >>> >>> The default number of hops for a route is -1. This is >>> currently being printed as %u. Change that to %d to >>> make it print out properly. >> >> -1 hops??? I wish I could hop -1 times - it would be a good party >> trick!! >> >> What does -1 mean? Unlimited (just a guess). If so, could we print >> "unlimited"?? >> >> I'm fine with having magic numbers in the code, but I don't like them to >> leak out. >> >> NeilBrown >> >>> >>> Signed-off-by: Amir Shehata >>> WC-id: https://jira.whamcloud.com/browse/LU-9078 >>> Reviewed-on: https://review.whamcloud.com/25250 >>> Reviewed-by: Olaf Weber >>> Reviewed-by: Doug Oucharek >>> Reviewed-by: James Simmons >>> Reviewed-by: Oleg Drokin >>> Signed-off-by: James Simmons >>> --- >>> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >>> index 8856798..aa98ce5 100644 >>> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >>> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >>> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >>> int alive = lnet_is_route_alive(route); >>> >>> s += snprintf(s, tmpstr + tmpsiz - s, >>> - "%-8s %4u %8u %7s %s\n", >>> + "%-8s %4d %8u %7s %s\n", >>> libcfs_net2str(net), hops, >>> priority, >>> alive ? "up" : "down", >>> -- >>> 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: From neilb at suse.com Wed Aug 1 02:58:18 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 12:58:18 +1000 Subject: [lustre-devel] [PATCH 30/31] lustre: fid: race between client_fid_fini and seq_client_flush In-Reply-To: <7FB055E0B36B6F4EB93E637E0640A56FCB68C93C@fmsmsx118.amr.corp.intel.com> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-31-git-send-email-jsimmons@infradead.org> <87y3drqalt.fsf@notabene.neil.brown.name> <7FB055E0B36B6F4EB93E637E0640A56FCB68C93C@fmsmsx118.amr.corp.intel.com> Message-ID: <87600urdx1.fsf@notabene.neil.brown.name> On Wed, Aug 01 2018, Yong, Fan wrote: > The client_obd::cl_seq_rwsem protects the client_obd::cl_seq itself, > not the internal members inside client_obd::cl_seq. I do not think > simple refcount can work here. For example, if the client_fid_fini() > is destroying the client_obd::cl_seq, we need some mechanism, such as > the mutex, to pervert others accessing the client_obd::cl_seq. Under > such case, even though someone could acquire refcount (after the > client_fid_fini() start), it still cannot prevent the in-processing > destroy. A common pattern with refcounts is to free the object when the refcount reaches zero. kref_put(&cli->cl_refcount, free_cl_seq(cli)) or similar. So we start with a refcount of 1, the code that currently does 'down_read()' instead does if (kref_get_unless_zero(&cli->cl_refcount)) { do something with cli->cl_seq kref_put(.....); } and client_fid_fini() just does the kref_put(). An important question is whether client_fid_fini() really needs to wait for seq_client_flush() or seq_client_alloc_fid() to complete. If it does, then we probably can't do much better than the rwsem. If it doesn't, then kref_put() is the better way to go. In either case, I cannot see any justification for holding the lock in client_fid_init(). It would be better to completely initialize the lu_client_seq, and then atomically assign it to cli->cl_seq. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Wed Aug 1 03:17:22 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 13:17:22 +1000 Subject: [lustre-devel] [PATCH 1/3] lustre: obd: migrate lustre_fill_super() to llite In-Reply-To: <87tvogrtbj.fsf@notabene.neil.brown.name> References: <1532992594-2576-1-git-send-email-jsimmons@infradead.org> <1532992594-2576-2-git-send-email-jsimmons@infradead.org> <87tvogrtbj.fsf@notabene.neil.brown.name> Message-ID: <8736vyrd19.fsf@notabene.neil.brown.name> On Tue, Jul 31 2018, NeilBrown wrote: > On Mon, Jul 30 2018, James Simmons wrote: > >> Currently both obdclass and ptlrpc are built as separate modules >> with ptlrpc being a child of obdclass. A recent change placed >> ptlrpc_[inc|dec]_ref() into the obdclass code i.e obd_mount.c >> which now causes a curricular module dependency. Examining the > > Oops, that was careless - sorry about that. > Maybe I should just revert that patch .... but that probably > doesn't actually make things easier. Let's go with your fix. Actually, I changed my mind - sorry. I've reverted the offending patch, and written a patch that just moves the minimum from obdclass to llite. There is room for further cleaning up... Thanks, NeilBrown From cb6578971fd9e1d1dedb6e88629741dcf8e31318 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 1 Aug 2018 10:09:39 +1000 Subject: [PATCH] lustre: move client mounting from obdclass to llite. Mounting a lustre client is currently handled in obdclass, using services from llite. This requires obdclass to load the llite module and set up inter-module linkage. The purpose of this was for common code to support both client and server mounts. This isn't really a good idea and need to go. When we add the server, it will use a separate filesystem type. So move the mounting code from obdclass/obd_mount to llite/super25 and remove the inter-module linkages. Add some EXPORT_SYMBOL() so that llite can access some helpers that remain in obdclass. Signed-off-by: NeilBrown --- .../staging/lustre/lustre/include/lustre_disk.h | 7 +- drivers/staging/lustre/lustre/llite/super25.c | 116 +++++++++++++++- drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 - drivers/staging/lustre/lustre/obdclass/obd_mount.c | 152 +-------------------- 4 files changed, 125 insertions(+), 154 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 1a6d421ea64b..1d18b2fd210d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -142,13 +142,14 @@ struct lustre_sb_info { /* obd_mount.c */ int lustre_start_mgc(struct super_block *sb); -void lustre_register_super_ops(struct module *mod, - int (*cfs)(struct super_block *sb), - void (*ksc)(struct super_block *sb)); int lustre_common_put_super(struct super_block *sb); int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type); +struct lustre_sb_info *lustre_init_lsi(struct super_block *sb); +int lustre_put_lsi(struct super_block *sb); +int lmd_parse(char *options, struct lustre_mount_data *lmd); + /** @} disk */ #endif /* _LUSTRE_DISK_H */ diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index d335f29556c2..966b0564c952 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -32,6 +32,7 @@ */ #define DEBUG_SUBSYSTEM S_LLITE +#define D_MOUNT (D_SUPER | D_CONFIG/*|D_WARNING */) #include #include @@ -81,8 +82,115 @@ struct super_operations lustre_super_operations = { .remount_fs = ll_remount_fs, .show_options = ll_show_options, }; + +/** This is the entry point for the mount call into Lustre. + * This is called when a server or client is mounted, + * and this is where we start setting things up. + * @param data Mount options (e.g. -o flock,abort_recov) + */ +static int lustre_fill_super(struct super_block *sb, void *lmd2_data, int silent) +{ + struct lustre_mount_data *lmd; + struct lustre_sb_info *lsi; + int rc; + + CDEBUG(D_MOUNT | D_VFSTRACE, "VFS Op: sb %p\n", sb); + + lsi = lustre_init_lsi(sb); + if (!lsi) + return -ENOMEM; + lmd = lsi->lsi_lmd; + + /* + * Disable lockdep during mount, because mount locking patterns are + * `special'. + */ + lockdep_off(); + + /* + * LU-639: the obd cleanup of last mount may not finish yet, wait here. + */ + obd_zombie_barrier(); + + /* Figure out the lmd from the mount options */ + if (lmd_parse(lmd2_data, lmd)) { + lustre_put_lsi(sb); + rc = -EINVAL; + goto out; + } + + if (lmd_is_client(lmd)) { + CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile); + + rc = lustre_start_mgc(sb); + if (rc) { + lustre_common_put_super(sb); + goto out; + } + /* Connect and start */ + rc = ll_fill_super(sb); + /* + * c_f_s will call lustre_common_put_super on failure, otherwise + * c_f_s will have taken another reference to the module + */ + } else { + CERROR("This is client-side-only module, cannot handle server mount.\n"); + rc = -EINVAL; + } + + /* If error happens in fill_super() call, @lsi will be killed there. + * This is why we do not put it here. + */ + goto out; +out: + if (rc) { + CERROR("Unable to mount %s (%d)\n", + s2lsi(sb) ? lmd->lmd_dev : "", rc); + } else { + CDEBUG(D_SUPER, "Mount %s complete\n", + lmd->lmd_dev); + } + lockdep_on(); + return rc; +} + +/***************** FS registration ******************/ +static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, + const char *devname, void *data) +{ + return mount_nodev(fs_type, flags, data, lustre_fill_super); +} + +static void lustre_kill_super(struct super_block *sb) +{ + struct lustre_sb_info *lsi = s2lsi(sb); + + if (lsi) + ll_kill_super(sb); + + kill_anon_super(sb); +} + +/** Register the "lustre" fs type + */ +static struct file_system_type lustre_fs_type = { + .owner = THIS_MODULE, + .name = "lustre", + .mount = lustre_mount, + .kill_sb = lustre_kill_super, + .fs_flags = FS_RENAME_DOES_D_MOVE, +}; MODULE_ALIAS_FS("lustre"); +int lustre_register_fs(void) +{ + return register_filesystem(&lustre_fs_type); +} + +int lustre_unregister_fs(void) +{ + return unregister_filesystem(&lustre_fs_type); +} static int __init lustre_init(void) { int rc; @@ -145,7 +253,10 @@ static int __init lustre_init(void) if (rc != 0) goto out_inode_fini_env; - lustre_register_super_ops(THIS_MODULE, ll_fill_super, ll_kill_super); + rc = lustre_register_fs(); + if (rc) + goto out_inode_fini_env; + lustre_register_client_process_config(ll_process_config); return 0; @@ -166,7 +277,8 @@ static int __init lustre_init(void) static void __exit lustre_exit(void) { - lustre_register_super_ops(NULL, NULL, NULL); + lustre_unregister_fs(); + lustre_register_client_process_config(NULL); debugfs_remove(llite_root); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 81a4c666bb69..9d389288bea4 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -513,15 +513,11 @@ static int __init obdclass_init(void) if (err) return err; - err = lustre_register_fs(); - return err; } static void obdclass_exit(void) { - lustre_unregister_fs(); - misc_deregister(&obd_psdev); llog_info_fini(); cl_global_fini(); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 39911dcb0fd9..f0f00b779cf1 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -49,11 +49,6 @@ #include #include -static DEFINE_SPINLOCK(client_lock); -static struct module *client_mod; -static int (*client_fill_super)(struct super_block *sb); -static void (*kill_super_cb)(struct super_block *sb); - /**************** config llog ********************/ /** Get a config log from the MGS and process it. @@ -430,6 +425,7 @@ int lustre_start_mgc(struct super_block *sb) kfree(niduuid); return rc; } +EXPORT_SYMBOL(lustre_start_mgc); static int lustre_stop_mgc(struct super_block *sb) { @@ -507,7 +503,7 @@ static int lustre_stop_mgc(struct super_block *sb) /***************** lustre superblock **************/ -static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) +struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi; @@ -532,6 +528,7 @@ static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) return lsi; } +EXPORT_SYMBOL(lustre_init_lsi); static int lustre_free_lsi(struct super_block *sb) { @@ -567,7 +564,7 @@ static int lustre_free_lsi(struct super_block *sb) /* The lsi has one reference for every server that is using the disk - * e.g. MDT, MGS, and potentially MGC */ -static int lustre_put_lsi(struct super_block *sb) +int lustre_put_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); @@ -578,6 +575,7 @@ static int lustre_put_lsi(struct super_block *sb) } return 0; } +EXPORT_SYMBOL(lustre_put_lsi); /*** SERVER NAME *** * @@ -991,7 +989,7 @@ static int lmd_parse_nidlist(char *buf, char **endh) * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre * dev is passed as device=uml1:/lustre by mount.lustre */ -static int lmd_parse(char *options, struct lustre_mount_data *lmd) +int lmd_parse(char *options, struct lustre_mount_data *lmd) { char *s1, *s2, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; @@ -1215,141 +1213,5 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) CERROR("Bad mount options %s\n", options); return -EINVAL; } +EXPORT_SYMBOL(lmd_parse); -/** This is the entry point for the mount call into Lustre. - * This is called when a server or client is mounted, - * and this is where we start setting things up. - * @param data Mount options (e.g. -o flock,abort_recov) - */ -static int lustre_fill_super(struct super_block *sb, void *lmd2_data, int silent) -{ - struct lustre_mount_data *lmd; - struct lustre_sb_info *lsi; - int rc; - - CDEBUG(D_MOUNT | D_VFSTRACE, "VFS Op: sb %p\n", sb); - - lsi = lustre_init_lsi(sb); - if (!lsi) - return -ENOMEM; - lmd = lsi->lsi_lmd; - - /* - * Disable lockdep during mount, because mount locking patterns are - * `special'. - */ - lockdep_off(); - - /* - * LU-639: the obd cleanup of last mount may not finish yet, wait here. - */ - obd_zombie_barrier(); - - /* Figure out the lmd from the mount options */ - if (lmd_parse(lmd2_data, lmd)) { - lustre_put_lsi(sb); - rc = -EINVAL; - goto out; - } - - if (lmd_is_client(lmd)) { - bool have_client = false; - CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile); - if (!client_fill_super) - request_module("lustre"); - spin_lock(&client_lock); - if (client_fill_super && try_module_get(client_mod)) - have_client = true; - spin_unlock(&client_lock); - if (!have_client) { - LCONSOLE_ERROR_MSG(0x165, "Nothing registered for client mount! Is the 'lustre' module loaded?\n"); - lustre_put_lsi(sb); - rc = -ENODEV; - } else { - rc = lustre_start_mgc(sb); - if (rc) { - lustre_common_put_super(sb); - goto out; - } - /* Connect and start */ - /* (should always be ll_fill_super) */ - rc = (*client_fill_super)(sb); - /* - * c_f_s will call lustre_common_put_super on failure, otherwise - * c_f_s will have taken another reference to the module - */ - module_put(client_mod); - } - } else { - CERROR("This is client-side-only module, cannot handle server mount.\n"); - rc = -EINVAL; - } - - /* If error happens in fill_super() call, @lsi will be killed there. - * This is why we do not put it here. - */ - goto out; -out: - if (rc) { - CERROR("Unable to mount %s (%d)\n", - s2lsi(sb) ? lmd->lmd_dev : "", rc); - } else { - CDEBUG(D_SUPER, "Mount %s complete\n", - lmd->lmd_dev); - } - lockdep_on(); - return rc; -} - -/* We can't call ll_fill_super by name because it lives in a module that - * must be loaded after this one. - */ -void lustre_register_super_ops(struct module *mod, - int (*cfs)(struct super_block *sb), - void (*ksc)(struct super_block *sb)) -{ - spin_lock(&client_lock); - client_mod = mod; - client_fill_super = cfs; - kill_super_cb = ksc; - spin_unlock(&client_lock); -} -EXPORT_SYMBOL(lustre_register_super_ops); - -/***************** FS registration ******************/ -static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags, - const char *devname, void *data) -{ - return mount_nodev(fs_type, flags, data, lustre_fill_super); -} - -static void lustre_kill_super(struct super_block *sb) -{ - struct lustre_sb_info *lsi = s2lsi(sb); - - if (kill_super_cb && lsi) - (*kill_super_cb)(sb); - - kill_anon_super(sb); -} - -/** Register the "lustre" fs type - */ -static struct file_system_type lustre_fs_type = { - .owner = THIS_MODULE, - .name = "lustre", - .mount = lustre_mount, - .kill_sb = lustre_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE, -}; -MODULE_ALIAS_FS("lustre"); - -int lustre_register_fs(void) -{ - return register_filesystem(&lustre_fs_type); -} - -int lustre_unregister_fs(void) -{ - return unregister_filesystem(&lustre_fs_type); -} -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From paf at cray.com Wed Aug 1 03:23:30 2018 From: paf at cray.com (Patrick Farrell) Date: Wed, 1 Aug 2018 03:23:30 +0000 Subject: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h In-Reply-To: <87bmamrg49.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-26-git-send-email-jsimmons@infradead.org> <871sbjrpj3.fsf@notabene.neil.brown.name> <87va8vq6iu.fsf@notabene.neil.brown.name> , <87bmamrg49.fsf@notabene.neil.brown.name> Message-ID: Ah, that last one is a good example. All right, I'm converted. Thanks. - Patrick ________________________________ From: NeilBrown Sent: Tuesday, July 31, 2018 9:10:46 PM To: Patrick Farrell; James Simmons; Andreas Dilger; Oleg Drokin Cc: Lustre Development List Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h On Wed, Aug 01 2018, Patrick Farrell wrote: > Huh. I see your point, and the logic of it is obviously sound, but I'm curious - I don't think I've ever seen names like those you gave used. I've only seen MAX. uses "count": enum acpi_bus_device_type include/linux/acpi.h enum cgroup_subsys_id uses "reserved" as in "this number as larger are reserved" include/apci/actbl* enum bh_state_bits (uses "BH_PrivateStart, which is similar) uses "last" (just as bad as max) enum amd_asic_type enum req_opf include/linux/ccp.h uses "max" include/drm/bridge/dw_hdmi.h enum drm_color_encoding enum drm_color_range enum drm_sched_priority enum wb_reason enum backlight_type enum rdmacg_resource_type include/linux/clk/ti.h include/linux/crypto.h uses "size" (as good as 'num' or 'count') include/drm/bridge/mhl.h uses "num" enum drm_global_types enum ttm_ref_type ans1_ber_bytecode.h (actually 'nr' not 'num') enum wb_stat_item (actually uses "NR" prefix) enum bcm963xx_nvram_nand_part (__..._NR_PARTS) enum blkg_rwstat_type enum req_flag_bits I was looking at all matches of "git grep -w 'enum.*{' include/" and gave up when I had done include/[a-k]* and include/linux/[a-c]*. about 55 of the way.l Clearly havin a name to represent the number of names in the enum is a common need. There are several alternatives people use. "max" might be a little more common than "num", but I don't think it is a clear winner. Count, cnt, size, reserved, private, num, nr are all good and meaningful. max and last are wrong - unless the number actually is the max or the last, which it usually isn't. > > Am I wrong about that, or is MAX indeed the dominant choice? > > I also think in context, used in caps, MAX is clearly a special value > without other meaning. "clearly" except where it isn't clear. Not that long ago: http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-May/120870.html The code *looked* right - it is an error if the id number is larger than the MAX. That makes sense. But it was wrong, because the MAX wasn't the maximum, it was one more. NeilBrown > ________________________________ > From: NeilBrown > Sent: Tuesday, July 31, 2018 7:23:21 PM > To: Patrick Farrell; James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h > > On Tue, Jul 31 2018, Patrick Farrell wrote: > >> Neil, >> >> Do you have an objection to the concept, or just because this one's not used? >> Having a MAX makes it easy to write things like < MYENUM_MAX as sanity checking code, and then if the enum is added to, it still works. Seems useful to me. > > I object to the name. "MAX" is short for "MAXIMUM" which means the > highest value that is actually used. When comparing something to the > maximum it makes sense to say > if (foo <= maximum) > > but it rarely makes sense to say > if (foo < maximum) > > If you want a count of the number of values, use MYENUM_CNT or > MYENUM_NUM. This can sensibly be one more than the maximum value. > But if you have MYSENUM_MAX, make sure it is the maximum meaningful > value for the enum. > > > Thanks, > NeilBrown > > >> >> - Patrick >> ________________________________ >> From: lustre-devel on behalf of NeilBrown >> Sent: Tuesday, July 31, 2018 5:47:28 PM >> To: James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List >> Subject: Re: [lustre-devel] [PATCH 25/31] lustre: config: move config types into lustre_idl.h >> >> On Mon, Jul 30 2018, James Simmons wrote: >> >>> From: Niu Yawei >>> >>> Move config type values CONFIG_T_XXX into lustre_idl.h since they >>> will be put on wire when reading config logs. >>> >>> Add missing wire checks for mgs_nidtbl_entry, mgs_config_body and >>> mgs_config_res. >>> >>> Redefine CONFIG_SUB_XXX for the sub clds attached on config log. >>> >>> Signed-off-by: Niu Yawei >>> WC-id: https://jira.whamcloud.com/browse/LU-9216 >>> Reviewed-on: https://review.whamcloud.com/26022 >>> Reviewed-by: Fan Yong >>> Reviewed-by: John L. Hammond >>> Reviewed-by: Oleg Drokin >>> Signed-off-by: James Simmons >>> --- >>> .../lustre/include/uapi/linux/lustre/lustre_idl.h | 10 ++- >>> drivers/staging/lustre/lustre/include/obd_class.h | 12 +-- >>> drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +- >>> drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 85 ++++++++++++++++++++++ >>> 4 files changed, 103 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> index c9b32ef..bd3b45a 100644 >>> --- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> +++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h >>> @@ -2111,11 +2111,19 @@ struct mgs_nidtbl_entry { >>> } u; >>> }; >>> >>> +enum { >>> + CONFIG_T_CONFIG = 0, >>> + CONFIG_T_SPTLRPC = 1, >>> + CONFIG_T_RECOVER = 2, >>> + CONFIG_T_PARAMS = 3, >>> + CONFIG_T_MAX >> >> Arrrgggh. It's back. I thought we had killed CONFIG_T_MAX (which isn't >> a MAX). >> It's never used, so it'll have to go. >> >> NeilBrown >> >> >>> +}; >>> + >>> struct mgs_config_body { >>> char mcb_name[MTI_NAME_MAXLEN]; /* logname */ >>> __u64 mcb_offset; /* next index of config log to request */ >>> __u16 mcb_type; /* type of log: CONFIG_T_[CONFIG|RECOVER] */ >>> - __u8 mcb_reserved; >>> + __u8 mcb_nm_cur_pass; >>> __u8 mcb_bits; /* bits unit size of config log */ >>> __u32 mcb_units; /* # of units for bulk transfer */ >>> }; >>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h >>> index 184da99..647cc22 100644 >>> --- a/drivers/staging/lustre/lustre/include/obd_class.h >>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h >>> @@ -156,16 +156,16 @@ struct config_llog_instance { >>> int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, >>> char *name, struct config_llog_instance *cfg); >>> >>> -#define CONFIG_T_CONFIG BIT(0) >>> -#define CONFIG_T_SPTLRPC BIT(1) >>> -#define CONFIG_T_RECOVER BIT(2) >>> -#define CONFIG_T_PARAMS BIT(3) >>> +#define CONFIG_SUB_CONFIG BIT(0) >>> +#define CONFIG_SUB_SPTLRPC BIT(1) >>> +#define CONFIG_SUB_RECOVER BIT(2) >>> +#define CONFIG_SUB_PARAMS BIT(3) >>> >>> /* Sub clds should be attached to the config_llog_data when processing >>> * config log for client or server target. >>> */ >>> -#define CONFIG_SUB_CLIENT (CONFIG_T_SPTLRPC | CONFIG_T_RECOVER | \ >>> - CONFIG_T_PARAMS) >>> +#define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \ >>> + CONFIG_SUB_PARAMS) >>> >>> #define PARAMS_FILENAME "params" >>> #define LCTL_UPCALL "lctl" >>> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> index 06fcc7e..833e6a0 100644 >>> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c >>> @@ -315,7 +315,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> memcpy(seclogname, logname, ptr - logname); >>> strcpy(seclogname + (ptr - logname), "-sptlrpc"); >>> >>> - if (cfg->cfg_sub_clds & CONFIG_T_SPTLRPC) { >>> + if (cfg->cfg_sub_clds & CONFIG_SUB_SPTLRPC) { >>> sptlrpc_cld = config_log_find_or_add(obd, seclogname, NULL, >>> CONFIG_T_SPTLRPC, cfg); >>> if (IS_ERR(sptlrpc_cld)) { >>> @@ -325,7 +325,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> } >>> } >>> >>> - if (cfg->cfg_sub_clds & CONFIG_T_PARAMS) { >>> + if (cfg->cfg_sub_clds & CONFIG_SUB_PARAMS) { >>> params_cld = config_log_find_or_add(obd, PARAMS_FILENAME, sb, >>> CONFIG_T_PARAMS, cfg); >>> if (IS_ERR(params_cld)) { >>> @@ -345,7 +345,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, >>> >>> LASSERT(lsi->lsi_lmd); >>> if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR) && >>> - cfg->cfg_sub_clds & CONFIG_T_RECOVER) { >>> + cfg->cfg_sub_clds & CONFIG_SUB_RECOVER) { >>> ptr = strrchr(seclogname, '-'); >>> if (ptr) { >>> *ptr = 0; >>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> index 2f081ed..09b1298 100644 >>> --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c >>> @@ -3629,6 +3629,91 @@ void lustre_assert_wire_constants(void) >>> LASSERTF((int)sizeof(((struct mgs_target_info *)0)->mti_params) == 4096, "found %lld\n", >>> (long long)(int)sizeof(((struct mgs_target_info *)0)->mti_params)); >>> >>> + /* Checks for struct mgs_nidtbl_entry */ >>> + LASSERTF((int)sizeof(struct mgs_nidtbl_entry) == 24, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_nidtbl_entry)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_version) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_version)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_version)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_instance) == 8, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_instance)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_instance)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_index) == 12, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_index)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_index)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_length) == 16, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_length)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_length)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_type) == 20, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_type)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_type)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_type) == 21, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_type)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_type)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_size) == 22, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_size)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_size)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, mne_nid_count) == 23, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, mne_nid_count)); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->mne_nid_count)); >>> + LASSERTF((int)offsetof(struct mgs_nidtbl_entry, u.nids[0]) == 24, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_nidtbl_entry, u.nids[0])); >>> + LASSERTF((int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0]) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_nidtbl_entry *)0)->u.nids[0])); >>> + >>> + /* Checks for struct mgs_config_body */ >>> + LASSERTF((int)sizeof(struct mgs_config_body) == 80, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_config_body)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_name) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_name)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_name) == 64, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_name)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_offset) == 64, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_offset)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_offset) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_offset)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_type) == 72, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_type)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_type) == 2, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_type)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_nm_cur_pass) == 74, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_nm_cur_pass)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_nm_cur_pass)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_bits) == 75, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_bits)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_bits) == 1, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_bits)); >>> + LASSERTF((int)offsetof(struct mgs_config_body, mcb_units) == 76, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_body, mcb_units)); >>> + LASSERTF((int)sizeof(((struct mgs_config_body *)0)->mcb_units) == 4, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_body *)0)->mcb_units)); >>> + >>> + BUILD_BUG_ON(CONFIG_T_CONFIG != 0); >>> + BUILD_BUG_ON(CONFIG_T_SPTLRPC != 1); >>> + BUILD_BUG_ON(CONFIG_T_RECOVER != 2); >>> + BUILD_BUG_ON(CONFIG_T_PARAMS != 3); >>> + >>> + /* Checks for struct mgs_config_res */ >>> + LASSERTF((int)sizeof(struct mgs_config_res) == 16, "found %lld\n", >>> + (long long)(int)sizeof(struct mgs_config_res)); >>> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_offset) == 0, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_res, mcr_offset)); >>> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_offset) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_offset)); >>> + LASSERTF((int)offsetof(struct mgs_config_res, mcr_size) == 8, "found %lld\n", >>> + (long long)(int)offsetof(struct mgs_config_res, mcr_size)); >>> + LASSERTF((int)sizeof(((struct mgs_config_res *)0)->mcr_size) == 8, "found %lld\n", >>> + (long long)(int)sizeof(((struct mgs_config_res *)0)->mcr_size)); >>> + >>> /* Checks for struct lustre_capa */ >>> LASSERTF((int)sizeof(struct lustre_capa) == 120, "found %lld\n", >>> (long long)(int)sizeof(struct lustre_capa)); >>> -- >>> 1.8.3.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Wed Aug 1 03:41:43 2018 From: neilb at suse.com (NeilBrown) Date: Wed, 01 Aug 2018 13:41:43 +1000 Subject: [lustre-devel] [PATCH 00/31] lustre: missing fixes and cleanups from lustre 2.10 In-Reply-To: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> Message-ID: <87zhy6pxc8.fsf@notabene.neil.brown.name> On Mon, Jul 30 2018, James Simmons wrote: > This covers all the missing patches landed from the start of the > lustre 2.10 development cycle until right before the PFL feature > landed. Several bug fixes as well as cleanups. This is based on > top of the recent list patches as well as my mount code for llite > patch series. I've applied all these to my lustre-testing branch, plus the fixups I promised. I cannot review them for correctness, just for whether the code looks sensible and appears consistent with upstream style. If my testing shows no problems and I don't hear any complaints I suspect they will migrate to 'lustre' in a week or so. BTW I've created a new branch 'lustre-wip' which contains patches that depend on changes to non-lustre code, and so are likely to be delayed more than I would like... Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From ashehata at whamcloud.com Wed Aug 1 17:11:24 2018 From: ashehata at whamcloud.com (Amir Shehata) Date: Wed, 1 Aug 2018 17:11:24 +0000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <878t5qrea2.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> <87sh3zq634.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com>, <878t5qrea2.fsf@notabene.neil.brown.name> Message-ID: <3C0BF267DA2B2343B6A8D6013E6C43381AAE75@LAX-EX-MB3.datadirect.datadirectnet.com> Hi Neil, Thanks for the explanation. Speaking specifically for LNet, I'm not sure it's feasible to remove the code from master repo. As I mentioned LNet is a common piece between both the client and server sides. Both of them rely on it. And I believe LNet is also used by DVS, which is a cray developed layer, I'm not very familiar with it. So just deleting it from the master repo I don't think would work. Over the past years, there has been discussions about making it a standalone module that can be pulled in as a dependency. This approach makes a bit more sense to me. What are your thoughts on that? thanks amir ________________________________________ From: NeilBrown [neilb at suse.com] Sent: Tuesday, July 31, 2018 7:50 PM To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin Cc: Lustre Development List Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print Hi Amir, I think I'm happy to let this slide. I don't like magic numbers, but this one isn't important enough to justify the problems that might be caused by changing it. To answer your broader question: > The code bases are already diverging significantly between the > upstream client and the master repo, which makes porting features from > master to upstream a difficult task. Do we have a strategy on how to > deal with this? The long term strategy is just to get the work done so that the client code - and then all the kernel code - can be deleted from the master repo and can live solely in Linux. I know that is still quite a way away. Shorter term, there are no magic answers. Yes it is difficult but it is far from impossible. My plan has always been to get the code that is already in drivers/staging into a reasonable state, then start forward-porting patches from master. If other people do some of the forward-porting, that just makes me happier. If you think there is too much churn in my lustre tree, then just provide patches based on some old commit - I'm quite happy to receive patches based on fairly old code, and to do the final steps of forward-porting/conflict resolution myself (I have lots of practice). NeilBrown On Wed, Aug 01 2018, Amir Shehata wrote: > Hi Neil, > > This issue actually came up because of LU-6060, which changed the behavior for LLNL. The behavior then was changed again by LU-6851: https://jira.whamcloud.com/browse/LU-6851 (if you'd like more background) > > As a result of LU-6851 we were printing the unsigned value of -1. That's why we ended up printing it as -1, which is more bearable than just printing a large unsigned value. > > I'm not disagreeing that it'll be better to print a clearer value, "unknown" does sound like it relays the correct meaning. However, I've sometimes run into issues where changing user facing interfaces caused problems to user scripts. Would this be the case here, I'm not 100% sure. We can always make the change and then wait for tickets to be opened. > > However, I think of more concern to me is that if we make changes like this to the upstreamed client, it's probably a good idea to also make them to the whamcloud repo as well, so as not to diverge the client and server (LNet is common between them). This particular case, might not be very significant, but other issues might come up that are of more significance. > > The code bases are already diverging significantly between the upstream client and the master repo, which makes porting features from master to upstream a difficult task. Do we have a strategy on how to deal with this? > > thanks > amir > ________________________________________ > From: NeilBrown [neilb at suse.com] > Sent: Tuesday, July 31, 2018 5:32 PM > To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print > > Hi Amir, > thanks for the background. > > I had to chuckle at "0 being the highest", though I know that this > distortion is not something specific to lustre. > > Your description seems to suggest that "-1" means "unknown" with an > implication that the number of hops might be high, and best not to take > the risk. > > Your point about compatability with scripts has some validity, though > it is annoying to have to support such ugly interfaces indefinitely. > Are there really likely to be dependencies? lustre has only been > printing -1 since Feb last year when this patch went upstream. > That was presumably an abi change as it would have printed MAXINT-1 > previously. Did that cause any problems? > > Thanks, > NeilBrown > > > On Tue, Jul 31 2018, Amir Shehata wrote: > >> The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. >> >> In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. >> >> Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. >> >> thanks >> amir >> ________________________________________ >> From: NeilBrown [neilb at suse.com] >> Sent: Tuesday, July 31, 2018 3:38 PM >> To: James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List; Amir Shehata; James Simmons >> Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print >> >> On Mon, Jul 30 2018, James Simmons wrote: >> >>> From: Amir Shehata >>> >>> The default number of hops for a route is -1. This is >>> currently being printed as %u. Change that to %d to >>> make it print out properly. >> >> -1 hops??? I wish I could hop -1 times - it would be a good party >> trick!! >> >> What does -1 mean? Unlimited (just a guess). If so, could we print >> "unlimited"?? >> >> I'm fine with having magic numbers in the code, but I don't like them to >> leak out. >> >> NeilBrown >> >>> >>> Signed-off-by: Amir Shehata >>> WC-id: https://jira.whamcloud.com/browse/LU-9078 >>> Reviewed-on: https://review.whamcloud.com/25250 >>> Reviewed-by: Olaf Weber >>> Reviewed-by: Doug Oucharek >>> Reviewed-by: James Simmons >>> Reviewed-by: Oleg Drokin >>> Signed-off-by: James Simmons >>> --- >>> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >>> index 8856798..aa98ce5 100644 >>> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >>> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >>> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >>> int alive = lnet_is_route_alive(route); >>> >>> s += snprintf(s, tmpstr + tmpsiz - s, >>> - "%-8s %4u %8u %7s %s\n", >>> + "%-8s %4d %8u %7s %s\n", >>> libcfs_net2str(net), hops, >>> priority, >>> alive ? "up" : "down", >>> -- >>> 1.8.3.1 From fan.yong at intel.com Wed Aug 1 00:44:02 2018 From: fan.yong at intel.com (Yong, Fan) Date: Wed, 1 Aug 2018 00:44:02 +0000 Subject: [lustre-devel] [PATCH 30/31] lustre: fid: race between client_fid_fini and seq_client_flush In-Reply-To: <87y3drqalt.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-31-git-send-email-jsimmons@infradead.org> <87y3drqalt.fsf@notabene.neil.brown.name> Message-ID: <7FB055E0B36B6F4EB93E637E0640A56FCB68C93C@fmsmsx118.amr.corp.intel.com> The client_obd::cl_seq_rwsem protects the client_obd::cl_seq itself, not the internal members inside client_obd::cl_seq. I do not think simple refcount can work here. For example, if the client_fid_fini() is destroying the client_obd::cl_seq, we need some mechanism, such as the mutex, to pervert others accessing the client_obd::cl_seq. Under such case, even though someone could acquire refcount (after the client_fid_fini() start), it still cannot prevent the in-processing destroy. -- Cheers, Nasf -----Original Message----- From: NeilBrown [mailto:neilb at suse.com] Sent: Wednesday, August 1, 2018 6:55 AM To: James Simmons ; Andreas Dilger ; Oleg Drokin Cc: Lustre Development List ; Yong, Fan ; James Simmons Subject: Re: [PATCH 30/31] lustre: fid: race between client_fid_fini and seq_client_flush On Mon, Jul 30 2018, James Simmons wrote: > From: Fan Yong > > When the client mount failed or umount, the client_fid_fini() will be > called. At that time, the async connection failure will trigger > seq_client_flush() which parameter may have been released by the > client_fid_fini() by race. > > Introduce client_obd::cl_seq_rwsem to protect client_obd::cl_seq. This looks odd.. I think the cl_seq_rwsem is being used like a refcount on cl_seq, to prevent it from being freed while it is still in use. If I'm correct, then I would much prefer that a refcount was used. Is this more than just a disguised refcount? NeilBrown > > Signed-off-by: Fan Yong > WC-id: https://jira.whamcloud.com/browse/LU-9224 > Reviewed-on: https://review.whamcloud.com/26079 > Reviewed-by: John L. Hammond > Reviewed-by: Andreas Dilger > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/fid/fid_request.c | 21 +++++++++++++++------ > drivers/staging/lustre/lustre/include/obd.h | 1 + > drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 ++ > drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++++++++-- > 4 files changed, 27 insertions(+), 8 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c > b/drivers/staging/lustre/lustre/fid/fid_request.c > index a34fd90..f91242c 100644 > --- a/drivers/staging/lustre/lustre/fid/fid_request.c > +++ b/drivers/staging/lustre/lustre/fid/fid_request.c > @@ -343,11 +343,14 @@ int client_fid_init(struct obd_device *obd, { > struct client_obd *cli = &obd->u.cli; > char *prefix; > - int rc; > + int rc = 0; > > + down_write(&cli->cl_seq_rwsem); > cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS); > - if (!cli->cl_seq) > - return -ENOMEM; > + if (!cli->cl_seq) { > + rc = -ENOMEM; > + goto out_free_lock; > + } > > prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS); > if (!prefix) { > @@ -361,10 +364,14 @@ int client_fid_init(struct obd_device *obd, > seq_client_init(cli->cl_seq, exp, type, prefix); > kfree(prefix); > > - return 0; > out_free_seq: > - kfree(cli->cl_seq); > - cli->cl_seq = NULL; > + if (rc) { > + kfree(cli->cl_seq); > + cli->cl_seq = NULL; > + } > +out_free_lock: > + up_write(&cli->cl_seq_rwsem); > + > return rc; > } > EXPORT_SYMBOL(client_fid_init); > @@ -373,11 +380,13 @@ int client_fid_fini(struct obd_device *obd) { > struct client_obd *cli = &obd->u.cli; > > + down_write(&cli->cl_seq_rwsem); > if (cli->cl_seq) { > seq_client_fini(cli->cl_seq); > kfree(cli->cl_seq); > cli->cl_seq = NULL; > } > + up_write(&cli->cl_seq_rwsem); > > return 0; > } > diff --git a/drivers/staging/lustre/lustre/include/obd.h > b/drivers/staging/lustre/lustre/include/obd.h > index 333c703..3c0dbb6 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -333,6 +333,7 @@ struct client_obd { > > /* sequence manager */ > struct lu_client_seq *cl_seq; > + struct rw_semaphore cl_seq_rwsem; > > atomic_t cl_resends; /* resend count */ > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > index c36d1e4..32eda4f 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c > @@ -308,6 +308,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) > } > > init_rwsem(&cli->cl_sem); > + cli->cl_seq = NULL; > + init_rwsem(&cli->cl_seq_rwsem); > cli->cl_conn_count = 0; > memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2), > min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2), diff --git > a/drivers/staging/lustre/lustre/mdc/mdc_request.c > b/drivers/staging/lustre/lustre/mdc/mdc_request.c > index c2f0a54..a759da2 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c > @@ -2517,8 +2517,10 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, > * Flush current sequence to make client obtain new one > * from server in case of disconnect/reconnect. > */ > + down_read(&cli->cl_seq_rwsem); > if (cli->cl_seq) > seq_client_flush(cli->cl_seq); > + up_read(&cli->cl_seq_rwsem); > > rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE); > break; > @@ -2557,9 +2559,14 @@ int mdc_fid_alloc(const struct lu_env *env, struct obd_export *exp, > struct lu_fid *fid, struct md_op_data *op_data) { > struct client_obd *cli = &exp->exp_obd->u.cli; > - struct lu_client_seq *seq = cli->cl_seq; > + int rc = -EIO; > > - return seq_client_alloc_fid(env, seq, fid); > + down_read(&cli->cl_seq_rwsem); > + if (cli->cl_seq) > + rc = seq_client_alloc_fid(env, cli->cl_seq, fid); > + up_read(&cli->cl_seq_rwsem); > + > + return rc; > } > > static struct obd_uuid *mdc_get_uuid(struct obd_export *exp) > -- > 1.8.3.1 From ashehata at whamcloud.com Wed Aug 1 01:15:04 2018 From: ashehata at whamcloud.com (Amir Shehata) Date: Wed, 1 Aug 2018 01:15:04 +0000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <87sh3zq634.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com>, <87sh3zq634.fsf@notabene.neil.brown.name> Message-ID: <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> Hi Neil, This issue actually came up because of LU-6060, which changed the behavior for LLNL. The behavior then was changed again by LU-6851: https://jira.whamcloud.com/browse/LU-6851 (if you'd like more background) As a result of LU-6851 we were printing the unsigned value of -1. That's why we ended up printing it as -1, which is more bearable than just printing a large unsigned value. I'm not disagreeing that it'll be better to print a clearer value, "unknown" does sound like it relays the correct meaning. However, I've sometimes run into issues where changing user facing interfaces caused problems to user scripts. Would this be the case here, I'm not 100% sure. We can always make the change and then wait for tickets to be opened. However, I think of more concern to me is that if we make changes like this to the upstreamed client, it's probably a good idea to also make them to the whamcloud repo as well, so as not to diverge the client and server (LNet is common between them). This particular case, might not be very significant, but other issues might come up that are of more significance. The code bases are already diverging significantly between the upstream client and the master repo, which makes porting features from master to upstream a difficult task. Do we have a strategy on how to deal with this? thanks amir ________________________________________ From: NeilBrown [neilb at suse.com] Sent: Tuesday, July 31, 2018 5:32 PM To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin Cc: Lustre Development List Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print Hi Amir, thanks for the background. I had to chuckle at "0 being the highest", though I know that this distortion is not something specific to lustre. Your description seems to suggest that "-1" means "unknown" with an implication that the number of hops might be high, and best not to take the risk. Your point about compatability with scripts has some validity, though it is annoying to have to support such ugly interfaces indefinitely. Are there really likely to be dependencies? lustre has only been printing -1 since Feb last year when this patch went upstream. That was presumably an abi change as it would have printed MAXINT-1 previously. Did that cause any problems? Thanks, NeilBrown On Tue, Jul 31 2018, Amir Shehata wrote: > The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. > > In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. > > Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. > > thanks > amir > ________________________________________ > From: NeilBrown [neilb at suse.com] > Sent: Tuesday, July 31, 2018 3:38 PM > To: James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List; Amir Shehata; James Simmons > Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print > > On Mon, Jul 30 2018, James Simmons wrote: > >> From: Amir Shehata >> >> The default number of hops for a route is -1. This is >> currently being printed as %u. Change that to %d to >> make it print out properly. > > -1 hops??? I wish I could hop -1 times - it would be a good party > trick!! > > What does -1 mean? Unlimited (just a guess). If so, could we print > "unlimited"?? > > I'm fine with having magic numbers in the code, but I don't like them to > leak out. > > NeilBrown > >> >> Signed-off-by: Amir Shehata >> WC-id: https://jira.whamcloud.com/browse/LU-9078 >> Reviewed-on: https://review.whamcloud.com/25250 >> Reviewed-by: Olaf Weber >> Reviewed-by: Doug Oucharek >> Reviewed-by: James Simmons >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >> index 8856798..aa98ce5 100644 >> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >> int alive = lnet_is_route_alive(route); >> >> s += snprintf(s, tmpstr + tmpsiz - s, >> - "%-8s %4u %8u %7s %s\n", >> + "%-8s %4d %8u %7s %s\n", >> libcfs_net2str(net), hops, >> priority, >> alive ? "up" : "down", >> -- >> 1.8.3.1 From fan.yong at intel.com Wed Aug 1 04:15:51 2018 From: fan.yong at intel.com (Yong, Fan) Date: Wed, 1 Aug 2018 04:15:51 +0000 Subject: [lustre-devel] [PATCH 30/31] lustre: fid: race between client_fid_fini and seq_client_flush In-Reply-To: <87600urdx1.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-31-git-send-email-jsimmons@infradead.org> <87y3drqalt.fsf@notabene.neil.brown.name> <7FB055E0B36B6F4EB93E637E0640A56FCB68C93C@fmsmsx118.amr.corp.intel.com> <87600urdx1.fsf@notabene.neil.brown.name> Message-ID: <7FB055E0B36B6F4EB93E637E0640A56FCB68D9A1@fmsmsx118.amr.corp.intel.com> >From the logic view, the client_fid_fini() should wait all the client_obd::cl_seq users (in spite of flush() or fid_allocation() or other possible new users in the future) done or abort their things before destroying the client_obd::cl_seq. The rwsem build up the framework for that. > In either case, I cannot see any justification for holding the lock in client_fid_init(). As for holding the rwsem during the initiation, honestly, it is unnecessary since currently there is neither concurrent initialization nor other accessing during the initialization. And just because of no contend on the rwsem, holding such rwsem here will not cause too much overhead. On the other hand, if someone will change the caller logic as to there will be possible concurrent initialization, then we need to hold the rwsem during the initialization instead of atomically assigning it to cli->cl_seq. -- Cheers, Nasf -----Original Message----- From: NeilBrown [mailto:neilb at suse.com] Sent: Wednesday, August 1, 2018 10:58 AM To: Yong, Fan ; James Simmons ; Andreas Dilger ; Oleg Drokin Cc: Lustre Development List ; James Simmons Subject: RE: [PATCH 30/31] lustre: fid: race between client_fid_fini and seq_client_flush On Wed, Aug 01 2018, Yong, Fan wrote: > The client_obd::cl_seq_rwsem protects the client_obd::cl_seq itself, > not the internal members inside client_obd::cl_seq. I do not think > simple refcount can work here. For example, if the client_fid_fini() > is destroying the client_obd::cl_seq, we need some mechanism, such as > the mutex, to pervert others accessing the client_obd::cl_seq. Under > such case, even though someone could acquire refcount (after the > client_fid_fini() start), it still cannot prevent the in-processing > destroy. A common pattern with refcounts is to free the object when the refcount reaches zero. kref_put(&cli->cl_refcount, free_cl_seq(cli)) or similar. So we start with a refcount of 1, the code that currently does 'down_read()' instead does if (kref_get_unless_zero(&cli->cl_refcount)) { do something with cli->cl_seq kref_put(.....); } and client_fid_fini() just does the kref_put(). An important question is whether client_fid_fini() really needs to wait for seq_client_flush() or seq_client_alloc_fid() to complete. If it does, then we probably can't do much better than the rwsem. If it doesn't, then kref_put() is the better way to go. In either case, I cannot see any justification for holding the lock in client_fid_init(). It would be better to completely initialize the lu_client_seq, and then atomically assign it to cli->cl_seq. Thanks, NeilBrown From neilb at suse.com Thu Aug 2 02:09:50 2018 From: neilb at suse.com (NeilBrown) Date: Thu, 02 Aug 2018 12:09:50 +1000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <3C0BF267DA2B2343B6A8D6013E6C43381AAE75@LAX-EX-MB3.datadirect.datadirectnet.com> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> <87sh3zq634.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> <878t5qrea2.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE75@LAX-EX-MB3.datadirect.datadirectnet.com> Message-ID: <87o9elplht.fsf@notabene.neil.brown.name> Once lustre and lnet are part of upstream Linux, what is the value of keeping any of it in the master repo? There would be be a need to keep it only to support old versions of Linux, which will hopefully be less and less over time. It might make sense to backport the upstream-linux code those particular versions where it is needed, and do all development work in upstream Linux, and just backport. NeilBrown On Wed, Aug 01 2018, Amir Shehata wrote: > Hi Neil, > > Thanks for the explanation. > > Speaking specifically for LNet, I'm not sure it's feasible to remove the code from master repo. As I mentioned LNet is a common piece between both the client and server sides. Both of them rely on it. And I believe LNet is also used by DVS, which is a cray developed layer, I'm not very familiar with it. So just deleting it from the master repo I don't think would work. > > Over the past years, there has been discussions about making it a standalone module that can be pulled in as a dependency. This approach makes a bit more sense to me. > > What are your thoughts on that? > > thanks > amir > ________________________________________ > From: NeilBrown [neilb at suse.com] > Sent: Tuesday, July 31, 2018 7:50 PM > To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin > Cc: Lustre Development List > Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print > > Hi Amir, > I think I'm happy to let this slide. I don't like magic numbers, but > this one isn't important enough to justify the problems that might be > caused by changing it. > > To answer your broader question: >> The code bases are already diverging significantly between the >> upstream client and the master repo, which makes porting features from >> master to upstream a difficult task. Do we have a strategy on how to >> deal with this? > > The long term strategy is just to get the work done so that the client > code - and then all the kernel code - can be deleted from the master > repo and can live solely in Linux. I know that is still quite a way > away. > > Shorter term, there are no magic answers. Yes it is difficult but it > is far from impossible. My plan has always been to get the code that > is already in drivers/staging into a reasonable state, then start > forward-porting patches from master. If other people do some of the > forward-porting, that just makes me happier. > If you think there is too much churn in my lustre tree, then just > provide patches based on some old commit - I'm quite happy to receive > patches based on fairly old code, and to do the final steps of > forward-porting/conflict resolution myself (I have lots of practice). > > NeilBrown > > > On Wed, Aug 01 2018, Amir Shehata wrote: > >> Hi Neil, >> >> This issue actually came up because of LU-6060, which changed the behavior for LLNL. The behavior then was changed again by LU-6851: https://jira.whamcloud.com/browse/LU-6851 (if you'd like more background) >> >> As a result of LU-6851 we were printing the unsigned value of -1. That's why we ended up printing it as -1, which is more bearable than just printing a large unsigned value. >> >> I'm not disagreeing that it'll be better to print a clearer value, "unknown" does sound like it relays the correct meaning. However, I've sometimes run into issues where changing user facing interfaces caused problems to user scripts. Would this be the case here, I'm not 100% sure. We can always make the change and then wait for tickets to be opened. >> >> However, I think of more concern to me is that if we make changes like this to the upstreamed client, it's probably a good idea to also make them to the whamcloud repo as well, so as not to diverge the client and server (LNet is common between them). This particular case, might not be very significant, but other issues might come up that are of more significance. >> >> The code bases are already diverging significantly between the upstream client and the master repo, which makes porting features from master to upstream a difficult task. Do we have a strategy on how to deal with this? >> >> thanks >> amir >> ________________________________________ >> From: NeilBrown [neilb at suse.com] >> Sent: Tuesday, July 31, 2018 5:32 PM >> To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List >> Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print >> >> Hi Amir, >> thanks for the background. >> >> I had to chuckle at "0 being the highest", though I know that this >> distortion is not something specific to lustre. >> >> Your description seems to suggest that "-1" means "unknown" with an >> implication that the number of hops might be high, and best not to take >> the risk. >> >> Your point about compatability with scripts has some validity, though >> it is annoying to have to support such ugly interfaces indefinitely. >> Are there really likely to be dependencies? lustre has only been >> printing -1 since Feb last year when this patch went upstream. >> That was presumably an abi change as it would have printed MAXINT-1 >> previously. Did that cause any problems? >> >> Thanks, >> NeilBrown >> >> >> On Tue, Jul 31 2018, Amir Shehata wrote: >> >>> The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. >>> >>> In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. >>> >>> Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. >>> >>> thanks >>> amir >>> ________________________________________ >>> From: NeilBrown [neilb at suse.com] >>> Sent: Tuesday, July 31, 2018 3:38 PM >>> To: James Simmons; Andreas Dilger; Oleg Drokin >>> Cc: Lustre Development List; Amir Shehata; James Simmons >>> Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print >>> >>> On Mon, Jul 30 2018, James Simmons wrote: >>> >>>> From: Amir Shehata >>>> >>>> The default number of hops for a route is -1. This is >>>> currently being printed as %u. Change that to %d to >>>> make it print out properly. >>> >>> -1 hops??? I wish I could hop -1 times - it would be a good party >>> trick!! >>> >>> What does -1 mean? Unlimited (just a guess). If so, could we print >>> "unlimited"?? >>> >>> I'm fine with having magic numbers in the code, but I don't like them to >>> leak out. >>> >>> NeilBrown >>> >>>> >>>> Signed-off-by: Amir Shehata >>>> WC-id: https://jira.whamcloud.com/browse/LU-9078 >>>> Reviewed-on: https://review.whamcloud.com/25250 >>>> Reviewed-by: Olaf Weber >>>> Reviewed-by: Doug Oucharek >>>> Reviewed-by: James Simmons >>>> Reviewed-by: Oleg Drokin >>>> Signed-off-by: James Simmons >>>> --- >>>> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >>>> index 8856798..aa98ce5 100644 >>>> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >>>> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >>>> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >>>> int alive = lnet_is_route_alive(route); >>>> >>>> s += snprintf(s, tmpstr + tmpsiz - s, >>>> - "%-8s %4u %8u %7s %s\n", >>>> + "%-8s %4d %8u %7s %s\n", >>>> libcfs_net2str(net), hops, >>>> priority, >>>> alive ? "up" : "down", >>>> -- >>>> 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: From jsimmons at infradead.org Thu Aug 2 02:49:51 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:49:51 +0100 (BST) Subject: [lustre-devel] [PATCH 10/22] Revert "staging: lustre: lnet: conrpc: Use list_for_each_entry_safe" In-Reply-To: <153292186099.13840.6595803769201521471.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186099.13840.6595803769201521471.stgit@noble> Message-ID: > This reverts commit a9a6cb4f4693253349358f8163d826eb0cfecfbc. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. > > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c > index 95cbd1a14e1b..3afde0141db5 100644 > --- a/drivers/staging/lustre/lnet/selftest/conrpc.c > +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c > @@ -1327,7 +1327,6 @@ lstcon_rpc_cleanup_wait(void) > { > struct lstcon_rpc_trans *trans; > struct lstcon_rpc *crpc; > - struct lstcon_rpc *temp; > struct list_head *pacer; > struct list_head zlist; > > @@ -1367,7 +1366,9 @@ lstcon_rpc_cleanup_wait(void) > > spin_unlock(&console_session.ses_rpc_lock); > > - list_for_each_entry_safe(crpc, temp, &zlist, crp_link) { > + while (!list_empty(&zlist)) { > + crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link); > + Nak. This one needs to be updated to. The typedef lstcon_rpc_t no longer exist. Now you need to use struct lstcon_rpc. > list_del(&crpc->crp_link); > kfree(crpc); > } > > > From jsimmons at infradead.org Thu Aug 2 02:52:58 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:52:58 +0100 (BST) Subject: [lustre-devel] [PATCH 01/22] Revert "staging: lustre: lnet: api-ni: Use list_for_each_entry_safe" In-Reply-To: <153292186042.13840.10901014935265304451.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186042.13840.10901014935265304451.stgit@noble> Message-ID: > This reverts commit c997866cd27495ae28bc07596457e2bd83fb3275. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. In this case, the first loop is > currently buggy. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/api-ni.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index d21bceeaceda..51a81075f8d5 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -1077,17 +1077,18 @@ lnet_clear_zombies_nis_locked(void) > int i; > int islo; > struct lnet_ni *ni; > - struct lnet_ni *temp; > > /* > * Now wait for the NI's I just nuked to show up on ln_zombie_nis > * and shut them down in guaranteed thread context > */ > i = 2; > - list_for_each_entry_safe(ni, temp, &the_lnet.ln_nis_zombie, ni_list) { > + while (!list_empty(&the_lnet.ln_nis_zombie)) { > int *ref; > int j; > > + ni = list_entry(the_lnet.ln_nis_zombie.next, > + struct lnet_ni, ni_list); > list_del_init(&ni->ni_list); > cfs_percpt_for_each(ref, j, ni->ni_refs) { > if (!*ref) > @@ -1137,7 +1138,6 @@ static void > lnet_shutdown_lndnis(void) > { > struct lnet_ni *ni; > - struct lnet_ni *temp; > int i; > > /* NB called holding the global mutex */ > @@ -1151,7 +1151,9 @@ lnet_shutdown_lndnis(void) > the_lnet.ln_shutdown = 1; /* flag shutdown */ > > /* Unlink NIs from the global table */ > - list_for_each_entry_safe(ni, temp, &the_lnet.ln_nis, ni_list) { > + while (!list_empty(&the_lnet.ln_nis)) { > + ni = list_entry(the_lnet.ln_nis.next, > + struct lnet_ni, ni_list); > lnet_ni_unlink_locked(ni); > } > > > > From jsimmons at infradead.org Thu Aug 2 02:53:31 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:53:31 +0100 (BST) Subject: [lustre-devel] [PATCH 02/22] Revert "staging: lustre: o2iblnd: Use list_for_each_entry_safe in kiblnd_destroy_fmr_pool_list" In-Reply-To: <153292186069.13840.6426045683936468910.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186069.13840.6426045683936468910.stgit@noble> Message-ID: > This reverts commit 0d33ec5f95fe068d7e96b6e7ed9216de93f6b5b0. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. > Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 05835cc0f0a5..124870ada28b 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1306,9 +1306,10 @@ static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) > > static void kiblnd_destroy_fmr_pool_list(struct list_head *head) > { > - struct kib_fmr_pool *fpo, *tmp; > + struct kib_fmr_pool *fpo; > > - list_for_each_entry_safe(fpo, tmp, head, fpo_list) { > + while (!list_empty(head)) { > + fpo = list_entry(head->next, struct kib_fmr_pool, fpo_list); > list_del(&fpo->fpo_list); > kiblnd_destroy_fmr_pool(fpo); > } > > > From jsimmons at infradead.org Thu Aug 2 02:53:57 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:53:57 +0100 (BST) Subject: [lustre-devel] [PATCH 03/22] Revert "staging: lustre: lnet: o2iblnd: Use list_for_each_entry_safe" In-Reply-To: <153292186073.13840.10228341482615967034.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186073.13840.10228341482615967034.stgit@noble> Message-ID: > This reverts commit 995ae68c30a5d4947f7685f29b1e69b436ddcdb3. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > index a5ef4cc6c04f..9cf1f64e3d76 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > @@ -3185,7 +3185,6 @@ kiblnd_check_conns(int idx) > struct list_head *ptmp; > struct kib_peer *peer; > struct kib_conn *conn; > - struct kib_conn *temp; > struct kib_conn *tmp; > struct list_head *ctmp; > unsigned long flags; > @@ -3253,7 +3252,8 @@ kiblnd_check_conns(int idx) > * NOOP, but there were no non-blocking tx descs > * free to do it last time... > */ > - list_for_each_entry_safe(conn, temp, &checksends, ibc_connd_list) { > + while (!list_empty(&checksends)) { > + conn = list_entry(checksends.next, struct kib_conn, ibc_connd_list); > list_del(&conn->ibc_connd_list); > > spin_lock(&conn->ibc_lock); > > > From jsimmons at infradead.org Thu Aug 2 02:54:33 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:54:33 +0100 (BST) Subject: [lustre-devel] [PATCH 04/22] Revert "staging: lustre: lnet: socklnd: Use list_for_each_entry_safe" In-Reply-To: <153292186077.13840.2365613926140981649.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186077.13840.2365613926140981649.stgit@noble> Message-ID: > This reverts commit 2aff15d43a832cd0af0263e4456e5b01e15f86c6. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 6b1df0c98cbd..a48b1b9a850b 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1546,7 +1546,6 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) > { > struct ksock_peer *peer = conn->ksnc_peer; > struct ksock_tx *tx; > - struct ksock_tx *temp; > struct ksock_tx *tmp; > LIST_HEAD(zlist); > > @@ -1572,7 +1571,9 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) > > spin_unlock(&peer->ksnp_lock); > > - list_for_each_entry_safe(tx, temp, &zlist, tx_zc_list) { > + while (!list_empty(&zlist)) { > + tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); > + > list_del(&tx->tx_zc_list); > ksocknal_tx_decref(tx); > } > @@ -2270,13 +2271,13 @@ ksocknal_free_buffers(void) > if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { > struct list_head zlist; > struct ksock_tx *tx; > - struct ksock_tx *temp; > > list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs); > list_del_init(&ksocknal_data.ksnd_idle_noop_txs); > spin_unlock(&ksocknal_data.ksnd_tx_lock); > > - list_for_each_entry_safe(tx, temp, &zlist, tx_list) { > + while (!list_empty(&zlist)) { > + tx = list_entry(zlist.next, struct ksock_tx, tx_list); > list_del(&tx->tx_list); > kfree(tx); > } > > > From jsimmons at infradead.org Thu Aug 2 02:56:24 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:56:24 +0100 (BST) Subject: [lustre-devel] [PATCH 04/22] Revert "staging: lustre: lnet: socklnd: Use list_for_each_entry_safe" In-Reply-To: <153292186077.13840.2365613926140981649.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186077.13840.2365613926140981649.stgit@noble> Message-ID: > This reverts commit 2aff15d43a832cd0af0263e4456e5b01e15f86c6. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 6b1df0c98cbd..a48b1b9a850b 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1546,7 +1546,6 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) > { > struct ksock_peer *peer = conn->ksnc_peer; > struct ksock_tx *tx; > - struct ksock_tx *temp; > struct ksock_tx *tmp; > LIST_HEAD(zlist); > > @@ -1572,7 +1571,9 @@ ksocknal_finalize_zcreq(struct ksock_conn *conn) > > spin_unlock(&peer->ksnp_lock); > > - list_for_each_entry_safe(tx, temp, &zlist, tx_zc_list) { > + while (!list_empty(&zlist)) { > + tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); > + > list_del(&tx->tx_zc_list); > ksocknal_tx_decref(tx); > } > @@ -2270,13 +2271,13 @@ ksocknal_free_buffers(void) > if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { > struct list_head zlist; > struct ksock_tx *tx; > - struct ksock_tx *temp; > > list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs); > list_del_init(&ksocknal_data.ksnd_idle_noop_txs); > spin_unlock(&ksocknal_data.ksnd_tx_lock); > > - list_for_each_entry_safe(tx, temp, &zlist, tx_list) { > + while (!list_empty(&zlist)) { > + tx = list_entry(zlist.next, struct ksock_tx, tx_list); > list_del(&tx->tx_list); > kfree(tx); > } > > > From jsimmons at infradead.org Thu Aug 2 02:56:48 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:56:48 +0100 (BST) Subject: [lustre-devel] [PATCH 05/22] Revert "staging: lustre: lnet: socklnd_proto: Use list_for_each_entry_safe" In-Reply-To: <153292186081.13840.4047441745421559567.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186081.13840.4047441745421559567.stgit@noble> Message-ID: > This reverts commit 1edae04ff85fe65a333949de6101578c015a21fa. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > index aaa04a5f0527..abfaf5701758 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > @@ -413,7 +413,6 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2) > { > struct ksock_peer *peer = conn->ksnc_peer; > struct ksock_tx *tx; > - struct ksock_tx *temp; > struct ksock_tx *tmp; > LIST_HEAD(zlist); > int count; > @@ -448,7 +447,8 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2) > > spin_unlock(&peer->ksnp_lock); > > - list_for_each_entry_safe(tx, temp, &zlist, tx_zc_list) { > + while (!list_empty(&zlist)) { > + tx = list_entry(zlist.next, struct ksock_tx, tx_zc_list); > list_del(&tx->tx_zc_list); > ksocknal_tx_decref(tx); > } > > > From jsimmons at infradead.org Thu Aug 2 02:57:15 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 03:57:15 +0100 (BST) Subject: [lustre-devel] [PATCH 06/22] Revert "staging: lustre: osc_cache: Use list_for_each_entry_safe" In-Reply-To: <153292186084.13840.7272276537169852360.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186084.13840.7272276537169852360.stgit@noble> Message-ID: > This reverts commit 4a81ce53a61c72afb079c096599a5d34749b9dd7. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/osc/osc_cache.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c > index 15a48173e148..87d0d16d942b 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_cache.c > +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c > @@ -2060,7 +2060,6 @@ static unsigned int get_write_extents(struct osc_object *obj, > { > struct client_obd *cli = osc_cli(obj); > struct osc_extent *ext; > - struct osc_extent *temp; > struct extent_rpc_data data = { > .erd_rpc_list = rpclist, > .erd_page_count = 0, > @@ -2070,7 +2069,9 @@ static unsigned int get_write_extents(struct osc_object *obj, > }; > > LASSERT(osc_object_is_locked(obj)); > - list_for_each_entry_safe(ext, temp, &obj->oo_hp_exts, oe_link) { > + while (!list_empty(&obj->oo_hp_exts)) { > + ext = list_entry(obj->oo_hp_exts.next, struct osc_extent, > + oe_link); > LASSERT(ext->oe_state == OES_CACHE); > if (!try_to_add_extent_for_io(cli, ext, &data)) > return data.erd_page_count; > @@ -2829,7 +2830,6 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, > { > struct client_obd *cli = osc_cli(obj); > struct osc_extent *ext; > - struct osc_extent *temp; > struct osc_extent *waiting = NULL; > pgoff_t index; > LIST_HEAD(list); > @@ -2888,9 +2888,10 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, > > osc_list_maint(cli, obj); > > - list_for_each_entry_safe(ext, temp, &list, oe_link) { > + while (!list_empty(&list)) { > int rc; > > + ext = list_entry(list.next, struct osc_extent, oe_link); > list_del_init(&ext->oe_link); > > /* extent may be in OES_ACTIVE state because inode mutex > > > From jsimmons at infradead.org Thu Aug 2 03:03:55 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:03:55 +0100 (BST) Subject: [lustre-devel] [PATCH 07/22] Revert "staging: lustre: lnet: peer: Use list_for_each_entry_safe" In-Reply-To: <153292186088.13840.12536228855978938054.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186088.13840.12536228855978938054.stgit@noble> Message-ID: > This reverts commit 3e47a1cfba5a8af7dc3c10a4705d8047abdc26c3. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/peer.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index 6ce175d77d0f..7c303ef6bb34 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -176,7 +176,6 @@ lnet_peer_tables_cleanup(struct lnet_ni *ni) > struct lnet_peer_table *ptable; > struct list_head deathrow; > struct lnet_peer *lp; > - struct lnet_peer *temp; > int i; > > INIT_LIST_HEAD(&deathrow); > @@ -210,7 +209,8 @@ lnet_peer_tables_cleanup(struct lnet_ni *ni) > lnet_net_unlock(i); > } > > - list_for_each_entry_safe(lp, temp, &deathrow, lp_hashlist) { > + while (!list_empty(&deathrow)) { > + lp = list_entry(deathrow.next, struct lnet_peer, lp_hashlist); > list_del(&lp->lp_hashlist); > kfree(lp); > } > > > From jsimmons at infradead.org Thu Aug 2 03:04:18 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:04:18 +0100 (BST) Subject: [lustre-devel] [PATCH 08/22] Revert "staging: lustre: lnet: config: Use list_for_each_entry_safe" In-Reply-To: <153292186091.13840.114221205536468808.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186091.13840.114221205536468808.stgit@noble> Message-ID: > This reverts commit cb734cf73eaed9b9bb7f190cceaafc15af0d8815. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/config.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index 136905db2746..26b799e66e53 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -1026,7 +1026,6 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip) > struct list_head *t; > struct list_head *t2; > struct lnet_text_buf *tb; > - struct lnet_text_buf *temp; > struct lnet_text_buf *tb2; > __u32 net1; > __u32 net2; > @@ -1049,7 +1048,9 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip) > len = 0; > rc = 0; > > - list_for_each_entry_safe(tb, temp, &raw_entries, ltb_list) { > + while (!list_empty(&raw_entries)) { > + tb = list_entry(raw_entries.next, struct lnet_text_buf, > + ltb_list); > strncpy(source, tb->ltb_text, sizeof(source)); > source[sizeof(source) - 1] = '\0'; > > > > From jsimmons at infradead.org Thu Aug 2 03:04:56 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:04:56 +0100 (BST) Subject: [lustre-devel] [PATCH 09/22] Revert "staging: lustre: lnet: router: Use list_for_each_entry_safe" In-Reply-To: <153292186096.13840.6296110306335811050.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186096.13840.6296110306335811050.stgit@noble> Message-ID: > This reverts commit 37cce1bcb750ac12773f1c53afe88a8433f53eb3. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/router.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 3f84df6cb3b1..965087b7359c 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -1340,7 +1340,6 @@ lnet_rtrpool_free_bufs(struct lnet_rtrbufpool *rbp, int cpt) > int npages = rbp->rbp_npages; > struct list_head tmp; > struct lnet_rtrbuf *rb; > - struct lnet_rtrbuf *temp; > > if (!rbp->rbp_nbuffers) /* not initialized or already freed */ > return; > @@ -1357,7 +1356,8 @@ lnet_rtrpool_free_bufs(struct lnet_rtrbufpool *rbp, int cpt) > lnet_net_unlock(cpt); > > /* Free buffers on the free list. */ > - list_for_each_entry_safe(rb, temp, &tmp, rb_list) { > + while (!list_empty(&tmp)) { > + rb = list_entry(tmp.next, struct lnet_rtrbuf, rb_list); > list_del(&rb->rb_list); > lnet_destroy_rtrbuf(rb, npages); > } > > > From jsimmons at infradead.org Thu Aug 2 03:05:30 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:05:30 +0100 (BST) Subject: [lustre-devel] [PATCH 10/22] Revert "staging: lustre: lnet: conrpc: Use list_for_each_entry_safe" In-Reply-To: <153292186099.13840.6595803769201521471.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186099.13840.6595803769201521471.stgit@noble> Message-ID: > This reverts commit a9a6cb4f4693253349358f8163d826eb0cfecfbc. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c > index 95cbd1a14e1b..3afde0141db5 100644 > --- a/drivers/staging/lustre/lnet/selftest/conrpc.c > +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c > @@ -1327,7 +1327,6 @@ lstcon_rpc_cleanup_wait(void) > { > struct lstcon_rpc_trans *trans; > struct lstcon_rpc *crpc; > - struct lstcon_rpc *temp; > struct list_head *pacer; > struct list_head zlist; > > @@ -1367,7 +1366,9 @@ lstcon_rpc_cleanup_wait(void) > > spin_unlock(&console_session.ses_rpc_lock); > > - list_for_each_entry_safe(crpc, temp, &zlist, crp_link) { > + while (!list_empty(&zlist)) { > + crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link); > + > list_del(&crpc->crp_link); > kfree(crpc); > } > > > From jsimmons at infradead.org Thu Aug 2 03:05:55 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:05:55 +0100 (BST) Subject: [lustre-devel] [PATCH 11/22] Revert "staging: lustre: lnet: lib-move: Use list_for_each_entry_safe" In-Reply-To: <153292186104.13840.12696227873574036682.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186104.13840.12696227873574036682.stgit@noble> Message-ID: > This reverts commit 24f695909440b79b04bb75205384c9772e4c7d0a. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/lib-move.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index e8092b1b6b27..2756e91b34bb 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -49,7 +49,6 @@ int > lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) > { > struct lnet_test_peer *tp; > - struct lnet_test_peer *temp; > struct list_head *el; > struct list_head *next; > struct list_head cull; > @@ -88,7 +87,9 @@ lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) > > lnet_net_unlock(0); > > - list_for_each_entry_safe(tp, temp, &cull, tp_list) { > + while (!list_empty(&cull)) { > + tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > + > list_del(&tp->tp_list); > kfree(tp); > } > @@ -99,7 +100,6 @@ static int > fail_peer(lnet_nid_t nid, int outgoing) > { > struct lnet_test_peer *tp; > - struct lnet_test_peer *temp; > struct list_head *el; > struct list_head *next; > struct list_head cull; > @@ -146,7 +146,8 @@ fail_peer(lnet_nid_t nid, int outgoing) > > lnet_net_unlock(0); > > - list_for_each_entry_safe(tp, temp, &cull, tp_list) { > + while (!list_empty(&cull)) { > + tp = list_entry(cull.next, struct lnet_test_peer, tp_list); > list_del(&tp->tp_list); > > kfree(tp); > > > From jsimmons at infradead.org Thu Aug 2 03:06:31 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:06:31 +0100 (BST) Subject: [lustre-devel] [PATCH 12/22] Revert "staging: lustre: obdclass: Use list_for_each_entry_safe" In-Reply-To: <153292186108.13840.4929208218603720715.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186108.13840.4929208218603720715.stgit@noble> Message-ID: > This reverts commit 6069f756d42160e454f49286183712514db3ca6b. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c > index e286a2665423..7fc62b7e95b4 100644 > --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c > +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c > @@ -146,7 +146,6 @@ int class_del_uuid(const char *uuid) > { > LIST_HEAD(deathrow); > struct uuid_nid_data *data; > - struct uuid_nid_data *temp; > > spin_lock(&g_uuid_lock); > if (uuid) { > @@ -169,7 +168,9 @@ int class_del_uuid(const char *uuid) > return -EINVAL; > } > > - list_for_each_entry_safe(data, temp, &deathrow, un_list) { > + while (!list_empty(&deathrow)) { > + data = list_entry(deathrow.next, struct uuid_nid_data, > + un_list); > list_del(&data->un_list); > > CDEBUG(D_INFO, "del uuid %s %s/%d\n", > > > From jsimmons at infradead.org Thu Aug 2 03:06:56 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:06:56 +0100 (BST) Subject: [lustre-devel] [PATCH 13/22] Revert "staging: lustre: lnet: Use list_for_each_entry_safe" In-Reply-To: <153292186113.13840.10926881392361029642.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186113.13840.10926881392361029642.stgit@noble> Message-ID: > This reverts commit 0daec763260e4f0d8038512b72971ddbcf1c63a1. > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > index 3f69618ad85b..d531847305e4 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > @@ -2260,12 +2260,13 @@ static inline void > ksocknal_flush_stale_txs(struct ksock_peer *peer) > { > struct ksock_tx *tx; > - struct ksock_tx *tmp; > LIST_HEAD(stale_txs); > > write_lock_bh(&ksocknal_data.ksnd_global_lock); > > - list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) { > + while (!list_empty(&peer->ksnp_tx_queue)) { > + tx = list_entry(peer->ksnp_tx_queue.next, struct ksock_tx, tx_list); > + > if (ktime_get_seconds() < tx->tx_deadline) > break; > > > > From jsimmons at infradead.org Thu Aug 2 03:07:17 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:07:17 +0100 (BST) Subject: [lustre-devel] [PATCH 14/22] Revert: Staging: lustre: Iterate list using list_for_each_entry In-Reply-To: <153292186117.13840.9041811734708835901.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186117.13840.9041811734708835901.stgit@noble> Message-ID: > This reverts (what is left of) 5a2ca43fa54f561c252c2ceb986daa49e258ab13 > > These loops really want to remove everything, and using a > while(!list_empty()) > loop makes this more obvious. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > index 9cf1f64e3d76..bda67d49597d 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > @@ -2106,7 +2106,6 @@ kiblnd_connreq_done(struct kib_conn *conn, int status) > { > struct kib_peer *peer = conn->ibc_peer; > struct kib_tx *tx; > - struct kib_tx *tmp; > struct list_head txs; > unsigned long flags; > int active; > @@ -2197,7 +2196,8 @@ kiblnd_connreq_done(struct kib_conn *conn, int status) > * scheduled. We won't be using round robin on this first batch. > */ > spin_lock(&conn->ibc_lock); > - list_for_each_entry_safe(tx, tmp, &txs, tx_list) { > + while (!list_empty(&txs)) { > + tx = list_first_entry(&txs, struct kib_tx, tx_list); > list_del(&tx->tx_list); > > kiblnd_queue_tx_locked(tx, conn); > @@ -3185,7 +3185,6 @@ kiblnd_check_conns(int idx) > struct list_head *ptmp; > struct kib_peer *peer; > struct kib_conn *conn; > - struct kib_conn *tmp; > struct list_head *ctmp; > unsigned long flags; > > @@ -3241,7 +3240,8 @@ kiblnd_check_conns(int idx) > * connection. We can only be sure RDMA activity > * has ceased once the QP has been modified. > */ > - list_for_each_entry_safe(conn, tmp, &closes, ibc_connd_list) { > + while (!list_empty(&closes)) { > + conn = list_first_entry(&closes, struct kib_conn, ibc_connd_list); > list_del(&conn->ibc_connd_list); > kiblnd_close_conn(conn, -ETIMEDOUT); > kiblnd_conn_decref(conn); > > > From jsimmons at infradead.org Thu Aug 2 03:07:41 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:07:41 +0100 (BST) Subject: [lustre-devel] [PATCH 15/22] lustre: o2iblnd: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186122.13840.1195251525324756487.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186122.13840.1195251525324756487.stgit@noble> Message-ID: > These loops are removing all element from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 124870ada28b..830a5bf34c16 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1283,11 +1283,13 @@ static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) > if (fpo->fmr.fpo_fmr_pool) > ib_destroy_fmr_pool(fpo->fmr.fpo_fmr_pool); > } else { > - struct kib_fast_reg_descriptor *frd, *tmp; > + struct kib_fast_reg_descriptor *frd; > int i = 0; > > - list_for_each_entry_safe(frd, tmp, &fpo->fast_reg.fpo_pool_list, > - frd_list) { > + while (!list_empty(&fpo->fast_reg.fpo_pool_list)) { > + frd = list_first_entry(&fpo->fast_reg.fpo_pool_list, > + struct kib_fast_reg_descriptor, > + frd_list); > list_del(&frd->frd_list); > ib_dereg_mr(frd->frd_mr); > kfree(frd); > @@ -1362,7 +1364,7 @@ static int kiblnd_alloc_fmr_pool(struct kib_fmr_poolset *fps, struct kib_fmr_poo > > static int kiblnd_alloc_freg_pool(struct kib_fmr_poolset *fps, struct kib_fmr_pool *fpo) > { > - struct kib_fast_reg_descriptor *frd, *tmp; > + struct kib_fast_reg_descriptor *frd; > int i, rc; > > INIT_LIST_HEAD(&fpo->fast_reg.fpo_pool_list); > @@ -1399,8 +1401,10 @@ static int kiblnd_alloc_freg_pool(struct kib_fmr_poolset *fps, struct kib_fmr_po > kfree(frd); > > out: > - list_for_each_entry_safe(frd, tmp, &fpo->fast_reg.fpo_pool_list, > - frd_list) { > + while (!list_empty(&fpo->fast_reg.fpo_pool_list)) { > + frd = list_first_entry(&fpo->fast_reg.fpo_pool_list, > + struct kib_fast_reg_descriptor, > + frd_list); > list_del(&frd->frd_list); > ib_dereg_mr(frd->frd_mr); > kfree(frd); > > > From jsimmons at infradead.org Thu Aug 2 03:08:13 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:08:13 +0100 (BST) Subject: [lustre-devel] [PATCH 16/22] lustre: tracefile: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186126.13840.13964285941561581566.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186126.13840.13964285941561581566.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/tracefile.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c > index 07242d4ed41b..a4768e930021 100644 > --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c > +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c > @@ -896,11 +896,12 @@ void cfs_trace_flush_pages(void) > { > struct page_collection pc; > struct cfs_trace_page *tage; > - struct cfs_trace_page *tmp; > > pc.pc_want_daemon_pages = 1; > collect_pages(&pc); > - list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) { > + while (!list_empty(&pc.pc_pages)) { > + tage = list_first_entry(&pc.pc_pages, > + struct cfs_trace_page, linkage); > __LASSERT_TAGE_INVARIANT(tage); > > list_del(&tage->linkage); > @@ -1331,7 +1332,6 @@ static void trace_cleanup_on_all_cpus(void) > { > struct cfs_trace_cpu_data *tcd; > struct cfs_trace_page *tage; > - struct cfs_trace_page *tmp; > int i, cpu; > > for_each_possible_cpu(cpu) { > @@ -1341,8 +1341,10 @@ static void trace_cleanup_on_all_cpus(void) > continue; > tcd->tcd_shutting_down = 1; > > - list_for_each_entry_safe(tage, tmp, &tcd->tcd_pages, > - linkage) { > + while (!list_empty(&tcd->tcd_pages)) { > + tage = list_first_entry(&tcd->tcd_pages, > + struct cfs_trace_page, > + linkage); > __LASSERT_TAGE_INVARIANT(tage); > > list_del(&tage->linkage); > > > From jsimmons at infradead.org Thu Aug 2 03:08:43 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:08:43 +0100 (BST) Subject: [lustre-devel] [PATCH 17/22] lustre: lib-move: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186130.13840.15403228991288155064.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186130.13840.15403228991288155064.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/lib-move.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 2756e91b34bb..19cab374b6bc 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -853,7 +853,6 @@ lnet_drop_routed_msgs_locked(struct list_head *list, int cpt) > { > struct list_head drop; > struct lnet_msg *msg; > - struct lnet_msg *tmp; > > INIT_LIST_HEAD(&drop); > > @@ -861,7 +860,8 @@ lnet_drop_routed_msgs_locked(struct list_head *list, int cpt) > > lnet_net_unlock(cpt); > > - list_for_each_entry_safe(msg, tmp, &drop, msg_list) { > + while(!list_empty(&drop)) { > + msg = list_first_entry(&drop, struct lnet_msg, msg_list); > lnet_ni_recv(msg->msg_rxpeer->lp_ni, msg->msg_private, NULL, > 0, 0, 0, msg->msg_hdr.payload_length); > list_del_init(&msg->msg_list); > > > From jsimmons at infradead.org Thu Aug 2 03:09:09 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:09:09 +0100 (BST) Subject: [lustre-devel] [PATCH 18/22] lustre: net_fault: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186135.13840.3626019723821443531.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186135.13840.3626019723821443531.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/net_fault.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c > index cb1f9053ef48..41d6131ee15a 100644 > --- a/drivers/staging/lustre/lnet/lnet/net_fault.c > +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c > @@ -216,7 +216,8 @@ lnet_drop_rule_del(lnet_nid_t src, lnet_nid_t dst) > } > lnet_net_unlock(LNET_LOCK_EX); > > - list_for_each_entry_safe(rule, tmp, &zombies, dr_link) { > + while (!list_empty(&zombies)) { > + rule = list_first_entry(&zombies, struct lnet_drop_rule, dr_link); > CDEBUG(D_NET, "Remove drop rule: src %s->dst: %s (1/%d, %d)\n", > libcfs_nid2str(rule->dr_attr.fa_src), > libcfs_nid2str(rule->dr_attr.fa_dst), > @@ -841,7 +842,9 @@ lnet_delay_rule_del(lnet_nid_t src, lnet_nid_t dst, bool shutdown) > !list_empty(&rule_list); > lnet_net_unlock(LNET_LOCK_EX); > > - list_for_each_entry_safe(rule, tmp, &rule_list, dl_link) { > + while (!list_empty(&rule_list)) { > + rule = list_first_entry(&rule_list, > + struct lnet_delay_rule, dl_link); > list_del_init(&rule->dl_link); > > del_timer_sync(&rule->dl_timer); > > > From jsimmons at infradead.org Thu Aug 2 03:09:34 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:09:34 +0100 (BST) Subject: [lustre-devel] [PATCH 19/22] lustre: fld_request: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186139.13840.14587588638167610162.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186139.13840.14587588638167610162.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. > Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/fld/fld_request.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c > index 97f7ea632346..7b0365b3e413 100644 > --- a/drivers/staging/lustre/lustre/fld/fld_request.c > +++ b/drivers/staging/lustre/lustre/fld/fld_request.c > @@ -280,10 +280,12 @@ EXPORT_SYMBOL(fld_client_init); > > void fld_client_fini(struct lu_client_fld *fld) > { > - struct lu_fld_target *target, *tmp; > + struct lu_fld_target *target; > > spin_lock(&fld->lcf_lock); > - list_for_each_entry_safe(target, tmp, &fld->lcf_targets, ft_chain) { > + while (!list_empty(&fld->lcf_targets)) { > + target = list_first_entry(&fld->lcf_targets, > + struct lu_fld_target, ft_chain); > fld->lcf_count--; > list_del(&target->ft_chain); > if (target->ft_exp) > > > From jsimmons at infradead.org Thu Aug 2 03:09:55 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:09:55 +0100 (BST) Subject: [lustre-devel] [PATCH 20/22] lustre: lov_obd: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186143.13840.16227510388221165130.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186143.13840.16227510388221165130.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/lov/lov_obd.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c > index ee0898cbd9c9..0dd471cfe9a1 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_obd.c > +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c > @@ -83,7 +83,7 @@ static void lov_putref(struct obd_device *obd) > if (atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) { > LIST_HEAD(kill); > int i; > - struct lov_tgt_desc *tgt, *n; > + struct lov_tgt_desc *tgt; > > CDEBUG(D_CONFIG, "destroying %d lov targets\n", > lov->lov_death_row); > @@ -103,7 +103,8 @@ static void lov_putref(struct obd_device *obd) > } > mutex_unlock(&lov->lov_lock); > > - list_for_each_entry_safe(tgt, n, &kill, ltd_kill) { > + while (!list_empty(&kill)) { > + tgt = list_first_entry(&kill, struct lov_tgt_desc, ltd_kill); > list_del(&tgt->ltd_kill); > /* Disconnect */ > __lov_del_obd(obd, tgt); > > > From jsimmons at infradead.org Thu Aug 2 03:10:15 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:10:15 +0100 (BST) Subject: [lustre-devel] [PATCH 21/22] lustre: ldlm_request: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186147.13840.314584204805282590.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186147.13840.314584204805282590.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > index cdc52eed6d85..80260b07f0f0 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > @@ -2000,7 +2000,7 @@ int ldlm_replay_locks(struct obd_import *imp) > { > struct ldlm_namespace *ns = imp->imp_obd->obd_namespace; > LIST_HEAD(list); > - struct ldlm_lock *lock, *next; > + struct ldlm_lock *lock; > int rc = 0; > > LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); > @@ -2017,7 +2017,9 @@ int ldlm_replay_locks(struct obd_import *imp) > > ldlm_namespace_foreach(ns, ldlm_chain_lock_for_replay, &list); > > - list_for_each_entry_safe(lock, next, &list, l_pending_chain) { > + while (!list_empty(&list)) { > + lock = list_first_entry(&list, struct ldlm_lock, > + l_pending_chain); > list_del_init(&lock->l_pending_chain); > if (rc) { > LDLM_LOCK_RELEASE(lock); > > > From jsimmons at infradead.org Thu Aug 2 03:10:34 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:10:34 +0100 (BST) Subject: [lustre-devel] [PATCH 22/22] lustre: sec_config: convert list_for_each_entry_safe() to while(!list_empty()) In-Reply-To: <153292186151.13840.8095964948258952076.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186151.13840.8095964948258952076.stgit@noble> Message-ID: > These loops are removing all elements from a list. > So using while(!list_empty()) makes the intent clearer. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > index 2389f9a8f534..1844ada6780f 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c > @@ -839,12 +839,13 @@ int sptlrpc_conf_init(void) > > void sptlrpc_conf_fini(void) > { > - struct sptlrpc_conf *conf, *conf_next; > + struct sptlrpc_conf *conf; > > mutex_lock(&sptlrpc_conf_lock); > - list_for_each_entry_safe(conf, conf_next, &sptlrpc_confs, sc_list) { > + while (!list_empty(&sptlrpc_confs)) { > + conf = list_first_entry(&sptlrpc_confs, > + struct sptlrpc_conf, sc_list); > sptlrpc_conf_free(conf); > } > - LASSERT(list_empty(&sptlrpc_confs)); > mutex_unlock(&sptlrpc_conf_lock); > } > > > From jsimmons at infradead.org Thu Aug 2 03:12:10 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:12:10 +0100 (BST) Subject: [lustre-devel] [PATCH 00/22] Lustre: use while loop when emptying a list In-Reply-To: <153292153459.13840.17465048403476297915.stgit@noble> References: <153292153459.13840.17465048403476297915.stgit@noble> Message-ID: > If you have a list that needs to be emptied, it is best to have a loop > like > while (!list_empty(...)) > > because then it is obvious what the purpose of the loop is. > Many places in lustre use > list_for_each_entry_safe() > instead, which obscures the purpose. > Several of these were from patches which deliberately converted from > the while loop the list list_for_each_entry_safe() loop, at least some > of which introduced real bugs. > > This series reverts all those patches, and then makes other > conversions. > There are still several places which could be converted, but I got > bored... > I've particularly converted all where the list_head is a local > variable. In these cases it is obviously wrong not to empty the > list completely. > > For those conversions that I did manual (not reverts) I use > list_first_entry() > to get the first entry, rather then list_entry(head->next). > Others could be converted as well. So much heart burn with these patches. Nice to see them reverted. I have tested this patch series but I like Doug or another Lnet to review these patches as well. > > NeilBrown > > > --- > > NeilBrown (22): > Revert "staging: lustre: lnet: api-ni: Use list_for_each_entry_safe" > Revert "staging: lustre: o2iblnd: Use list_for_each_entry_safe in kiblnd_destroy_fmr_pool_list" > Revert "staging: lustre: lnet: o2iblnd: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: socklnd: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: socklnd_proto: Use list_for_each_entry_safe" > Revert "staging: lustre: osc_cache: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: peer: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: config: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: router: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: conrpc: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: lib-move: Use list_for_each_entry_safe" > Revert "staging: lustre: obdclass: Use list_for_each_entry_safe" > Revert "staging: lustre: lnet: Use list_for_each_entry_safe" > Revert: Staging: lustre: Iterate list using list_for_each_entry > lustre: o2iblnd: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: tracefile: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: lib-move: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: net_fault: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: fld_request: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: lov_obd: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: ldlm_request: convert list_for_each_entry_safe() to while(!list_empty()) > lustre: sec_config: convert list_for_each_entry_safe() to while(!list_empty()) > > > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 21 ++++++++++++-------- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 12 ++++++----- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 9 +++++---- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 5 +++-- > .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 4 ++-- > drivers/staging/lustre/lnet/libcfs/tracefile.c | 12 +++++++---- > drivers/staging/lustre/lnet/lnet/api-ni.c | 10 ++++++---- > drivers/staging/lustre/lnet/lnet/config.c | 5 +++-- > drivers/staging/lustre/lnet/lnet/lib-move.c | 13 +++++++----- > drivers/staging/lustre/lnet/lnet/net_fault.c | 7 +++++-- > drivers/staging/lustre/lnet/lnet/peer.c | 4 ++-- > drivers/staging/lustre/lnet/lnet/router.c | 4 ++-- > drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +++-- > drivers/staging/lustre/lustre/fld/fld_request.c | 6 ++++-- > drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 6 ++++-- > drivers/staging/lustre/lustre/lov/lov_obd.c | 5 +++-- > .../staging/lustre/lustre/obdclass/lustre_peer.c | 5 +++-- > drivers/staging/lustre/lustre/osc/osc_cache.c | 9 +++++---- > drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 7 ++++--- > 19 files changed, 87 insertions(+), 62 deletions(-) > > -- > Signature > > From jsimmons at infradead.org Thu Aug 2 03:12:46 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:12:46 +0100 (BST) Subject: [lustre-devel] [PATCH 1/6] lustre: convert list_for_each() to list_for_each_entry(). In-Reply-To: <153292233953.26104.11218548856426762220.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233953.26104.11218548856426762220.stgit@noble> Message-ID: On Mon, 30 Jul 2018, NeilBrown wrote: > Where we have > struct list_head *tmp; > list_for_each(tmp,....) { > foo = list_entry(tmp, ....); > ... > } > > convert to > list_for_each_entry(foo, .....) { > ..... > } > > This patch only changes instances which are straight forward, where > neither the 'tmp' variable nor the 'foo' variable is not used outside > the loop in any way that isn't trivially correct. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 17 ++----- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 20 ++------ > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 51 +++++--------------- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 20 ++------ > drivers/staging/lustre/lnet/lnet/api-ni.c | 29 ++--------- > drivers/staging/lustre/lnet/lnet/config.c | 17 ++----- > drivers/staging/lustre/lnet/lnet/lib-move.c | 9 +--- > drivers/staging/lustre/lnet/lnet/router.c | 47 ++++-------------- > drivers/staging/lustre/lnet/selftest/conrpc.c | 7 +-- > drivers/staging/lustre/lustre/obdclass/genops.c | 4 -- > .../staging/lustre/lustre/obdecho/echo_client.c | 4 -- > 11 files changed, 53 insertions(+), 172 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 830a5bf34c16..e15ad94151bd 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -386,11 +386,9 @@ struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid) > * that this creates > */ > struct list_head *peer_list = kiblnd_nid2peerlist(nid); > - struct list_head *tmp; > struct kib_peer *peer; > > - list_for_each(tmp, peer_list) { > - peer = list_entry(tmp, struct kib_peer, ibp_list); > + list_for_each_entry(peer, peer_list, ibp_list) { > LASSERT(!kiblnd_peer_idle(peer)); > > if (peer->ibp_nid != nid) > @@ -419,15 +417,13 @@ static int kiblnd_get_peer_info(struct lnet_ni *ni, int index, > lnet_nid_t *nidp, int *count) > { > struct kib_peer *peer; > - struct list_head *ptmp; > int i; > unsigned long flags; > > read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > > for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) { > - list_for_each(ptmp, &kiblnd_data.kib_peers[i]) { > - peer = list_entry(ptmp, struct kib_peer, ibp_list); > + list_for_each_entry(peer, &kiblnd_data.kib_peers[i], ibp_list) { > LASSERT(!kiblnd_peer_idle(peer)); > > if (peer->ibp_ni != ni) > @@ -526,28 +522,23 @@ static int kiblnd_del_peer(struct lnet_ni *ni, lnet_nid_t nid) > static struct kib_conn *kiblnd_get_conn_by_idx(struct lnet_ni *ni, int index) > { > struct kib_peer *peer; > - struct list_head *ptmp; > struct kib_conn *conn; > - struct list_head *ctmp; > int i; > unsigned long flags; > > read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > > for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) { > - list_for_each(ptmp, &kiblnd_data.kib_peers[i]) { > - peer = list_entry(ptmp, struct kib_peer, ibp_list); > + list_for_each_entry(peer, &kiblnd_data.kib_peers[i], ibp_list) { > LASSERT(!kiblnd_peer_idle(peer)); > > if (peer->ibp_ni != ni) > continue; > > - list_for_each(ctmp, &peer->ibp_conns) { > + list_for_each_entry(conn, &peer->ibp_conns, ibc_list) { > if (index-- > 0) > continue; > > - conn = list_entry(ctmp, struct kib_conn, > - ibc_list); > kiblnd_conn_addref(conn); > read_unlock_irqrestore( > &kiblnd_data.kib_global_lock, > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > index bda67d49597d..2f7a64f2f13a 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > @@ -225,11 +225,9 @@ kiblnd_post_rx(struct kib_rx *rx, int credit) > static struct kib_tx * > kiblnd_find_waiting_tx_locked(struct kib_conn *conn, int txtype, __u64 cookie) > { > - struct list_head *tmp; > - > - list_for_each(tmp, &conn->ibc_active_txs) { > - struct kib_tx *tx = list_entry(tmp, struct kib_tx, tx_list); > + struct kib_tx *tx; > > + list_for_each_entry(tx, &conn->ibc_active_txs, tx_list) { > LASSERT(!tx->tx_queued); > LASSERT(tx->tx_sending || tx->tx_waiting); > > @@ -3142,11 +3140,8 @@ static int > kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs) > { > struct kib_tx *tx; > - struct list_head *ttmp; > - > - list_for_each(ttmp, txs) { > - tx = list_entry(ttmp, struct kib_tx, tx_list); > > + list_for_each_entry(tx, txs, tx_list) { > if (txs != &conn->ibc_active_txs) { > LASSERT(tx->tx_queued); > } else { > @@ -3182,10 +3177,8 @@ kiblnd_check_conns(int idx) > LIST_HEAD(closes); > LIST_HEAD(checksends); > struct list_head *peers = &kiblnd_data.kib_peers[idx]; > - struct list_head *ptmp; > struct kib_peer *peer; > struct kib_conn *conn; > - struct list_head *ctmp; > unsigned long flags; > > /* > @@ -3195,15 +3188,12 @@ kiblnd_check_conns(int idx) > */ > read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > > - list_for_each(ptmp, peers) { > - peer = list_entry(ptmp, struct kib_peer, ibp_list); > + list_for_each_entry(peer, peers, ibp_list) { > > - list_for_each(ctmp, &peer->ibp_conns) { > + list_for_each_entry(conn, &peer->ibp_conns, ibc_list) { > int timedout; > int sendnoop; > > - conn = list_entry(ctmp, struct kib_conn, ibc_list); > - > LASSERT(conn->ibc_state == IBLND_CONN_ESTABLISHED); > > spin_lock(&conn->ibc_lock); > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index a48b1b9a850b..491d2ed5b673 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -250,9 +250,7 @@ ksocknal_get_peer_info(struct lnet_ni *ni, int index, > int *port, int *conn_count, int *share_count) > { > struct ksock_peer *peer; > - struct list_head *ptmp; > struct ksock_route *route; > - struct list_head *rtmp; > int i; > int j; > int rc = -ENOENT; > @@ -260,8 +258,7 @@ ksocknal_get_peer_info(struct lnet_ni *ni, int index, > read_lock(&ksocknal_data.ksnd_global_lock); > > for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { > - list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { > - peer = list_entry(ptmp, struct ksock_peer, ksnp_list); > + list_for_each_entry(peer, &ksocknal_data.ksnd_peers[i], ksnp_list) { > > if (peer->ksnp_ni != ni) > continue; > @@ -295,13 +292,11 @@ ksocknal_get_peer_info(struct lnet_ni *ni, int index, > goto out; > } > > - list_for_each(rtmp, &peer->ksnp_routes) { > + list_for_each_entry(route, &peer->ksnp_routes, > + ksnr_list) { > if (index-- > 0) > continue; > > - route = list_entry(rtmp, struct ksock_route, > - ksnr_list); > - > *id = peer->ksnp_id; > *myip = route->ksnr_myipaddr; > *peer_ip = route->ksnr_ipaddr; > @@ -368,7 +363,6 @@ ksocknal_associate_route_conn_locked(struct ksock_route *route, > static void > ksocknal_add_route_locked(struct ksock_peer *peer, struct ksock_route *route) > { > - struct list_head *tmp; > struct ksock_conn *conn; > struct ksock_route *route2; > > @@ -379,9 +373,7 @@ ksocknal_add_route_locked(struct ksock_peer *peer, struct ksock_route *route) > LASSERT(!route->ksnr_connected); > > /* LASSERT(unique) */ > - list_for_each(tmp, &peer->ksnp_routes) { > - route2 = list_entry(tmp, struct ksock_route, ksnr_list); > - > + list_for_each_entry(route2, &peer->ksnp_routes, ksnr_list) { > if (route2->ksnr_ipaddr == route->ksnr_ipaddr) { > CERROR("Duplicate route %s %pI4h\n", > libcfs_id2str(peer->ksnp_id), > @@ -395,9 +387,7 @@ ksocknal_add_route_locked(struct ksock_peer *peer, struct ksock_route *route) > /* peer's routelist takes over my ref on 'route' */ > list_add_tail(&route->ksnr_list, &peer->ksnp_routes); > > - list_for_each(tmp, &peer->ksnp_conns) { > - conn = list_entry(tmp, struct ksock_conn, ksnc_list); > - > + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { > if (conn->ksnc_ipaddr != route->ksnr_ipaddr) > continue; > > @@ -624,28 +614,22 @@ static struct ksock_conn * > ksocknal_get_conn_by_idx(struct lnet_ni *ni, int index) > { > struct ksock_peer *peer; > - struct list_head *ptmp; > struct ksock_conn *conn; > - struct list_head *ctmp; > int i; > > read_lock(&ksocknal_data.ksnd_global_lock); > > for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { > - list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { > - peer = list_entry(ptmp, struct ksock_peer, ksnp_list); > - > + list_for_each_entry(peer, &ksocknal_data.ksnd_peers[i], ksnp_list) { > LASSERT(!peer->ksnp_closing); > > if (peer->ksnp_ni != ni) > continue; > > - list_for_each(ctmp, &peer->ksnp_conns) { > + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { > if (index-- > 0) > continue; > > - conn = list_entry(ctmp, struct ksock_conn, > - ksnc_list); > ksocknal_conn_addref(conn); > read_unlock(&ksocknal_data.ksnd_global_lock); > return conn; > @@ -1025,7 +1009,6 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, > rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; > LIST_HEAD(zombies); > struct lnet_process_id peerid; > - struct list_head *tmp; > __u64 incarnation; > struct ksock_conn *conn; > struct ksock_conn *conn2; > @@ -1226,8 +1209,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, > * loopback connection > */ > if (conn->ksnc_ipaddr != conn->ksnc_myipaddr) { > - list_for_each(tmp, &peer->ksnp_conns) { > - conn2 = list_entry(tmp, struct ksock_conn, ksnc_list); > + list_for_each_entry(conn2, &peer->ksnp_conns, ksnc_list) { > > if (conn2->ksnc_ipaddr != conn->ksnc_ipaddr || > conn2->ksnc_myipaddr != conn->ksnc_myipaddr || > @@ -1266,9 +1248,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, > * by routes in my peer to match my own route entries so I don't > * continually create duplicate routes. > */ > - list_for_each(tmp, &peer->ksnp_routes) { > - route = list_entry(tmp, struct ksock_route, ksnr_list); > - > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { > if (route->ksnr_ipaddr != conn->ksnc_ipaddr) > continue; > > @@ -1980,9 +1960,7 @@ ksocknal_add_interface(struct lnet_ni *ni, __u32 ipaddress, __u32 netmask) > int rc; > int i; > int j; > - struct list_head *ptmp; > struct ksock_peer *peer; > - struct list_head *rtmp; > struct ksock_route *route; > > if (!ipaddress || !netmask) > @@ -2005,18 +1983,15 @@ ksocknal_add_interface(struct lnet_ni *ni, __u32 ipaddress, __u32 netmask) > iface->ksni_npeers = 0; > > for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { > - list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { > - peer = list_entry(ptmp, struct ksock_peer, > - ksnp_list); > + list_for_each_entry(peer, &ksocknal_data.ksnd_peers[i], > + ksnp_list) { > > for (j = 0; j < peer->ksnp_n_passive_ips; j++) > if (peer->ksnp_passive_ips[j] == ipaddress) > iface->ksni_npeers++; > > - list_for_each(rtmp, &peer->ksnp_routes) { > - route = list_entry(rtmp, struct ksock_route, > - ksnr_list); > - > + list_for_each_entry(route, &peer->ksnp_routes, > + ksnr_list) { > if (route->ksnr_myipaddr == ipaddress) > iface->ksni_nroutes++; > } > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > index d531847305e4..a5c0e8a9bc40 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > @@ -561,18 +561,16 @@ struct ksock_conn * > ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx, > int nonblk) > { > - struct list_head *tmp; > + struct ksock_conn *c; > struct ksock_conn *conn; > struct ksock_conn *typed = NULL; > struct ksock_conn *fallback = NULL; > int tnob = 0; > int fnob = 0; > > - list_for_each(tmp, &peer->ksnp_conns) { > - struct ksock_conn *c; > + list_for_each_entry(c, &peer->ksnp_conns, ksnc_list) { > int nob, rc; > > - c = list_entry(tmp, struct ksock_conn, ksnc_list); > nob = atomic_read(&c->ksnc_tx_nob) + > c->ksnc_sock->sk->sk_wmem_queued; > > @@ -729,12 +727,9 @@ struct ksock_route * > ksocknal_find_connectable_route_locked(struct ksock_peer *peer) > { > time64_t now = ktime_get_seconds(); > - struct list_head *tmp; > struct ksock_route *route; > > - list_for_each(tmp, &peer->ksnp_routes) { > - route = list_entry(tmp, struct ksock_route, ksnr_list); > - > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { > LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); > > /* connections being established */ > @@ -765,11 +760,9 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer) > struct ksock_route * > ksocknal_find_connecting_route_locked(struct ksock_peer *peer) > { > - struct list_head *tmp; > struct ksock_route *route; > > - list_for_each(tmp, &peer->ksnp_routes) { > - route = list_entry(tmp, struct ksock_route, ksnr_list); > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { > > LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); > > @@ -2180,13 +2173,10 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer) > { > /* We're called with a shared lock on ksnd_global_lock */ > struct ksock_conn *conn; > - struct list_head *ctmp; > > - list_for_each(ctmp, &peer->ksnp_conns) { > + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { > int error; > > - conn = list_entry(ctmp, struct ksock_conn, ksnc_list); > - > /* Don't need the {get,put}connsock dance to deref ksnc_sock */ > LASSERT(!conn->ksnc_closing); > > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 51a81075f8d5..14b797802a85 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -269,12 +269,9 @@ static struct lnet_lnd * > lnet_find_lnd_by_type(__u32 type) > { > struct lnet_lnd *lnd; > - struct list_head *tmp; > > /* holding lnd mutex */ > - list_for_each(tmp, &the_lnet.ln_lnds) { > - lnd = list_entry(tmp, struct lnet_lnd, lnd_list); > - > + list_for_each_entry(lnd, &the_lnet.ln_lnds, lnd_list) { > if (lnd->lnd_type == type) > return lnd; > } > @@ -653,14 +650,11 @@ lnet_unprepare(void) > struct lnet_ni * > lnet_net2ni_locked(__u32 net, int cpt) > { > - struct list_head *tmp; > struct lnet_ni *ni; > > LASSERT(cpt != LNET_LOCK_EX); > > - list_for_each(tmp, &the_lnet.ln_nis) { > - ni = list_entry(tmp, struct lnet_ni, ni_list); > - > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (LNET_NIDNET(ni->ni_nid) == net) { > lnet_ni_addref_locked(ni, cpt); > return ni; > @@ -767,13 +761,10 @@ struct lnet_ni * > lnet_nid2ni_locked(lnet_nid_t nid, int cpt) > { > struct lnet_ni *ni; > - struct list_head *tmp; > > LASSERT(cpt != LNET_LOCK_EX); > > - list_for_each(tmp, &the_lnet.ln_nis) { > - ni = list_entry(tmp, struct lnet_ni, ni_list); > - > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (ni->ni_nid == nid) { > lnet_ni_addref_locked(ni, cpt); > return ni; > @@ -803,14 +794,11 @@ lnet_count_acceptor_nis(void) > { > /* Return the # of NIs that need the acceptor. */ > int count = 0; > - struct list_head *tmp; > struct lnet_ni *ni; > int cpt; > > cpt = lnet_net_lock_current(); > - list_for_each(tmp, &the_lnet.ln_nis) { > - ni = list_entry(tmp, struct lnet_ni, ni_list); > - > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (ni->ni_lnd->lnd_accept) > count++; > } > @@ -1731,18 +1719,16 @@ static int > lnet_get_net_config(struct lnet_ioctl_config_data *config) > { > struct lnet_ni *ni; > - struct list_head *tmp; > int idx = config->cfg_count; > int cpt, i = 0; > int rc = -ENOENT; > > cpt = lnet_net_lock_current(); > > - list_for_each(tmp, &the_lnet.ln_nis) { > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (i++ != idx) > continue; > > - ni = list_entry(tmp, struct lnet_ni, ni_list); > lnet_ni_lock(ni); > lnet_fill_ni_info(ni, config); > lnet_ni_unlock(ni); > @@ -2119,7 +2105,6 @@ int > LNetGetId(unsigned int index, struct lnet_process_id *id) > { > struct lnet_ni *ni; > - struct list_head *tmp; > int cpt; > int rc = -ENOENT; > > @@ -2127,12 +2112,10 @@ LNetGetId(unsigned int index, struct lnet_process_id *id) > > cpt = lnet_net_lock_current(); > > - list_for_each(tmp, &the_lnet.ln_nis) { > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (index--) > continue; > > - ni = list_entry(tmp, struct lnet_ni, ni_list); > - > id->nid = ni->ni_nid; > id->pid = the_lnet.ln_pid; > rc = 0; > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index 26b799e66e53..96336ecdacaf 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -81,12 +81,9 @@ lnet_issep(char c) > int > lnet_net_unique(__u32 net, struct list_head *nilist) > { > - struct list_head *tmp; > struct lnet_ni *ni; > > - list_for_each(tmp, nilist) { > - ni = list_entry(tmp, struct lnet_ni, ni_list); > - > + list_for_each_entry(ni, nilist, ni_list) { > if (LNET_NIDNET(ni->ni_nid) == net) > return 0; > } > @@ -942,7 +939,6 @@ lnet_splitnets(char *source, struct list_head *nets) > int len; > struct lnet_text_buf *tb; > struct lnet_text_buf *tb2; > - struct list_head *t; > char *sep; > char *bracket; > __u32 net; > @@ -983,9 +979,7 @@ lnet_splitnets(char *source, struct list_head *nets) > return -EINVAL; > } > > - list_for_each(t, nets) { > - tb2 = list_entry(t, struct lnet_text_buf, ltb_list); > - > + list_for_each_entry(tb2, nets, ltb_list) { > if (tb2 == tb) > continue; > > @@ -1074,14 +1068,11 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip) > break; > > dup = 0; > - list_for_each(t, ¤t_nets) { > - tb = list_entry(t, struct lnet_text_buf, ltb_list); > + list_for_each_entry(tb, ¤t_nets, ltb_list) { > net1 = lnet_netspec2net(tb->ltb_text); > LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY)); > > - list_for_each(t2, &matched_nets) { > - tb2 = list_entry(t2, struct lnet_text_buf, > - ltb_list); > + list_for_each_entry(tb2, &matched_nets, ltb_list) { > net2 = lnet_netspec2net(tb2->ltb_text); > LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY)); > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 19cab374b6bc..edcafac055ed 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -2288,7 +2288,6 @@ EXPORT_SYMBOL(LNetGet); > int > LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) > { > - struct list_head *e; > struct lnet_ni *ni; > struct lnet_remotenet *rnet; > __u32 dstnet = LNET_NIDNET(dstnid); > @@ -2307,9 +2306,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) > > cpt = lnet_net_lock_current(); > > - list_for_each(e, &the_lnet.ln_nis) { > - ni = list_entry(e, struct lnet_ni, ni_list); > - > + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { > if (ni->ni_nid == dstnid) { > if (srcnidp) > *srcnidp = dstnid; > @@ -2346,9 +2343,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp) > } > > rn_list = lnet_net2rnethash(dstnet); > - list_for_each(e, rn_list) { > - rnet = list_entry(e, struct lnet_remotenet, lrn_list); > - > + list_for_each_entry(rnet, rn_list, lrn_list) { > if (rnet->lrn_net == dstnet) { > struct lnet_route *route; > struct lnet_route *shortest = NULL; > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 965087b7359c..53373372b526 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -292,10 +292,10 @@ int > lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, > unsigned int priority) > { > - struct list_head *e; > struct lnet_remotenet *rnet; > struct lnet_remotenet *rnet2; > struct lnet_route *route; > + struct lnet_route *route2; > struct lnet_ni *ni; > int add_route; > int rc; > @@ -359,10 +359,8 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, > > /* Search for a duplicate route (it's a NOOP if it is) */ > add_route = 1; > - list_for_each(e, &rnet2->lrn_routes) { > - struct lnet_route *route2; > + list_for_each_entry(route2, &rnet2->lrn_routes, lr_list) { > > - route2 = list_entry(e, struct lnet_route, lr_list); > if (route2->lr_gateway == route->lr_gateway) { > add_route = 0; > break; > @@ -411,8 +409,6 @@ lnet_check_routes(void) > struct lnet_remotenet *rnet; > struct lnet_route *route; > struct lnet_route *route2; > - struct list_head *e1; > - struct list_head *e2; > int cpt; > struct list_head *rn_list; > int i; > @@ -421,17 +417,13 @@ lnet_check_routes(void) > > for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) { > rn_list = &the_lnet.ln_remote_nets_hash[i]; > - list_for_each(e1, rn_list) { > - rnet = list_entry(e1, struct lnet_remotenet, lrn_list); > - > + list_for_each_entry(rnet, rn_list, lrn_list) { > route2 = NULL; > - list_for_each(e2, &rnet->lrn_routes) { > + list_for_each_entry(route, &rnet->lrn_routes, lr_list) { > lnet_nid_t nid1; > lnet_nid_t nid2; > int net; > > - route = list_entry(e2, struct lnet_route, lr_list); > - > if (!route2) { > route2 = route; > continue; > @@ -466,8 +458,6 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) > struct lnet_peer *gateway; > struct lnet_remotenet *rnet; > struct lnet_route *route; > - struct list_head *e1; > - struct list_head *e2; > int rc = -ENOENT; > struct list_head *rn_list; > int idx = 0; > @@ -486,16 +476,12 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) > rn_list = lnet_net2rnethash(net); > > again: > - list_for_each(e1, rn_list) { > - rnet = list_entry(e1, struct lnet_remotenet, lrn_list); > - > + list_for_each_entry(rnet, rn_list, lrn_list) { > if (!(net == LNET_NIDNET(LNET_NID_ANY) || > net == rnet->lrn_net)) > continue; > > - list_for_each(e2, &rnet->lrn_routes) { > - route = list_entry(e2, struct lnet_route, lr_list); > - > + list_for_each_entry(route, &rnet->lrn_routes, lr_list) { > gateway = route->lr_gateway; > if (!(gw_nid == LNET_NID_ANY || > gw_nid == gateway->lp_nid)) > @@ -576,8 +562,6 @@ int > lnet_get_route(int idx, __u32 *net, __u32 *hops, > lnet_nid_t *gateway, __u32 *alive, __u32 *priority) > { > - struct list_head *e1; > - struct list_head *e2; > struct lnet_remotenet *rnet; > struct lnet_route *route; > int cpt; > @@ -588,13 +572,8 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, > > for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) { > rn_list = &the_lnet.ln_remote_nets_hash[i]; > - list_for_each(e1, rn_list) { > - rnet = list_entry(e1, struct lnet_remotenet, lrn_list); > - > - list_for_each(e2, &rnet->lrn_routes) { > - route = list_entry(e2, struct lnet_route, > - lr_list); > - > + list_for_each_entry(rnet, rn_list, lrn_list) { > + list_for_each_entry(route, &rnet->lrn_routes, lr_list) { > if (!idx--) { > *net = rnet->lrn_net; > *hops = route->lr_hops; > @@ -784,7 +763,6 @@ static void > lnet_wait_known_routerstate(void) > { > struct lnet_peer *rtr; > - struct list_head *entry; > int all_known; > > LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING); > @@ -793,9 +771,7 @@ lnet_wait_known_routerstate(void) > int cpt = lnet_net_lock_current(); > > all_known = 1; > - list_for_each(entry, &the_lnet.ln_routers) { > - rtr = list_entry(entry, struct lnet_peer, lp_rtr_list); > - > + list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) { > if (!rtr->lp_alive_count) { > all_known = 0; > break; > @@ -1223,7 +1199,6 @@ static int > lnet_router_checker(void *arg) > { > struct lnet_peer *rtr; > - struct list_head *entry; > > while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) { > __u64 version; > @@ -1234,9 +1209,7 @@ lnet_router_checker(void *arg) > rescan: > version = the_lnet.ln_routers_version; > > - list_for_each(entry, &the_lnet.ln_routers) { > - rtr = list_entry(entry, struct lnet_peer, lp_rtr_list); > - > + list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) { > cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid); > if (cpt != cpt2) { > lnet_net_unlock(cpt); > diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c > index 3afde0141db5..e73b956d15e4 100644 > --- a/drivers/staging/lustre/lnet/selftest/conrpc.c > +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c > @@ -1327,7 +1327,6 @@ lstcon_rpc_cleanup_wait(void) > { > struct lstcon_rpc_trans *trans; > struct lstcon_rpc *crpc; > - struct list_head *pacer; > struct list_head zlist; > > /* Called with hold of global mutex */ > @@ -1335,10 +1334,8 @@ lstcon_rpc_cleanup_wait(void) > LASSERT(console_session.ses_shutdown); > > while (!list_empty(&console_session.ses_trans_list)) { > - list_for_each(pacer, &console_session.ses_trans_list) { > - trans = list_entry(pacer, struct lstcon_rpc_trans, > - tas_link); > - > + list_for_each_entry(trans, &console_session.ses_trans_list, > + tas_link) { > CDEBUG(D_NET, "Session closed, wakeup transaction %s\n", > lstcon_rpc_trans_name(trans->tas_opc)); > > diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c > index 234f383ce6d9..8454b4470b8c 100644 > --- a/drivers/staging/lustre/lustre/obdclass/genops.c > +++ b/drivers/staging/lustre/lustre/obdclass/genops.c > @@ -84,12 +84,10 @@ static void obd_device_free(struct obd_device *obd) > > static struct obd_type *class_search_type(const char *name) > { > - struct list_head *tmp; > struct obd_type *type; > > spin_lock(&obd_types_lock); > - list_for_each(tmp, &obd_types) { > - type = list_entry(tmp, struct obd_type, typ_chain); > + list_for_each_entry(type, &obd_types, typ_chain) { > if (strcmp(type->typ_name, name) == 0) { > spin_unlock(&obd_types_lock); > return type; > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c > index 484b8d6db6ef..3022706c6985 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c > +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c > @@ -950,12 +950,10 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, > { > struct echo_client_obd *ec = ed->ed_ec; > struct echo_lock *ecl = NULL; > - struct list_head *el; > int found = 0, still_used = 0; > > spin_lock(&ec->ec_lock); > - list_for_each(el, &ec->ec_locks) { > - ecl = list_entry(el, struct echo_lock, el_chain); > + list_for_each_entry(ecl, &ec->ec_locks, el_chain) { > CDEBUG(D_INFO, "ecl: %p, cookie: %#llx\n", ecl, ecl->el_cookie); > found = (ecl->el_cookie == cookie); > if (found) { > > > From jsimmons at infradead.org Thu Aug 2 03:13:09 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:13:09 +0100 (BST) Subject: [lustre-devel] [PATCH 2/6] lustre: lnet/config: convert list_for_each to list_for_each_entry In-Reply-To: <153292233958.26104.10972399803477314475.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233958.26104.10972399803477314475.stgit@noble> Message-ID: > This conversion to list_for_each_entry isn't quite trivial > as the 'tmp' loop variables are used elsewhere in the function. > This means we cannot just delete them, and so must inspect the > code to ensure the values aren't used elsewhere - they aren't. > > Also we need to introduce new loop variables: ltb1 and ltb2 as > the lnet_text_buf was the some for both the original (nested) loops. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/config.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index 96336ecdacaf..091c4f714e84 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -662,6 +662,7 @@ lnet_parse_route(char *str, int *im_a_router) > __u32 net; > lnet_nid_t nid; > struct lnet_text_buf *ltb; > + struct lnet_text_buf *ltb1, *ltb2; > int rc; > char *sep; > char *token = str; > @@ -760,14 +761,12 @@ lnet_parse_route(char *str, int *im_a_router) > LASSERT(!list_empty(&nets)); > LASSERT(!list_empty(&gateways)); > > - list_for_each(tmp1, &nets) { > - ltb = list_entry(tmp1, struct lnet_text_buf, ltb_list); > - net = libcfs_str2net(ltb->ltb_text); > + list_for_each_entry(ltb1, &nets, ltb_list) { > + net = libcfs_str2net(ltb1->ltb_text); > LASSERT(net != LNET_NIDNET(LNET_NID_ANY)); > > - list_for_each(tmp2, &gateways) { > - ltb = list_entry(tmp2, struct lnet_text_buf, ltb_list); > - nid = libcfs_str2nid(ltb->ltb_text); > + list_for_each_entry(ltb2, &gateways, ltb_list) { > + nid = libcfs_str2nid(ltb2->ltb_text); > LASSERT(nid != LNET_NID_ANY); > > if (lnet_islocalnid(nid)) { > > > From jsimmons at infradead.org Thu Aug 2 03:13:32 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:13:32 +0100 (BST) Subject: [lustre-devel] [PATCH 3/6] lustre: convert list_for_each in ksocknal_create_routes In-Reply-To: <153292233962.26104.2678883514539213796.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233962.26104.2678883514539213796.stgit@noble> Message-ID: > The two list_for_each() loops in ksocknal_create_routes() cannot be > trivially converted to list_for_each_entry() as the new loop variable > is expected to be NULL after the loop, if the loop completed normally. > > If the loop did not complete normally - if an interesting entry was > found - a 'continue' is required in the higher level loop. Change > this 'continue' to a 'goto' so it can be called in the inner loop, and > we don't need to check for a variable being NULL. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 29 +++++--------------- > 1 file changed, 7 insertions(+), 22 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 491d2ed5b673..f495e0faeac4 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -846,7 +846,6 @@ ksocknal_create_routes(struct ksock_peer *peer, int port, > rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; > struct lnet_ni *ni = peer->ksnp_ni; > struct ksock_net *net = ni->ni_data; > - struct list_head *rtmp; > struct ksock_route *route; > struct ksock_interface *iface; > struct ksock_interface *best_iface; > @@ -894,17 +893,9 @@ ksocknal_create_routes(struct ksock_peer *peer, int port, > } > > /* Already got a route? */ > - route = NULL; > - list_for_each(rtmp, &peer->ksnp_routes) { > - route = list_entry(rtmp, struct ksock_route, ksnr_list); > - > - if (route->ksnr_ipaddr == newroute->ksnr_ipaddr) > - break; > - > - route = NULL; > - } > - if (route) > - continue; > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) > + if (route->ksnr_ipaddr != newroute->ksnr_ipaddr) > + goto next_ipaddr; > > best_iface = NULL; > best_nroutes = 0; > @@ -917,17 +908,9 @@ ksocknal_create_routes(struct ksock_peer *peer, int port, > iface = &net->ksnn_interfaces[j]; > > /* Using this interface already? */ > - list_for_each(rtmp, &peer->ksnp_routes) { > - route = list_entry(rtmp, struct ksock_route, > - ksnr_list); > - > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) > if (route->ksnr_myipaddr == iface->ksni_ipaddr) > - break; > - > - route = NULL; > - } > - if (route) > - continue; > + goto next_iface; > > this_netmatch = (!((iface->ksni_ipaddr ^ > newroute->ksnr_ipaddr) & > @@ -942,6 +925,7 @@ ksocknal_create_routes(struct ksock_peer *peer, int port, > best_iface = iface; > best_netmatch = this_netmatch; > best_nroutes = iface->ksni_nroutes; > + next_iface:; > } > > if (!best_iface) > @@ -952,6 +936,7 @@ ksocknal_create_routes(struct ksock_peer *peer, int port, > > ksocknal_add_route_locked(peer, newroute); > newroute = NULL; > + next_ipaddr:; > } > > write_unlock_bh(global_lock); > > > From jsimmons at infradead.org Thu Aug 2 03:13:54 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:13:54 +0100 (BST) Subject: [lustre-devel] [PATCH 4/6] lustre: convert list_for_each in ksocknal_close_conn_locked() In-Reply-To: <153292233965.26104.17508687927758478856.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233965.26104.17508687927758478856.stgit@noble> Message-ID: > The use of list_for_each in ksocknal_close_conn_locked() cannot be > trivially converted to list_for_each_entry() as the new > loop variable has NULL tests outside the loop. > > Change these to use a goto inside the loop. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index f495e0faeac4..ea95bff79996 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1402,7 +1402,6 @@ ksocknal_close_conn_locked(struct ksock_conn *conn, int error) > struct ksock_peer *peer = conn->ksnc_peer; > struct ksock_route *route; > struct ksock_conn *conn2; > - struct list_head *tmp; > > LASSERT(!peer->ksnp_error); > LASSERT(!conn->ksnc_closing); > @@ -1417,19 +1416,13 @@ ksocknal_close_conn_locked(struct ksock_conn *conn, int error) > LASSERT(!route->ksnr_deleted); > LASSERT(route->ksnr_connected & (1 << conn->ksnc_type)); > > - conn2 = NULL; > - list_for_each(tmp, &peer->ksnp_conns) { > - conn2 = list_entry(tmp, struct ksock_conn, ksnc_list); > - > + list_for_each_entry(conn2, &peer->ksnp_conns, ksnc_list) { > if (conn2->ksnc_route == route && > conn2->ksnc_type == conn->ksnc_type) > - break; > - > - conn2 = NULL; > + goto conn2_found; > } > - if (!conn2) > - route->ksnr_connected &= ~(1 << conn->ksnc_type); > - > + route->ksnr_connected &= ~(1 << conn->ksnc_type); > + conn2_found: > conn->ksnc_route = NULL; > > ksocknal_route_decref(route); /* drop conn's ref on route */ > > > From jsimmons at infradead.org Thu Aug 2 03:14:27 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:14:27 +0100 (BST) Subject: [lustre-devel] [PATCH 5/6] lustre: convert list_for_each() in ksocknal_push_peer() In-Reply-To: <153292233968.26104.1980002621622141877.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233968.26104.1980002621622141877.stgit@noble> Message-ID: > The use of list_for_each() in ksocknal_push_peer() cannot be trivially > converted to list_for_each_entry() as the new loop variable > is tested outside the loop. We can change that test to compare 'i' > to 'index' instead. Then a trivial conversion is possible. > Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index ea95bff79996..33335713b371 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1853,7 +1853,6 @@ ksocknal_push_peer(struct ksock_peer *peer) > { > int index; > int i; > - struct list_head *tmp; > struct ksock_conn *conn; > > for (index = 0; ; index++) { > @@ -1862,10 +1861,8 @@ ksocknal_push_peer(struct ksock_peer *peer) > i = 0; > conn = NULL; > > - list_for_each(tmp, &peer->ksnp_conns) { > + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { > if (i++ == index) { > - conn = list_entry(tmp, struct ksock_conn, > - ksnc_list); > ksocknal_conn_addref(conn); > break; > } > @@ -1873,7 +1870,7 @@ ksocknal_push_peer(struct ksock_peer *peer) > > read_unlock(&ksocknal_data.ksnd_global_lock); > > - if (!conn) > + if (i <= index) > break; > > ksocknal_lib_push_conn(conn); > > > From jsimmons at infradead.org Thu Aug 2 03:14:56 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:14:56 +0100 (BST) Subject: [lustre-devel] [PATCH 6/6] lustre: convert list_for_each() in ksocknal_debug_peerhash() In-Reply-To: <153292233972.26104.9739049020807431895.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> <153292233972.26104.9739049020807431895.stgit@noble> Message-ID: > This list_for_each() loop searches for a particular entry, > then acts of in. It currently acts after the loop by testing > if the variable is NULL. When we convert to list_for_each_entry() > it won't be NULL. > > Change the code so the acting happens inside the loop. > list_for_each_entry() { > if (this isn't it) > continue; > act on entry; > goto done; // break out of 2 loops > } Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 64 +++++++++----------- > 1 file changed, 28 insertions(+), 36 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 33335713b371..f0b0480686dc 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -2462,52 +2462,44 @@ static void > ksocknal_debug_peerhash(struct lnet_ni *ni) > { > struct ksock_peer *peer = NULL; > - struct list_head *tmp; > int i; > > read_lock(&ksocknal_data.ksnd_global_lock); > > for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { > - list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) { > - peer = list_entry(tmp, struct ksock_peer, ksnp_list); > - > - if (peer->ksnp_ni == ni) > - break; > + list_for_each_entry(peer, &ksocknal_data.ksnd_peers[i], ksnp_list) { > + struct ksock_route *route; > + struct ksock_conn *conn; > > - peer = NULL; > - } > - } > + if (peer->ksnp_ni != ni) > + continue; > > - if (peer) { > - struct ksock_route *route; > - struct ksock_conn *conn; > - > - CWARN("Active peer on shutdown: %s, ref %d, scnt %d, closing %d, accepting %d, err %d, zcookie %llu, txq %d, zc_req %d\n", > - libcfs_id2str(peer->ksnp_id), > - atomic_read(&peer->ksnp_refcount), > - peer->ksnp_sharecount, peer->ksnp_closing, > - peer->ksnp_accepting, peer->ksnp_error, > - peer->ksnp_zc_next_cookie, > - !list_empty(&peer->ksnp_tx_queue), > - !list_empty(&peer->ksnp_zc_req_list)); > - > - list_for_each(tmp, &peer->ksnp_routes) { > - route = list_entry(tmp, struct ksock_route, ksnr_list); > - CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n", > - atomic_read(&route->ksnr_refcount), > - route->ksnr_scheduled, route->ksnr_connecting, > - route->ksnr_connected, route->ksnr_deleted); > - } > + CWARN("Active peer on shutdown: %s, ref %d, scnt %d, closing %d, accepting %d, err %d, zcookie %llu, txq %d, zc_req %d\n", > + libcfs_id2str(peer->ksnp_id), > + atomic_read(&peer->ksnp_refcount), > + peer->ksnp_sharecount, peer->ksnp_closing, > + peer->ksnp_accepting, peer->ksnp_error, > + peer->ksnp_zc_next_cookie, > + !list_empty(&peer->ksnp_tx_queue), > + !list_empty(&peer->ksnp_zc_req_list)); > + > + list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { > + CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n", > + atomic_read(&route->ksnr_refcount), > + route->ksnr_scheduled, route->ksnr_connecting, > + route->ksnr_connected, route->ksnr_deleted); > + } > > - list_for_each(tmp, &peer->ksnp_conns) { > - conn = list_entry(tmp, struct ksock_conn, ksnc_list); > - CWARN("Conn: ref %d, sref %d, t %d, c %d\n", > - atomic_read(&conn->ksnc_conn_refcount), > - atomic_read(&conn->ksnc_sock_refcount), > - conn->ksnc_type, conn->ksnc_closing); > + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { > + CWARN("Conn: ref %d, sref %d, t %d, c %d\n", > + atomic_read(&conn->ksnc_conn_refcount), > + atomic_read(&conn->ksnc_sock_refcount), > + conn->ksnc_type, conn->ksnc_closing); > + } > + goto done; > } > } > - > +done: > read_unlock(&ksocknal_data.ksnd_global_lock); > } > > > > From jsimmons at infradead.org Thu Aug 2 03:16:06 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:16:06 +0100 (BST) Subject: [lustre-devel] [PATCH 0/6] lustre: convert list_for_each() to list_for_each_entry() In-Reply-To: <153292233170.26104.16164388413209501300.stgit@noble> References: <153292233170.26104.16164388413209501300.stgit@noble> Message-ID: > list_for_each_entry(foo) is generally preferred to > list_for_each(l,...) > foo = list_entry(l,...) > > as there is less noise in the code. > The first patch contains seveveral trivial conversions. > The remaining patches are less obvious and are separate > so they are easier to review. > > NeilBrown > > The following series implements... Looks good and testing shows no problems. I will poke the LNet guys to look at these as well. > --- > > NeilBrown (6): > lustre: convert list_for_each() to list_for_each_entry(). > lustre: lnet/config: convert list_for_each to list_for_each_entry > lustre: convert list_for_each in ksocknal_create_routes > lustre: convert list_for_each in ksocknal_close_conn_locked() > lustre: convert list_for_each() in ksocknal_push_peer() > lustre: convert list_for_each() in ksocknal_debug_peerhash() > > > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 17 -- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 20 +- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 166 +++++++------------- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 20 +- > drivers/staging/lustre/lnet/lnet/api-ni.c | 29 +-- > drivers/staging/lustre/lnet/lnet/config.c | 28 +-- > drivers/staging/lustre/lnet/lnet/lib-move.c | 9 - > drivers/staging/lustre/lnet/lnet/router.c | 47 +----- > drivers/staging/lustre/lnet/selftest/conrpc.c | 7 - > drivers/staging/lustre/lustre/obdclass/genops.c | 4 > .../staging/lustre/lustre/obdecho/echo_client.c | 4 > 11 files changed, 99 insertions(+), 252 deletions(-) > > -- > Signature > > From jsimmons at infradead.org Thu Aug 2 03:45:31 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:45:31 +0100 (BST) Subject: [lustre-devel] [PATCH 1/7] lustre: use schedule_timeout_$state(). In-Reply-To: <153292257279.26496.13641642926795469723.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257279.26496.13641642926795469723.stgit@noble> Message-ID: > Lustre has many calls to > set_current_state(STATE); > schedule_timeout(time); > > > These can more easily be done as > schedule_timeout_STATE(time); > > Also clean up some oddities, such as setting the state > to TASK_RUNNING after the timeout, and simplify > some time calculations. > > Some schedule_timeout() calls remain as the state was set earlier, > before an 'add_wait_queue()'. It would be incorrect to convert these. >From a time long ago. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 ++++-------- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 ++---- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 14 ++++++-------- > drivers/staging/lustre/lnet/libcfs/fail.c | 3 +-- > drivers/staging/lustre/lnet/libcfs/tracefile.c | 3 +-- > drivers/staging/lustre/lnet/lnet/acceptor.c | 3 +-- > drivers/staging/lustre/lnet/lnet/api-ni.c | 6 ++---- > drivers/staging/lustre/lnet/lnet/peer.c | 3 +-- > drivers/staging/lustre/lnet/lnet/router.c | 19 +++++-------------- > drivers/staging/lustre/lnet/selftest/conrpc.c | 3 +-- > drivers/staging/lustre/lnet/selftest/rpc.c | 3 +-- > drivers/staging/lustre/lnet/selftest/selftest.h | 3 +-- > drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 +- > drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 +-- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +++----- > drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- > .../staging/lustre/lustre/obdecho/echo_client.c | 3 +-- > drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- > drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +-- > 19 files changed, 36 insertions(+), 71 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index e15ad94151bd..f496e6fcc416 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1201,8 +1201,7 @@ static struct kib_hca_dev *kiblnd_current_hdev(struct kib_dev *dev) > if (!(i++ % 50)) > CDEBUG(D_NET, "%s: Wait for failover\n", > dev->ibd_ifname); > - set_current_state(TASK_INTERRUPTIBLE); > - schedule_timeout(HZ / 100); > + schedule_timeout_interruptible(HZ / 100); > > read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > } > @@ -1916,8 +1915,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps) > CDEBUG(D_NET, "Another thread is allocating new %s pool, waiting %d HZs for her to complete. trips = %d\n", > ps->ps_name, interval, trips); > > - set_current_state(TASK_INTERRUPTIBLE); > - schedule_timeout(interval); > + schedule_timeout_interruptible(interval); > if (interval < HZ) > interval *= 2; > > @@ -2548,8 +2546,7 @@ static void kiblnd_base_shutdown(void) > CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, > "Waiting for %d threads to terminate\n", > atomic_read(&kiblnd_data.kib_nthreads)); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > } > > /* fall through */ > @@ -2599,8 +2596,7 @@ static void kiblnd_shutdown(struct lnet_ni *ni) > "%s: waiting for %d peers to disconnect\n", > libcfs_nid2str(ni->ni_nid), > atomic_read(&net->ibn_npeers)); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > } > > kiblnd_net_fini_pools(net); > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index f0b0480686dc..4dde158451ea 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -2307,8 +2307,7 @@ ksocknal_base_shutdown(void) > "waiting for %d threads to terminate\n", > ksocknal_data.ksnd_nthreads); > read_unlock(&ksocknal_data.ksnd_global_lock); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > read_lock(&ksocknal_data.ksnd_global_lock); > } > read_unlock(&ksocknal_data.ksnd_global_lock); > @@ -2533,8 +2532,7 @@ ksocknal_shutdown(struct lnet_ni *ni) > CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */ > "waiting for %d peers to disconnect\n", > net->ksnn_npeers); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > > ksocknal_debug_peerhash(ni); > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > index a5c0e8a9bc40..32b76727f400 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > @@ -188,10 +188,9 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx) > int rc; > int bufnob; > > - if (ksocknal_data.ksnd_stall_tx) { > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(ksocknal_data.ksnd_stall_tx * HZ); > - } > + if (ksocknal_data.ksnd_stall_tx) > + schedule_timeout_uninterruptible( > + ksocknal_data.ksnd_stall_tx * HZ); > > LASSERT(tx->tx_resid); > > @@ -293,10 +292,9 @@ ksocknal_receive(struct ksock_conn *conn) > */ > int rc; > > - if (ksocknal_data.ksnd_stall_rx) { > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(ksocknal_data.ksnd_stall_rx * HZ); > - } > + if (ksocknal_data.ksnd_stall_rx) > + schedule_timeout_uninterruptible( > + ksocknal_data.ksnd_stall_rx * HZ); > > rc = ksocknal_connsock_addref(conn); > if (rc) { > diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c b/drivers/staging/lustre/lnet/libcfs/fail.c > index bd86b3b5bc34..6ee4de2178ce 100644 > --- a/drivers/staging/lustre/lnet/libcfs/fail.c > +++ b/drivers/staging/lustre/lnet/libcfs/fail.c > @@ -137,8 +137,7 @@ int __cfs_fail_timeout_set(u32 id, u32 value, int ms, int set) > if (ret && likely(ms > 0)) { > CERROR("cfs_fail_timeout id %x sleeping for %dms\n", > id, ms); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(ms * HZ / 1000); > + schedule_timeout_uninterruptible(ms * HZ / 1000); > CERROR("cfs_fail_timeout id %x awake\n", id); > } > return ret; > diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c > index a4768e930021..d4c80cf254e4 100644 > --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c > +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c > @@ -1208,8 +1208,7 @@ static int tracefiled(void *arg) > } > init_waitqueue_entry(&__wait, current); > add_wait_queue(&tctl->tctl_waitq, &__wait); > - set_current_state(TASK_INTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_interruptible(HZ); > remove_wait_queue(&tctl->tctl_waitq, &__wait); > } > complete(&tctl->tctl_stop); > diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c > index 5648f17eddc0..3ae3ca1311a1 100644 > --- a/drivers/staging/lustre/lnet/lnet/acceptor.c > +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c > @@ -362,8 +362,7 @@ lnet_acceptor(void *arg) > if (rc) { > if (rc != -EAGAIN) { > CWARN("Accept error %d: pausing...\n", rc); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > } > continue; > } > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 14b797802a85..cdbbe9cc8d95 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -955,8 +955,7 @@ lnet_ping_md_unlink(struct lnet_ping_info *pinfo, > /* NB md could be busy; this just starts the unlink */ > while (pinfo->pi_features != LNET_PING_FEAT_INVAL) { > CDEBUG(D_NET, "Still waiting for ping MD to unlink\n"); > - set_current_state(TASK_NOLOAD); > - schedule_timeout(HZ); > + schedule_timeout_idle(HZ); > } > } > > @@ -1093,8 +1092,7 @@ lnet_clear_zombies_nis_locked(void) > CDEBUG(D_WARNING, "Waiting for zombie LNI %s\n", > libcfs_nid2str(ni->ni_nid)); > } > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > lnet_net_lock(LNET_LOCK_EX); > continue; > } > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index 7c303ef6bb34..d9452c322e4d 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -136,8 +136,7 @@ lnet_peer_table_deathrow_wait_locked(struct lnet_peer_table *ptable, > "Waiting for %d zombies on peer table\n", > ptable->pt_zombies); > } > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ >> 1); > + schedule_timeout_uninterruptible(HZ >> 1); > lnet_net_lock(cpt_locked); > } > } > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 53373372b526..02241fbc9eaa 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -783,8 +783,7 @@ lnet_wait_known_routerstate(void) > if (all_known) > return; > > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > } > } > > @@ -1159,8 +1158,7 @@ lnet_prune_rc_data(int wait_unlink) > i++; > CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, > "Waiting for rc buffers to unlink\n"); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ / 4); > + schedule_timeout_uninterruptible(HZ / 4); > > lnet_net_lock(LNET_LOCK_EX); > } > @@ -1236,23 +1234,16 @@ lnet_router_checker(void *arg) > > lnet_prune_rc_data(0); /* don't wait for UNLINK */ > > - /* > - * Call schedule_timeout() here always adds 1 to load average > - * because kernel counts # active tasks as nr_running > - * + nr_uninterruptible. > - */ > /* > * if there are any routes then wakeup every second. If > * there are no routes then sleep indefinitely until woken > * up by a user adding a route > */ > if (!lnet_router_checker_active()) > - wait_event_interruptible(the_lnet.ln_rc_waitq, > - lnet_router_checker_active()); > + wait_event_idle(the_lnet.ln_rc_waitq, > + lnet_router_checker_active()); > else > - wait_event_interruptible_timeout(the_lnet.ln_rc_waitq, > - false, > - HZ); > + schedule_timeout_idle(HZ); > } > > lnet_prune_rc_data(1); /* wait for UNLINK */ > diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c > index e73b956d15e4..7809c1fc6f73 100644 > --- a/drivers/staging/lustre/lnet/selftest/conrpc.c > +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c > @@ -1345,8 +1345,7 @@ lstcon_rpc_cleanup_wait(void) > mutex_unlock(&console_session.ses_mutex); > > CWARN("Session is shutting down, waiting for termination of transactions\n"); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > > mutex_lock(&console_session.ses_mutex); > } > diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c > index e097ef8414a6..298de41444b3 100644 > --- a/drivers/staging/lustre/lnet/selftest/rpc.c > +++ b/drivers/staging/lustre/lnet/selftest/rpc.c > @@ -1603,8 +1603,7 @@ srpc_startup(void) > spin_lock_init(&srpc_data.rpc_glock); > > /* 1 second pause to avoid timestamp reuse */ > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > srpc_data.rpc_matchbits = ((__u64)ktime_get_real_seconds()) << 48; > > srpc_data.rpc_state = SRPC_STATE_NONE; > diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h > index ad9be095c4ea..9dbb0a51d430 100644 > --- a/drivers/staging/lustre/lnet/selftest/selftest.h > +++ b/drivers/staging/lustre/lnet/selftest/selftest.h > @@ -573,8 +573,7 @@ swi_state2str(int state) > > #define selftest_wait_events() \ > do { \ > - set_current_state(TASK_UNINTERRUPTIBLE); \ > - schedule_timeout(HZ / 10); \ > + schedule_timeout_uninterruptible(HZ / 10); \ > } while (0) > > #define lst_wait_until(cond, lock, fmt, ...) \ > diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h > index a9c9992a2502..6ac7fc4fa8c6 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h > +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h > @@ -124,7 +124,7 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, > */ > while (unlikely(lck->rpcl_it == MDC_FAKE_RPCL_IT)) { > mutex_unlock(&lck->rpcl_mutex); > - schedule_timeout(HZ / 4); > + schedule_timeout_uninterruptible(HZ / 4); > goto again; > } > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c > index 5b125fdc7321..0ee4798f1bb9 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c > @@ -167,8 +167,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, > int to = HZ; > > while (to > 0) { > - set_current_state(TASK_INTERRUPTIBLE); > - schedule_timeout(to); > + schedule_timeout_interruptible(to); > if (lock->l_granted_mode == lock->l_req_mode || > ldlm_is_destroyed(lock)) > break; > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index f06cbd8b6d13..33d73fa8e9d5 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -749,11 +749,9 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, > */ > unlock_res(res); > LDLM_DEBUG(lock, "setting FL_LOCAL_ONLY"); > - if (lock->l_flags & LDLM_FL_FAIL_LOC) { > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(4 * HZ); > - set_current_state(TASK_RUNNING); > - } > + if (lock->l_flags & LDLM_FL_FAIL_LOC) > + schedule_timeout_uninterruptible(4 * HZ); > + > if (lock->l_completion_ast) > lock->l_completion_ast(lock, LDLM_FL_FAILED, > NULL); > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 5c8d0fe7217e..3dedc61d2257 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -706,10 +706,8 @@ void ll_kill_super(struct super_block *sb) > sbi->ll_umounting = 1; > > /* wait running statahead threads to quit */ > - while (atomic_read(&sbi->ll_sa_running) > 0) { > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC >> 3)); > - } > + while (atomic_read(&sbi->ll_sa_running) > 0) > + schedule_timeout_uninterruptible(HZ >> 3); > } > } > > diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c > index 3022706c6985..1ddb4a6dd8f3 100644 > --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c > +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c > @@ -751,8 +751,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, > while (!list_empty(&ec->ec_objects)) { > spin_unlock(&ec->ec_lock); > CERROR("echo_client still has objects at cleanup time, wait for 1 second\n"); > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(HZ); > + schedule_timeout_uninterruptible(HZ); > lu_site_purge(env, ed->ed_site, -1); > spin_lock(&ec->ec_lock); > } > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index 7a3d83c0e50b..91dd09867260 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -761,9 +761,7 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, > /* The RPC is infected, let the test change the > * fail_loc > */ > - set_current_state(TASK_UNINTERRUPTIBLE); > - schedule_timeout(2 * HZ); > - set_current_state(TASK_RUNNING); > + schedule_timeout_uninterruptible(2 * HZ); > } > } > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c > index 9b60292370a7..9c598710b576 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c > @@ -514,8 +514,7 @@ static int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) > "ctx (%p, fl %lx) doesn't switch, relax a little bit\n", > newctx, newctx->cc_flags); > > - set_current_state(TASK_INTERRUPTIBLE); > - schedule_timeout(msecs_to_jiffies(MSEC_PER_SEC)); > + schedule_timeout_interruptible(HZ); > } else if (unlikely(!test_bit(PTLRPC_CTX_UPTODATE_BIT, &newctx->cc_flags))) { > /* > * new ctx not up to date yet > > > From jsimmons at infradead.org Thu Aug 2 03:46:00 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:46:00 +0100 (BST) Subject: [lustre-devel] [PATCH 2/7] lustre/libcfs: fix freeing after kmalloc failure. In-Reply-To: <153292257285.26496.5271671024215297861.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257285.26496.5271671024215297861.stgit@noble> Message-ID: > The new_bkts array is *not* zeroed (any more) so when > freeing recently allocated buckets on failure, we > must no free beyond the last bucket successfully > allocated. Reviewed-by: James Simmons > Fixes: 12e46c461cb9 ("staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL)") > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c > index 48be66f0d654..f452c4540ca1 100644 > --- a/drivers/staging/lustre/lnet/libcfs/hash.c > +++ b/drivers/staging/lustre/lnet/libcfs/hash.c > @@ -904,7 +904,7 @@ cfs_hash_buckets_realloc(struct cfs_hash *hs, struct cfs_hash_bucket **old_bkts, > new_bkts[i] = kzalloc(cfs_hash_bkt_size(hs), GFP_KERNEL); > if (!new_bkts[i]) { > cfs_hash_buckets_free(new_bkts, cfs_hash_bkt_size(hs), > - old_size, new_size); > + old_size, i); > return NULL; > } > > > > From jsimmons at infradead.org Thu Aug 2 03:46:27 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:46:27 +0100 (BST) Subject: [lustre-devel] [PATCH 3/7] lustre/libfs: move debugfs registration from libcfs_setup back to libcfs_init In-Reply-To: <153292257289.26496.3865601138425685904.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257289.26496.3865601138425685904.stgit@noble> Message-ID: > large memory allocations should be avoided at module-init, > but registering services is appropriate. > So move the registration of debugfs files > back into libcfs_init(). > Without this, /sys/kernel/debug/lnet etc are not visible > immediately that libcfs is loaded. > No debugfs file access needs anything allocated by libcfs_setup(). Reviewed-by: James Simmons > Fixes: 64bf0b1a079d ("staging: lustre: refactor libcfs initialization.") > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/module.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c > index bfadfcfa3c44..5d2be941777e 100644 > --- a/drivers/staging/lustre/lnet/libcfs/module.c > +++ b/drivers/staging/lustre/lnet/libcfs/module.c > @@ -719,10 +719,6 @@ int libcfs_setup(void) > goto err; > } > > - lnet_insert_debugfs(lnet_table); > - if (!IS_ERR_OR_NULL(lnet_debugfs_root)) > - lnet_insert_debugfs_links(lnet_debugfs_symlinks); > - > CDEBUG(D_OTHER, "portals setup OK\n"); > out: > libcfs_active = 1; > @@ -743,6 +739,10 @@ static int libcfs_init(void) > { > int rc; > > + lnet_insert_debugfs(lnet_table); > + if (!IS_ERR_OR_NULL(lnet_debugfs_root)) > + lnet_insert_debugfs_links(lnet_debugfs_symlinks); > + > rc = misc_register(&libcfs_dev); > if (rc) > CERROR("misc_register: error %d\n", rc); > > > From jsimmons at infradead.org Thu Aug 2 03:46:53 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:46:53 +0100 (BST) Subject: [lustre-devel] [PATCH 4/7] lustre: give different tcd_lock types different classes. In-Reply-To: <153292257292.26496.6025900918938045378.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257292.26496.6025900918938045378.stgit@noble> Message-ID: > There are three different trace contexts: > process, softirq, irq. > Each has its own lock (tcd_lock) which is locked > as appropriate for that context. > lockdep currently doesn't see that they are different > and so deduces that the different uses might lead to > deadlocks. > So use separate calls to spin_lock_init() so that they > each get a separate lock class, and lockdep sees no > problem. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/tracefile.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c > index d4c80cf254e4..40048165fc16 100644 > --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c > +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c > @@ -1285,7 +1285,23 @@ int cfs_tracefile_init(int max_pages) > cfs_tcd_for_each(tcd, i, j) { > int factor = pages_factor[i]; > > - spin_lock_init(&tcd->tcd_lock); > + /* Note that we have three separate calls so > + * they the locks get three separate classes > + * and lockdep never thinks they are related. > + * As they are used in different interrupt > + * contexts, lockdep think the usage would conflict. > + */ > + switch(i) { > + case CFS_TCD_TYPE_PROC: > + spin_lock_init(&tcd->tcd_lock); > + break; > + case CFS_TCD_TYPE_SOFTIRQ: > + spin_lock_init(&tcd->tcd_lock); > + break; > + case CFS_TCD_TYPE_IRQ: > + spin_lock_init(&tcd->tcd_lock); > + break; > + } > tcd->tcd_pages_factor = factor; > tcd->tcd_type = i; > tcd->tcd_cpu = j; > > > From jsimmons at infradead.org Thu Aug 2 03:47:14 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:47:14 +0100 (BST) Subject: [lustre-devel] [PATCH 5/7] lustre/libcfs: discard cfs_trace_allocate_string_buffer() In-Reply-To: <153292257295.26496.1353870060207416213.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257295.26496.1353870060207416213.stgit@noble> Message-ID: > cfs_trace_allocate_string_buffer() is a simple wrapper > around kzalloc() that adds little value. The code is > clearer if we perform the test and the allocation > directly where needed. > > Also change the test from '>' to '>=' to ensure we > never try to allocate more than 2 pages, as that seems > to be the intent. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/libcfs/module.c | 6 +++-- > drivers/staging/lustre/lnet/libcfs/tracefile.c | 28 +++++++++--------------- > drivers/staging/lustre/lnet/libcfs/tracefile.h | 1 - > 3 files changed, 13 insertions(+), 22 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c > index 5d2be941777e..1de83b1997c6 100644 > --- a/drivers/staging/lustre/lnet/libcfs/module.c > +++ b/drivers/staging/lustre/lnet/libcfs/module.c > @@ -305,9 +305,9 @@ static int proc_dobitmasks(struct ctl_table *table, int write, > int is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0; > int is_printk = (mask == &libcfs_printk) ? 1 : 0; > > - rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen); > - if (rc < 0) > - return rc; > + tmpstr = kzalloc(tmpstrlen, GFP_KERNEL); > + if (!tmpstr) > + return -ENOMEM; > > if (!write) { > libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys); > diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c > index 40048165fc16..b273107b3815 100644 > --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c > +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c > @@ -963,26 +963,16 @@ int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, > } > EXPORT_SYMBOL(cfs_trace_copyout_string); > > -int cfs_trace_allocate_string_buffer(char **str, int nob) > -{ > - if (nob > 2 * PAGE_SIZE) /* string must be "sensible" */ > - return -EINVAL; > - > - *str = kmalloc(nob, GFP_KERNEL | __GFP_ZERO); > - if (!*str) > - return -ENOMEM; > - > - return 0; > -} > - > int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob) > { > char *str; > int rc; > > - rc = cfs_trace_allocate_string_buffer(&str, usr_str_nob + 1); > - if (rc) > - return rc; > + if (usr_str_nob >= 2 * PAGE_SIZE) > + return -EINVAL; > + str = kzalloc(usr_str_nob + 1, GFP_KERNEL); > + if (!str) > + return -ENOMEM; > > rc = cfs_trace_copyin_string(str, usr_str_nob + 1, > usr_str, usr_str_nob); > @@ -1044,9 +1034,11 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob) > char *str; > int rc; > > - rc = cfs_trace_allocate_string_buffer(&str, usr_str_nob + 1); > - if (rc) > - return rc; > + if (usr_str_nob >= 2 * PAGE_SIZE) > + return -EINVAL; > + str = kzalloc(usr_str_nob + 1, GFP_KERNEL); > + if (!str) > + return -ENOMEM; > > rc = cfs_trace_copyin_string(str, usr_str_nob + 1, > usr_str, usr_str_nob); > diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h > index 82f090fd8dfa..2134549bb3d7 100644 > --- a/drivers/staging/lustre/lnet/libcfs/tracefile.h > +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h > @@ -63,7 +63,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, > const char __user *usr_buffer, int usr_buffer_nob); > int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, > const char *knl_str, char *append); > -int cfs_trace_allocate_string_buffer(char **str, int nob); > int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob); > int cfs_trace_daemon_command(char *str); > int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob); > > > From jsimmons at infradead.org Thu Aug 2 03:47:38 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:47:38 +0100 (BST) Subject: [lustre-devel] [PATCH 6/7] lustre: lnet: convert ni_refs to percpu_refcount. In-Reply-To: <153292257300.26496.12952743323721291033.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257300.26496.12952743323721291033.stgit@noble> Message-ID: > ni_refs is a per-cpt refcount. > Linux already has a per-cpu refcount implementation > which doesn't require anylocking. > > So convert ni_refs to percpu_refcount. > As a bonus, we can get a wake-up when the refcount > reaches zero, rather than having to wait a full second. > The waiting in lnet_clear_zombies_nis_locked() is > modified so that instead of waiting one second each > time, and printing a warning on power-of-two seconds, > we wait an increasing power-of-two seconds and print > a warning if the wait ever timed out. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > .../staging/lustre/include/linux/lnet/lib-lnet.h | 11 +----- > .../staging/lustre/include/linux/lnet/lib-types.h | 2 + > drivers/staging/lustre/lnet/lnet/api-ni.c | 34 +++++++++----------- > drivers/staging/lustre/lnet/lnet/config.c | 13 +++++--- > drivers/staging/lustre/lnet/lnet/router_proc.c | 2 + > 5 files changed, 28 insertions(+), 34 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > index 0fecf0d32c58..371002825a7d 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > @@ -338,34 +338,27 @@ static inline void > lnet_ni_addref_locked(struct lnet_ni *ni, int cpt) > { > LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER); > - LASSERT(*ni->ni_refs[cpt] >= 0); > - > - (*ni->ni_refs[cpt])++; > + percpu_ref_get(&ni->ni_refs); > } > > static inline void > lnet_ni_addref(struct lnet_ni *ni) > { > - lnet_net_lock(0); > lnet_ni_addref_locked(ni, 0); > - lnet_net_unlock(0); > } > > static inline void > lnet_ni_decref_locked(struct lnet_ni *ni, int cpt) > { > LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER); > - LASSERT(*ni->ni_refs[cpt] > 0); > > - (*ni->ni_refs[cpt])--; > + percpu_ref_put(&ni->ni_refs); > } > > static inline void > lnet_ni_decref(struct lnet_ni *ni) > { > - lnet_net_lock(0); > lnet_ni_decref_locked(ni, 0); > - lnet_net_unlock(0); > } > > void lnet_ni_free(struct lnet_ni *ni); > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h > index 6d4106fd9039..7527fef90cac 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h > @@ -269,7 +269,7 @@ struct lnet_ni { > void *ni_data; /* instance-specific data */ > struct lnet_lnd *ni_lnd; /* procedural interface */ > struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ > - int **ni_refs; /* percpt reference count */ > + struct percpu_ref ni_refs; > time64_t ni_last_alive;/* when I was last alive */ > struct lnet_ni_status *ni_status; /* my health status */ > /* per NI LND tunables */ > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index cdbbe9cc8d95..fea03737439a 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -1055,7 +1055,7 @@ lnet_ni_unlink_locked(struct lnet_ni *ni) > /* move it to zombie list and nobody can find it anymore */ > LASSERT(!list_empty(&ni->ni_list)); > list_move(&ni->ni_list, &the_lnet.ln_nis_zombie); > - lnet_ni_decref_locked(ni, 0); /* drop ln_nis' ref */ > + percpu_ref_kill_and_confirm(&ni->ni_refs, NULL); /* drop ln_nis' ref */ > } > > static void > @@ -1069,34 +1069,32 @@ lnet_clear_zombies_nis_locked(void) > * Now wait for the NI's I just nuked to show up on ln_zombie_nis > * and shut them down in guaranteed thread context > */ > - i = 2; > + i = 1; > while (!list_empty(&the_lnet.ln_nis_zombie)) { > - int *ref; > - int j; > > ni = list_entry(the_lnet.ln_nis_zombie.next, > struct lnet_ni, ni_list); > - list_del_init(&ni->ni_list); > - cfs_percpt_for_each(ref, j, ni->ni_refs) { > - if (!*ref) > - continue; > - /* still busy, add it back to zombie list */ > - list_add(&ni->ni_list, &the_lnet.ln_nis_zombie); > - break; > - } > > - if (!list_empty(&ni->ni_list)) { > + if (!percpu_ref_is_zero(&ni->ni_refs)) { > + /* still busy, wait a while */ > + > lnet_net_unlock(LNET_LOCK_EX); > ++i; > - if ((i & (-i)) == i) { > + > + if (wait_var_event_timeout( > + &ni->ni_refs, > + percpu_ref_is_zero(&ni->ni_refs), > + HZ << i) == 0) > CDEBUG(D_WARNING, "Waiting for zombie LNI %s\n", > libcfs_nid2str(ni->ni_nid)); > - } > + > schedule_timeout_uninterruptible(HZ); > lnet_net_lock(LNET_LOCK_EX); > continue; > } > > + list_del_init(&ni->ni_list); > + > ni->ni_lnd->lnd_refcount--; > lnet_net_unlock(LNET_LOCK_EX); > > @@ -1114,7 +1112,7 @@ lnet_clear_zombies_nis_locked(void) > libcfs_nid2str(ni->ni_nid)); > > lnet_ni_free(ni); > - i = 2; > + i = 1; > > lnet_net_lock(LNET_LOCK_EX); > } > @@ -1305,8 +1303,8 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf) > LASSERT(ni->ni_peertimeout <= 0 || lnd->lnd_query); > > lnet_net_lock(LNET_LOCK_EX); > - /* refcount for ln_nis */ > - lnet_ni_addref_locked(ni, 0); > + /* Initialise refcount for ln_nis to 1 */ > + percpu_ref_reinit(&ni->ni_refs); > list_add_tail(&ni->ni_list, &the_lnet.ln_nis); > if (ni->ni_cpts) { > lnet_ni_addref_locked(ni, 0); > diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c > index 091c4f714e84..4145c7431576 100644 > --- a/drivers/staging/lustre/lnet/lnet/config.c > +++ b/drivers/staging/lustre/lnet/lnet/config.c > @@ -96,8 +96,7 @@ lnet_ni_free(struct lnet_ni *ni) > { > int i; > > - if (ni->ni_refs) > - cfs_percpt_free(ni->ni_refs); > + percpu_ref_exit(&ni->ni_refs); > > if (ni->ni_tx_queues) > cfs_percpt_free(ni->ni_tx_queues); > @@ -117,6 +116,11 @@ lnet_ni_free(struct lnet_ni *ni) > kfree(ni); > } > > +static void ref_release(struct percpu_ref *ref) > +{ > + wake_up_var(ref); > +} > + > struct lnet_ni * > lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) > { > @@ -140,9 +144,8 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) > > spin_lock_init(&ni->ni_lock); > INIT_LIST_HEAD(&ni->ni_cptlist); > - ni->ni_refs = cfs_percpt_alloc(lnet_cpt_table(), > - sizeof(*ni->ni_refs[0])); > - if (!ni->ni_refs) > + if (percpu_ref_init(&ni->ni_refs, ref_release, > + PERCPU_REF_INIT_DEAD, GFP_KERNEL) < 0) > goto failed; > > ni->ni_tx_queues = cfs_percpt_alloc(lnet_cpt_table(), > diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c > index d779445fefb5..8856798d263f 100644 > --- a/drivers/staging/lustre/lnet/lnet/router_proc.c > +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c > @@ -703,7 +703,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, > s += snprintf(s, tmpstr + tmpsiz - s, > "%-24s %6s %5lld %4d %4d %4d %5d %5d %5d\n", > libcfs_nid2str(ni->ni_nid), stat, > - last_alive, *ni->ni_refs[i], > + last_alive, 0/* No per-cpt refcount */, > ni->ni_peertxcredits, > ni->ni_peerrtrcredits, > tq->tq_credits_max, > > > From jsimmons at infradead.org Thu Aug 2 03:48:52 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:48:52 +0100 (BST) Subject: [lustre-devel] [PATCH 7/7] lustre: change TASK_NOLOAD to TASK_IDLE. In-Reply-To: <153292257303.26496.13996008210683917463.stgit@noble> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257303.26496.13996008210683917463.stgit@noble> Message-ID: > TASK_NOLOAD is not a task state to be use by > itself, it should only be used together with > TASK_UNINTERRUPTIBLE, which easily done > by using TASK_IDLE. > > So convert to TASK_IDLE. Sad only the latest kernel support this :-( Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c > index 8347cc44e47d..f085388895ea 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c > @@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock) > * \param timeout Time in jiffies to wait for an event to occur on > * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an > * infinite timeout. > - * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD > + * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE > * \param event,which On successful return (1 or -EOVERFLOW), \a event will > * hold the next event in the EQs, and \a which will contain the index of the > * EQ from which the event was taken. > @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, > */ > wait = lnet_eq_wait_locked(&timeout, > interruptible ? TASK_INTERRUPTIBLE > - : TASK_NOLOAD); > + : TASK_IDLE); > if (wait < 0) /* no new event */ > break; > } > > > From jsimmons at infradead.org Thu Aug 2 03:52:21 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 2 Aug 2018 04:52:21 +0100 (BST) Subject: [lustre-devel] [PATCH 06/31] lustre: llite: reduce jobstats race window In-Reply-To: References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org>, <1533003983-29311-7-git-send-email-jsimmons@infradead.org> Message-ID: > I'm puzzled, James - Why is "cache_jobid" in there?  Isn't that from Ben Evans' work?  This patch landed before all of that... All back ported patches have the potential to be modified so it can pass checkpatch as well as perfered standards. One of the common complaints was that lustre tends to use generic goto lables which can make grepping of the code more challenging. So I often change generic got lables to something with more meat. In this case I picked a nice name that came from a later patch :-) > ______________________________________________________________________________________________________________________________ > From: James Simmons > Sent: Monday, July 30, 2018 9:25:58 PM > To: Andreas Dilger; Oleg Drokin; NeilBrown > Cc: Lustre Development List; Patrick Farrell; James Simmons > Subject: [PATCH 06/31] lustre: llite: reduce jobstats race window   > From: Patrick Farrell > > In the current code, lli_jobid is set to zero on every call > to lustre_get_jobid.  This causes problems, because it's > used asynchronously to set the job id in RPCs, and some > RPCs will falsely get no jobid set.  (For small IO sizes, > this can be up to 60% of RPCs.) > > It would be very expensive to put hard synchronization > between this and every outbound RPC, and it's OK to very > rarely get an RPC without correct job stats info. > > This patch only updates the lli_jobid when the job id has > changed, which leaves only a very small window for reading > an inconsistent job id. > > Signed-off-by: Patrick Farrell > WC-id: https://jira.whamcloud.com/browse/LU-8926 > Reviewed-on: https://review.whamcloud.com/24253 > Reviewed-by: Andreas Dilger > Reviewed-by: Chris Horn > Signed-off-by: James Simmons > --- >  drivers/staging/lustre/lustre/llite/llite_lib.c    |  1 + >  drivers/staging/lustre/lustre/obdclass/class_obd.c | 20 ++++++++++++++------ >  2 files changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index c0861b9..72b118a 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -894,6 +894,7 @@ void ll_lli_init(struct ll_inode_info *lli) >                  lli->lli_async_rc = 0; >          } >          mutex_init(&lli->lli_layout_mutex); > +       memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); >  } >   >  int ll_fill_super(struct super_block *sb) > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index cdaf729..87327ef 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -95,26 +95,34 @@ >   */ >  int lustre_get_jobid(char *jobid) >  { > -       memset(jobid, 0, LUSTRE_JOBID_SIZE); > +       char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 }; > + >          /* Jobstats isn't enabled */ >          if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) > -               return 0; > +               goto out_cache_jobid; >   >          /* Use process name + fsuid as jobid */ >          if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { > -               snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u", > +               snprintf(tmp_jobid, LUSTRE_JOBID_SIZE, "%s.%u", >                           current->comm, >                           from_kuid(&init_user_ns, current_fsuid())); > -               return 0; > +               goto out_cache_jobid; >          } >   >          /* Whole node dedicated to single job */ >          if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) { > -               strcpy(jobid, obd_jobid_node); > -               return 0; > +               strcpy(tmp_jobid, obd_jobid_node); > +               goto out_cache_jobid; >          } >   >          return -ENOENT; > + > +out_cache_jobid: > +       /* Only replace the job ID if it changed. */ > +       if (strcmp(jobid, tmp_jobid) != 0) > +               strcpy(jobid, tmp_jobid); > + > +       return 0; >  } >  EXPORT_SYMBOL(lustre_get_jobid); >   > -- > 1.8.3.1 > > > From paf at cray.com Thu Aug 2 03:58:50 2018 From: paf at cray.com (Patrick Farrell) Date: Thu, 2 Aug 2018 03:58:50 +0000 Subject: [lustre-devel] [PATCH 06/31] lustre: llite: reduce jobstats race window In-Reply-To: References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org>, <1533003983-29311-7-git-send-email-jsimmons@infradead.org> , Message-ID: Fair enough. It doesn’t really make sense in context, but that’s fine since it’s temporary. ________________________________ From: James Simmons Sent: Wednesday, August 1, 2018 10:52:21 PM To: Patrick Farrell Cc: Andreas Dilger; Oleg Drokin; NeilBrown; Lustre Development List Subject: Re: [PATCH 06/31] lustre: llite: reduce jobstats race window > I'm puzzled, James - Why is "cache_jobid" in there? Isn't that from Ben Evans' work? This patch landed before all of that... All back ported patches have the potential to be modified so it can pass checkpatch as well as perfered standards. One of the common complaints was that lustre tends to use generic goto lables which can make grepping of the code more challenging. So I often change generic got lables to something with more meat. In this case I picked a nice name that came from a later patch :-) > ______________________________________________________________________________________________________________________________ > From: James Simmons > Sent: Monday, July 30, 2018 9:25:58 PM > To: Andreas Dilger; Oleg Drokin; NeilBrown > Cc: Lustre Development List; Patrick Farrell; James Simmons > Subject: [PATCH 06/31] lustre: llite: reduce jobstats race window > From: Patrick Farrell > > In the current code, lli_jobid is set to zero on every call > to lustre_get_jobid. This causes problems, because it's > used asynchronously to set the job id in RPCs, and some > RPCs will falsely get no jobid set. (For small IO sizes, > this can be up to 60% of RPCs.) > > It would be very expensive to put hard synchronization > between this and every outbound RPC, and it's OK to very > rarely get an RPC without correct job stats info. > > This patch only updates the lli_jobid when the job id has > changed, which leaves only a very small window for reading > an inconsistent job id. > > Signed-off-by: Patrick Farrell > WC-id: https://jira.whamcloud.com/browse/LU-8926 > Reviewed-on: https://review.whamcloud.com/24253 > Reviewed-by: Andreas Dilger > Reviewed-by: Chris Horn > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/llite/llite_lib.c | 1 + > drivers/staging/lustre/lustre/obdclass/class_obd.c | 20 ++++++++++++++------ > 2 files changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index c0861b9..72b118a 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -894,6 +894,7 @@ void ll_lli_init(struct ll_inode_info *lli) > lli->lli_async_rc = 0; > } > mutex_init(&lli->lli_layout_mutex); > + memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); > } > > int ll_fill_super(struct super_block *sb) > diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c > index cdaf729..87327ef 100644 > --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c > +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c > @@ -95,26 +95,34 @@ > */ > int lustre_get_jobid(char *jobid) > { > - memset(jobid, 0, LUSTRE_JOBID_SIZE); > + char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 }; > + > /* Jobstats isn't enabled */ > if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) > - return 0; > + goto out_cache_jobid; > > /* Use process name + fsuid as jobid */ > if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { > - snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u", > + snprintf(tmp_jobid, LUSTRE_JOBID_SIZE, "%s.%u", > current->comm, > from_kuid(&init_user_ns, current_fsuid())); > - return 0; > + goto out_cache_jobid; > } > > /* Whole node dedicated to single job */ > if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) { > - strcpy(jobid, obd_jobid_node); > - return 0; > + strcpy(tmp_jobid, obd_jobid_node); > + goto out_cache_jobid; > } > > return -ENOENT; > + > +out_cache_jobid: > + /* Only replace the job ID if it changed. */ > + if (strcmp(jobid, tmp_jobid) != 0) > + strcpy(jobid, tmp_jobid); > + > + return 0; > } > EXPORT_SYMBOL(lustre_get_jobid); > > -- > 1.8.3.1 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From neilb at suse.com Thu Aug 2 04:18:57 2018 From: neilb at suse.com (NeilBrown) Date: Thu, 02 Aug 2018 14:18:57 +1000 Subject: [lustre-devel] [PATCH 7/7] lustre: change TASK_NOLOAD to TASK_IDLE. In-Reply-To: References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257303.26496.13996008210683917463.stgit@noble> Message-ID: <87lg9ppfim.fsf@notabene.neil.brown.name> On Thu, Aug 02 2018, James Simmons wrote: >> TASK_NOLOAD is not a task state to be use by >> itself, it should only be used together with >> TASK_UNINTERRUPTIBLE, which easily done >> by using TASK_IDLE. >> >> So convert to TASK_IDLE. > > Sad only the latest kernel support this :-( So? The patch to add support is trivial. commit 80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf Author: Peter Zijlstra Date: Fri May 8 14:23:45 2015 +0200 sched/wait: Introduce TASK_NOLOAD and TASK_IDLE .... include/linux/sched.h | 10 +++++++--- include/trace/events/sched.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) You would then need to add some macors like wait_event_idle(), but they could go in the lustre code. If you need it in any vendor kernel I'd be quite surprised if they wouldn't accept it, at least in a service-pack. I just checked SLES and the only release that isn't in long-term-support (no new features) that doesn't already have this patch (linux 4.2 and later) is SLE11-SP4. Do you still provide new features for older kernels, or just bug-fix updates? NeilBrown > > Reviewed-by: James Simmons > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c >> index 8347cc44e47d..f085388895ea 100644 >> --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c >> +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c >> @@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock) >> * \param timeout Time in jiffies to wait for an event to occur on >> * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an >> * infinite timeout. >> - * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD >> + * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE >> * \param event,which On successful return (1 or -EOVERFLOW), \a event will >> * hold the next event in the EQs, and \a which will contain the index of the >> * EQ from which the event was taken. >> @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, >> */ >> wait = lnet_eq_wait_locked(&timeout, >> interruptible ? TASK_INTERRUPTIBLE >> - : TASK_NOLOAD); >> + : TASK_IDLE); >> if (wait < 0) /* no new event */ >> break; >> } >> >> >> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From paf at cray.com Thu Aug 2 12:48:35 2018 From: paf at cray.com (Patrick Farrell) Date: Thu, 2 Aug 2018 12:48:35 +0000 Subject: [lustre-devel] [PATCH 7/7] lustre: change TASK_NOLOAD to TASK_IDLE. In-Reply-To: <87lg9ppfim.fsf@notabene.neil.brown.name> References: <153292249340.26496.13985174182824912332.stgit@noble> <153292257303.26496.13996008210683917463.stgit@noble> , <87lg9ppfim.fsf@notabene.neil.brown.name> Message-ID: We generally provide full updates for older kernels, until we don’t. There’s a gradually moving window of kernel support for new versions of Lustre, with a heavy eye on the major enterprise distro versions. But when a feature depends on something new, we wrap it in config stuff and either disable it when not found, or we copy the required bits in to Lustre if they’re small or hard to do without. So, kind of what you’re suggesting. No problem at all. ________________________________ From: lustre-devel on behalf of NeilBrown Sent: Wednesday, August 1, 2018 11:18:57 PM To: James Simmons Cc: Lustre Development List Subject: Re: [lustre-devel] [PATCH 7/7] lustre: change TASK_NOLOAD to TASK_IDLE. On Thu, Aug 02 2018, James Simmons wrote: >> TASK_NOLOAD is not a task state to be use by >> itself, it should only be used together with >> TASK_UNINTERRUPTIBLE, which easily done >> by using TASK_IDLE. >> >> So convert to TASK_IDLE. > > Sad only the latest kernel support this :-( So? The patch to add support is trivial. commit 80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf Author: Peter Zijlstra Date: Fri May 8 14:23:45 2015 +0200 sched/wait: Introduce TASK_NOLOAD and TASK_IDLE .... include/linux/sched.h | 10 +++++++--- include/trace/events/sched.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) You would then need to add some macors like wait_event_idle(), but they could go in the lustre code. If you need it in any vendor kernel I'd be quite surprised if they wouldn't accept it, at least in a service-pack. I just checked SLES and the only release that isn't in long-term-support (no new features) that doesn't already have this patch (linux 4.2 and later) is SLE11-SP4. Do you still provide new features for older kernels, or just bug-fix updates? NeilBrown > > Reviewed-by: James Simmons > >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c >> index 8347cc44e47d..f085388895ea 100644 >> --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c >> +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c >> @@ -349,7 +349,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock) >> * \param timeout Time in jiffies to wait for an event to occur on >> * one of the EQs. The constant MAX_SCHEDULE_TIMEOUT can be used to indicate an >> * infinite timeout. >> - * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_NOLOAD >> + * \param interruptible, if true, use TASK_INTERRUPTIBLE, else TASK_IDLE >> * \param event,which On successful return (1 or -EOVERFLOW), \a event will >> * hold the next event in the EQs, and \a which will contain the index of the >> * EQ from which the event was taken. >> @@ -406,7 +406,7 @@ LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, signed long timeout, >> */ >> wait = lnet_eq_wait_locked(&timeout, >> interruptible ? TASK_INTERRUPTIBLE >> - : TASK_NOLOAD); >> + : TASK_IDLE); >> if (wait < 0) /* no new event */ >> break; >> } >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From adilger at whamcloud.com Fri Aug 3 00:01:18 2018 From: adilger at whamcloud.com (Andreas Dilger) Date: Fri, 3 Aug 2018 00:01:18 +0000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: <87o9elplht.fsf@notabene.neil.brown.name> References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> <87sh3zq634.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> <878t5qrea2.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE75@LAX-EX-MB3.datadirect.datadirectnet.com> <87o9elplht.fsf@notabene.neil.brown.name> Message-ID: On Aug 1, 2018, at 20:09, NeilBrown wrote: > > > Once lustre and lnet are part of upstream Linux, what is the value of > keeping any of it in the master repo? > There would be be a need to keep it only to support old versions of > Linux, which will hopefully be less and less over time. > It might make sense to backport the upstream-linux code those particular > versions where it is needed, and do all development work in upstream > Linux, and just backport. I think the main reason is that none of the distros (which is what our customers use) will be running an upstream kernel for years after the client and later the server have landed upsteam. Also, since the upstream kernel doesn't allow any kind of interoperability code, backporting the upstream client to the older kernels will essentially involve recreating all of the interop code that lives in the out-of-tree client and server today, since there are a thousand small API changes going into the kernel that affect the Lustre code. I suspect there will be at least a couple of years of overlap, until we start seeing the distro kernels including a version of Lustre, then we can deprecate to out-of-tree code and only keep it maintained for older kernels, as happens today for older Lustre releases. Cheers, Andreas > On Wed, Aug 01 2018, Amir Shehata wrote: > >> Hi Neil, >> >> Thanks for the explanation. >> >> Speaking specifically for LNet, I'm not sure it's feasible to remove the code from master repo. As I mentioned LNet is a common piece between both the client and server sides. Both of them rely on it. And I believe LNet is also used by DVS, which is a cray developed layer, I'm not very familiar with it. So just deleting it from the master repo I don't think would work. >> >> Over the past years, there has been discussions about making it a standalone module that can be pulled in as a dependency. This approach makes a bit more sense to me. >> >> What are your thoughts on that? >> >> thanks >> amir >> ________________________________________ >> From: NeilBrown [neilb at suse.com] >> Sent: Tuesday, July 31, 2018 7:50 PM >> To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin >> Cc: Lustre Development List >> Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print >> >> Hi Amir, >> I think I'm happy to let this slide. I don't like magic numbers, but >> this one isn't important enough to justify the problems that might be >> caused by changing it. >> >> To answer your broader question: >>> The code bases are already diverging significantly between the >>> upstream client and the master repo, which makes porting features from >>> master to upstream a difficult task. Do we have a strategy on how to >>> deal with this? >> >> The long term strategy is just to get the work done so that the client >> code - and then all the kernel code - can be deleted from the master >> repo and can live solely in Linux. I know that is still quite a way >> away. >> >> Shorter term, there are no magic answers. Yes it is difficult but it >> is far from impossible. My plan has always been to get the code that >> is already in drivers/staging into a reasonable state, then start >> forward-porting patches from master. If other people do some of the >> forward-porting, that just makes me happier. >> If you think there is too much churn in my lustre tree, then just >> provide patches based on some old commit - I'm quite happy to receive >> patches based on fairly old code, and to do the final steps of >> forward-porting/conflict resolution myself (I have lots of practice). >> >> NeilBrown >> >> >> On Wed, Aug 01 2018, Amir Shehata wrote: >> >>> Hi Neil, >>> >>> This issue actually came up because of LU-6060, which changed the behavior for LLNL. The behavior then was changed again by LU-6851: https://jira.whamcloud.com/browse/LU-6851 (if you'd like more background) >>> >>> As a result of LU-6851 we were printing the unsigned value of -1. That's why we ended up printing it as -1, which is more bearable than just printing a large unsigned value. >>> >>> I'm not disagreeing that it'll be better to print a clearer value, "unknown" does sound like it relays the correct meaning. However, I've sometimes run into issues where changing user facing interfaces caused problems to user scripts. Would this be the case here, I'm not 100% sure. We can always make the change and then wait for tickets to be opened. >>> >>> However, I think of more concern to me is that if we make changes like this to the upstreamed client, it's probably a good idea to also make them to the whamcloud repo as well, so as not to diverge the client and server (LNet is common between them). This particular case, might not be very significant, but other issues might come up that are of more significance. >>> >>> The code bases are already diverging significantly between the upstream client and the master repo, which makes porting features from master to upstream a difficult task. Do we have a strategy on how to deal with this? >>> >>> thanks >>> amir >>> ________________________________________ >>> From: NeilBrown [neilb at suse.com] >>> Sent: Tuesday, July 31, 2018 5:32 PM >>> To: Amir Shehata; James Simmons; Andreas Dilger; Oleg Drokin >>> Cc: Lustre Development List >>> Subject: RE: [PATCH 11/31] lustre: lnet: Fix route hops print >>> >>> Hi Amir, >>> thanks for the background. >>> >>> I had to chuckle at "0 being the highest", though I know that this >>> distortion is not something specific to lustre. >>> >>> Your description seems to suggest that "-1" means "unknown" with an >>> implication that the number of hops might be high, and best not to take >>> the risk. >>> >>> Your point about compatability with scripts has some validity, though >>> it is annoying to have to support such ugly interfaces indefinitely. >>> Are there really likely to be dependencies? lustre has only been >>> printing -1 since Feb last year when this patch went upstream. >>> That was presumably an abi change as it would have printed MAXINT-1 >>> previously. Did that cause any problems? >>> >>> Thanks, >>> NeilBrown >>> >>> >>> On Tue, Jul 31 2018, Amir Shehata wrote: >>> >>>> The way hop and priority work in the code is they serve to select the preferred route. If you have multiple gateways leading to the same destination, you select the one with the highest priority (0 being the highest), followed by selecting the one with the least number of hops. If you don't specify hops, then it's actually treated as the least favoured if there are other routes with hops specified. If hops and priority are equivalent between routes, then you select the one with the most credits available, if that's equivalent you select in round robin. >>>> >>>> In that sense hops and priority really serve the same purpose, select the preferred route. If it was up to me I would keep only one of them, but for historical reasons, both are kept. >>>> >>>> Therefore, I'm not sure if "unlimited" actually relays the correct interpretation of that value. Note there could be user scripts out there that are already parsing the output. So by changing the -1 you could break the scripts. Also changing that will create an inconsistency between the server and client. >>>> >>>> thanks >>>> amir >>>> ________________________________________ >>>> From: NeilBrown [neilb at suse.com] >>>> Sent: Tuesday, July 31, 2018 3:38 PM >>>> To: James Simmons; Andreas Dilger; Oleg Drokin >>>> Cc: Lustre Development List; Amir Shehata; James Simmons >>>> Subject: Re: [PATCH 11/31] lustre: lnet: Fix route hops print >>>> >>>> On Mon, Jul 30 2018, James Simmons wrote: >>>> >>>>> From: Amir Shehata >>>>> >>>>> The default number of hops for a route is -1. This is >>>>> currently being printed as %u. Change that to %d to >>>>> make it print out properly. >>>> >>>> -1 hops??? I wish I could hop -1 times - it would be a good party >>>> trick!! >>>> >>>> What does -1 mean? Unlimited (just a guess). If so, could we print >>>> "unlimited"?? >>>> >>>> I'm fine with having magic numbers in the code, but I don't like them to >>>> leak out. >>>> >>>> NeilBrown >>>> >>>>> >>>>> Signed-off-by: Amir Shehata >>>>> WC-id: https://jira.whamcloud.com/browse/LU-9078 >>>>> Reviewed-on: https://review.whamcloud.com/25250 >>>>> Reviewed-by: Olaf Weber >>>>> Reviewed-by: Doug Oucharek >>>>> Reviewed-by: James Simmons >>>>> Reviewed-by: Oleg Drokin >>>>> Signed-off-by: James Simmons >>>>> --- >>>>> drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- >>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c >>>>> index 8856798..aa98ce5 100644 >>>>> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c >>>>> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c >>>>> @@ -218,7 +218,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, >>>>> int alive = lnet_is_route_alive(route); >>>>> >>>>> s += snprintf(s, tmpstr + tmpsiz - s, >>>>> - "%-8s %4u %8u %7s %s\n", >>>>> + "%-8s %4d %8u %7s %s\n", >>>>> libcfs_net2str(net), hops, >>>>> priority, >>>>> alive ? "up" : "down", >>>>> -- >>>>> 1.8.3.1 Cheers, Andreas --- Andreas Dilger CTO 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: From neilb at suse.com Fri Aug 3 01:58:12 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 03 Aug 2018 11:58:12 +1000 Subject: [lustre-devel] [PATCH 11/31] lustre: lnet: Fix route hops print In-Reply-To: References: <1533003983-29311-1-git-send-email-jsimmons@infradead.org> <1533003983-29311-12-git-send-email-jsimmons@infradead.org> <877elbrpxh.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE2A@LAX-EX-MB3.datadirect.datadirectnet.com> <87sh3zq634.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE41@LAX-EX-MB3.datadirect.datadirectnet.com> <878t5qrea2.fsf@notabene.neil.brown.name> <3C0BF267DA2B2343B6A8D6013E6C43381AAE75@LAX-EX-MB3.datadirect.datadirectnet.com> <87o9elplht.fsf@notabene.neil.brown.name> Message-ID: <87a7q4p5xn.fsf@notabene.neil.brown.name> On Fri, Aug 03 2018, Andreas Dilger wrote: > On Aug 1, 2018, at 20:09, NeilBrown wrote: >> >> >> Once lustre and lnet are part of upstream Linux, what is the value of >> keeping any of it in the master repo? >> There would be be a need to keep it only to support old versions of >> Linux, which will hopefully be less and less over time. >> It might make sense to backport the upstream-linux code those particular >> versions where it is needed, and do all development work in upstream >> Linux, and just backport. > > I think the main reason is that none of the distros (which is what our > customers use) will be running an upstream kernel for years after the > client and later the server have landed upsteam. Also, since the > upstream kernel doesn't allow any kind of interoperability code, > backporting the upstream client to the older kernels will essentially > involve recreating all of the interop code that lives in the out-of-tree > client and server today, since there are a thousand small API changes > going into the kernel that affect the Lustre code. > > I suspect there will be at least a couple of years of overlap, until > we start seeing the distro kernels including a version of Lustre, then > we can deprecate to out-of-tree code and only keep it maintained for > older kernels, as happens today for older Lustre releases. Yes, there will be overlap. It would be worth some effort to minimize that if we can. Once we have something credible in mainline, I'd like to encourage vendors to take a back-port of that, at least for their next SP. Hopefully we can then do development against mainline, and backport that to whatever still needs to be supported by out-of-tree code. Thanks, NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Fri Aug 3 02:36:26 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 03 Aug 2018 12:36:26 +1000 Subject: [lustre-devel] [PATCH 10/22] Revert "staging: lustre: lnet: conrpc: Use list_for_each_entry_safe" In-Reply-To: References: <153292153459.13840.17465048403476297915.stgit@noble> <153292186099.13840.6595803769201521471.stgit@noble> Message-ID: <871sbgp45x.fsf@notabene.neil.brown.name> On Thu, Aug 02 2018, James Simmons wrote: >> This reverts commit a9a6cb4f4693253349358f8163d826eb0cfecfbc. >> >> These loops really want to remove everything, and using a >> while(!list_empty()) >> loop makes this more obvious. >> >> Signed-off-by: NeilBrown >> --- >> drivers/staging/lustre/lnet/selftest/conrpc.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c >> index 95cbd1a14e1b..3afde0141db5 100644 >> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c >> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c >> @@ -1327,7 +1327,6 @@ lstcon_rpc_cleanup_wait(void) >> { >> struct lstcon_rpc_trans *trans; >> struct lstcon_rpc *crpc; >> - struct lstcon_rpc *temp; >> struct list_head *pacer; >> struct list_head zlist; >> >> @@ -1367,7 +1366,9 @@ lstcon_rpc_cleanup_wait(void) >> >> spin_unlock(&console_session.ses_rpc_lock); >> >> - list_for_each_entry_safe(crpc, temp, &zlist, crp_link) { >> + while (!list_empty(&zlist)) { >> + crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link); >> + > > Nak. This one needs to be updated to. The typedef lstcon_rpc_t no longer > exist. Now you need to use struct lstcon_rpc. Clearly I wasn't compiled with CONFIG_LNET_SELFTEST enabled. I am now. Thanks - I've added all your Reviewed-bys. NeilBrown -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From neilb at suse.com Mon Aug 6 03:40:59 2018 From: neilb at suse.com (NeilBrown) Date: Mon, 06 Aug 2018 13:40:59 +1000 Subject: [lustre-devel] lustre: RFC patch to restore watchdog functionality Message-ID: <87d0uwnovo.fsf@notabene.neil.brown.name> Lustre in drivers/staging lost the watchdog functionality some time ago Commit: 5d4450c41fe3 ("staging/lustre: fix build error on non-x86 platforms") This is an attempt to provide the same core functionality in a simpler way. It compiles, but I haven't tested it. I don't plan to pursue this further at the moment, but as watchdogs have been under discussion lately I thought it might be interesting to some. NeilBrown From: NeilBrown Date: Mon, 6 Aug 2018 13:37:40 +1000 Subject: [PATCH] lustre: add watchdog for ptlrpc service threads. If a ptlrpc thread takes longer than expected, it can be used to get a stack trace to see where the problem is. This patch restores this functionality by using a delayed work struct to report a back trace of the thread if it ever fires. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_net.h | 10 +-- drivers/staging/lustre/lustre/ptlrpc/service.c | 87 ++++++++++++++++++---- 2 files changed, 76 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 361b8970368e..3eccec7c7dcc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1283,18 +1283,14 @@ struct ptlrpc_thread { */ unsigned int t_id; /** - * service thread pid + * service thread */ + struct task_struct *t_task; pid_t t_pid; /** * put watchdog in the structure per thread b=14840 - * - * Lustre watchdog is removed for client in the hope - * of a generic watchdog can be merged in kernel. - * When that happens, we should add below back. - * - * struct lc_watchdog *t_watchdog; */ + struct delayed_work t_watchdog; /** * the svc this thread belonged to b=18582 */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 55f68b9b3818..4d508a691e89 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1949,6 +1949,73 @@ ptlrpc_at_check(struct ptlrpc_service_part *svcpt) return svcpt->scp_at_check; } +/* + * If a thread spends too long, we want to know about it, + * so we set up a delayed work item as a watchdog. + * If it fires, we display a stack trace of the delayed thread, + * providing we aren't rate-limited + */ +#ifdef CONFIG_STACKTRACE +#define MAX_STACK_TRACE_DEPTH 64 +static void lc_watchdog_fire(struct work_struct *w) +{ + struct ptlrpc_thread *thread = container_of(w, struct ptlrpc_thread, + t_watchdog.work); + struct stack_trace trace; + unsigned long *entries; + unsigned int i; + static DEFINE_RATELIMIT_STATE(_rs, + DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + + pr_emerg("ptlrpc thread %d blocked for too long\n", thread->t_pid); + + if (!__ratelimit(&_rs)) + return; + + entries = kmalloc_array(MAX_STACK_TRACE_DEPTH, sizeof(*entries), + GFP_KERNEL); + if (!entries) + return; + + trace.nr_entries = 0; + trace.max_entries = MAX_STACK_TRACE_DEPTH; + trace.entries = entries; + trace.skip = 0; + + pr_warn("Stack trace of blocked thread\n"); + save_stack_trace_tsk(thread->t_task, &trace); + + for (i = 0; i < trace.nr_entries; i++) + pr_warn("[<0>] %pB\n", (void *)entries[i]); + + kfree(entries); +} +#else +static void lc_watchdog_fire(struct work_struct *w) +{ + struct ptlrpc_thread *thread = container_of(w, struct ptlrpc_thread, + lc_watchdog.work); + pr_emerg("ptlrpc thread %d blocked for too long\n", thread->t_pid); + +} +#endif + +static inline void lc_watchdog_init(struct delayed_work *work, int time) +{ + INIT_DELAYED_WORK(work, lc_watchdog_fire); + schedule_delayed_work(work, time); +} + +static inline void lc_watchdog_disable(struct delayed_work *work) +{ + cancel_delayed_work_sync(work); +} +static inline void lc_watchdog_touch(struct delayed_work *work, int time) +{ + mod_delayed_work(system_wq, work, time); +} + /** * requests wait on preprocessing * user can call it w/o any lock but need to hold @@ -1972,9 +2039,7 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, { /* Don't exit while there are replies to be handled */ - /* XXX: Add this back when libcfs watchdog is merged upstream - lc_watchdog_disable(thread->t_watchdog); - */ + lc_watchdog_disable(&thread->t_watchdog); cond_resched(); @@ -2001,10 +2066,8 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, if (ptlrpc_thread_stopping(thread)) return -EINTR; - /* - lc_watchdog_touch(thread->t_watchdog, + lc_watchdog_touch(&thread->t_watchdog, ptlrpc_server_get_timeout(svcpt)); - */ return 0; } @@ -2024,6 +2087,7 @@ static int ptlrpc_main(void *arg) struct lu_env *env; int counter = 0, rc = 0; + thread->t_task = current; thread->t_pid = current->pid; unshare_fs_struct(); @@ -2104,10 +2168,8 @@ static int ptlrpc_main(void *arg) /* wake up our creator in case he's still waiting. */ wake_up(&thread->t_ctl_waitq); - /* - thread->t_watchdog = lc_watchdog_add(ptlrpc_server_get_timeout(svcpt), - NULL, NULL); - */ + lc_watchdog_init(&thread->t_watchdog, + ptlrpc_server_get_timeout(svcpt)); spin_lock(&svcpt->scp_rep_lock); list_add(&rs->rs_list, &svcpt->scp_rep_idle); @@ -2163,10 +2225,7 @@ static int ptlrpc_main(void *arg) } } - /* - lc_watchdog_delete(thread->t_watchdog); - thread->t_watchdog = NULL; - */ + lc_watchdog_disable(&thread->t_watchdog); out_srv_fini: /* -- 2.14.0.rc0.dirty -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From jsimmons at infradead.org Fri Aug 17 03:10:04 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:04 -0400 Subject: [lustre-devel] [PATCH 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-2-git-send-email-jsimmons@infradead.org> Rename from ldebugfs_[un]register_mountpoint() to ll_debugfs_[un]register_super(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 6 +++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 6ed7034..b2cdf75 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -675,9 +675,9 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc); -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index fb3bc16..50ea5fb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -573,7 +573,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(osfs); if (llite_root) { - err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); + err = ll_debugfs_register_super(llite_root, sb, dt, md); if (err < 0) { CERROR("%s: could not register mount in debugfs: " "rc = %d\n", ll_get_fsname(sb, NULL, 0), err); @@ -679,7 +679,7 @@ static void client_common_put_super(struct super_block *sb) obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - ldebugfs_unregister_mountpoint(sbi); + ll_debugfs_unregister_super(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 617aabb..996703d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1175,8 +1175,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1285,7 +1285,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent, return err; } -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); kobject_put(&sbi->ll_kobj); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:03 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:03 -0400 Subject: [lustre-devel] [PATCH 00/38] lustre: fixes for sysfs handling Message-ID: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> 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 -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:14 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:14 -0400 Subject: [lustre-devel] [PATCH 11/38] lustre: llite: create ll_stats_pid_write() In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-12-git-send-email-jsimmons@infradead.org> From: Steve Guminski Several repeated code blocks are consolidated into a new function, ll_stats_pid_write(), to reduce duplication. Signed-off-by: Steve Guminski WC-bug-id: https://jira.whamcloud.com/browse/LU-8767 Reviewed-on: https://review.whamcloud.com/23942 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 90 +++++++++++------------ 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 0dc4d00..f57ad15 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -95,6 +95,41 @@ void llite_tunables_unregister(void) static const struct file_operations ll_rw_extents_stats_pp_fops; static const struct file_operations ll_rw_offset_stats_fops; +/** + * ll_stats_pid_write() - Determine if stats collection should be enabled + * @buf: Buffer containing the data written + * @len: Number of bytes in the buffer + * + * Several proc files begin collecting stats when a value is written, and stop + * collecting when either '0' or 'disable' is written. This function checks the + * written value to see if collection should be enabled or disabled. + * + * Return: If '0' or 'disable' is provided, 0 is returned. If the text + * equivalent of a number is written, that number is returned. Otherwise, + * 1 is returned. Non-zero return values indicate collection should be enabled. + */ +static s64 ll_stats_pid_write(const char __user *buf, size_t len) +{ + unsigned long long value = 1; + char kernbuf[16]; + int rc; + + rc = kstrtoull_from_user(buf, len, 0, &value); + if (rc < 0 && len < sizeof(kernbuf)) { + if (copy_from_user(kernbuf, buf, len)) + return -EFAULT; + kernbuf[len] = 0; + + if (kernbuf[len - 1] == '\n') + kernbuf[len - 1] = 0; + + if (strncasecmp(kernbuf, "disable", 7) == 0) + value = 0; + } + + return value; +} + static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -1425,26 +1460,12 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int i; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; @@ -1498,26 +1519,12 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int i; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; @@ -1702,27 +1709,12 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, struct ll_sb_info *sbi = seq->private; struct ll_rw_process_info *process_info = sbi->ll_rw_process_info; struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info; - int value = 1, rc = 0; + s64 value; if (len == 0) return -EINVAL; - rc = lprocfs_write_helper(buf, len, &value); - - if (rc < 0 && len < 16) { - char kernbuf[16]; - - if (copy_from_user(kernbuf, buf, len)) - return -EFAULT; - kernbuf[len] = 0; - - if (kernbuf[len - 1] == '\n') - kernbuf[len - 1] = 0; - - if (strcmp(kernbuf, "disabled") == 0 || - strcmp(kernbuf, "Disabled") == 0) - value = 0; - } + value = ll_stats_pid_write(buf, len); if (value == 0) sbi->ll_rw_stats_on = 0; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:05 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:05 -0400 Subject: [lustre-devel] [PATCH 02/38] lustre: llite: change ll_statfs_internal to use struct ll_sb_info In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-3-git-send-email-jsimmons@infradead.org> The only reason ll_statfs_internal() needs struct super_block is for the super block magic. We can use LL_SUPER_MAGIC directly thus removing the need to pass in struct super_block. This will help to remove ll_sb in struct ll_sb_info. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 4 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 9 ++++----- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index b2cdf75..4053314 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -832,8 +832,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, unsigned int xvalid, bool hsm_import); int ll_setattr(struct dentry *de, struct iattr *attr); int ll_statfs(struct dentry *de, struct kstatfs *sfs); -int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags); +int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, + u64 max_age, u32 flags); int ll_update_inode(struct inode *inode, struct lustre_md *md); int ll_read_inode2(struct inode *inode, void *opaque); void ll_delete_inode(struct inode *inode); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 50ea5fb..437f4cc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1643,10 +1643,9 @@ int ll_setattr(struct dentry *de, struct iattr *attr) return ll_setattr_raw(de, attr, xvalid, false); } -int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags) +int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, + u64 max_age, u32 flags) { - struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; int rc; @@ -1656,7 +1655,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, return rc; } - osfs->os_type = sb->s_magic; + osfs->os_type = LL_SUPER_MAGIC; CDEBUG(D_SUPER, "MDC blocks %llu/%llu objects %llu/%llu\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree, @@ -1703,7 +1702,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); /* Some amount of caching on the client is allowed */ - rc = ll_statfs_internal(sb, &osfs, + rc = ll_statfs_internal(ll_s2sbi(sb), &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, 0); if (rc) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 996703d..cae483f 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -52,7 +52,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) @@ -70,7 +70,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -95,7 +95,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -120,7 +120,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) { @@ -145,7 +145,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) @@ -163,7 +163,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_statfs osfs; int rc; - rc = ll_statfs_internal(sbi->ll_sb, &osfs, + rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); if (!rc) -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:11 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:11 -0400 Subject: [lustre-devel] [PATCH 08/38] lustre: llite: move lmd_profile handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-9-git-send-email-jsimmons@infradead.org> The function ll_debugfs_register_super() should only handling sysfs related things so move the lmd_profile parsing out of that function. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 17 ++++++++++++++++- drivers/staging/lustre/lustre/llite/lproc_llite.c | 18 ++---------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 9e60c5e..1130ea3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -677,7 +677,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct super_block *sb); +int ll_debugfs_register_super(struct super_block *sb, const char *name); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 95568b7..ce072da 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -909,6 +909,8 @@ void ll_lli_init(struct ll_inode_info *lli) memset(lli->lli_jobid, 0, LUSTRE_JOBID_SIZE); } +#define MAX_STRING_SIZE 128 + int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof = NULL; @@ -917,6 +919,9 @@ int ll_fill_super(struct super_block *sb) char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; + char name[MAX_STRING_SIZE]; + char *ptr; + int len; int err; static atomic_t ll_bdi_num = ATOMIC_INIT(0); @@ -951,10 +956,20 @@ int ll_fill_super(struct super_block *sb) /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ sb->s_d_op = &ll_d_ops; + /* Get fsname */ + len = strlen(lsi->lsi_lmd->lmd_profile); + ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); + if (ptr && (strcmp(ptr, "-client") == 0)) + len -= 7; + + /* Mount info */ + snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, + lsi->lsi_lmd->lmd_profile, sb); + /* Call ll_debugsfs_register_super() before lustre_process_log() * so that "llite.*.*" params can be processed correctly. */ - err = ll_debugfs_register_super(sb); + err = ll_debugfs_register_super(sb, name); if (err < 0) { CERROR("%s: could not register mountpoint in llite: rc = %d\n", ll_get_fsname(sb, NULL, 0), err); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 868c9b0..4186a8d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1227,28 +1227,14 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct super_block *sb) +int ll_debugfs_register_super(struct super_block *sb, const char *name) { - struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct dentry *dir; - char name[MAX_STRING_SIZE + 1], *ptr; - int err, id, len; - - name[MAX_STRING_SIZE] = '\0'; + int err, id; LASSERT(sbi); - /* Get fsname */ - len = strlen(lsi->lsi_lmd->lmd_profile); - ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-'); - if (ptr && (strcmp(ptr, "-client") == 0)) - len -= 7; - - /* Mount info */ - snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, - lsi->lsi_lmd->lmd_profile, sb); - dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:10 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:10 -0400 Subject: [lustre-devel] [PATCH 07/38] lustre: llite: register mountpoint before process llog In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-8-git-send-email-jsimmons@infradead.org> From: Emoly Liu In ll_fill_super(), ll_debugfs_register_super() should be called before lustre_process_log(), otherwise the directory /sys/fs/lustre/llite/* can't be created in time and the params "llite.*.*" won't be set correctly. Also, this patch adds sbi->ll_xattr_cache_set to mark the flag LL_SBI_XATTR_CACHE already set during lustre_process_log(), in case that it will be overwritten in client_common_fill_super(). Signed-off-by: Emoly Liu WC-bug-id: https://jira.whamcloud.com/browse/LU-9399 Reviewed-on: https://review.whamcloud.com/27241 Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/#/c/32516 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 5 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 75 ++++++++++++++++------ drivers/staging/lustre/lustre/llite/lproc_llite.c | 30 +++------ 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5577407..9e60c5e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -461,12 +461,15 @@ struct ll_sb_info { struct obd_uuid ll_sb_uuid; struct obd_export *ll_md_exp; struct obd_export *ll_dt_exp; + struct obd_device *ll_md_obd; + struct obd_device *ll_dt_obd; struct dentry *ll_debugfs_entry; struct lu_fid ll_root_fid; /* root object fid */ int ll_flags; unsigned int ll_umounting:1, ll_xattr_cache_enabled:1, + ll_xattr_cache_set:1, /* already set to 0/1 */ ll_client_common_fill_super_succeeded:1; struct lustre_client_ocd ll_lco; @@ -674,7 +677,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc); +int ll_debugfs_register_super(struct super_block *sb); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d352287..95568b7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -156,7 +156,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) { struct inode *root = NULL; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct obd_device *obd; struct obd_statfs *osfs = NULL; struct ptlrpc_request *request = NULL; struct obd_connect_data *data = NULL; @@ -166,8 +165,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) u64 valid; int size, err, checksum; - obd = class_name2obd(md); - if (!obd) { + sbi->ll_md_obd = class_name2obd(md); + if (!sbi->ll_md_obd) { CERROR("MD %s: not setup or attached\n", md); return -EINVAL; } @@ -247,8 +246,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) data->ocd_brw_size = MD_MAX_BRW_SIZE; - err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, - data, NULL); + err = obd_connect(NULL, &sbi->ll_md_exp, sbi->ll_md_obd, + &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", @@ -360,14 +359,19 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) LCONSOLE_INFO( "%s: disabling xattr cache due to unknown maximum xattr size.\n", dt); - } else { + } else if (!sbi->ll_xattr_cache_set) { + /* If xattr_cache is already set (no matter 0 or 1) + * during processing llog, it won't be enabled here. + */ + spin_lock(&sbi->ll_lock); sbi->ll_flags |= LL_SBI_XATTR_CACHE; + spin_unlock(&sbi->ll_lock); sbi->ll_xattr_cache_enabled = 1; } } - obd = class_name2obd(dt); - if (!obd) { + sbi->ll_dt_obd = class_name2obd(dt); + if (!sbi->ll_dt_obd) { CERROR("DT %s: not setup or attached\n", dt); err = -ENODEV; goto out_md_fid; @@ -414,13 +418,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) data->ocd_connect_flags, data->ocd_version, data->ocd_grant); - obd->obd_upcall.onu_owner = &sbi->ll_lco; - obd->obd_upcall.onu_upcall = cl_ocd_update; + sbi->ll_dt_obd->obd_upcall.onu_owner = &sbi->ll_lco; + sbi->ll_dt_obd->obd_upcall.onu_upcall = cl_ocd_update; data->ocd_brw_size = DT_MAX_BRW_SIZE; - err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, - NULL); + err = obd_connect(NULL, &sbi->ll_dt_exp, sbi->ll_dt_obd, + &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", @@ -568,11 +572,26 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(data); kfree(osfs); - err = ll_debugfs_register_super(sb, dt, md); - if (err < 0) { - CERROR("%s: could not register mount in debugfs: rc = %d\n", - ll_get_fsname(sb, NULL, 0), err); - err = 0; + if (sbi->ll_dt_obd) { + err = sysfs_create_link(&sbi->ll_kset.kobj, + &sbi->ll_dt_obd->obd_kobj, + sbi->ll_dt_obd->obd_type->typ_name); + if (err < 0) { + CERROR("%s: could not register %s in llite: rc = %d\n", + dt, ll_get_fsname(sb, NULL, 0), err); + err = 0; + } + } + + if (sbi->ll_md_obd) { + err = sysfs_create_link(&sbi->ll_kset.kobj, + &sbi->ll_md_obd->obd_kobj, + sbi->ll_md_obd->obd_type->typ_name); + if (err < 0) { + CERROR("%s: could not register %s in llite: rc = %d\n", + md, ll_get_fsname(sb, NULL, 0), err); + err = 0; + } } return err; @@ -583,6 +602,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) out_dt: obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; + sbi->ll_dt_obd = NULL; out_md_fid: obd_fid_fini(sbi->ll_md_exp->exp_obd); out_md: @@ -931,6 +951,16 @@ int ll_fill_super(struct super_block *sb) /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ sb->s_d_op = &ll_d_ops; + /* Call ll_debugsfs_register_super() before lustre_process_log() + * so that "llite.*.*" params can be processed correctly. + */ + err = ll_debugfs_register_super(sb); + if (err < 0) { + CERROR("%s: could not register mountpoint in llite: rc = %d\n", + ll_get_fsname(sb, NULL, 0), err); + err = 0; + } + /* Generate a string unique to this super, in case some joker tries * to mount the same fs at two mount points. * Use the address of the super itself. @@ -942,7 +972,7 @@ int ll_fill_super(struct super_block *sb) /* set up client obds */ err = lustre_process_log(sb, profilenm, cfg); if (err < 0) - goto out_free; + goto out_debugfs; /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ lprof = class_get_profile(profilenm); @@ -951,7 +981,7 @@ int ll_fill_super(struct super_block *sb) "The client profile '%s' could not be read from the MGS. Does that filesystem exist?\n", profilenm); err = -EINVAL; - goto out_free; + goto out_debugfs; } CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, lprof->lp_md, lprof->lp_dt); @@ -959,13 +989,13 @@ int ll_fill_super(struct super_block *sb) dt = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_dt, cfg->cfg_instance); if (!dt) { err = -ENOMEM; - goto out_free; + goto out_debugfs; } md = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_md, cfg->cfg_instance); if (!md) { err = -ENOMEM; - goto out_free; + goto out_debugfs; } /* connections, registrations, sb setup */ @@ -973,6 +1003,9 @@ int ll_fill_super(struct super_block *sb) if (!err) sbi->ll_client_common_fill_super_succeeded = 1; +out_debugfs: + if (err < 0) + ll_debugfs_unregister_super(sbi); out_free: kfree(md); kfree(dt); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 90140b0..868c9b0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -924,6 +924,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, return -ENOTSUPP; sbi->ll_xattr_cache_enabled = val; + sbi->ll_xattr_cache_set = 1; return count; } @@ -1226,11 +1227,10 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); - struct obd_device *obd; struct dentry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len; @@ -1238,8 +1238,6 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) name[MAX_STRING_SIZE] = '\0'; LASSERT(sbi); - LASSERT(mdc); - LASSERT(osc); /* Get fsname */ len = strlen(lsi->lsi_lmd->lmd_profile); @@ -1315,22 +1313,6 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) goto out; err = kset_register(&sbi->ll_kset); - if (err) - goto out; - - /* MDC info */ - obd = class_name2obd(mdc); - - err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, - obd->obd_type->typ_name); - if (err) - goto out; - - /* OSC */ - obd = class_name2obd(osc); - - err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, - obd->obd_type->typ_name); out: if (err) { debugfs_remove_recursive(sbi->ll_debugfs_entry); @@ -1344,6 +1326,14 @@ void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); + if (sbi->ll_dt_obd) + sysfs_remove_link(&sbi->ll_kset.kobj, + sbi->ll_dt_obd->obd_type->typ_name); + + if (sbi->ll_md_obd) + sysfs_remove_link(&sbi->ll_kset.kobj, + sbi->ll_md_obd->obd_type->typ_name); + kset_unregister(&sbi->ll_kset); wait_for_completion(&sbi->ll_kobj_unregister); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:12 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:12 -0400 Subject: [lustre-devel] [PATCH 09/38] lustre: llite: add proper error handling for ll_debugfs_register_super() In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-10-git-send-email-jsimmons@infradead.org> Having the single out label that cleans up everything is not proper kernel style and can create more bugs. Instead just cleanup the items we created only by introducing multiple goto label that handle specific cleanups. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 34 +++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 4186a8d..5530156 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1235,9 +1235,14 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LASSERT(sbi); + if (IS_ERR_OR_NULL(llite_root)) + goto out_ll_kset; + dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; + ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); + debugfs_create_file("dump_page_cache", 0444, dir, sbi, &vvp_dump_pgcache_file_ops); debugfs_create_file("extents_stats", 0644, dir, sbi, @@ -1252,8 +1257,9 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LPROCFS_STATS_FLAG_NONE); if (!sbi->ll_stats) { err = -ENOMEM; - goto out; + goto out_debugfs; } + /* do counter init */ for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) { __u32 type = llite_opcode_table[id].type; @@ -1278,7 +1284,7 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) LPROCFS_STATS_FLAG_NONE); if (!sbi->ll_ra_stats) { err = -ENOMEM; - goto out; + goto out_stats; } for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) @@ -1287,24 +1293,28 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry, sbi->ll_ra_stats, &lprocfs_stats_seq_fops); - - ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); - +out_ll_kset: /* Yes we also register sysfs mount kset here as well */ sbi->ll_kset.kobj.parent = llite_kobj; sbi->ll_kset.kobj.ktype = &llite_ktype; init_completion(&sbi->ll_kobj_unregister); err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name); if (err) - goto out; + goto out_ra_stats; err = kset_register(&sbi->ll_kset); -out: - if (err) { - debugfs_remove_recursive(sbi->ll_debugfs_entry); - lprocfs_free_stats(&sbi->ll_ra_stats); - lprocfs_free_stats(&sbi->ll_stats); - } + if (err) + goto out_ra_stats; + + return 0; + +out_ra_stats: + lprocfs_free_stats(&sbi->ll_ra_stats); +out_stats: + lprocfs_free_stats(&sbi->ll_stats); +out_debugfs: + debugfs_remove_recursive(sbi->ll_debugfs_entry); + return err; } -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:08 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:08 -0400 Subject: [lustre-devel] [PATCH 05/38] lustre: llite: change top kobject for llite into a kset In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-6-git-send-email-jsimmons@infradead.org> Currently the top of the sysfs tree for llite is represented by a kobject and each mount instance a kset. Change the top object into a kset and each mount instance into a kobject instead. The reason for this change is in the future lustre_kobj will be changed into a kset and you can't layer two ksets. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 114 +++++++++++++-------- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 92dc05d..5577407 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -523,7 +523,7 @@ struct ll_sb_info { struct path ll_mnt; __kernel_fsid_t ll_fsid; - struct kobject ll_kobj; /* sysfs object */ + struct kset ll_kset; /* sysfs object */ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8e418ba..8af6636 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -40,22 +40,42 @@ #include "llite_internal.h" #include "vvp_internal.h" +static struct kobject *llite_kobj; static struct dentry *llite_root; -static struct kset *llite_kset; + +static void class_sysfs_release(struct kobject *kobj) +{ + kfree(kobj); +} + +static struct kobj_type class_ktype = { + .sysfs_ops = &lustre_sysfs_ops, + .release = class_sysfs_release, +}; int llite_tunables_register(void) { + const char *name = "llite"; + struct kobject *kobj; int rc = 0; - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); - if (!llite_kset) + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return -ENOMEM; + + kobject_init(kobj, &class_ktype); + rc = kobject_add(kobj, lustre_kobj, "%s", name); + if (rc) { + kobject_put(kobj); return -ENOMEM; + } + llite_kobj = kobj; llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; llite_root = NULL; - kset_unregister(llite_kset); + kobject_put(kobj); } return rc; @@ -63,7 +83,8 @@ int llite_tunables_register(void) void llite_tunables_unregister(void) { - kset_unregister(llite_kset); + kobject_put(llite_kobj); + llite_kobj = NULL; debugfs_remove(llite_root); llite_root = NULL; @@ -78,7 +99,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -96,7 +117,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -121,7 +142,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -146,7 +167,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -171,7 +192,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -189,7 +210,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -214,7 +235,7 @@ static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%s\n", sbi->ll_mnt.mnt->mnt_sb->s_type->name); } @@ -224,7 +245,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid); } @@ -247,7 +268,7 @@ static ssize_t max_read_ahead_mb_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -265,7 +286,7 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -294,7 +315,7 @@ static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -312,7 +333,7 @@ static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -339,7 +360,7 @@ static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -357,7 +378,7 @@ static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -522,7 +543,7 @@ static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } @@ -533,7 +554,7 @@ static ssize_t checksum_pages_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -564,7 +585,7 @@ static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); if (sbi->ll_stats_track_type == type) return sprintf(buf, "%d\n", sbi->ll_stats_track_id); @@ -579,7 +600,7 @@ static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pid; @@ -648,7 +669,7 @@ static ssize_t statahead_max_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_sa_max); } @@ -659,7 +680,7 @@ static ssize_t statahead_max_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -682,7 +703,7 @@ static ssize_t statahead_agl_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } @@ -693,7 +714,7 @@ static ssize_t statahead_agl_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -734,7 +755,7 @@ static ssize_t lazystatfs_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); } @@ -745,7 +766,7 @@ static ssize_t lazystatfs_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -769,7 +790,7 @@ static ssize_t max_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -798,7 +819,7 @@ static ssize_t default_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -831,7 +852,7 @@ static ssize_t default_easize_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned long val; int rc; @@ -877,7 +898,7 @@ static ssize_t xattr_cache_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled); } @@ -888,7 +909,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -913,7 +934,7 @@ static ssize_t fast_read_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", !!(sbi->ll_flags & LL_SBI_FAST_READ)); } @@ -924,7 +945,7 @@ static ssize_t fast_read_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); bool val; int rc; @@ -1110,7 +1131,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, static void llite_sb_release(struct kobject *kobj) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); complete(&sbi->ll_kobj_unregister); } @@ -1285,17 +1306,22 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); - sbi->ll_kobj.kset = llite_kset; + /* Yes we also register sysfs mount kset here as well */ + sbi->ll_kset.kobj.parent = llite_kobj; + sbi->ll_kset.kobj.ktype = &llite_ktype; init_completion(&sbi->ll_kobj_unregister); - err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL, - "%s", name); + err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name); + if (err) + goto out; + + err = kset_register(&sbi->ll_kset); if (err) goto out; /* MDC info */ obd = class_name2obd(mdc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); if (err) goto out; @@ -1303,7 +1329,7 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) /* OSC */ obd = class_name2obd(osc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); out: if (err) { @@ -1317,8 +1343,10 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); - kobject_put(&sbi->ll_kobj); + + kset_unregister(&sbi->ll_kset); wait_for_completion(&sbi->ll_kobj_unregister); + lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:15 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:15 -0400 Subject: [lustre-devel] [PATCH 12/38] lustre: llite: improve sysfs file text in lproc_llite.c In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-13-git-send-email-jsimmons@infradead.org> From: Steve Guminski Improves the instructions displayed when reading from the stats files. Signed-off-by: Steve Guminski WC-bug-id: https://jira.whamcloud.com/browse/LU-8767 Reviewed-on: https://review.whamcloud.com/23942 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f57ad15..2a76c01 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1429,8 +1429,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then '0' or 'disabled' to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", @@ -1493,8 +1493,8 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then '0' or 'disabled' to deactivate\n"); return 0; } seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", @@ -1659,8 +1659,8 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) ktime_get_real_ts64(&now); if (!sbi->ll_rw_stats_on) { - seq_printf(seq, "disabled\n" - "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); + seq_puts(seq, "disabled\n" + "write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n"); return 0; } spin_lock(&sbi->ll_process_lock); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:21 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:21 -0400 Subject: [lustre-devel] [PATCH 18/38] lustre: obd: embedded struct lprocfs_vars in obd device In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-19-git-send-email-jsimmons@infradead.org> Currently struct lprocfs_vars is initialized by the function lprocfs_xxx_init_var() in many places. By initializing and caching the obd_vars inside of the obd device we can simplify the code greatly. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-3319 Reviewed-on: https://review.whamcloud.com/7135 Reviewed-by: Bob Glossman Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 1 + drivers/staging/lustre/lustre/lmv/lmv_internal.h | 3 ++- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 7 ++----- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 5 +++-- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 ++- drivers/staging/lustre/lustre/lov/lov_obd.c | 11 +++-------- drivers/staging/lustre/lustre/lov/lproc_lov.c | 5 +++-- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 5 +++-- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++-------- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 5 +++-- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 3 ++- drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ++-- drivers/staging/lustre/lustre/osc/lproc_osc.c | 5 +++-- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 ++- drivers/staging/lustre/lustre/osc/osc_request.c | 13 ++++--------- 18 files changed, 43 insertions(+), 51 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 495e6f5..ca4cd9a 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,7 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, +int lprocfs_obd_setup(struct obd_device *obd, const struct attribute_group *attrs); int lprocfs_obd_cleanup(struct obd_device *obd); diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 3c0dbb6..0b071e3 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -602,6 +602,7 @@ struct obd_device { struct dentry *obd_debugfs_entry; struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; + struct lprocfs_vars *obd_vars; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; struct list_head obd_evict_list; /* protected with pet_lock */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 68a9917..3157ab9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,7 +157,8 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_lmv_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); extern const struct file_operations lmv_proc_target_fops; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 55db904..1867f6a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1254,9 +1254,9 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(&lvars); + lprocfs_lmv_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, @@ -3098,11 +3098,8 @@ static int lmv_merge_attr(struct obd_export *exp, static int __init lmv_init(void) { - struct lprocfs_static_vars lvars; int rc; - lprocfs_lmv_init_vars(&lvars); - rc = libcfs_setup(); if (rc) return rc; diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 30727b7..bc6e13c 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -166,8 +166,9 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) .attrs = lmv_attrs, }; -void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_lmv_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_lmv_obd_vars; lvars->sysfs_vars = &lmv_attr_group; - lvars->obd_vars = lprocfs_lmv_obd_vars; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 47042f2..e93dfd4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -241,7 +241,8 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, /* lproc_lov.c */ extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_lov_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 07f6b1b..05d097e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -769,8 +769,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) goto out; - lprocfs_lov_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_lov_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); @@ -872,7 +872,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, goto out; } case LCFG_PARAM: { - struct lprocfs_static_vars lvars = { NULL }; struct lov_desc *desc = &obd->u.lov.desc; if (!desc) { @@ -880,9 +879,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, goto out; } - lprocfs_lov_init_vars(&lvars); - - rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars, + rc = class_process_proc_param(PARAM_LOV, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -1356,7 +1353,6 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, static int __init lov_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; /* print an address of _any_ initialized kernel symbol from this @@ -1380,7 +1376,6 @@ static int __init lov_init(void) lu_kmem_fini(lov_caches); return -ENOMEM; } - lprocfs_lov_init_vars(&lvars); rc = class_register_type(&lov_obd_ops, NULL, LUSTRE_LOV_NAME, &lov_device_type); diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 721440f..317c154 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -284,10 +284,11 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) .attrs = lov_attrs, }; -void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_lov_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_lov_obd_vars; lvars->sysfs_vars = &lov_attr_group; - lvars->obd_vars = lprocfs_lov_obd_vars; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 6cce324..bf92893 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -224,8 +224,9 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, .attrs = mdc_attrs, }; -void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_mdc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { + obd->obd_vars = lprocfs_mdc_obd_vars; lvars->sysfs_vars = &mdc_attr_group; - lvars->obd_vars = lprocfs_mdc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index f19b0ce..20be240 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,8 +36,8 @@ #include -void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars); - +void lprocfs_mdc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index a759da2..8a90dab 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2648,8 +2648,8 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_mdc_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -2716,13 +2716,11 @@ static int mdc_cleanup(struct obd_device *obd) static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) { struct lustre_cfg *lcfg = buf; - struct lprocfs_static_vars lvars = { NULL }; int rc = 0; - lprocfs_mdc_init_vars(&lvars); switch (lcfg->lcfg_command) { default: - rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars, + rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -2784,15 +2782,12 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) static int __init mdc_init(void) { - struct lprocfs_static_vars lvars = { NULL }; int rc; rc = libcfs_setup(); if (rc) return rc; - lprocfs_mdc_init_vars(&lvars); - return class_register_type(&mdc_obd_ops, &mdc_md_ops, LUSTRE_MDC_NAME, NULL); } diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 6367706..e92787d 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -63,7 +63,8 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { NULL } }; -void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_mgc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { - lvars->obd_vars = lprocfs_mgc_obd_vars; + obd->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 9541892..400d52c 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,7 +39,8 @@ #include #include -void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_mgc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 833e6a0..6c769c6 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -748,8 +748,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(&lvars); - lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars); + lprocfs_mgc_init_vars(obd, &lvars); + lprocfs_obd_setup(obd, lvars.sysfs_vars); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3776447..c032458 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1014,7 +1014,7 @@ static void obd_sysfs_release(struct kobject *kobj) .release = obd_sysfs_release, }; -int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, +int lprocfs_obd_setup(struct obd_device *obd, const struct attribute_group *attrs) { int rc = 0; @@ -1036,7 +1036,7 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list, obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name, obd->obd_type->typ_debugfs_entry); - ldebugfs_add_vars(obd->obd_debugfs_entry, list, obd); + ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_vars, obd); return rc; } diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 54a303e..1492ad9 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -824,8 +824,9 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) .attrs = osc_attrs, }; -void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) +void lprocfs_osc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars) { lvars->sysfs_vars = &osc_attr_group; - lvars->obd_vars = lprocfs_osc_obd_vars; + obd->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 02e8318..a762d31 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -146,7 +146,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); +void lprocfs_osc_init_vars(struct obd_device *obd, + struct lprocfs_static_vars *lvars); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index b2b55a7..9c226f0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2803,8 +2803,9 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out_ptlrpcd_work; cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(&lvars); - if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) { + + lprocfs_osc_init_vars(obd, &lvars); + if (lprocfs_obd_setup(obd, lvars.sysfs_vars) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); @@ -2911,14 +2912,11 @@ static int osc_cleanup(struct obd_device *obd) int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; int rc = 0; - lprocfs_osc_init_vars(&lvars); - switch (lcfg->lcfg_command) { default: - rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars, + rc = class_process_proc_param(PARAM_OSC, obd->obd_vars, lcfg, obd); if (rc > 0) rc = 0; @@ -2967,7 +2965,6 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf) static int __init osc_init(void) { - struct lprocfs_static_vars lvars = { NULL }; unsigned int reqpool_size; unsigned int reqsize; int rc; @@ -2986,8 +2983,6 @@ static int __init osc_init(void) if (rc) return rc; - lprocfs_osc_init_vars(&lvars); - rc = register_shrinker(&osc_cache_shrinker); if (rc) goto err; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:28 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:28 -0400 Subject: [lustre-devel] [PATCH 25/38] lustre: obd: enhance print_lustre_cfg() In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-26-git-send-email-jsimmons@infradead.org> Make the function print_lustre_cfg() exportables so we can provide details when debugging other parts of the stack that handle lustre_cfg processing. We currently report the index of the buffer in struct lustre_cfg as well as the buffers length. We don't report the actually string so lets add that info as well. Signed-off-by: James Simmons WC-id: https://jira.whamcloud.com/browse/LU-7004 Reviewed-on: https://review.whamcloud.com/28590 Reviewed-by: Fan Yong Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 1 + drivers/staging/lustre/lustre/obdclass/llog_swab.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e994c968..e250bc3 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -106,6 +106,7 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, /* obd_config.c */ char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); +void print_lustre_cfg(struct lustre_cfg *lcfg); int class_process_config(struct lustre_cfg *lcfg); int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index b431c34..3803056 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -308,12 +308,13 @@ void lustre_swab_llog_hdr(struct llog_log_hdr *h) } EXPORT_SYMBOL(lustre_swab_llog_hdr); -static void print_lustre_cfg(struct lustre_cfg *lcfg) +void print_lustre_cfg(struct lustre_cfg *lcfg) { int i; if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */ return; + CDEBUG(D_OTHER, "lustre_cfg: %p\n", lcfg); CDEBUG(D_OTHER, "\tlcfg->lcfg_version: %#x\n", lcfg->lcfg_version); @@ -324,10 +325,13 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) CDEBUG(D_OTHER, "\tlcfg->lcfg_bufcount: %d\n", lcfg->lcfg_bufcount); if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT) - for (i = 0; i < lcfg->lcfg_bufcount; i++) - CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d\n", - i, lcfg->lcfg_buflens[i]); + for (i = 0; i < lcfg->lcfg_bufcount; i++) { + CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d %s\n", + i, lcfg->lcfg_buflens[i], + lustre_cfg_string(lcfg, i)); + } } +EXPORT_SYMBOL(print_lustre_cfg); void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) { -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:33 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:33 -0400 Subject: [lustre-devel] [PATCH 30/38] lustre: mgc: update sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-31-git-send-email-jsimmons@infradead.org> Move mgc to using the new sysfs conn_uuid. Move all sysfs/debugfs handling to lprocfs_mgc.c and implement proper error handling. Signed-off-by: James Simmons WC-bug-id: https://jira.hpdd.intel.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/29250 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 43 ++++++++++++++++++------ drivers/staging/lustre/lustre/mgc/mgc_internal.h | 2 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 10 +++--- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 7951ec6..574233e 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -38,9 +38,11 @@ #include "mgc_internal.h" LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags); + LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid); + LPROC_SEQ_FOPS_RO_TYPE(mgc, import); + LPROC_SEQ_FOPS_RO_TYPE(mgc, state); LPROC_SEQ_FOPS_WR_ONLY(mgc, ping); @@ -52,18 +54,39 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO(mgc_ir_state); -static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { - { "ping", &mgc_ping_fops, NULL, 0222 }, - { "connect_flags", &mgc_connect_flags_fops, NULL, 0 }, - { "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 }, - { "mgs_conn_uuid", &mgc_conn_uuid_fops, NULL, 0 }, - { "import", &mgc_import_fops, NULL, 0 }, - { "state", &mgc_state_fops, NULL, 0 }, - { "ir_state", &mgc_ir_state_fops, NULL, 0 }, +struct lprocfs_vars lprocfs_mgc_obd_vars[] = { + { .name = "ping", + .fops = &mgc_ping_fops }, + { .name = "connect_flags", + .fops = &mgc_connect_flags_fops }, + { .name = "mgs_server_uuid", + .fops = &mgc_server_uuid_fops }, + { .name = "import", + .fops = &mgc_import_fops }, + { .name = "state", + .fops = &mgc_state_fops }, + { .name = "ir_state", + .fops = &mgc_ir_state_fops }, { NULL } }; -void lprocfs_mgc_init_vars(struct obd_device *obd) +#define mgs_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(mgs_conn_uuid); + +static struct attribute *mgc_attrs[] = { + &lustre_attr_mgs_conn_uuid.attr, + NULL, +}; + +int mgc_tunables_init(struct obd_device *obd) { + int rc; + + obd->obd_ktype.default_attrs = mgc_attrs; obd->obd_vars = lprocfs_mgc_obd_vars; + rc = lprocfs_obd_setup(obd, true); + if (rc) + return rc; + + return sptlrpc_lprocfs_cliobd_attach(obd); } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 5385d91..0a91624 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,7 +39,7 @@ #include #include -void lprocfs_mgc_init_vars(struct obd_device *obd); +int mgc_tunables_init(struct obd_device *obd); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 50da9cf..4552cc5 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -747,9 +747,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(obd); - lprocfs_obd_setup(obd, true); - sptlrpc_lprocfs_cliobd_attach(obd); + rc = mgc_tunables_init(obd); + if (rc) + goto err_sysfs; if (atomic_inc_return(&mgc_count) == 1) { rq_state = 0; @@ -761,7 +761,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = PTR_ERR(task); CERROR("%s: cannot start requeue thread: rc = %d; no more log updates\n", obd->obd_name, rc); - goto err_cleanup; + goto err_sysfs; } /* rc is the task_struct pointer of mgc_requeue_thread. */ rc = 0; @@ -770,6 +770,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return rc; +err_sysfs: + lprocfs_obd_cleanup(obd); err_cleanup: client_obd_cleanup(obd); err_decref: -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:37 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:37 -0400 Subject: [lustre-devel] [PATCH 34/38] lustre: osc: enhance end to end bulk cksum error report In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-35-git-send-email-jsimmons@infradead.org> From: Bruno Faccini Some sites have experienced spurious checksum errors upon bulk xfers where it is very difficult to determine the source of the corruption. With this patch, upon cksum error, full dump of all pages in a bulk xfer is now possible (enabled via a /sysfs tunable) on both Client and OSS sides, to allow easier root cause identification. Signed-off-by: Bruno Faccini WC-bug-id: https://jira.whamcloud.com/browse/LU-8376 Reviewed-on: https://review.whamcloud.com/23960 Reviewed-by: Nathaniel Clark Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lnet/libcfs/debug.c | 1 + drivers/staging/lustre/lustre/include/obd.h | 6 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 31 ++++++ drivers/staging/lustre/lustre/osc/osc_request.c | 140 +++++++++++++++++++----- 4 files changed, 147 insertions(+), 31 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index 0289f24..dd06a4c 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -219,6 +219,7 @@ static int param_set_uintpos(const char *val, const struct kernel_param *kp) static wait_queue_head_t debug_ctlwq; char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT; +EXPORT_SYMBOL(libcfs_debug_file_path_arr); /* We need to pass a pointer here, but elsewhere this must be a const */ static char *libcfs_debug_file_path; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 385a88d..329bae9 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -324,7 +324,8 @@ struct client_obd { struct obd_export *cl_mgc_mgsexp; /* checksumming for data sent over the network */ - unsigned int cl_checksum:1; /* 0 = disabled, 1 = enabled */ + unsigned int cl_checksum:1, /* 0 = disabled, 1 = enabled */ + cl_checksum_dump:1; /* same */ /* supported checksum types that are worked out at connect time */ __u32 cl_supp_cksum_types; /* checksum algorithm to be used */ @@ -557,7 +558,8 @@ struct obd_device { * (for sysfs status only!!) */ obd_no_ir:1, /* no imperative recovery. */ - obd_process_conf:1; /* device is processing mgs config */ + obd_process_conf:1, /* device is processing mgs config */ + obd_checksum_dump:1; /* dump pages upon cksum error */ /* use separate field as it is set in interrupt to don't mess with * protection of other bits using _bh lock */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 79a30b3..89dadba 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -491,6 +491,36 @@ static ssize_t resend_count_store(struct kobject *kobj, } LUSTRE_RW_ATTR(resend_count); +static ssize_t checksum_dump_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + + return sprintf(buf, "%d\n", obd->u.cli.cl_checksum_dump ? 1 : 0); +} + +static ssize_t checksum_dump_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + bool val; + int rc; + + rc = kstrtobool(buffer, &val); + if (rc) + return rc; + + obd->u.cli.cl_checksum_dump = val; + + return count; +} +LUSTRE_RW_ATTR(checksum_dump); + static ssize_t contention_seconds_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -828,6 +858,7 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) static struct attribute *osc_attrs[] = { &lustre_attr_active.attr, &lustre_attr_checksums.attr, + &lustre_attr_checksum_dump.attr, &lustre_attr_contention_seconds.attr, &lustre_attr_cur_dirty_bytes.attr, &lustre_attr_cur_grant_bytes.attr, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 4f57a8e..a7a4a53 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1306,6 +1306,12 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, body->oa.o_flags |= cksum_type_pack(cli->cl_cksum_type); body->oa.o_valid |= OBD_MD_FLCKSUM | OBD_MD_FLFLAGS; } + + /* Client cksum has been already copied to wire obdo in previous + * lustre_set_wire_obdo(), and in the case a bulk-read is being + * resent due to cksum error, this will allow Server to + * check+dump pages on its side + */ } ptlrpc_request_set_replen(req); @@ -1333,11 +1339,73 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, return rc; } +char dbgcksum_file_name[PATH_MAX]; + +static void dump_all_bulk_pages(struct obdo *oa, u32 page_count, + struct brw_page **pga, u32 server_cksum, + u32 client_cksum) +{ + struct file *filp; + unsigned int len; + int rc, i; + char *buf; + + /* will only keep dump of pages on first error for the same range in + * file/fid, not during the resends/retries. + */ + snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name), + "%s-checksum_dump-osc-" DFID ":[%llu-%llu]-%x-%x", + (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 ? + libcfs_debug_file_path_arr : + LIBCFS_DEBUG_FILE_PATH_DEFAULT), + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : 0ULL, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, + pga[0]->off, + pga[page_count - 1]->off + pga[page_count - 1]->count - 1, + client_cksum, server_cksum); + filp = filp_open(dbgcksum_file_name, + O_CREAT | O_EXCL | O_WRONLY | O_LARGEFILE, 0600); + if (IS_ERR(filp)) { + rc = PTR_ERR(filp); + if (rc == -EEXIST) + CDEBUG(D_INFO, + "%s: can't open to dump pages with checksum error: rc = %d\n", + dbgcksum_file_name, rc); + else + CERROR("%s: can't open to dump pages with checksum error: rc = %d\n", + dbgcksum_file_name, rc); + return; + } + + for (i = 0; i < page_count; i++) { + len = pga[i]->count; + buf = kmap(pga[i]->pg); + while (len != 0) { + rc = kernel_write(filp, buf, len, &filp->f_pos); + if (rc < 0) { + CERROR("%s: wanted to write %u but got %d error\n", + dbgcksum_file_name, len, rc); + break; + } + len -= rc; + buf += rc; + CDEBUG(D_INFO, "%s: wrote %d bytes\n", + dbgcksum_file_name, rc); + } + kunmap(pga[i]->pg); + } + + rc = vfs_fsync_range(filp, 0, LLONG_MAX, 1); + if (rc) + CERROR("%s: sync returns %d\n", dbgcksum_file_name, rc); + filp_close(filp, NULL); +} + static int check_write_checksum(struct obdo *oa, const struct lnet_process_id *peer, - __u32 client_cksum, __u32 server_cksum, int nob, - u32 page_count, struct brw_page **pga, - enum cksum_type client_cksum_type) + u32 client_cksum, u32 server_cksum, + struct osc_brw_async_args *aa) { __u32 new_cksum; char *msg; @@ -1348,12 +1416,16 @@ static int check_write_checksum(struct obdo *oa, return 0; } + if (aa->aa_cli->cl_checksum_dump) + dump_all_bulk_pages(oa, aa->aa_page_count, aa->aa_ppga, + server_cksum, client_cksum); + cksum_type = cksum_type_unpack(oa->o_valid & OBD_MD_FLFLAGS ? oa->o_flags : 0); - new_cksum = osc_checksum_bulk(nob, page_count, pga, OST_WRITE, - cksum_type); + new_cksum = osc_checksum_bulk(aa->aa_requested_nob, aa->aa_page_count, + aa->aa_ppga, OST_WRITE, cksum_type); - if (cksum_type != client_cksum_type) + if (cksum_type != cksum_type_unpack(aa->aa_oa->o_flags)) msg = "the server did not use the checksum type specified in the original request - likely a protocol problem" ; else if (new_cksum == server_cksum) @@ -1365,17 +1437,19 @@ static int check_write_checksum(struct obdo *oa, msg = "changed in transit AND doesn't match the original - likely false positive due to mmap IO (bug 11742)" ; - LCONSOLE_ERROR_MSG(0x132, "BAD WRITE CHECKSUM: %s: from %s inode " DFID " object " DOSTID " extent [%llu-%llu]\n", + LCONSOLE_ERROR_MSG(0x132, + "%s: BAD WRITE CHECKSUM: %s: from %s inode " DFID " object " DOSTID " extent [%llu-%llu], original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", + aa->aa_cli->cl_import->imp_obd->obd_name, msg, libcfs_nid2str(peer->nid), - oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (__u64)0, + oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (u64)0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, - POSTID(&oa->o_oi), pga[0]->off, - pga[page_count - 1]->off + - pga[page_count - 1]->count - 1); - CERROR("original client csum %x (type %x), server csum %x (type %x), client csum now %x\n", - client_cksum, client_cksum_type, - server_cksum, cksum_type, new_cksum); + POSTID(&oa->o_oi), aa->aa_ppga[0]->off, + aa->aa_ppga[aa->aa_page_count - 1]->off + + aa->aa_ppga[aa->aa_page_count - 1]->count - 1, + client_cksum, cksum_type_unpack(aa->aa_oa->o_flags), + server_cksum, cksum_type, new_cksum); + return 1; } @@ -1432,9 +1506,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if ((aa->aa_oa->o_valid & OBD_MD_FLCKSUM) && client_cksum && check_write_checksum(&body->oa, peer, client_cksum, - body->oa.o_cksum, aa->aa_requested_nob, - aa->aa_page_count, aa->aa_ppga, - cksum_type_unpack(aa->aa_oa->o_flags))) + body->oa.o_cksum, aa)) return -EAGAIN; rc = check_write_rcs(req, aa->aa_requested_nob, @@ -1487,23 +1559,33 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } if (server_cksum != client_cksum) { - LCONSOLE_ERROR_MSG(0x133, "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu]\n", + u32 page_count = aa->aa_page_count; + struct ost_body *clbody; + + clbody = req_capsule_client_get(&req->rq_pill, + &RMF_OST_BODY); + if (cli->cl_checksum_dump) + dump_all_bulk_pages(&clbody->oa, page_count, + aa->aa_ppga, server_cksum, + client_cksum); + + LCONSOLE_ERROR_MSG(0x133, + "%s: BAD READ CHECKSUM: from %s%s%s inode " DFID " object " DOSTID " extent [%llu-%llu], client %x, server %x, cksum_type %x\n", req->rq_import->imp_obd->obd_name, libcfs_nid2str(peer->nid), via, router, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_seq : (__u64)0, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_oid : 0, - body->oa.o_valid & OBD_MD_FLFID ? - body->oa.o_parent_ver : 0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_seq : (u64)0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_oid : 0, + clbody->oa.o_valid & OBD_MD_FLFID ? + clbody->oa.o_parent_ver : 0, POSTID(&body->oa.o_oi), aa->aa_ppga[0]->off, - aa->aa_ppga[aa->aa_page_count-1]->off + - aa->aa_ppga[aa->aa_page_count-1]->count - - 1); - CERROR("client %x, server %x, cksum_type %x\n", - client_cksum, server_cksum, cksum_type); + aa->aa_ppga[page_count - 1]->off + + aa->aa_ppga[page_count - 1]->count - 1, + client_cksum, server_cksum, + cksum_type); cksum_counter = 0; aa->aa_oa->o_cksum = client_cksum; rc = -EAGAIN; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:06 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:06 -0400 Subject: [lustre-devel] [PATCH 03/38] lustre: llite: move llite_root and llite_kset to lproc_llite.c In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-4-git-send-email-jsimmons@infradead.org> Move llite_root and llite_kset to lproc_llite.c so that all the sysfs and debugfs code is together. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 7 ++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 14 ++++----- drivers/staging/lustre/lustre/llite/lproc_llite.c | 34 ++++++++++++++++++++-- drivers/staging/lustre/lustre/llite/super25.c | 24 ++++----------- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 4053314..2719bc53 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -636,8 +636,8 @@ struct ll_file_data { struct list_head fd_lccs; /* list of ll_cl_context */ }; -extern struct dentry *llite_root; -extern struct kset *llite_kset; +void llite_tunables_unregister(void); +int llite_tunables_register(void); static inline struct inode *ll_info2i(struct ll_inode_info *lli) { @@ -675,8 +675,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ll_debugfs_register_super(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc); +int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc); void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 437f4cc..d16f5d1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -57,8 +57,6 @@ #include "llite_internal.h" struct kmem_cache *ll_file_data_slab; -struct dentry *llite_root; -struct kset *llite_kset; #ifndef log2 #define log2(n) ffz(~(n)) @@ -572,13 +570,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(data); kfree(osfs); - if (llite_root) { - err = ll_debugfs_register_super(llite_root, sb, dt, md); - if (err < 0) { - CERROR("%s: could not register mount in debugfs: " - "rc = %d\n", ll_get_fsname(sb, NULL, 0), err); - err = 0; - } + err = ll_debugfs_register_super(sb, dt, md); + if (err < 0) { + CERROR("%s: could not register mount in debugfs: rc = %d\n", + ll_get_fsname(sb, NULL, 0), err); + err = 0; } return err; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index cae483f..a9ad328 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -39,6 +39,35 @@ #include "llite_internal.h" #include "vvp_internal.h" +static struct dentry *llite_root; +static struct kset *llite_kset; + +int llite_tunables_register(void) +{ + int rc = 0; + + llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); + if (!llite_kset) + return -ENOMEM; + + llite_root = debugfs_create_dir("llite", debugfs_lustre_root); + if (IS_ERR_OR_NULL(llite_root)) { + rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; + llite_root = NULL; + kset_unregister(llite_kset); + } + + return rc; +} + +void llite_tunables_unregister(void) +{ + kset_unregister(llite_kset); + + debugfs_remove(llite_root); + llite_root = NULL; +} + /* debugfs llite mount point registration */ static const struct file_operations ll_rw_extents_stats_fops; static const struct file_operations ll_rw_extents_stats_pp_fops; @@ -1175,8 +1204,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ll_debugfs_register_super(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1201,7 +1229,7 @@ int ll_debugfs_register_super(struct dentry *parent, snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len, lsi->lsi_lmd->lmd_profile, sb); - dir = debugfs_create_dir(name, parent); + dir = debugfs_create_dir(name, llite_root); sbi->ll_debugfs_entry = dir; debugfs_create_file("dump_page_cache", 0444, dir, sbi, diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index a3bc57d..2f4306e 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -228,22 +228,13 @@ static int __init lustre_init(void) if (!ll_file_data_slab) goto out_cache; - llite_root = debugfs_create_dir("llite", debugfs_lustre_root); - if (IS_ERR_OR_NULL(llite_root)) { - rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; - llite_root = NULL; + rc = llite_tunables_register(); + if (rc) goto out_cache; - } - - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); - if (!llite_kset) { - rc = -ENOMEM; - goto out_debugfs; - } rc = vvp_global_init(); if (rc != 0) - goto out_sysfs; + goto out_tunables; cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck, LCT_REMEMBER | LCT_NOREF); @@ -270,10 +261,8 @@ static int __init lustre_init(void) cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); out_vvp: vvp_global_fini(); -out_sysfs: - kset_unregister(llite_kset); -out_debugfs: - debugfs_remove(llite_root); +out_tunables: + llite_tunables_unregister(); out_cache: kmem_cache_destroy(ll_inode_cachep); kmem_cache_destroy(ll_file_data_slab); @@ -286,8 +275,7 @@ static void __exit lustre_exit(void) lustre_register_client_process_config(NULL); - debugfs_remove(llite_root); - kset_unregister(llite_kset); + llite_tunables_unregister(); ll_xattr_fini(); cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:22 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:22 -0400 Subject: [lustre-devel] [PATCH 19/38] lustre: obdclass: swap obd device attrs and default_attrs In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-20-git-send-email-jsimmons@infradead.org> Currently the obd_ktype sets its default_attr field to the universal obd_def_attr and attaches additional attributes. Reverse this by making obd device specific attributes the default and add obd_def_attr as the extra. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index c032458..d370fbb 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -989,7 +989,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); -static struct attribute *obd_def_attrs[] = { +static const struct attribute *obd_def_attrs[] = { &lustre_attr_blocksize.attr, &lustre_attr_kbytestotal.attr, &lustre_attr_kbytesfree.attr, @@ -1009,7 +1009,6 @@ static void obd_sysfs_release(struct kobject *kobj) } static struct kobj_type obd_ktype = { - .default_attrs = obd_def_attrs, .sysfs_ops = &lustre_sysfs_ops, .release = obd_sysfs_release, }; @@ -1019,6 +1018,7 @@ int lprocfs_obd_setup(struct obd_device *obd, { int rc = 0; + obd_ktype.default_attrs = attrs->attrs; init_completion(&obd->obd_kobj_unregister); rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, obd->obd_type->typ_kobj, @@ -1026,12 +1026,10 @@ int lprocfs_obd_setup(struct obd_device *obd, if (rc) return rc; - if (attrs) { - rc = sysfs_create_group(&obd->obd_kobj, attrs); - if (rc) { - kobject_put(&obd->obd_kobj); - return rc; - } + rc = sysfs_create_files(&obd->obd_kobj, obd_def_attrs); + if (rc) { + kobject_put(&obd->obd_kobj); + return rc; } obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name, @@ -1049,6 +1047,8 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); + sysfs_remove_files(&obd->obd_kobj, obd_def_attrs); + kobject_put(&obd->obd_kobj); wait_for_completion(&obd->obd_kobj_unregister); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:23 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:23 -0400 Subject: [lustre-devel] [PATCH 20/38] lustre: obdclass: embedded attributes in struct obd_device In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-21-git-send-email-jsimmons@infradead.org> We can further simplify lprocfs_obd_setup() by embedding the obd devices attributes in struct obd_device. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-on: https://review.whamcloud.com/32377 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 3 +-- drivers/staging/lustre/lustre/include/obd.h | 2 ++ drivers/staging/lustre/lustre/lmv/lmv_internal.h | 3 +-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++--- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 9 ++------- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 +-- drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++--- drivers/staging/lustre/lustre/lov/lproc_lov.c | 5 ++--- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 9 ++------- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 3 +-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 5 ++--- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 5 ++--- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 3 +-- drivers/staging/lustre/lustre/mgc/mgc_request.c | 5 ++--- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 16 ++++++---------- drivers/staging/lustre/lustre/osc/lproc_osc.c | 9 ++------- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +-- drivers/staging/lustre/lustre/osc/osc_request.c | 5 ++--- 18 files changed, 34 insertions(+), 64 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index ca4cd9a..358ace3 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,8 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd, - const struct attribute_group *attrs); +int lprocfs_obd_setup(struct obd_device *obd); int lprocfs_obd_cleanup(struct obd_device *obd); /* Generic callbacks */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0b071e3..55aa035 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -602,6 +602,7 @@ struct obd_device { struct dentry *obd_debugfs_entry; struct dentry *obd_svc_debugfs_entry; struct lprocfs_stats *obd_svc_stats; + const struct attribute **obd_attrs; struct lprocfs_vars *obd_vars; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; @@ -623,6 +624,7 @@ struct obd_device { struct lu_ref obd_reference; struct kobject obd_kobj; /* sysfs object */ + struct kobj_type obd_ktype; struct completion obd_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 3157ab9..1b51dfb 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,8 +157,7 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_lmv_init_vars(struct obd_device *obd); extern const struct file_operations lmv_proc_target_fops; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1867f6a..212ca31 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1224,7 +1224,6 @@ int lmv_fid_alloc(const struct lu_env *env, struct obd_export *exp, static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lmv_obd *lmv = &obd->u.lmv; - struct lprocfs_static_vars lvars = { NULL }; struct lmv_desc *desc; int rc; @@ -1254,9 +1253,9 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(obd, &lvars); + lprocfs_lmv_init_vars(obd); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_obd_setup(obd); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index bc6e13c..c54227d 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -162,13 +162,8 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) NULL, }; -static const struct attribute_group lmv_attr_group = { - .attrs = lmv_attrs, -}; - -void lprocfs_lmv_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_lmv_init_vars(struct obd_device *obd) { obd->obd_vars = lprocfs_lmv_obd_vars; - lvars->sysfs_vars = &lmv_attr_group; + obd->obd_ktype.default_attrs = lmv_attrs; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index e93dfd4..7e0b9ac 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -241,8 +241,7 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, /* lproc_lov.c */ extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_lov_init_vars(struct obd_device *obd); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 05d097e..43ebec6 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -718,7 +718,6 @@ void lov_fix_desc(struct lov_desc *desc) int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct lov_desc *desc; struct lov_obd *lov = &obd->u.lov; int rc; @@ -769,8 +768,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) goto out; - lprocfs_lov_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_lov_init_vars(obd); + lprocfs_obd_setup(obd); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 317c154..ca86f16 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -284,11 +284,10 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) .attrs = lov_attrs, }; -void lprocfs_lov_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_lov_init_vars(struct obd_device *obd) { obd->obd_vars = lprocfs_lov_obd_vars; - lvars->sysfs_vars = &lov_attr_group; + obd->obd_ktype.default_attrs = lov_attrs; } const struct file_operations lov_proc_target_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index bf92893..fc5f3a3 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -220,13 +220,8 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, NULL, }; -static const struct attribute_group mdc_attr_group = { - .attrs = mdc_attrs, -}; - -void lprocfs_mdc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_mdc_init_vars(struct obd_device *obd) { + obd->obd_ktype.default_attrs = mdc_attrs; obd->obd_vars = lprocfs_mdc_obd_vars; - lvars->sysfs_vars = &mdc_attr_group; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index 20be240..d66663f 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,8 +36,7 @@ #include -void lprocfs_mdc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_mdc_init_vars(struct obd_device *obd); void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 8a90dab..a3c0461f 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2637,7 +2637,6 @@ static void mdc_llog_finish(struct obd_device *obd) static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) { - struct lprocfs_static_vars lvars = { NULL }; int rc; rc = ptlrpcd_addref(); @@ -2648,8 +2647,8 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_mdc_init_vars(obd); + lprocfs_obd_setup(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index e92787d..7951ec6 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -63,8 +63,7 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) { NULL } }; -void lprocfs_mgc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_mgc_init_vars(struct obd_device *obd) { - obd->obd_vars = lprocfs_mgc_obd_vars; + obd->obd_vars = lprocfs_mgc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 400d52c..5385d91 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -39,8 +39,7 @@ #include #include -void lprocfs_mgc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_mgc_init_vars(struct obd_device *obd); int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data); int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 6c769c6..46b1e36 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -730,7 +730,6 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct task_struct *task; int rc; @@ -748,8 +747,8 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto err_cleanup; } - lprocfs_mgc_init_vars(obd, &lvars); - lprocfs_obd_setup(obd, lvars.sysfs_vars); + lprocfs_mgc_init_vars(obd); + lprocfs_obd_setup(obd); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index d370fbb..a5676ff 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1008,19 +1008,15 @@ static void obd_sysfs_release(struct kobject *kobj) complete(&obd->obd_kobj_unregister); } -static struct kobj_type obd_ktype = { - .sysfs_ops = &lustre_sysfs_ops, - .release = obd_sysfs_release, -}; - -int lprocfs_obd_setup(struct obd_device *obd, - const struct attribute_group *attrs) +int lprocfs_obd_setup(struct obd_device *obd) { - int rc = 0; + int rc; + + obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; + obd->obd_ktype.release = obd_sysfs_release; - obd_ktype.default_attrs = attrs->attrs; init_completion(&obd->obd_kobj_unregister); - rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype, + rc = kobject_init_and_add(&obd->obd_kobj, &obd->obd_ktype, obd->obd_type->typ_kobj, "%s", obd->obd_name); if (rc) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 1492ad9..3bcb36b 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -820,13 +820,8 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) NULL, }; -static const struct attribute_group osc_attr_group = { - .attrs = osc_attrs, -}; - -void lprocfs_osc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars) +void lprocfs_osc_init_vars(struct obd_device *obd) { - lvars->sysfs_vars = &osc_attr_group; + obd->obd_ktype.default_attrs = osc_attrs; obd->obd_vars = lprocfs_osc_obd_vars; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index a762d31..6caabdb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -146,8 +146,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct obd_device *obd, - struct lprocfs_static_vars *lvars); +void lprocfs_osc_init_vars(struct obd_device *obd); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 9c226f0..0472165 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2767,7 +2767,6 @@ static int brw_queue_work(const struct lu_env *env, void *data) int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { - struct lprocfs_static_vars lvars = { NULL }; struct client_obd *cli = &obd->u.cli; void *handler; int rc; @@ -2804,8 +2803,8 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(obd, &lvars); - if (lprocfs_obd_setup(obd, lvars.sysfs_vars) == 0) { + lprocfs_osc_init_vars(obd); + if (lprocfs_obd_setup(obd) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:25 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:25 -0400 Subject: [lustre-devel] [PATCH 22/38] lustre: obd: migrate to ksets In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-23-git-send-email-jsimmons@infradead.org> Lustre's obd_device sysfs only uses kobjects but with the introduction of ksets we can use functionality like kset_find_kobj() and uevents. Currently lustre is layered as lustre_kobj -> class -> obd device. This patch changes the obd devices and the top level lustre_kobj into ksets. The class level is kept as kobjects but are bound to the top level lustre kset so they searchable and uevents can be created for them. Also much of the class functionality can be replaced with what ksets can do. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28948 Reviewed-by: John L. Hammond Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 3 +- drivers/staging/lustre/lustre/include/obd.h | 9 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 5 ++- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 4 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++- drivers/staging/lustre/lustre/lov/lproc_lov.c | 4 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 14 +++--- drivers/staging/lustre/lustre/obdclass/genops.c | 35 ++++++++++----- .../lustre/lustre/obdclass/lprocfs_status.c | 41 +++++++++++------- drivers/staging/lustre/lustre/obdclass/module.c | 17 ++++---- drivers/staging/lustre/lustre/obdclass/sysctl.c | 2 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 50 +++++++++++----------- 15 files changed, 116 insertions(+), 82 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index f428ce0..3863fff 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -339,7 +339,7 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ extern struct dentry *debugfs_lustre_root; -extern struct kobject *lustre_kobj; +extern struct kset *lustre_kset; struct obd_device; struct obd_histogram; @@ -572,6 +572,7 @@ struct lustre_attr { #define LUSTRE_ATTR(name, mode, show, store) \ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) +#define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store) #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 55aa035..36f6c10 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -34,7 +34,9 @@ #ifndef __OBD_H #define __OBD_H +#include #include +#include #include #include @@ -109,7 +111,8 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; - struct kobject *typ_kobj; + struct kobject typ_kobj; + struct completion typ_kobj_unregister; }; struct brw_page { @@ -623,9 +626,9 @@ struct obd_device { */ struct lu_ref obd_reference; - struct kobject obd_kobj; /* sysfs object */ + struct kset obd_kset; /* sysfs object collection */ struct kobj_type obd_ktype; - struct completion obd_kobj_unregister; + struct completion obd_kobj_unregister; }; int obd_uuid_add(struct obd_device *obd, struct obd_export *export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 0ee4798..adc96b6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -956,7 +956,7 @@ static int ldlm_setup(void) if (!ldlm_state) return -ENOMEM; - ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); + ldlm_kobj = kobject_create_and_add("ldlm", &lustre_kset->kobj); if (!ldlm_kobj) { rc = -ENOMEM; goto out; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index ce072da..7765060 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -574,7 +574,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) if (sbi->ll_dt_obd) { err = sysfs_create_link(&sbi->ll_kset.kobj, - &sbi->ll_dt_obd->obd_kobj, + &sbi->ll_dt_obd->obd_kset.kobj, sbi->ll_dt_obd->obd_type->typ_name); if (err < 0) { CERROR("%s: could not register %s in llite: rc = %d\n", @@ -585,7 +585,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) if (sbi->ll_md_obd) { err = sysfs_create_link(&sbi->ll_kset.kobj, - &sbi->ll_md_obd->obd_kobj, + &sbi->ll_md_obd->obd_kset.kobj, sbi->ll_md_obd->obd_type->typ_name); if (err < 0) { CERROR("%s: could not register %s in llite: rc = %d\n", diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index c2d27d7..ab2f102 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -63,8 +63,9 @@ int llite_tunables_register(void) if (!kobj) return -ENOMEM; + kobj->kset = lustre_kset; kobject_init(kobj, &class_ktype); - rc = kobject_add(kobj, lustre_kobj, "%s", name); + rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); if (rc) { kobject_put(kobj); return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index c36ecb7..7d5d03b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -210,7 +210,7 @@ static int lmv_connect(const struct lu_env *env, lmv->conn_data = *data; lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", - &obd->obd_kobj); + &obd->obd_kset.kobj); rc = lmv_check_connect(obd); if (rc) goto out_sysfs; @@ -349,7 +349,8 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) if (lmv->lmv_tgts_kobj) /* Even if we failed to create the link, that's fine */ - rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj, + rc = sysfs_create_link(lmv->lmv_tgts_kobj, + &mdc_obd->obd_kset.kobj, mdc_obd->obd_name); return 0; } diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index c54227d..6aae298 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -43,7 +43,7 @@ static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lmv_desc *desc; desc = &dev->u.lmv.desc; @@ -55,7 +55,7 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lmv_desc *desc; desc = &dev->u.lmv.desc; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 751bf64..28b7d91 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -191,7 +191,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (lov->lov_tgts_kobj) /* Even if we failed, that's ok */ - rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj, + rc = sysfs_create_link(lov->lov_tgts_kobj, + &tgt_obd->obd_kset.kobj, tgt_obd->obd_name); return 0; @@ -226,7 +227,7 @@ static int lov_connect(const struct lu_env *env, obd_getref(obd); lov->lov_tgts_kobj = kobject_create_and_add("target_obds", - &obd->obd_kobj); + &obd->obd_kset.kobj); for (i = 0; i < lov->desc.ld_tgt_count; i++) { tgt = lov->lov_tgts[i]; diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index ca86f16..9c5d6fc 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -171,7 +171,7 @@ static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lov_desc *desc; desc = &dev->u.lov.desc; @@ -183,7 +183,7 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct lov_desc *desc; desc = &dev->u.lov.desc; diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index fc5f3a3..47f23d6 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -41,7 +41,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", !dev->u.cli.cl_import->imp_deactive); } @@ -50,7 +50,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, const char *buffer, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); unsigned long val; int rc; @@ -79,7 +79,7 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, { int len; struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); __u32 max; max = obd_get_max_rpcs_in_flight(&dev->u.cli); @@ -94,7 +94,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -115,7 +115,7 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); u16 max; int len; @@ -131,7 +131,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); u16 val; int rc; @@ -187,7 +187,7 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 532418e..bf182e5 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -133,6 +133,19 @@ void class_put_type(struct obd_type *type) spin_unlock(&type->obd_type_lock); } +static void class_sysfs_release(struct kobject *kobj) +{ + struct obd_type *type = container_of(kobj, struct obd_type, + typ_kobj); + + complete(&type->typ_kobj_unregister); +} + +static struct kobj_type class_ktype = { + .sysfs_ops = &lustre_sysfs_ops, + .release = class_sysfs_release, +}; + #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, @@ -174,17 +187,21 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); - type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj); - if (!type->typ_kobj) { - rc = -ENOMEM; + type->typ_kobj.kset = lustre_kset; + init_completion(&type->typ_kobj_unregister); + rc = kobject_init_and_add(&type->typ_kobj, &class_ktype, + &lustre_kset->kobj, "%s", type->typ_name); + if (rc) goto failed; - } + if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); - if (rc != 0) + if (rc != 0) { + kobject_put(&type->typ_kobj); goto failed; + } } spin_lock(&obd_types_lock); @@ -193,9 +210,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; - failed: - if (type->typ_kobj) - kobject_put(type->typ_kobj); +failed: kfree(type->typ_name); kfree(type->typ_md_ops); kfree(type->typ_dt_ops); @@ -222,8 +237,8 @@ int class_unregister_type(const char *name) return -EBUSY; } - if (type->typ_kobj) - kobject_put(type->typ_kobj); + kobject_put(&type->typ_kobj); + wait_for_completion(&type->typ_kobj_unregister); debugfs_remove_recursive(type->typ_debugfs_entry); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 91d37fc..b3ba554 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -353,7 +353,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%s\n", obd->obd_uuid.uuid); } @@ -363,7 +363,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -379,7 +379,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -402,7 +402,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -425,7 +425,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -448,7 +448,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -464,7 +464,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct obd_statfs osfs; int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, @@ -1008,7 +1008,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) static void obd_sysfs_release(struct kobject *kobj) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); complete(&obd->obd_kobj_unregister); } @@ -1017,13 +1017,20 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) { int rc; + if (!obd || obd->obd_magic != OBD_DEVICE_MAGIC) + return -ENODEV; + + rc = kobject_set_name(&obd->obd_kset.kobj, "%s", obd->obd_name); + if (rc) + return rc; + obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; obd->obd_ktype.release = obd_sysfs_release; + obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj; + obd->obd_kset.kobj.ktype = &obd->obd_ktype; init_completion(&obd->obd_kobj_unregister); - rc = kobject_init_and_add(&obd->obd_kobj, &obd->obd_ktype, - obd->obd_type->typ_kobj, - "%s", obd->obd_name); + rc = kset_register(&obd->obd_kset); if (rc) return rc; @@ -1032,9 +1039,9 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) else obd->obd_attrs = obd_def_attrs; - rc = sysfs_create_files(&obd->obd_kobj, obd->obd_attrs); + rc = sysfs_create_files(&obd->obd_kset.kobj, obd->obd_attrs); if (rc) { - kobject_put(&obd->obd_kobj); + kset_unregister(&obd->obd_kset); return rc; } @@ -1053,12 +1060,16 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); + /* obd device never allocated a kset */ + if (!obd->obd_kset.kobj.state_initialized) + return 0; + if (obd->obd_attrs) { - sysfs_remove_files(&obd->obd_kobj, obd->obd_attrs); + sysfs_remove_files(&obd->obd_kset.kobj, obd->obd_attrs); obd->obd_attrs = NULL; } - kobject_put(&obd->obd_kobj); + kset_unregister(&obd->obd_kset); wait_for_completion(&obd->obd_kobj_unregister); return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 9c80058..0ce2617 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -471,8 +471,8 @@ static int obd_device_list_open(struct inode *inode, struct file *file) .release = seq_release, }; -struct kobject *lustre_kobj; -EXPORT_SYMBOL_GPL(lustre_kobj); +struct kset *lustre_kset; +EXPORT_SYMBOL_GPL(lustre_kset); static const struct attribute_group lustre_attr_group = { .attrs = lustre_attrs, @@ -482,14 +482,14 @@ int class_procfs_init(void) { int rc = -ENOMEM; - lustre_kobj = kobject_create_and_add("lustre", fs_kobj); - if (!lustre_kobj) + lustre_kset = kset_create_and_add("lustre", NULL, fs_kobj); + if (!lustre_kset) goto out; /* Create the files associated with this kobject */ - rc = sysfs_create_group(lustre_kobj, &lustre_attr_group); + rc = sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); if (rc) { - kobject_put(lustre_kobj); + kset_unregister(lustre_kset); goto out; } @@ -507,8 +507,9 @@ int class_procfs_clean(void) debugfs_lustre_root = NULL; - sysfs_remove_group(lustre_kobj, &lustre_attr_group); - kobject_put(lustre_kobj); + sysfs_remove_group(&lustre_kset->kobj, &lustre_attr_group); + + kset_unregister(lustre_kset); return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/sysctl.c b/drivers/staging/lustre/lustre/obdclass/sysctl.c index e5e8687..f8760b2 100644 --- a/drivers/staging/lustre/lustre/obdclass/sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/sysctl.c @@ -158,5 +158,5 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, int obd_sysctl_init(void) { - return sysfs_create_group(lustre_kobj, &lustre_attr_group); + return sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); } diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3bcb36b..4ed289b 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -44,7 +44,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); } @@ -54,7 +54,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -80,7 +80,7 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); @@ -92,7 +92,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; int rc; unsigned long val; @@ -133,7 +133,7 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; long val; int mult; @@ -149,7 +149,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; int rc; unsigned long pages_number; @@ -247,7 +247,7 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); @@ -260,7 +260,7 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_avail_grant); @@ -272,7 +272,7 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &obd->u.cli; int rc; unsigned long long val; @@ -298,7 +298,7 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_lost_grant); @@ -310,7 +310,7 @@ static ssize_t cur_dirty_grant_bytes_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%lu\n", cli->cl_dirty_grant); @@ -322,7 +322,7 @@ static ssize_t grant_shrink_interval_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval); } @@ -333,7 +333,7 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -355,7 +355,7 @@ static ssize_t checksums_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); } @@ -366,7 +366,7 @@ static ssize_t checksums_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -442,7 +442,7 @@ static ssize_t resend_count_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } @@ -453,7 +453,7 @@ static ssize_t resend_count_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); int rc; unsigned long val; @@ -472,7 +472,7 @@ static ssize_t contention_seconds_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); return sprintf(buf, "%u\n", od->od_contention_time); @@ -484,7 +484,7 @@ static ssize_t contention_seconds_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); int rc; int val; @@ -507,7 +507,7 @@ static ssize_t lockless_truncate_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); return sprintf(buf, "%u\n", od->od_lockless_truncate); @@ -519,7 +519,7 @@ static ssize_t lockless_truncate_store(struct kobject *kobj, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); int rc; unsigned int val; @@ -539,7 +539,7 @@ static ssize_t destroys_in_flight_show(struct kobject *kobj, char *buf) { struct obd_device *obd = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight)); @@ -551,7 +551,7 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); @@ -563,7 +563,7 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; @@ -598,7 +598,7 @@ static ssize_t unstable_stats_show(struct kobject *kobj, char *buf) { struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kobj); + obd_kset.kobj); struct client_obd *cli = &dev->u.cli; long pages; int mb; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:31 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:31 -0400 Subject: [lustre-devel] [PATCH 28/38] lustre: obd: move ioctl handling to class_obd.c In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-29-git-send-email-jsimmons@infradead.org> Move the ioctl handling in module.c to class_obd.c and rename module.c to obd_sysfs.c since it only contains sysfs/debugfs code. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8837 Reviewed-on: https://review.whamcloud.com/32100 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 1 - drivers/staging/lustre/lustre/obdclass/Makefile | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 205 ++++++++++++++++++++ .../lustre/obdclass/{module.c => obd_sysfs.c} | 207 --------------------- 4 files changed, 206 insertions(+), 209 deletions(-) rename drivers/staging/lustre/lustre/obdclass/{module.c => obd_sysfs.c} (67%) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 1925bda..33c0b87 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1568,7 +1568,6 @@ struct lwp_register_item { /* class_obd.c */ extern char obd_jobid_node[]; -extern struct miscdevice obd_psdev; int class_procfs_init(void); int class_procfs_clean(void); diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 5d050f0..19c8bd9 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := module.o \ +obdclass-y := obd_sysfs.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index bbffede..eabaafe 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -153,6 +153,168 @@ static int class_resolve_dev_name(__u32 len, const char *name) return rc; } +#define OBD_MAX_IOCTL_BUFFER 8192 + +static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) +{ + if (data->ioc_len > BIT(30)) { + CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen1 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen2 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen3 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inllen4 > BIT(30)) { + CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); + return 1; + } + + if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) { + CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) { + CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf3 && data->ioc_inllen3 == 0) { + CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_inlbuf4 && data->ioc_inllen4 == 0) { + CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf1 && data->ioc_plen1 == 0) { + CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); + return 1; + } + + if (data->ioc_pbuf2 && data->ioc_plen2 == 0) { + CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); + return 1; + } + + if (!data->ioc_pbuf1 && data->ioc_plen1 != 0) { + CERROR("OBD ioctl: plen1 set but NULL pointer\n"); + return 1; + } + + if (!data->ioc_pbuf2 && data->ioc_plen2 != 0) { + CERROR("OBD ioctl: plen2 set but NULL pointer\n"); + return 1; + } + + if (obd_ioctl_packlen(data) > data->ioc_len) { + CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", + obd_ioctl_packlen(data), data->ioc_len); + return 1; + } + + return 0; +} + +/* buffer MUST be at least the size of obd_ioctl_hdr */ +int obd_ioctl_getdata(char **buf, int *len, void __user *arg) +{ + struct obd_ioctl_data *data; + struct obd_ioctl_hdr hdr; + int offset = 0; + int err; + + if (copy_from_user(&hdr, arg, sizeof(hdr))) + return -EFAULT; + + if (hdr.ioc_version != OBD_IOCTL_VERSION) { + CERROR("Version mismatch kernel (%x) vs application (%x)\n", + OBD_IOCTL_VERSION, hdr.ioc_version); + return -EINVAL; + } + + if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { + CERROR("User buffer len %d exceeds %d max buffer\n", + hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); + return -EINVAL; + } + + if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { + CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); + return -EINVAL; + } + + /* When there are lots of processes calling vmalloc on multi-core + * system, the high lock contention will hurt performance badly, + * obdfilter-survey is an example, which relies on ioctl. So we'd + * better avoid vmalloc on ioctl path. LU-66 + */ + *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); + if (!*buf) { + CERROR("Cannot allocate control buffer of len %d\n", + hdr.ioc_len); + return -EINVAL; + } + *len = hdr.ioc_len; + data = (struct obd_ioctl_data *)*buf; + + if (copy_from_user(*buf, arg, hdr.ioc_len)) { + err = -EFAULT; + goto free_buf; + } + + if (hdr.ioc_len != data->ioc_len) { + err = -EINVAL; + goto free_buf; + } + + if (obd_ioctl_is_invalid(data)) { + CERROR("ioctl not correctly formatted\n"); + err = -EINVAL; + goto free_buf; + } + + if (data->ioc_inllen1) { + data->ioc_inlbuf1 = &data->ioc_bulk[0]; + offset += cfs_size_round(data->ioc_inllen1); + } + + if (data->ioc_inllen2) { + data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; + offset += cfs_size_round(data->ioc_inllen2); + } + + if (data->ioc_inllen3) { + data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; + offset += cfs_size_round(data->ioc_inllen3); + } + + if (data->ioc_inllen4) + data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; + + return 0; + +free_buf: + kvfree(*buf); + return err; +} +EXPORT_SYMBOL(obd_ioctl_getdata); + int class_handle_ioctl(unsigned int cmd, unsigned long arg) { char *buf = NULL; @@ -379,6 +541,49 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) return err; } /* class_handle_ioctl */ +/* opening /dev/obd */ +static int obd_class_open(struct inode *inode, struct file *file) +{ + try_module_get(THIS_MODULE); + return 0; +} + +/* closing /dev/obd */ +static int obd_class_release(struct inode *inode, struct file *file) +{ + module_put(THIS_MODULE); + return 0; +} + +/* to control /dev/obd */ +static long obd_class_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) +{ + /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ + if (!capable(CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) + return -EACCES; + + if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ + return -ENOTTY; + + return class_handle_ioctl(cmd, (unsigned long)arg); +} + +/* declare character device */ +static const struct file_operations obd_psdev_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ + .open = obd_class_open, /* open */ + .release = obd_class_release, /* release */ +}; + +/* modules setup */ +static struct miscdevice obd_psdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = OBD_DEV_NAME, + .fops = &obd_psdev_fops, +}; + #define OBD_INIT_CHECK static int obd_init_checks(void) { diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c similarity index 67% rename from drivers/staging/lustre/lustre/obdclass/module.c rename to drivers/staging/lustre/lustre/obdclass/obd_sysfs.c index eab9820..6669c23 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_sysfs.c @@ -67,213 +67,6 @@ #include #include -#define OBD_MAX_IOCTL_BUFFER 8192 - -static int obd_ioctl_is_invalid(struct obd_ioctl_data *data) -{ - if (data->ioc_len > BIT(30)) { - CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen1 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen2 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen3 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inllen4 > BIT(30)) { - CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); - return 1; - } - - if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) { - CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) { - CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf3 && data->ioc_inllen3 == 0) { - CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_inlbuf4 && data->ioc_inllen4 == 0) { - CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_pbuf1 && data->ioc_plen1 == 0) { - CERROR("OBD ioctl: pbuf1 pointer but 0 length\n"); - return 1; - } - - if (data->ioc_pbuf2 && data->ioc_plen2 == 0) { - CERROR("OBD ioctl: pbuf2 pointer but 0 length\n"); - return 1; - } - - if (!data->ioc_pbuf1 && data->ioc_plen1 != 0) { - CERROR("OBD ioctl: plen1 set but NULL pointer\n"); - return 1; - } - - if (!data->ioc_pbuf2 && data->ioc_plen2 != 0) { - CERROR("OBD ioctl: plen2 set but NULL pointer\n"); - return 1; - } - - if (obd_ioctl_packlen(data) > data->ioc_len) { - CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n", - obd_ioctl_packlen(data), data->ioc_len); - return 1; - } - - return 0; -} - -/* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void __user *arg) -{ - struct obd_ioctl_hdr hdr; - struct obd_ioctl_data *data; - int err; - int offset = 0; - - if (copy_from_user(&hdr, arg, sizeof(hdr))) - return -EFAULT; - - if (hdr.ioc_version != OBD_IOCTL_VERSION) { - CERROR("Version mismatch kernel (%x) vs application (%x)\n", - OBD_IOCTL_VERSION, hdr.ioc_version); - return -EINVAL; - } - - if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { - CERROR("User buffer len %d exceeds %d max buffer\n", - hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); - return -EINVAL; - } - - if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { - CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); - return -EINVAL; - } - - /* When there are lots of processes calling vmalloc on multi-core - * system, the high lock contention will hurt performance badly, - * obdfilter-survey is an example, which relies on ioctl. So we'd - * better avoid vmalloc on ioctl path. LU-66 - */ - *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); - if (!*buf) { - CERROR("Cannot allocate control buffer of len %d\n", - hdr.ioc_len); - return -EINVAL; - } - *len = hdr.ioc_len; - data = (struct obd_ioctl_data *)*buf; - - if (copy_from_user(*buf, arg, hdr.ioc_len)) { - err = -EFAULT; - goto free_buf; - } - if (hdr.ioc_len != data->ioc_len) { - err = -EINVAL; - goto free_buf; - } - - if (obd_ioctl_is_invalid(data)) { - CERROR("ioctl not correctly formatted\n"); - err = -EINVAL; - goto free_buf; - } - - if (data->ioc_inllen1) { - data->ioc_inlbuf1 = &data->ioc_bulk[0]; - offset += cfs_size_round(data->ioc_inllen1); - } - - if (data->ioc_inllen2) { - data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen2); - } - - if (data->ioc_inllen3) { - data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset; - offset += cfs_size_round(data->ioc_inllen3); - } - - if (data->ioc_inllen4) - data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; - - return 0; - -free_buf: - kvfree(*buf); - return err; -} -EXPORT_SYMBOL(obd_ioctl_getdata); - -/* opening /dev/obd */ -static int obd_class_open(struct inode *inode, struct file *file) -{ - try_module_get(THIS_MODULE); - return 0; -} - -/* closing /dev/obd */ -static int obd_class_release(struct inode *inode, struct file *file) -{ - module_put(THIS_MODULE); - return 0; -} - -/* to control /dev/obd */ -static long obd_class_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - int err = 0; - - /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ - if (!capable(CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) - return err = -EACCES; - if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ - return err = -ENOTTY; - - err = class_handle_ioctl(cmd, (unsigned long)arg); - - return err; -} - -/* declare character device */ -static const struct file_operations obd_psdev_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */ - .open = obd_class_open, /* open */ - .release = obd_class_release, /* release */ -}; - -/* modules setup */ -struct miscdevice obd_psdev = { - .minor = MISC_DYNAMIC_MINOR, - .name = OBD_DEV_NAME, - .fops = &obd_psdev_fops, -}; - struct static_lustre_uintvalue_attr { struct { struct attribute attr; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:32 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:32 -0400 Subject: [lustre-devel] [PATCH 29/38] lustre: llite: replace ll_process_config with class_modify_config In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-30-git-send-email-jsimmons@infradead.org> The current method of handling tunables with ll_process_config can not work with sysfs. So replace ll_process_config handling with class_modify_config() which can handle both sysfs and debugfs. This is just to make llite work but eventually the code will be updated to pass in a kobject to class_process_config(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32722 Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lustre_disk.h | 2 ++ .../staging/lustre/lustre/llite/llite_internal.h | 4 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 36 ++----------------- drivers/staging/lustre/lustre/llite/lproc_llite.c | 15 ++++---- drivers/staging/lustre/lustre/llite/super25.c | 4 --- .../staging/lustre/lustre/obdclass/obd_config.c | 41 +++++++++++++++------- 6 files changed, 43 insertions(+), 59 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 6bed07a..7b6421d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -114,6 +114,7 @@ struct lustre_mount_data { /****************** superblock additional info *********************/ struct ll_sb_info; +struct kobject; struct lustre_sb_info { int lsi_flags; @@ -122,6 +123,7 @@ struct lustre_sb_info { struct ll_sb_info *lsi_llsbi; /* add'l client sbi info */ struct dt_device *lsi_dt_dev; /* dt device to access disk fs*/ atomic_t lsi_mounts; /* references to the srv_mnt */ + struct kobject *lsi_kobj; char lsi_svname[MTI_NAME_MAXLEN]; char lsi_osd_obdname[64]; char lsi_osd_uuid[64]; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 1130ea3..bf679c9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -678,9 +678,8 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, /* llite/lproc_llite.c */ int ll_debugfs_register_super(struct super_block *sb, const char *name); -void ll_debugfs_unregister_super(struct ll_sb_info *sbi); +void ll_debugfs_unregister_super(struct super_block *sb); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); -void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); @@ -851,7 +850,6 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize); -int ll_process_config(struct lustre_cfg *lcfg); enum { LUSTRE_OPC_MKDIR = 0, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 7765060..f0fe21f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -693,7 +693,7 @@ static void client_common_put_super(struct super_block *sb) obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - ll_debugfs_unregister_super(sbi); + ll_debugfs_unregister_super(sb); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); @@ -1020,7 +1020,7 @@ int ll_fill_super(struct super_block *sb) out_debugfs: if (err < 0) - ll_debugfs_unregister_super(sbi); + ll_debugfs_unregister_super(sb); out_free: kfree(md); kfree(dt); @@ -2319,38 +2319,6 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) return rc; } -int ll_process_config(struct lustre_cfg *lcfg) -{ - char *ptr; - void *sb; - struct lprocfs_static_vars lvars; - unsigned long x; - int rc = 0; - - lprocfs_llite_init_vars(&lvars); - - /* The instance name contains the sb: lustre-client-aacfe000 */ - ptr = strrchr(lustre_cfg_string(lcfg, 0), '-'); - if (!ptr || !*(++ptr)) - return -EINVAL; - rc = kstrtoul(ptr, 16, &x); - if (rc != 0) - return -EINVAL; - sb = (void *)x; - /* This better be a real Lustre superblock! */ - LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == - LMD_MAGIC); - - /* Note we have not called client_common_fill_super yet, so - * proc fns must be able to handle that! - */ - rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars, - lcfg, sb); - if (rc > 0) - rc = 0; - return rc; -} - /* this function prepares md_op_data hint for passing ot down to MD stack. */ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 30873fc..1492d70 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1252,6 +1252,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) int ll_debugfs_register_super(struct super_block *sb, const char *name) { + struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct dentry *dir; int err, id; @@ -1329,6 +1330,8 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) if (err) goto out_ra_stats; + lsi->lsi_kobj = kobject_get(&sbi->ll_kset.kobj); + return 0; out_ra_stats: @@ -1341,8 +1344,13 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name) return err; } -void ll_debugfs_unregister_super(struct ll_sb_info *sbi) +void ll_debugfs_unregister_super(struct super_block *sb) { + struct lustre_sb_info *lsi = s2lsi(sb); + struct ll_sb_info *sbi = ll_s2sbi(sb); + + kobject_put(lsi->lsi_kobj); + debugfs_remove_recursive(sbi->ll_debugfs_entry); if (sbi->ll_dt_obd) @@ -1719,8 +1727,3 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, } LPROC_SEQ_FOPS(ll_rw_offset_stats); - -void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars) -{ - lvars->obd_vars = lprocfs_llite_obd_vars; -} diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 2f4306e..562bf329 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -253,8 +253,6 @@ static int __init lustre_init(void) if (rc) goto out_inode_fini_env; - lustre_register_client_process_config(ll_process_config); - return 0; out_inode_fini_env: @@ -273,8 +271,6 @@ static void __exit lustre_exit(void) { lustre_unregister_fs(); - lustre_register_client_process_config(NULL); - llite_tunables_unregister(); ll_xattr_fini(); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 823ddb0..9e46eb2 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -814,18 +814,11 @@ void class_del_profiles(void) } EXPORT_SYMBOL(class_del_profiles); -/* We can't call ll_process_config or lquota_process_config directly because +/* We can't call lquota_process_config directly because * it lives in a module that must be loaded after this one. */ -static int (*client_process_config)(struct lustre_cfg *lcfg); static int (*quota_process_config)(struct lustre_cfg *lcfg); -void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)) -{ - client_process_config = cpc; -} -EXPORT_SYMBOL(lustre_register_client_process_config); - static int process_param2_config(struct lustre_cfg *lcfg) { char *param = lustre_cfg_string(lcfg, 1); @@ -958,11 +951,35 @@ int class_process_config(struct lustre_cfg *lcfg) } case LCFG_PARAM: { char *tmp; + /* llite has no obd */ - if ((class_match_param(lustre_cfg_string(lcfg, 1), - PARAM_LLITE, NULL) == 0) && - client_process_config) { - err = (*client_process_config)(lcfg); + if (class_match_param(lustre_cfg_string(lcfg, 1), + PARAM_LLITE, NULL) == 0) { + struct lustre_sb_info *lsi; + unsigned long addr; + ssize_t count; + + /* The instance name contains the sb: + * lustre-client-aacfe000 + */ + tmp = strrchr(lustre_cfg_string(lcfg, 0), '-'); + if (!tmp || !*(++tmp)) { + err = -EINVAL; + goto out; + } + + if (sscanf(tmp, "%lx", &addr) != 1) { + err = -EINVAL; + goto out; + } + + lsi = s2lsi((struct super_block *)addr); + /* This better be a real Lustre superblock! */ + LASSERT(lsi->lsi_lmd->lmd_magic == LMD_MAGIC); + + count = class_modify_config(lcfg, PARAM_LLITE, + lsi->lsi_kobj); + err = count < 0 ? count : 0; goto out; } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:16 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:16 -0400 Subject: [lustre-devel] [PATCH 13/38] lustre: llite: don't handle success case for blocksize sysfs code In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-14-git-send-email-jsimmons@infradead.org> The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32496 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 2a76c01..7bd557b 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -141,10 +141,10 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%u\n", osfs.os_bsize); + if (rc) + return rc; - return rc; + return sprintf(buf, "%u\n", osfs.os_bsize); } LUSTRE_RO_ATTR(blocksize); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:17 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:17 -0400 Subject: [lustre-devel] [PATCH 14/38] lustre: llite: don't handle success case for kbyte* sysfs code In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-15-git-send-email-jsimmons@infradead.org> The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32497 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 7bd557b..72a8f8d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -154,22 +154,23 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_blocks; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_blocks; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytestotal); @@ -179,22 +180,23 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_bfree; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_bfree; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesfree); @@ -204,22 +206,23 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); struct obd_statfs osfs; + u32 blk_size; + u64 result; int rc; rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) { - __u32 blk_size = osfs.os_bsize >> 10; - __u64 result = osfs.os_bavail; + if (rc) + return rc; - while (blk_size >>= 1) - result <<= 1; + blk_size = osfs.os_bsize >> 10; + result = osfs.os_bavail; - rc = sprintf(buf, "%llu\n", result); - } + while (blk_size >>= 1) + result <<= 1; - return rc; + return sprintf(buf, "%llu\n", result); } LUSTRE_RO_ATTR(kbytesavail); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:35 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:35 -0400 Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-33-git-send-email-jsimmons@infradead.org> Access to struct client_obd should be protected with the spinlock cl_loi_list_lock. This was dropped during the port to sysfs so restore the proper locking. Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3c31e98..5fb7a16 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, @@ -136,7 +141,10 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, long val; int mult; + spin_lock(&cli->cl_loi_list_lock); val = cli->cl_dirty_max_pages; + spin_unlock(&cli->cl_loi_list_lock); + mult = 1 << (20 - PAGE_SHIFT); return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } @@ -247,9 +255,13 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_unlock(&cli->cl_loi_list_lock); + return len; } LUSTRE_RO_ATTR(cur_dirty_bytes); @@ -260,8 +272,13 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t cur_grant_bytes_store(struct kobject *kobj, @@ -280,8 +297,12 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, return rc; /* this is only for shrinking grant */ - if (val >= cli->cl_avail_grant) + spin_lock(&cli->cl_loi_list_lock); + if (val >= cli->cl_avail_grant) { + spin_unlock(&cli->cl_loi_list_lock); return -EINVAL; + } + spin_unlock(&cli->cl_loi_list_lock); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); @@ -298,8 +319,13 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } LUSTRE_RO_ATTR(cur_lost_grant_bytes); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:38 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:38 -0400 Subject: [lustre-devel] [PATCH 35/38] lustre: osc: update sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-36-git-send-email-jsimmons@infradead.org> Move sysfs/debugfs handling to lproc_osc.c. Do proper cleanup if any of the sysfs handling code fails. Fix up the style issues. Move to class_modify_params(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30962 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 68 ++++++++++++++++-------- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +- drivers/staging/lustre/lustre/osc/osc_request.c | 26 +++------ 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 89dadba..284ceed 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -50,8 +50,7 @@ static ssize_t active_show(struct kobject *kobj, struct attribute *attr, } static ssize_t active_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, - size_t count) + const char *buffer, size_t count) { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); @@ -157,8 +156,8 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; - int rc; unsigned long pages_number; + int rc; rc = kstrtoul(buffer, 10, &pages_number); if (rc) @@ -180,6 +179,9 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_dirty_mb); +#define ost_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(ost_conn_uuid); + static int osc_cached_mb_seq_show(struct seq_file *m, void *v) { struct obd_device *dev = m->private; @@ -407,9 +409,8 @@ static ssize_t checksums_store(struct kobject *kobj, static int osc_checksum_type_seq_show(struct seq_file *m, void *v) { struct obd_device *obd = m->private; - int i; - DECLARE_CKSUM_NAME; + int i; if (!obd) return 0; @@ -431,10 +432,9 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, size_t count, loff_t *off) { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int i; - DECLARE_CKSUM_NAME; char kernbuf[10]; + int i; if (!obd) return 0; @@ -665,7 +665,6 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(osc, state); @@ -675,17 +674,24 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); static struct lprocfs_vars lprocfs_osc_obd_vars[] = { - { "ping", &osc_ping_fops, NULL, 0222 }, - { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, - { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, - { "osc_cached_mb", &osc_cached_mb_fops, NULL }, - { "checksum_type", &osc_checksum_type_fops, NULL }, - { "timeouts", &osc_timeouts_fops, NULL, 0 }, - { "import", &osc_import_fops, NULL }, - { "state", &osc_state_fops, NULL, 0 }, - { "pinger_recov", &osc_pinger_recov_fops, NULL }, + { .name = "ping", + .fops = &osc_ping_fops }, + { .name = "connect_flags", + .fops = &osc_connect_flags_fops }, + { .name = "ost_server_uuid", + .fops = &osc_server_uuid_fops }, + { .name = "osc_cached_mb", + .fops = &osc_cached_mb_fops }, + { .name = "checksum_type", + .fops = &osc_checksum_type_fops }, + { .name = "timeouts", + .fops = &osc_timeouts_fops }, + { .name = "import", + .fops = &osc_import_fops }, + { .name = "state", + .fops = &osc_state_fops }, + { .name = "pinger_recov", + .fops = &osc_pinger_recov_fops }, { .name = "unstable_stats", .fops = &osc_unstable_stats_fops }, { NULL } @@ -871,11 +877,31 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_resend_count.attr, + &lustre_attr_ost_conn_uuid.attr, NULL, }; -void lprocfs_osc_init_vars(struct obd_device *obd) +int osc_tunables_init(struct obd_device *obd) { - obd->obd_ktype.default_attrs = osc_attrs; + int rc; + obd->obd_vars = lprocfs_osc_obd_vars; + obd->obd_ktype.default_attrs = osc_attrs; + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; + + rc = sptlrpc_lprocfs_cliobd_attach(obd); + if (rc) { + lprocfs_obd_cleanup(obd); + return rc; + } + + debugfs_create_file("osc_stats", 0644, obd->obd_debugfs_entry, obd, + &osc_stats_fops); + debugfs_create_file("rpc_stats", 0644, obd->obd_debugfs_entry, obd, + &osc_rpc_stats_fops); + + ptlrpc_lprocfs_register_obd(obd); + return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 6caabdb..55054d7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -145,8 +145,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -void lproc_osc_attach_seqstat(struct obd_device *dev); -void lprocfs_osc_init_vars(struct obd_device *obd); +int osc_tunables_init(struct obd_device *obd); extern struct lu_device_type osc_device_type; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index a7a4a53..7c91c4b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2885,12 +2885,9 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; - lprocfs_osc_init_vars(obd); - if (lprocfs_obd_setup(obd, false) == 0) { - lproc_osc_attach_seqstat(obd); - sptlrpc_lprocfs_cliobd_attach(obd); - ptlrpc_lprocfs_register_obd(obd); - } + rc = osc_tunables_init(obd); + if (rc) + goto out_quota; /* * We try to control the total number of requests with a upper limit @@ -2916,6 +2913,8 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return rc; +out_quota: + osc_quota_cleanup(obd); out_ptlrpcd_work: if (cli->cl_writeback_work) { ptlrpcd_destroy_work(cli->cl_writeback_work); @@ -2993,18 +2992,9 @@ static int osc_cleanup(struct obd_device *obd) int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) { - int rc = 0; - - switch (lcfg->lcfg_command) { - default: - rc = class_process_proc_param(PARAM_OSC, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; - break; - } - - return rc; + ssize_t count = class_modify_config(lcfg, PARAM_OSC, + &obd->obd_kset.kobj); + return count > 0 ? 0 : count; } static int osc_process_config(struct obd_device *obd, u32 len, void *buf) -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:40 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:40 -0400 Subject: [lustre-devel] [PATCH 37/38] lustre: lov: update sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-38-git-send-email-jsimmons@infradead.org> Move all the sysfs/debugfs handling to lproc_lov.c. Properly handle failure cases for sysfs/debugfs bring up. Migrate all the debugfs files to sys so we don't clutter debugfs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30960 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_internal.h | 3 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 40 +++-- drivers/staging/lustre/lustre/lov/lproc_lov.c | 213 +++++++++++------------ 3 files changed, 131 insertions(+), 125 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 7e0b9ac..dbb79d4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -240,8 +240,7 @@ struct lov_stripe_md *lov_unpackmd(struct lov_obd *lov, struct lov_mds_md *lmm, void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); /* lproc_lov.c */ -extern const struct file_operations lov_proc_target_fops; -void lprocfs_lov_init_vars(struct obd_device *obd); +int lov_tunables_init(struct obd_device *obd); /* lov_cl.c */ extern struct lu_device_type lov_device_type; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 28b7d91..3483f9b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -189,12 +189,19 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); - if (lov->lov_tgts_kobj) + if (lov->lov_tgts_kobj) { /* Even if we failed, that's ok */ rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kset.kobj, tgt_obd->obd_name); - + if (rc) { + CERROR("%s: can't register LOV target /sys/fs/lustre/%s/%s/target_obds/%s : rc = %d\n", + obd->obd_name, obd->obd_type->typ_name, + obd->obd_name, + lov->lov_tgts[index]->ltd_exp->exp_obd->obd_name, + rc); + } + } return 0; } @@ -764,22 +771,23 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lov->lov_pool_count = 0; rc = lov_pool_hash_init(&lov->lov_pools_hash_body); if (rc) - goto out; + goto out_hash; + rc = lov_ost_pool_init(&lov->lov_packed, 0); if (rc) - goto out; - - lprocfs_lov_init_vars(obd); - lprocfs_obd_setup(obd, false); + goto out_pool; - debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, - &lov_proc_target_fops); + rc = lov_tunables_init(obd); + if (rc) + goto out_tunables; - lov->lov_pool_debugfs_entry = debugfs_create_dir("pools", - obd->obd_debugfs_entry); return 0; -out: +out_tunables: + lov_ost_pool_free(&lov->lov_packed); +out_pool: + lov_pool_hash_destroy(&lov->lov_pools_hash_body); +out_hash: return rc; } @@ -873,16 +881,16 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, } case LCFG_PARAM: { struct lov_desc *desc = &obd->u.lov.desc; + ssize_t count; if (!desc) { rc = -EINVAL; goto out; } - rc = class_process_proc_param(PARAM_LOV, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; + count = class_modify_config(lcfg, PARAM_LOV, + &obd->obd_kset.kobj); + rc = count < 0 ? count : 0; goto out; } case LCFG_POOL_NEW: diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 9c5d6fc..771c6f8 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -38,134 +38,131 @@ #include #include "lov_internal.h" -static int lov_stripesize_seq_show(struct seq_file *m, void *v) +static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%llu\n", desc->ld_default_stripe_size); - return 0; + return sprintf(buf, "%llu\n", desc->ld_default_stripe_size); } -static ssize_t lov_stripesize_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - __u64 val; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + u64 val; int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buf, 10, &val); if (rc) return rc; lov_fix_desc_stripe_size(&val); desc->ld_default_stripe_size = val; + return count; } +LUSTRE_RW_ATTR(stripesize); -LPROC_SEQ_FOPS(lov_stripesize); - -static int lov_stripeoffset_seq_show(struct seq_file *m, void *v) +static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%llu\n", desc->ld_default_stripe_offset); - return 0; + return sprintf(buf, "%llu\n", desc->ld_default_stripe_offset); } -static ssize_t lov_stripeoffset_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripeoffset_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - __u64 val; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + long val; int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtol(buf, 0, &val); if (rc) return rc; + if (val < -1 || val > LOV_MAX_STRIPE_COUNT) + return -ERANGE; + desc->ld_default_stripe_offset = val; + return count; } +LUSTRE_RW_ATTR(stripeoffset); -LPROC_SEQ_FOPS(lov_stripeoffset); - -static int lov_stripetype_seq_show(struct seq_file *m, void *v) +static ssize_t stripetype_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%u\n", desc->ld_pattern); - return 0; + return sprintf(buf, "%u\n", desc->ld_pattern); } -static ssize_t lov_stripetype_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripetype_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + u32 pattern; + int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtouint(buffer, 0, &pattern); if (rc) return rc; - lov_fix_desc_pattern(&val); - desc->ld_pattern = val; + lov_fix_desc_pattern(&pattern); + desc->ld_pattern = pattern; + return count; } +LUSTRE_RW_ATTR(stripetype); -LPROC_SEQ_FOPS(lov_stripetype); - -static int lov_stripecount_seq_show(struct seq_file *m, void *v) +static ssize_t stripecount_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_desc *desc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - desc = &dev->u.lov.desc; - seq_printf(m, "%d\n", (__s16)(desc->ld_default_stripe_count + 1) - 1); - return 0; + return sprintf(buf, "%d\n", + (s16)(desc->ld_default_stripe_count + 1) - 1); } -static ssize_t lov_stripecount_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t stripecount_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lov_desc *desc; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; + int stripe_count; + int rc; - LASSERT(dev); - desc = &dev->u.lov.desc; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoint(buffer, 0, &stripe_count); if (rc) return rc; - lov_fix_desc_stripe_count(&val); - desc->ld_default_stripe_count = val; + if (stripe_count < -1) + return -ERANGE; + + lov_fix_desc_stripe_count(&stripe_count); + desc->ld_default_stripe_count = stripe_count; + return count; } - -LPROC_SEQ_FOPS(lov_stripecount); +LUSTRE_RW_ATTR(stripecount); static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, char *buf) @@ -191,18 +188,16 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(activeobd); -static int lov_desc_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lov_obd *lov; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lov_desc *desc = &dev->u.lov.desc; - LASSERT(dev); - lov = &dev->u.lov; - seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid); - return 0; + return sprintf(buf, "%s\n", desc->ld_uuid.uuid); } - -LPROC_SEQ_FOPS_RO(lov_desc_uuid); +LUSTRE_RO_ATTR(desc_uuid); static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos) { @@ -264,36 +259,40 @@ static int lov_target_seq_open(struct inode *inode, struct file *file) return 0; } -static struct lprocfs_vars lprocfs_lov_obd_vars[] = { - { "stripesize", &lov_stripesize_fops, NULL }, - { "stripeoffset", &lov_stripeoffset_fops, NULL }, - { "stripecount", &lov_stripecount_fops, NULL }, - { "stripetype", &lov_stripetype_fops, NULL }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 }, - { NULL } +static const struct file_operations lov_debugfs_target_fops = { + .owner = THIS_MODULE, + .open = lov_target_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = lprocfs_seq_release, }; static struct attribute *lov_attrs[] = { &lustre_attr_activeobd.attr, &lustre_attr_numobd.attr, + &lustre_attr_desc_uuid.attr, + &lustre_attr_stripesize.attr, + &lustre_attr_stripeoffset.attr, + &lustre_attr_stripetype.attr, + &lustre_attr_stripecount.attr, NULL, }; -static const struct attribute_group lov_attr_group = { - .attrs = lov_attrs, -}; - -void lprocfs_lov_init_vars(struct obd_device *obd) +int lov_tunables_init(struct obd_device *obd) { - obd->obd_vars = lprocfs_lov_obd_vars; + struct lov_obd *lov = &obd->u.lov; + int rc; + obd->obd_ktype.default_attrs = lov_attrs; -} + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; -const struct file_operations lov_proc_target_fops = { - .owner = THIS_MODULE, - .open = lov_target_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = lprocfs_seq_release, -}; + debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, + &lov_debugfs_target_fops); + + lov->lov_pool_debugfs_entry = debugfs_create_dir("pools", + obd->obd_debugfs_entry); + + return 0; +} -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:18 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:18 -0400 Subject: [lustre-devel] [PATCH 15/38] lustre: llite: don't handle success case for file* sysfs code In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-16-git-send-email-jsimmons@infradead.org> The proper thing to due is return on failure so reverse the logic to conform to kernel standards. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/32497 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 72a8f8d..02a09e7 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -237,10 +237,10 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%llu\n", osfs.os_files); + if (rc) + return rc; - return rc; + return sprintf(buf, "%llu\n", osfs.os_files); } LUSTRE_RO_ATTR(filestotal); @@ -255,10 +255,10 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, rc = ll_statfs_internal(sbi, &osfs, get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, OBD_STATFS_NODELAY); - if (!rc) - return sprintf(buf, "%llu\n", osfs.os_ffree); + if (rc) + return rc; - return rc; + return sprintf(buf, "%llu\n", osfs.os_ffree); } LUSTRE_RO_ATTR(filesfree); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:20 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:20 -0400 Subject: [lustre-devel] [PATCH 17/38] lustre: llite: add newline to llite.*.offset_stats In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-18-git-send-email-jsimmons@infradead.org> From: Andreas Dilger The llite.*.offset_stats file is missing a newline in the output. Signed-off-by: Andreas Dilger WC-bug-id: https://jira.whamcloud.com/browse/LU-11147 Reviewed-on: https://review.whamcloud.com/32817 Reviewed-by: James Simmons Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index e35b3ea..c2d27d7 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1678,7 +1678,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < LL_OFFSET_HIST_MAX; i++) { if (offset[i].rw_pid != 0) seq_printf(seq, - "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + "%3c %10d %14llu %14llu %17lu %17lu %14llu\n", offset[i].rw_op == READ ? 'R' : 'W', offset[i].rw_pid, offset[i].rw_range_start, @@ -1691,7 +1691,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid != 0) seq_printf(seq, - "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + "%3c %10d %14llu %14llu %17lu %17lu %14llu\n", process[i].rw_op == READ ? 'R' : 'W', process[i].rw_pid, process[i].rw_range_start, -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:26 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:26 -0400 Subject: [lustre-devel] [PATCH 23/38] lustre: obd: create class_setup_tunables() function In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-24-git-send-email-jsimmons@infradead.org> Creat class_setup_tunables() so sysfs kobject creation is handled for both obd_devices and llite. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28108 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd.h | 3 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 ++ drivers/staging/lustre/lustre/llite/lproc_llite.c | 30 +++------------- drivers/staging/lustre/lustre/obdclass/genops.c | 40 +++++++++++++++------- .../lustre/lustre/obdclass/lprocfs_status.c | 2 +- 5 files changed, 36 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 36f6c10..385a88d 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -111,8 +111,7 @@ struct obd_type { int typ_refcnt; struct lu_device_type *typ_lu; spinlock_t obd_type_lock; - struct kobject typ_kobj; - struct completion typ_kobj_unregister; + struct kobject *typ_kobj; }; struct brw_page { diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index fd9d99b..e994c968 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -33,6 +33,7 @@ #ifndef __CLASS_OBD_H #define __CLASS_OBD_H +#include #include #include #include @@ -59,6 +60,7 @@ /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *conn); +struct kobject *class_setup_tunables(const char *name); int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, const char *name, struct lu_device_type *ldt); int class_unregister_type(const char *name); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index ab2f102..30873fc 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -43,40 +43,20 @@ static struct kobject *llite_kobj; static struct dentry *llite_root; -static void class_sysfs_release(struct kobject *kobj) -{ - kfree(kobj); -} - -static struct kobj_type class_ktype = { - .sysfs_ops = &lustre_sysfs_ops, - .release = class_sysfs_release, -}; - int llite_tunables_register(void) { - const char *name = "llite"; - struct kobject *kobj; int rc = 0; - kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); - if (!kobj) - return -ENOMEM; - - kobj->kset = lustre_kset; - kobject_init(kobj, &class_ktype); - rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); - if (rc) { - kobject_put(kobj); - return -ENOMEM; - } - llite_kobj = kobj; + llite_kobj = class_setup_tunables("llite"); + if (IS_ERR(llite_kobj)) + return PTR_ERR(llite_kobj); llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; llite_root = NULL; - kobject_put(kobj); + kobject_put(llite_kobj); + llite_kobj = NULL; } return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index bf182e5..29ed498 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -135,10 +135,7 @@ void class_put_type(struct obd_type *type) static void class_sysfs_release(struct kobject *kobj) { - struct obd_type *type = container_of(kobj, struct obd_type, - typ_kobj); - - complete(&type->typ_kobj_unregister); + kfree(kobj); } static struct kobj_type class_ktype = { @@ -146,6 +143,26 @@ static void class_sysfs_release(struct kobject *kobj) .release = class_sysfs_release, }; +struct kobject *class_setup_tunables(const char *name) +{ + struct kobject *kobj; + int rc; + + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return ERR_PTR(-ENOMEM); + + kobj->kset = lustre_kset; + kobject_init(kobj, &class_ktype); + rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name); + if (rc) { + kobject_put(kobj); + return ERR_PTR(rc); + } + return kobj; +} +EXPORT_SYMBOL(class_setup_tunables); + #define CLASS_MAX_NAME 1024 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, @@ -187,19 +204,17 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, type->typ_debugfs_entry = debugfs_create_dir(type->typ_name, debugfs_lustre_root); - type->typ_kobj.kset = lustre_kset; - init_completion(&type->typ_kobj_unregister); - rc = kobject_init_and_add(&type->typ_kobj, &class_ktype, - &lustre_kset->kobj, "%s", type->typ_name); - if (rc) + type->typ_kobj = class_setup_tunables(type->typ_name); + if (IS_ERR(type->typ_kobj)) { + rc = PTR_ERR(type->typ_kobj); goto failed; - + } if (ldt) { type->typ_lu = ldt; rc = lu_device_type_init(ldt); if (rc != 0) { - kobject_put(&type->typ_kobj); + kobject_put(type->typ_kobj); goto failed; } } @@ -237,8 +252,7 @@ int class_unregister_type(const char *name) return -EBUSY; } - kobject_put(&type->typ_kobj); - wait_for_completion(&type->typ_kobj_unregister); + kobject_put(type->typ_kobj); debugfs_remove_recursive(type->typ_debugfs_entry); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index b3ba554..f889fb8 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1027,7 +1027,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops; obd->obd_ktype.release = obd_sysfs_release; - obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj; + obd->obd_kset.kobj.parent = obd->obd_type->typ_kobj; obd->obd_kset.kobj.ktype = &obd->obd_ktype; init_completion(&obd->obd_kobj_unregister); rc = kset_register(&obd->obd_kset); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:09 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:09 -0400 Subject: [lustre-devel] [PATCH 06/38] lustre: llite: rename llite_sb_release In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-7-git-send-email-jsimmons@infradead.org> Since we are freeing a kobject rename llite_sb_release() to llite_kobj_release(). Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8af6636..90140b0 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1128,7 +1128,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, NULL, }; -static void llite_sb_release(struct kobject *kobj) +static void llite_kobj_release(struct kobject *kobj) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); @@ -1138,7 +1138,7 @@ static void llite_sb_release(struct kobject *kobj) static struct kobj_type llite_ktype = { .default_attrs = llite_attrs, .sysfs_ops = &lustre_sysfs_ops, - .release = llite_sb_release, + .release = llite_kobj_release, }; static const struct llite_file_opcode { -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:13 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:13 -0400 Subject: [lustre-devel] [PATCH 10/38] lustre: llite: use C99 for struct lprocfs_llite_obd_vars In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-11-git-send-email-jsimmons@infradead.org> Remove mntpt_path and filegroups since they don't even exit. Migrate the rest to C99 structure initialization. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-3319 Reviewed-on: http://review.whamcloud.com/7290 Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 5530156..0dc4d00 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1086,17 +1086,20 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, LPROC_SEQ_FOPS(ll_nosquash_nids); static struct lprocfs_vars lprocfs_llite_obd_vars[] = { - /* { "mntpt_path", ll_rd_path, 0, 0 }, */ - { "site", &ll_site_stats_fops, NULL, 0 }, - /* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */ - { "max_cached_mb", &ll_max_cached_mb_fops, NULL }, - { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, - { "unstable_stats", &ll_unstable_stats_fops, NULL }, - { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, - { .name = "root_squash", + { .name = "site", + .fops = &ll_site_stats_fops }, + { .name = "max_cached_mb", + .fops = &ll_max_cached_mb_fops }, + { .name = "statahead_stats", + .fops = &ll_statahead_stats_fops }, + { .name = "unstable_stats", + .fops = &ll_unstable_stats_fops }, + { .name = "sbi_flags", + .fops = &ll_sbi_flags_fops }, + { .name = "root_squash", .fops = &ll_root_squash_fops }, - { .name = "nosquash_nids", - .fops = &ll_nosquash_nids_fops }, + { .name = "nosquash_nids", + .fops = &ll_nosquash_nids_fops }, { NULL } }; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:19 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:19 -0400 Subject: [lustre-devel] [PATCH 16/38] lustre: llite: user kstrtobool for some sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-17-git-send-email-jsimmons@infradead.org> Some of the llite sysfs files only allow 1 or 0 which was retrieved with kstrtoul(). A much better fit would be to use kstrtobool(). This adds 'Y' or 'N' as valid options as well. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9325 Reviewed-on: https://review.whamcloud.com/30539 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 02a09e7..e35b3ea 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -593,25 +593,28 @@ static ssize_t checksum_pages_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; + int tmp; int rc; - unsigned long val; if (!sbi->ll_dt_exp) /* Not set up yet */ return -EAGAIN; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; + spin_lock(&sbi->ll_lock); if (val) sbi->ll_flags |= LL_SBI_CHECKSUM; else sbi->ll_flags &= ~LL_SBI_CHECKSUM; spin_unlock(&sbi->ll_lock); + tmp = val; rc = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CHECKSUM), - KEY_CHECKSUM, sizeof(val), &val, NULL); + KEY_CHECKSUM, sizeof(tmp), &tmp, NULL); if (rc) CWARN("Failed to set OSC checksum flags: %d\n", rc); @@ -753,10 +756,10 @@ static ssize_t statahead_agl_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; @@ -805,10 +808,10 @@ static ssize_t lazystatfs_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; @@ -948,17 +951,14 @@ static ssize_t xattr_cache_store(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val != 0 && val != 1) - return -ERANGE; - - if (val == 1 && !(sbi->ll_flags & LL_SBI_XATTR_CACHE)) + if (val && !(sbi->ll_flags & LL_SBI_XATTR_CACHE)) return -ENOTSUPP; sbi->ll_xattr_cache_enabled = val; @@ -1030,7 +1030,8 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); char kernbuf[128]; - int val, rc; + bool val; + int rc; if (!count) return 0; @@ -1043,13 +1044,13 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, buffer += lprocfs_find_named_value(kernbuf, "unstable_check:", &count) - kernbuf; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtobool_from_user(buffer, count, &val); if (rc < 0) return rc; /* borrow lru lock to set the value */ spin_lock(&sbi->ll_cache->ccc_lru_lock); - sbi->ll_cache->ccc_unstable_check = !!val; + sbi->ll_cache->ccc_unstable_check = val; spin_unlock(&sbi->ll_cache->ccc_lru_lock); return count; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:24 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:24 -0400 Subject: [lustre-devel] [PATCH 21/38] lustre: obdclass: add light weight obd_def_uuid_attrs In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-22-git-send-email-jsimmons@infradead.org> It was assumed that all obd devices supported every attribute in obd_def_attrs but that is not true. Several obd devices only have a uuid sysfs file. Add an option to lprocfs_obd_setup() to select the proper obd_def_attrs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/26020 Reviewed-by: John L. Hammond Reviewed-by: Niu Yawei Reviewed-by: Fan Yong Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- .../staging/lustre/lustre/obdclass/lprocfs_status.c | 19 ++++++++++++++++--- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 358ace3..f428ce0 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -453,7 +453,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var, void *data); -int lprocfs_obd_setup(struct obd_device *obd); +int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only); int lprocfs_obd_cleanup(struct obd_device *obd); /* Generic callbacks */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 212ca31..c36ecb7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1255,7 +1255,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_lmv_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, true); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 43ebec6..751bf64 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -769,7 +769,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) goto out; lprocfs_lov_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, false); debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, &lov_proc_target_fops); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index a3c0461f..fcba599 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2648,7 +2648,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) goto err_ptlrpcd_decref; lprocfs_mdc_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, false); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 46b1e36..50da9cf 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -748,7 +748,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } lprocfs_mgc_init_vars(obd); - lprocfs_obd_setup(obd); + lprocfs_obd_setup(obd, true); sptlrpc_lprocfs_cliobd_attach(obd); if (atomic_inc_return(&mgc_count) == 1) { diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a5676ff..91d37fc 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -989,6 +989,11 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_connect_flags); +static const struct attribute *obd_def_uuid_attrs[] = { + &lustre_attr_uuid.attr, + NULL, +}; + static const struct attribute *obd_def_attrs[] = { &lustre_attr_blocksize.attr, &lustre_attr_kbytestotal.attr, @@ -1008,7 +1013,7 @@ static void obd_sysfs_release(struct kobject *kobj) complete(&obd->obd_kobj_unregister); } -int lprocfs_obd_setup(struct obd_device *obd) +int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only) { int rc; @@ -1022,7 +1027,12 @@ int lprocfs_obd_setup(struct obd_device *obd) if (rc) return rc; - rc = sysfs_create_files(&obd->obd_kobj, obd_def_attrs); + if (uuid_only) + obd->obd_attrs = obd_def_uuid_attrs; + else + obd->obd_attrs = obd_def_attrs; + + rc = sysfs_create_files(&obd->obd_kobj, obd->obd_attrs); if (rc) { kobject_put(&obd->obd_kobj); return rc; @@ -1043,7 +1053,10 @@ int lprocfs_obd_cleanup(struct obd_device *obd) debugfs_remove_recursive(obd->obd_debugfs_entry); - sysfs_remove_files(&obd->obd_kobj, obd_def_attrs); + if (obd->obd_attrs) { + sysfs_remove_files(&obd->obd_kobj, obd->obd_attrs); + obd->obd_attrs = NULL; + } kobject_put(&obd->obd_kobj); wait_for_completion(&obd->obd_kobj_unregister); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 0472165..4f57a8e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2804,7 +2804,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(obd); - if (lprocfs_obd_setup(obd) == 0) { + if (lprocfs_obd_setup(obd, false) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:27 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:27 -0400 Subject: [lustre-devel] [PATCH 24/38] lustre: obd: create conn_uuid sysfs file In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-25-git-send-email-jsimmons@infradead.org> Change conn_uuid from a debugfs file to sysfs file. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28108 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 1 + .../lustre/lustre/obdclass/lprocfs_status.c | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 3863fff..bc7a390 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -463,6 +463,7 @@ int lprocfs_wr_uint(struct file *file, const char __user *buffer, unsigned long count, void *data); int lprocfs_rd_server_uuid(struct seq_file *m, void *data); int lprocfs_rd_conn_uuid(struct seq_file *m, void *data); +ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf); int lprocfs_rd_import(struct seq_file *m, void *data); int lprocfs_rd_state(struct seq_file *m, void *data); int lprocfs_rd_connect_flags(struct seq_file *m, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index f889fb8..3fbf10b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -476,6 +476,29 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(filesfree); +ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct ptlrpc_connection *conn; + ssize_t count; + int rc; + + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + + conn = obd->u.cli.cl_import->imp_connection; + if (conn && obd->u.cli.cl_import) + count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid); + else + count = sprintf(buf, "%s\n", ""); + + up_read(&obd->u.cli.cl_sem); + return count; +} +EXPORT_SYMBOL(conn_uuid_show); + int lprocfs_rd_server_uuid(struct seq_file *m, void *data) { struct obd_device *obd = data; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:29 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:29 -0400 Subject: [lustre-devel] [PATCH 26/38] lustre: obd: merge both top lustre sysfs attributes In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-27-git-send-email-jsimmons@infradead.org> The top of the lustre sysfs tree is handled by two sets of attributes, one in sysctl.c and the other in modules.c. Worst is the the sysfs attributes in sysctl.c are never cleaned up. So merge all the sysfs handling in sysctl.c into the one managed in modules.c. Additionally now all the top level attributes will be cleaned up. This eliminates the sysctl.c file as well. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9431 Reviewed-on: https://review.whamcloud.com/30143 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd_class.h | 3 - drivers/staging/lustre/lustre/obdclass/Makefile | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 - drivers/staging/lustre/lustre/obdclass/module.c | 97 ++++++++++++ drivers/staging/lustre/lustre/obdclass/sysctl.c | 162 --------------------- 5 files changed, 98 insertions(+), 170 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/sysctl.c diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index e250bc3..02a3f97 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1553,9 +1553,6 @@ struct lwp_register_item { int lustre_register_fs(void); int lustre_check_exclusion(struct super_block *sb, char *svname); -/* sysctl.c */ -int obd_sysctl_init(void); - /* uuid.c */ typedef __u8 class_uuid_t[16]; void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 686bd54..5d050f0 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -4,7 +4,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := module.o sysctl.o \ +obdclass-y := module.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 8100184..bbffede 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -494,10 +494,6 @@ static int __init obdclass_init(void) if (err) goto cleanup_caches; - err = obd_sysctl_init(); - if (err) - goto cleanup_class_procfs; - err = lu_global_init(); if (err) goto cleanup_class_procfs; diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 0ce2617..27b3849 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -274,6 +274,93 @@ struct miscdevice obd_psdev = { .fops = &obd_psdev_fops, }; +struct static_lustre_uintvalue_attr { + struct { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + } u; + int *value; +}; + +static ssize_t static_uintvalue_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct static_lustre_uintvalue_attr *lattr = (void *)attr; + + return sprintf(buf, "%d\n", *lattr->value); +} + +static ssize_t static_uintvalue_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, size_t count) +{ + struct static_lustre_uintvalue_attr *lattr = (void *)attr; + unsigned int val; + int rc; + + rc = kstrtouint(buffer, 10, &val); + if (rc) + return rc; + + *lattr->value = val; + + return count; +} + +#define LUSTRE_STATIC_UINT_ATTR(name, value) \ +static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ + { __ATTR(name, 0644, static_uintvalue_show, \ + static_uintvalue_store), value } + +LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout); +LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout); +LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout); +LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction); +LUSTRE_STATIC_UINT_ATTR(at_min, &at_min); +LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); +LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); +LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); +LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); + +static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%lu\n", + obd_max_dirty_pages / (1 << (20 - PAGE_SHIFT))); +} + +static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) +{ + unsigned long val; + int rc; + + rc = kstrtoul(buffer, 10, &val); + if (rc) + return rc; + + val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */ + + if (val > ((totalram_pages / 10) * 9)) { + /* Somebody wants to assign too much memory to dirty pages */ + return -EINVAL; + } + + if (val < 4 << (20 - PAGE_SHIFT)) { + /* Less than 4 Mb for dirty cache is also bad */ + return -EINVAL; + } + + obd_max_dirty_pages = val; + + return count; +} +LUSTRE_RW_ATTR(max_dirty_mb); + static ssize_t version_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -390,6 +477,16 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr, &lustre_attr_health_check.attr, &lustre_attr_jobid_name.attr, &lustre_attr_jobid_var.attr, + &lustre_sattr_timeout.u.attr, + &lustre_attr_max_dirty_mb.attr, + &lustre_sattr_debug_peer_on_timeout.u.attr, + &lustre_sattr_dump_on_timeout.u.attr, + &lustre_sattr_dump_on_eviction.u.attr, + &lustre_sattr_at_min.u.attr, + &lustre_sattr_at_max.u.attr, + &lustre_sattr_at_extra.u.attr, + &lustre_sattr_at_early_margin.u.attr, + &lustre_sattr_at_history.u.attr, NULL, }; diff --git a/drivers/staging/lustre/lustre/obdclass/sysctl.c b/drivers/staging/lustre/lustre/obdclass/sysctl.c deleted file mode 100644 index f8760b2..0000000 --- a/drivers/staging/lustre/lustre/obdclass/sysctl.c +++ /dev/null @@ -1,162 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2015, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include -#include - -struct static_lustre_uintvalue_attr { - struct { - struct attribute attr; - ssize_t (*show)(struct kobject *kobj, struct attribute *attr, - char *buf); - ssize_t (*store)(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len); - } u; - int *value; -}; - -static ssize_t static_uintvalue_show(struct kobject *kobj, - struct attribute *attr, - char *buf) -{ - struct static_lustre_uintvalue_attr *lattr = (void *)attr; - - return sprintf(buf, "%d\n", *lattr->value); -} - -static ssize_t static_uintvalue_store(struct kobject *kobj, - struct attribute *attr, - const char *buffer, size_t count) -{ - struct static_lustre_uintvalue_attr *lattr = (void *)attr; - int rc; - unsigned int val; - - rc = kstrtouint(buffer, 10, &val); - if (rc) - return rc; - - *lattr->value = val; - - return count; -} - -#define LUSTRE_STATIC_UINT_ATTR(name, value) \ -static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ - {__ATTR(name, 0644, \ - static_uintvalue_show, \ - static_uintvalue_store),\ - value } - -LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout); - -static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", - obd_max_dirty_pages / (1 << (20 - PAGE_SHIFT))); -} - -static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) -{ - int rc; - unsigned long val; - - rc = kstrtoul(buffer, 10, &val); - if (rc) - return rc; - - val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */ - - if (val > ((totalram_pages / 10) * 9)) { - /* Somebody wants to assign too much memory to dirty pages */ - return -EINVAL; - } - - if (val < 4 << (20 - PAGE_SHIFT)) { - /* Less than 4 Mb for dirty cache is also bad */ - return -EINVAL; - } - - obd_max_dirty_pages = val; - - return count; -} -LUSTRE_RW_ATTR(max_dirty_mb); - -LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout); -LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout); -LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction); -LUSTRE_STATIC_UINT_ATTR(at_min, &at_min); -LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); -LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); -LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); -LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); - -static struct attribute *lustre_attrs[] = { - &lustre_sattr_timeout.u.attr, - &lustre_attr_max_dirty_mb.attr, - &lustre_sattr_debug_peer_on_timeout.u.attr, - &lustre_sattr_dump_on_timeout.u.attr, - &lustre_sattr_dump_on_eviction.u.attr, - &lustre_sattr_at_min.u.attr, - &lustre_sattr_at_max.u.attr, - &lustre_sattr_at_extra.u.attr, - &lustre_sattr_at_early_margin.u.attr, - &lustre_sattr_at_history.u.attr, - NULL, -}; - -static const struct attribute_group lustre_attr_group = { - .attrs = lustre_attrs, -}; - -int obd_sysctl_init(void) -{ - return sysfs_create_group(&lustre_kset->kobj, &lustre_attr_group); -} -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:30 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:30 -0400 Subject: [lustre-devel] [PATCH 27/38] lustre: obd: resolve config log sysfs issues In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-28-git-send-email-jsimmons@infradead.org> This resolves long standing issues with modifying sysfs settings on multiple nodes simultaneously by running a single command on the backend MGS server. Their are two ways to change the settings, LCFG_PARAM and LCFG_SET_PARAM. For the LCFG_PARAM case we create a new function class_modify_config() that grabs the attributes from the passed in kobject. We can use those attributes to modify the sysfs settings. If we can't find the attribute then send a uevent to let userland resolve the change. For the LCFG_SET_PARAM case we handle two class of settings. The function class_set_global() was modifiy to handle the top lustre sysfs files since they are not searchable with kset_find_obj. If we can find a kobject with kset_find_obj then we can send a uevent so userland change manage the change. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9431 Reviewed-on: https://review.whamcloud.com/30143 Reviewed-by: Dmitry Eremin Reviewed-by: Ben Evans Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 5 + drivers/staging/lustre/lustre/include/obd_class.h | 3 + .../lustre/lustre/obdclass/lprocfs_status.c | 10 +- drivers/staging/lustre/lustre/obdclass/module.c | 18 +++ .../staging/lustre/lustre/obdclass/obd_config.c | 172 ++++++++++++++------- 5 files changed, 152 insertions(+), 56 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index bc7a390..c841aba 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -577,6 +577,11 @@ struct lustre_attr { #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) +ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr, + char *buf); +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len); + extern const struct sysfs_ops lustre_sysfs_ops; struct root_squash_info; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 02a3f97..1925bda 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -108,6 +108,9 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); void print_lustre_cfg(struct lustre_cfg *lcfg); int class_process_config(struct lustre_cfg *lcfg); +ssize_t class_set_global(const char *param); +ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, + struct kobject *kobj); int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 3fbf10b..84e5a8c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1762,21 +1762,23 @@ int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, } EXPORT_SYMBOL(lprocfs_wr_nosquash_nids); -static ssize_t lustre_attr_show(struct kobject *kobj, - struct attribute *attr, char *buf) +ssize_t lustre_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) { struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); return a->show ? a->show(kobj, attr, buf) : 0; } +EXPORT_SYMBOL_GPL(lustre_attr_show); -static ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t len) +ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr, + const char *buf, size_t len) { struct lustre_attr *a = container_of(attr, struct lustre_attr, attr); return a->store ? a->store(kobj, attr, buf, len) : len; } +EXPORT_SYMBOL_GPL(lustre_attr_store); const struct sysfs_ops lustre_sysfs_ops = { .show = lustre_attr_show, diff --git a/drivers/staging/lustre/lustre/obdclass/module.c b/drivers/staging/lustre/lustre/obdclass/module.c index 27b3849..eab9820 100644 --- a/drivers/staging/lustre/lustre/obdclass/module.c +++ b/drivers/staging/lustre/lustre/obdclass/module.c @@ -575,6 +575,24 @@ static int obd_device_list_open(struct inode *inode, struct file *file) .attrs = lustre_attrs, }; +ssize_t class_set_global(const char *param) +{ + const char *value = strchr(param, '=') + 1; + size_t off = value - param - 1; + ssize_t count = -ENOENT; + int i; + + for (i = 0; lustre_attrs[i]; i++) { + if (!strncmp(lustre_attrs[i]->name, param, off)) { + count = lustre_attr_store(&lustre_kset->kobj, + lustre_attrs[i], value, + strlen(value)); + break; + } + } + return count; +} + int class_procfs_init(void) { int rc = -ENOMEM; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index d962f0c..823ddb0 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -814,28 +814,6 @@ void class_del_profiles(void) } EXPORT_SYMBOL(class_del_profiles); -static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) -{ - if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) - at_min = val; - else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) - at_max = val; - else if (class_match_param(ptr, PARAM_AT_EXTRA, NULL) == 0) - at_extra = val; - else if (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, NULL) == 0) - at_early_margin = val; - else if (class_match_param(ptr, PARAM_AT_HISTORY, NULL) == 0) - at_history = val; - else if (class_match_param(ptr, PARAM_JOBID_VAR, NULL) == 0) - strlcpy(obd_jobid_var, lustre_cfg_string(lcfg, 2), - JOBSTATS_JOBID_VAR_MAX_LEN + 1); - else - return -EINVAL; - - CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); - return 0; -} - /* We can't call ll_process_config or lquota_process_config directly because * it lives in a module that must be loaded after this one. */ @@ -851,38 +829,44 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)) static int process_param2_config(struct lustre_cfg *lcfg) { char *param = lustre_cfg_string(lcfg, 1); - char *upcall = lustre_cfg_string(lcfg, 2); - char *argv[] = { - [0] = "/usr/sbin/lctl", - [1] = "set_param", - [2] = param, - [3] = NULL - }; - ktime_t start; - ktime_t end; - int rc; + struct kobject *kobj = NULL; + const char *subsys = param; + char *envp[3]; + char *value; + size_t len; + int rc; + int i; - /* Add upcall processing here. Now only lctl is supported */ - if (strcmp(upcall, LCTL_UPCALL) != 0) { - CERROR("Unsupported upcall %s\n", upcall); + print_lustre_cfg(lcfg); + + len = strcspn(param, ".="); + if (!len) return -EINVAL; - } - start = ktime_get(); - rc = call_usermodehelper(argv[0], argv, NULL, UMH_WAIT_PROC); - end = ktime_get(); + /* If we find '=' then its the top level sysfs directory */ + if (param[len] == '=') + return class_set_global(param); - if (rc < 0) { - CERROR( - "lctl: error invoking upcall %s %s %s: rc = %d; time %ldus\n", - argv[0], argv[1], argv[2], rc, - (long)ktime_us_delta(end, start)); - } else { - CDEBUG(D_HA, "lctl: invoked upcall %s %s %s, time %ldus\n", - argv[0], argv[1], argv[2], - (long)ktime_us_delta(end, start)); - rc = 0; - } + subsys = kstrndup(param, len, GFP_KERNEL); + if (!subsys) + return -ENOMEM; + + kobj = kset_find_obj(lustre_kset, subsys); + kfree(subsys); + if (!kobj) + return -ENODEV; + + value = param; + param = strsep(&value, "="); + envp[0] = kasprintf(GFP_KERNEL, "PARAM=%s", param); + envp[1] = kasprintf(GFP_KERNEL, "SETTING=%s", value); + envp[2] = NULL; + + rc = kobject_uevent_env(kobj, KOBJ_CHANGE, envp); + for (i = 0; i < ARRAY_SIZE(envp); i++) + kfree(envp[i]); + + kobject_put(kobj); return rc; } @@ -983,12 +967,12 @@ int class_process_config(struct lustre_cfg *lcfg) } else if ((class_match_param(lustre_cfg_string(lcfg, 1), PARAM_SYS, &tmp) == 0)) { /* Global param settings */ - err = class_set_global(tmp, lcfg->lcfg_num, lcfg); + err = class_set_global(tmp); /* * Client or server should not fail to mount if * it hits an unknown configuration parameter. */ - if (err != 0) + if (err < 0) CWARN("Ignoring unknown param %s\n", tmp); err = 0; @@ -1082,6 +1066,90 @@ int class_process_config(struct lustre_cfg *lcfg) } EXPORT_SYMBOL(class_process_config); +ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix, + struct kobject *kobj) +{ + struct kobj_type *typ; + ssize_t count = 0; + int i; + + if (lcfg->lcfg_command != LCFG_PARAM) { + CERROR("Unknown command: %d\n", lcfg->lcfg_command); + return -EINVAL; + } + + typ = get_ktype(kobj); + if (!typ || !typ->default_attrs) + return -ENODEV; + + print_lustre_cfg(lcfg); + + /* + * e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt + * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar + * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 + */ + for (i = 1; i < lcfg->lcfg_bufcount; i++) { + struct attribute *attr; + size_t keylen; + char *value; + char *key; + int j; + + key = lustre_cfg_buf(lcfg, i); + /* Strip off prefix */ + if (class_match_param(key, prefix, &key)) + /* If the prefix doesn't match, return error so we + * can pass it down the stack + */ + return -EINVAL; + + value = strchr(key, '='); + if (!value || *(value + 1) == 0) { + CERROR("%s: can't parse param '%s' (missing '=')\n", + lustre_cfg_string(lcfg, 0), + lustre_cfg_string(lcfg, i)); + /* continue parsing other params */ + continue; + } + keylen = value - key; + value++; + + attr = NULL; + for (j = 0; typ->default_attrs[j]; j++) { + if (!strncmp(typ->default_attrs[j]->name, key, + keylen)) { + attr = typ->default_attrs[j]; + break; + } + } + + if (!attr) { + char *envp[3]; + + envp[0] = kasprintf(GFP_KERNEL, "PARAM=%s.%s.%.*s", + kobject_name(kobj->parent), + kobject_name(kobj), + (int)keylen, key); + envp[1] = kasprintf(GFP_KERNEL, "SETTING=%s", value); + envp[2] = NULL; + + if (kobject_uevent_env(kobj, KOBJ_CHANGE, envp)) { + CERROR("%s: failed to send uevent %s\n", + kobject_name(kobj), key); + } + + for (i = 0; i < ARRAY_SIZE(envp); i++) + kfree(envp[i]); + } else { + count += lustre_attr_store(kobj, attr, value, + strlen(value)); + } + } + return count; +} +EXPORT_SYMBOL(class_modify_config); + int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data) { -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:34 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:34 -0400 Subject: [lustre-devel] [PATCH 31/38] lustre: osc: fixup kstrto* for sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-32-git-send-email-jsimmons@infradead.org> Some of the osc sysfs files only allow 1 or 0 which was retrieved with kstrtoul(). A much better fit would be to use kstrtobool(). This adds 'Y' or 'N' as valid options as well. Instead of using kstrtoull() for everything with additional range checking we can change to a different kstrtoxxx() so the range checking can be removed. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9325 Reviewed-on: https://review.whamcloud.com/30539 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 43 ++++++++++++--------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 4ed289b..3c31e98 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -55,20 +55,18 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val > 1) - return -ERANGE; /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else - CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n", + CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n", val); return count; @@ -94,15 +92,15 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; - int rc; - unsigned long val; int adding, added, req_count; + unsigned int val; + int rc; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val < 1 || val > OSC_MAX_RIF_MAX) + if (val == 0 || val > OSC_MAX_RIF_MAX) return -ERANGE; adding = val - cli->cl_max_rpcs_in_flight; @@ -334,14 +332,14 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val <= 0) + if (val == 0) return -ERANGE; obd->u.cli.cl_grant_shrink_interval = val; @@ -367,14 +365,14 @@ static ssize_t checksums_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + bool val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - obd->u.cli.cl_checksum = (val ? 1 : 0); + obd->u.cli.cl_checksum = val; return count; } @@ -454,10 +452,10 @@ static ssize_t resend_count_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; @@ -486,16 +484,13 @@ static ssize_t contention_seconds_store(struct kobject *kobj, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); + unsigned int val; int rc; - int val; - rc = kstrtoint(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; - if (val < 0) - return -EINVAL; - od->od_contention_time = val; return count; @@ -521,10 +516,10 @@ static ssize_t lockless_truncate_store(struct kobject *kobj, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct osc_device *od = obd2osc_dev(obd); + bool val; int rc; - unsigned int val; - rc = kstrtouint(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:36 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:36 -0400 Subject: [lustre-devel] [PATCH 33/38] lustre: osc: make unstable_stats a debugfs file In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-34-git-send-email-jsimmons@infradead.org> The sysfs attribute unstable_stats breaks the one item per file rule. Make it a debugfs file instead. Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 5fb7a16..79a30b3 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -614,12 +614,9 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_pages_per_rpc); -static ssize_t unstable_stats_show(struct kobject *kobj, - struct attribute *attr, - char *buf) +static int osc_unstable_stats_seq_show(struct seq_file *m, void *v) { - struct obd_device *dev = container_of(kobj, struct obd_device, - obd_kset.kobj); + struct obd_device *dev = m->private; struct client_obd *cli = &dev->u.cli; long pages; int mb; @@ -627,10 +624,14 @@ static ssize_t unstable_stats_show(struct kobject *kobj, pages = atomic_long_read(&cli->cl_unstable_count); mb = (pages * PAGE_SIZE) >> 20; - return sprintf(buf, "unstable_pages: %20ld\n" - "unstable_mb: %10d\n", pages, mb); + seq_printf(m, + "unstable_pages: %20ld\n" + "unstable_mb: %10d\n", + pages, mb); + return 0; } -LUSTRE_RO_ATTR(unstable_stats); + +LPROC_SEQ_FOPS_RO(osc_unstable_stats); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); @@ -655,6 +656,8 @@ static ssize_t unstable_stats_show(struct kobject *kobj, { "import", &osc_import_fops, NULL }, { "state", &osc_state_fops, NULL, 0 }, { "pinger_recov", &osc_pinger_recov_fops, NULL }, + { .name = "unstable_stats", + .fops = &osc_unstable_stats_fops }, { NULL } }; @@ -837,7 +840,6 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_resend_count.attr, - &lustre_attr_unstable_stats.attr, NULL, }; -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:39 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:39 -0400 Subject: [lustre-devel] [PATCH 36/38] lustre: lmv: update sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-37-git-send-email-jsimmons@infradead.org> Move all the sysfs/debugfs handling to lproc_lmv.c. Properly handle failure cases for sysfs/debugfs bring up. Change desc_uuid into a sysfs files since its a simple one item file so we don't clutter debugfs. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/28460 Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lmv/lmv_internal.h | 4 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 17 +++++---- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 48 +++++++++++++----------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 1b51dfb..f2c41c7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -157,8 +157,6 @@ struct lmv_tgt_desc *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data, struct lu_fid *fid); /* lproc_lmv.c */ -void lprocfs_lmv_init_vars(struct obd_device *obd); - -extern const struct file_operations lmv_proc_target_fops; +int lmv_tunables_init(struct obd_device *obd); #endif diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 7d5d03b..cf2a4c6 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -211,6 +211,10 @@ static int lmv_connect(const struct lu_env *env, lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds", &obd->obd_kset.kobj); + if (!lmv->lmv_tgts_kobj) + CERROR("%s: cannot create /sys/fs/lustre/%s/%s/target_obds\n", + obd->obd_name, obd->obd_type->typ_name, obd->obd_name); + rc = lmv_check_connect(obd); if (rc) goto out_sysfs; @@ -1254,22 +1258,19 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_lock_init(&lmv->lmv_lock); mutex_init(&lmv->lmv_init_mutex); - lprocfs_lmv_init_vars(obd); + rc = lmv_tunables_init(obd); + if (rc) + CWARN("%s: error adding LMV sysfs/debugfs files: rc = %d\n", + obd->obd_name, rc); - lprocfs_obd_setup(obd, true); - debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, - &lmv_proc_target_fops); rc = fld_client_init(&lmv->lmv_fld, obd->obd_name, LUSTRE_CLI_FLD_HASH_DHT); if (rc) { CERROR("Can't init FLD, err %d\n", rc); - goto out; + return rc; } return 0; - -out: - return rc; } static int lmv_cleanup(struct obd_device *obd) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 6aae298..efc12ad 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -37,6 +37,7 @@ #include #include #include + #include "lmv_internal.h" static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr, @@ -63,18 +64,17 @@ static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr, } LUSTRE_RO_ATTR(activeobd); -static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v) +static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = (struct obd_device *)m->private; - struct lmv_obd *lmv; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kset.kobj); + struct lmv_desc *desc; - LASSERT(dev); - lmv = &dev->u.lmv; - seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid); - return 0; + desc = &dev->u.lmv.desc; + return sprintf(buf, "%s\n", desc->ld_uuid.uuid); } - -LPROC_SEQ_FOPS_RO(lmv_desc_uuid); +LUSTRE_RO_ATTR(desc_uuid); static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos) { @@ -115,6 +115,7 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v) if (!tgt) return 0; + seq_printf(p, "%u: %s %sACTIVE\n", tgt->ltd_idx, tgt->ltd_uuid.uuid, tgt->ltd_active ? "" : "IN"); @@ -143,27 +144,32 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) return 0; } -static struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, - { NULL } -}; - -const struct file_operations lmv_proc_target_fops = { +static const struct file_operations lmv_debugfs_target_fops = { .owner = THIS_MODULE, - .open = lmv_target_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, + .open = lmv_target_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static struct attribute *lmv_attrs[] = { &lustre_attr_activeobd.attr, + &lustre_attr_desc_uuid.attr, &lustre_attr_numobd.attr, NULL, }; -void lprocfs_lmv_init_vars(struct obd_device *obd) +int lmv_tunables_init(struct obd_device *obd) { - obd->obd_vars = lprocfs_lmv_obd_vars; + int rc; + obd->obd_ktype.default_attrs = lmv_attrs; + rc = lprocfs_obd_setup(obd, true); + if (rc) + return rc; + + debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd, + &lmv_debugfs_target_fops); + + return 0; } -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:41 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:41 -0400 Subject: [lustre-devel] [PATCH 38/38] lustre: mdc: update sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-39-git-send-email-jsimmons@infradead.org> Move all the sysfs/debugfs handling to lproc_mdc.c. Properly handle failure cases for sysfs/debugfs bring up. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/30961 Reviewed-by: Dmitry Eremin Reviewed-by: Sonia Sharma Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 72 ++++++++++++++---------- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 3 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 31 ++++------ 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 47f23d6..3bff8b5 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -51,23 +51,20 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - unsigned long val; + bool val; int rc; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtobool(buffer, &val); if (rc) return rc; - if (val > 1) - return -ERANGE; - /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) { rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); if (rc) count = rc; } else { - CDEBUG(D_CONFIG, "activate %lu: ignoring repeat request\n", val); + CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n", val); } return count; } @@ -77,15 +74,10 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, struct attribute *attr, char *buf) { - int len; struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - __u32 max; - - max = obd_get_max_rpcs_in_flight(&dev->u.cli); - len = sprintf(buf, "%u\n", max); - return len; + return sprintf(buf, "%u\n", obd_get_max_rpcs_in_flight(&dev->u.cli)); } static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, @@ -95,10 +87,10 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); + unsigned int val; int rc; - unsigned long val; - rc = kstrtoul(buffer, 10, &val); + rc = kstrtouint(buffer, 10, &val); if (rc) return rc; @@ -116,13 +108,8 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj, { struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); - u16 max; - int len; - - max = dev->u.cli.cl_max_mod_rpcs_in_flight; - len = sprintf(buf, "%hu\n", max); - return len; + return sprintf(buf, "%hu\n", dev->u.cli.cl_max_mod_rpcs_in_flight); } static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, @@ -147,6 +134,9 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj, } LUSTRE_RW_ATTR(max_mod_rpcs_in_flight); +#define mdc_conn_uuid_show conn_uuid_show +LUSTRE_RO_ATTR(mdc_conn_uuid); + static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v) { struct obd_device *dev = seq->private; @@ -172,7 +162,6 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file, LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid); -LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts); LPROC_SEQ_FOPS_RO_TYPE(mdc, state); @@ -198,15 +187,20 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { - { "ping", &mdc_ping_fops, NULL, 0222 }, - { "connect_flags", &mdc_connect_flags_fops, NULL, 0 }, - /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ - { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 }, - { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 }, - { "timeouts", &mdc_timeouts_fops, NULL, 0 }, - { "import", &mdc_import_fops, NULL, 0 }, - { "state", &mdc_state_fops, NULL, 0 }, - { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 }, + { .name = "ping", + .fops = &mdc_ping_fops }, + { .name = "connect_flags", + .fops = &mdc_connect_flags_fops }, + { .name = "mds_server_uuid", + .fops = &mdc_server_uuid_fops, }, + { .name = "timeouts", + .fops = &mdc_timeouts_fops }, + { .name = "import", + .fops = &mdc_import_fops }, + { .name = "state", + .fops = &mdc_state_fops }, + { .name = "pinger_recov", + .fops = &mdc_pinger_recov_fops }, { .name = "rpc_stats", .fops = &mdc_rpc_stats_fops }, { NULL } @@ -217,11 +211,27 @@ static ssize_t max_pages_per_rpc_show(struct kobject *kobj, &lustre_attr_max_rpcs_in_flight.attr, &lustre_attr_max_mod_rpcs_in_flight.attr, &lustre_attr_max_pages_per_rpc.attr, + &lustre_attr_mdc_conn_uuid.attr, NULL, }; -void lprocfs_mdc_init_vars(struct obd_device *obd) +int mdc_tunables_init(struct obd_device *obd) { + int rc; + obd->obd_ktype.default_attrs = mdc_attrs; obd->obd_vars = lprocfs_mdc_obd_vars; + + rc = lprocfs_obd_setup(obd, false); + if (rc) + return rc; + + rc = sptlrpc_lprocfs_cliobd_attach(obd); + if (rc) { + lprocfs_obd_cleanup(obd); + return rc; + } + ptlrpc_lprocfs_register_obd(obd); + + return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index d66663f..941a896 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -36,7 +36,8 @@ #include -void lprocfs_mdc_init_vars(struct obd_device *obd); +int mdc_tunables_init(struct obd_device *obd); + void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid, __u64 valid, size_t ea_size, __u32 suppgid, u32 flags); void mdc_swap_layouts_pack(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index fcba599..f3c0722 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -60,8 +60,6 @@ #define REQUEST_MINOR 244 -static int mdc_cleanup(struct obd_device *obd); - static inline int mdc_queue_wait(struct ptlrpc_request *req) { struct client_obd *cli = &req->rq_import->imp_obd->u.cli; @@ -2647,10 +2645,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (rc) goto err_ptlrpcd_decref; - lprocfs_mdc_init_vars(obd); - lprocfs_obd_setup(obd, false); - sptlrpc_lprocfs_cliobd_attach(obd); - ptlrpc_lprocfs_register_obd(obd); + rc = mdc_tunables_init(obd); + if (rc) + goto err_osc_cleanup; ns_register_cancel(obd->obd_namespace, mdc_cancel_weight); @@ -2658,13 +2655,16 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) rc = mdc_llog_init(obd); if (rc) { - mdc_cleanup(obd); CERROR("failed to setup llogging subsystems\n"); - return rc; + goto err_llog_cleanup; } - return rc; + return 0; +err_llog_cleanup: + ptlrpc_lprocfs_unregister_obd(obd); +err_osc_cleanup: + client_obd_cleanup(obd); err_ptlrpcd_decref: ptlrpcd_decref(); return rc; @@ -2715,17 +2715,10 @@ static int mdc_cleanup(struct obd_device *obd) static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) { struct lustre_cfg *lcfg = buf; - int rc = 0; + size_t count = class_modify_config(lcfg, PARAM_MDC, + &obd->obd_kset.kobj); - switch (lcfg->lcfg_command) { - default: - rc = class_process_proc_param(PARAM_MDC, obd->obd_vars, - lcfg, obd); - if (rc > 0) - rc = 0; - break; - } - return rc; + return count > 0 ? 0 : count; } static struct obd_ops mdc_obd_ops = { -- 1.8.3.1 From jsimmons at infradead.org Fri Aug 17 03:10:07 2018 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Aug 2018 23:10:07 -0400 Subject: [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <1534475441-15543-5-git-send-email-jsimmons@infradead.org> The only user of ll_sb in struct ll_sb_info is used to query the name locate in the file_system_type. We can get that information from using the super block located in struct path instead. This enables us to use struct ll_sb_info directly for every sysfs or debugfs entry. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_internal.h | 1 - drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- drivers/staging/lustre/lustre/llite/lproc_llite.c | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 2719bc53..92dc05d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -524,7 +524,6 @@ struct ll_sb_info { __kernel_fsid_t ll_fsid; struct kobject ll_kobj; /* sysfs object */ - struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d16f5d1..d352287 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -62,7 +62,7 @@ #define log2(n) ffz(~(n)) #endif -static struct ll_sb_info *ll_init_sbi(struct super_block *sb) +static struct ll_sb_info *ll_init_sbi(void) { struct ll_sb_info *sbi = NULL; unsigned long pages; @@ -129,8 +129,6 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids); init_rwsem(&sbi->ll_squash.rsi_sem); - sbi->ll_sb = sb; - return sbi; } @@ -912,7 +910,7 @@ int ll_fill_super(struct super_block *sb) try_module_get(THIS_MODULE); /* client additional sb info */ - sbi = ll_init_sbi(sb); + sbi = ll_init_sbi(); lsi->lsi_llsbi = sbi; if (!sbi) { module_put(THIS_MODULE); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a9ad328..8e418ba 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -33,6 +33,7 @@ #define DEBUG_SUBSYSTEM S_LLITE #include +#include #include #include @@ -215,7 +216,7 @@ static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kobj); - return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); + return sprintf(buf, "%s\n", sbi->ll_mnt.mnt->mnt_sb->s_type->name); } LUSTRE_RO_ATTR(fstype); -- 1.8.3.1 From neilb at suse.com Fri Aug 17 04:24:09 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 14:24:09 +1000 Subject: [lustre-devel] [PATCH 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint In-Reply-To: <1534475441-15543-2-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-2-git-send-email-jsimmons@infradead.org> Message-ID: <87d0uhsjrq.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > 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: From neilb at suse.com Fri Aug 17 04:27:00 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 14:27:00 +1000 Subject: [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb In-Reply-To: <1534475441-15543-5-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-5-git-send-email-jsimmons@infradead.org> Message-ID: <87a7plsjmz.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > 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. > .... > @@ -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 > } > LUSTRE_RO_ATTR(fstype); > > -- > 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: From neilb at suse.com Fri Aug 17 05:56:08 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 15:56:08 +1000 Subject: [lustre-devel] [PATCH 06/38] lustre: llite: rename llite_sb_release In-Reply-To: <1534475441-15543-7-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-7-git-send-email-jsimmons@infradead.org> Message-ID: <874lftsfif.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > 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: From neilb at suse.com Fri Aug 17 06:21:53 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 16:21:53 +1000 Subject: [lustre-devel] [PATCH 07/38] lustre: llite: register mountpoint before process llog In-Reply-To: <1534475441-15543-8-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-8-git-send-email-jsimmons@infradead.org> Message-ID: <871saxsebi.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > From: Emoly Liu > > In ll_fill_super(), ll_debugfs_register_super() should be > called before lustre_process_log(), otherwise the directory > /sys/fs/lustre/llite/* can't be created in time and the params > "llite.*.*" won't be set correctly. > > Also, this patch adds sbi->ll_xattr_cache_set to mark the flag > LL_SBI_XATTR_CACHE already set during lustre_process_log(), > in case that it will be overwritten in client_common_fill_super(). > > Signed-off-by: Emoly Liu > WC-bug-id: https://jira.whamcloud.com/browse/LU-9399 > Reviewed-on: https://review.whamcloud.com/27241 > Signed-off-by: James Simmons > WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 > Reviewed-on: https://review.whamcloud.com/#/c/32516 > Reviewed-by: John L. Hammond > Reviewed-by: James Simmons > Reviewed-by: Andreas Dilger > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > .../staging/lustre/lustre/llite/llite_internal.h | 5 +- > drivers/staging/lustre/lustre/llite/llite_lib.c | 75 ++++++++++++++++------ > drivers/staging/lustre/lustre/llite/lproc_llite.c | 30 +++------ > 3 files changed, 68 insertions(+), 42 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h > index 5577407..9e60c5e 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_internal.h > +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h > @@ -461,12 +461,15 @@ struct ll_sb_info { > struct obd_uuid ll_sb_uuid; > struct obd_export *ll_md_exp; > struct obd_export *ll_dt_exp; > + struct obd_device *ll_md_obd; > + struct obd_device *ll_dt_obd; > struct dentry *ll_debugfs_entry; > struct lu_fid ll_root_fid; /* root object fid */ > > int ll_flags; > unsigned int ll_umounting:1, > ll_xattr_cache_enabled:1, > + ll_xattr_cache_set:1, /* already set to 0/1 */ > ll_client_common_fill_super_succeeded:1; 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: From neilb at suse.com Fri Aug 17 06:32:20 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 16:32:20 +1000 Subject: [lustre-devel] [PATCH 14/38] lustre: llite: don't handle success case for kbyte* sysfs code In-Reply-To: <1534475441-15543-15-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-15-git-send-email-jsimmons@infradead.org> Message-ID: <87y3d5qz9n.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > The proper thing to due is return on failure so reverse the logic > to conform to kernel standards. > > Signed-off-by: James Simmons > WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 > Reviewed-on: https://review.whamcloud.com/32497 > Reviewed-by: John L. Hammond > Reviewed-by: Andreas Dilger > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 51 ++++++++++++----------- > 1 file changed, 27 insertions(+), 24 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index 7bd557b..72a8f8d 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -154,22 +154,23 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, > struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, > ll_kset.kobj); > struct obd_statfs osfs; > + u32 blk_size; > + u64 result; > int rc; > > rc = ll_statfs_internal(sbi, &osfs, > get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ, > OBD_STATFS_NODELAY); > - if (!rc) { > - __u32 blk_size = osfs.os_bsize >> 10; > - __u64 result = osfs.os_blocks; > + if (rc) > + return rc; > > - while (blk_size >>= 1) > - result <<= 1; > + blk_size = osfs.os_bsize >> 10; > + result = osfs.os_blocks; > > - rc = sprintf(buf, "%llu\n", result); > - } > + while (blk_size >>= 1) > + result <<= 1; 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: From neilb at suse.com Fri Aug 17 06:52:04 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 16:52:04 +1000 Subject: [lustre-devel] [PATCH 27/38] lustre: obd: resolve config log sysfs issues In-Reply-To: <1534475441-15543-28-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-28-git-send-email-jsimmons@infradead.org> Message-ID: <87va89qycr.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > 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. > .. > +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: From neilb at suse.com Fri Aug 17 07:30:33 2018 From: neilb at suse.com (NeilBrown) Date: Fri, 17 Aug 2018 17:30:33 +1000 Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock In-Reply-To: <1534475441-15543-33-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-33-git-send-email-jsimmons@infradead.org> Message-ID: <87sh3dqwkm.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > Access to struct client_obd should be protected with the spinlock > cl_loi_list_lock. This was dropped during the port to sysfs so > restore the proper locking. > > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- > 1 file changed, 31 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c > index 3c31e98..5fb7a16 100644 > --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c > +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c > @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, > struct obd_device *dev = container_of(kobj, struct obd_device, > obd_kset.kobj); > struct client_obd *cli = &dev->u.cli; > + ssize_t len; > > - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); > + spin_lock(&cli->cl_loi_list_lock); > + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); > + spin_unlock(&cli->cl_loi_list_lock); 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: From green at whamcloud.com Fri Aug 17 20:24:57 2018 From: green at whamcloud.com (Oleg Drokin) Date: Fri, 17 Aug 2018 20:24:57 +0000 Subject: [lustre-devel] New tag 2.11.54 Message-ID: <88C7E25C-EB5E-497C-91F0-547162BC7831@whamcloud.com> Hello! I just tagged 2.11.54 in the Lustre community master branch. Here’s the changelog: Alex Zhuravlev (1): LU-10928 tests: sanity/133b should wait a bit Alexander Boyko (2): LU-11156 scrub: skip project quota inode LU-11186 ofd: fix for a final oid at sequence Andreas Dilger (4): LU-11147 llite: add newline to llite.*.offset_stats LU-10254 tests: fix racer version checks LU-9538 utils: fix lfs xattr.h header usage LU-1895 tests: don't fail mmp test_5 due to race Arshad Hussain (3): LU-11087 osd-ldiskfs: Fix style issues for osd_compat.c LU-11094 osd-ldiskfs: Fix style issues for osd_quota.c LU-6142 obdclass: Fix style issues for obdo_server.c Bobi Jam (7): LU-8708 osc: depart grant shrinking from pinger LU-11022 lfs: accept specifing comp_id in mirror split LU-11138 lfs: getstripe display certain mirror(s) LU-9007 lod: improve obj alloc for FLR file LU-10916 lfs: improve lfs mirror resync LU-11127 test: sanity-flr OST not recovery fast enough LU-9007 lod: get rid of comp ost in use array Fan Yong (1): LU-10288 lfsck: layout LFSCK for mirrored file Hongchao Zhang (4): LU-10683 osd_zfs: set offset in page correctly LU-11141 quota: reset adjust schedule when updating lqe LU-11174 quota: use sync io to test quota LU-11153 quota: initialize ver for default quota James Nunez (7): LU-5638 tests: resume running sanity-quota tests LU-11010 tests: remove calls to return after skip() LU-11141 tests: put sanity-quota 61 on slow list LU-11166 tests: remove use of /proc/fs/jbd2/*/history file LU-7372 tests: stop running replay-dual test 26 LU-11171 tests: set parameters for racer_on_nfs LU-10940 tests: skip sanity test 802 when quota enabled James Simmons (10): LU-8066 osp: migrate from proc to sysfs LU-6142 ko2iblnd: remove typedefs from ko2iblnd LU-8066 llite: move /proc/fs/lustre/llite/blocksize to sysfs LU-8066 llite: move /proc/fs/lustre/llite/kbytes* to sysfs LU-8066 llite: move /proc/fs/lustre/llite/files* to sysfs LU-8066 llite: move /proc/fs/lustre/llite/client_type to sysfs LU-8066 llite: move /proc/fs/lustre/llite/fstype to sysfs LU-10947 build: test if xfsprogs are installed LU-10627 tests: don't use libtool wrapper for applications LU-11176 systemd: use univeral path for modprobe Jian Yu (2): LU-11115 lod: skip max_create_count=0 OST in QoS and RR algorithms LU-11159 kernel: kernel update RHEL7.5 [3.10.0-862.9.1.el7] John L. Hammond (5): LU-11108 mdt: propagate errors in mdt_getxattr() LU-11107 mdt: handle nonexistent xattrs correctly LU-11083 tests: automatically load external modules LU-11109 mdt: handle zero length xattr values correctly LU-11152 test: work around find bug in sanity 133[fg] Lai Siyao (6): LU-11103 lod: add lock for lod_object layout LU-11102 ldlm: run local lock bl_ast only when necessary LU-11104 mdt: rename may cause deadlock LU-11148 ldlm: enable trybits for PDO lock LU-11102 test: test fewer files on ZFS system LU-4684 migrate: pack lmv ea in migrate rpc Li Dongyang (1): LU-11071 build: Add server build support for Ubuntu 18.04 Michael Kuhn (1): LU-9087 build: add support for DKMS debs Mikhail Pershin (3): LU-11120 test: add compilebench and DNE tests LU-10181 mds: init cpt params for mdt IO service LU-10181 mdt: read on open for DoM files Minh Diep (2): LU-11068 build: remove invalid kernel srpm location LU-11149 build: enable KMP for Mellanox build Nathaniel Clark (1): LU-11160 build: Fix uuid / blkid dependency Oleg Drokin (1): New tag 2.11.54 Patrick Farrell (2): LU-10970 tests: make sure write is complete LU-11027 doc: Add lockahead to llapi_ladvise man Qian Yingjin (3): LU-11032 hsm: memory leak in mdt_hsm_cdt_cleanup LU-9538 mdt: Lazy size on MDT LU-9538 utils: Tool for syncing file LSOM xattr Quentin Bouget (1): LU-9474 tests: replace import_file with copytool import Teddy Zheng (1): LU-10114 hsm: add OBD_CONNECT2_ARCHIVE_ID_ARRAY to pass archive_id lists in array Yang Sheng (2): LU-11129 kernel: kernel update RHEL7.5 [3.10.0-862.6.3.el7] LU-11062 libcfs: use save_stack_trace for stack dump From jsimmons at infradead.org Fri Aug 17 22:03:58 2018 From: jsimmons at infradead.org (James Simmons) Date: Fri, 17 Aug 2018 23:03:58 +0100 (BST) Subject: [lustre-devel] [PATCH 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint In-Reply-To: <87d0uhsjrq.fsf@notabene.neil.brown.name> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-2-git-send-email-jsimmons@infradead.org> <87d0uhsjrq.fsf@notabene.neil.brown.name> Message-ID: > On Thu, Aug 16 2018, James Simmons wrote: > > > 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. 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 From jsimmons at infradead.org Sat Aug 18 00:35:32 2018 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Aug 2018 01:35:32 +0100 (BST) Subject: [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb In-Reply-To: <87a7plsjmz.fsf@notabene.neil.brown.name> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-5-git-send-email-jsimmons@infradead.org> <87a7plsjmz.fsf@notabene.neil.brown.name> Message-ID: > On Thu, Aug 16 2018, James Simmons wrote: > > > 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. > > > .... > > > @@ -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). 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? > 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. From jsimmons at infradead.org Sat Aug 18 00:59:07 2018 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Aug 2018 01:59:07 +0100 (BST) Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock In-Reply-To: <87sh3dqwkm.fsf@notabene.neil.brown.name> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-33-git-send-email-jsimmons@infradead.org> <87sh3dqwkm.fsf@notabene.neil.brown.name> Message-ID: > > Access to struct client_obd should be protected with the spinlock > > cl_loi_list_lock. This was dropped during the port to sysfs so > > restore the proper locking. > > > > Signed-off-by: James Simmons > > --- > > drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- > > 1 file changed, 31 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c > > index 3c31e98..5fb7a16 100644 > > --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c > > +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c > > @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, > > struct obd_device *dev = container_of(kobj, struct obd_device, > > obd_kset.kobj); > > struct client_obd *cli = &dev->u.cli; > > + ssize_t len; > > > > - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); > > + spin_lock(&cli->cl_loi_list_lock); > > + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); > > + spin_unlock(&cli->cl_loi_list_lock); > > 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? From adilger at whamcloud.com Sat Aug 18 05:08:30 2018 From: adilger at whamcloud.com (Andreas Dilger) Date: Sat, 18 Aug 2018 05:08:30 +0000 Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock In-Reply-To: References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-33-git-send-email-jsimmons@infradead.org> <87sh3dqwkm.fsf@notabene.neil.brown.name> Message-ID: <483E9D1A-7BC8-4492-B3F4-1E4D572C3562@whamcloud.com> On Aug 17, 2018, at 18:59, James Simmons wrote: > > >>> Access to struct client_obd should be protected with the spinlock >>> cl_loi_list_lock. This was dropped during the port to sysfs so >>> restore the proper locking. >>> >>> Signed-off-by: James Simmons >>> --- >>> drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- >>> 1 file changed, 31 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c >>> index 3c31e98..5fb7a16 100644 >>> --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c >>> +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c >>> @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, >>> struct obd_device *dev = container_of(kobj, struct obd_device, >>> obd_kset.kobj); >>> struct client_obd *cli = &dev->u.cli; >>> + ssize_t len; >>> >>> - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); >>> + spin_lock(&cli->cl_loi_list_lock); >>> + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); >>> + spin_unlock(&cli->cl_loi_list_lock); >> >> 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? 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: From adilger at whamcloud.com Sat Aug 18 05:10:05 2018 From: adilger at whamcloud.com (Andreas Dilger) Date: Sat, 18 Aug 2018 05:10:05 +0000 Subject: [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock In-Reply-To: <483E9D1A-7BC8-4492-B3F4-1E4D572C3562@whamcloud.com> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-33-git-send-email-jsimmons@infradead.org> <87sh3dqwkm.fsf@notabene.neil.brown.name> <483E9D1A-7BC8-4492-B3F4-1E4D572C3562@whamcloud.com> Message-ID: <93D762CF-52EE-4514-A422-C48A0448C78D@whamcloud.com> On Aug 17, 2018, at 23:08, Andreas Dilger wrote: > > Signed PGP part > On Aug 17, 2018, at 18:59, James Simmons wrote: >> >> >>>> Access to struct client_obd should be protected with the spinlock >>>> cl_loi_list_lock. This was dropped during the port to sysfs so >>>> restore the proper locking. >>>> >>>> Signed-off-by: James Simmons >>>> --- >>>> drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- >>>> 1 file changed, 31 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c >>>> index 3c31e98..5fb7a16 100644 >>>> --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c >>>> +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c >>>> @@ -80,8 +80,13 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, >>>> struct obd_device *dev = container_of(kobj, struct obd_device, >>>> obd_kset.kobj); >>>> struct client_obd *cli = &dev->u.cli; >>>> + ssize_t len; >>>> >>>> - return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); >>>> + spin_lock(&cli->cl_loi_list_lock); >>>> + len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); >>>> + spin_unlock(&cli->cl_loi_list_lock); >>> >>> 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? > > 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). 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: From adilger at whamcloud.com Sat Aug 18 05:12:57 2018 From: adilger at whamcloud.com (Andreas Dilger) Date: Sat, 18 Aug 2018 05:12:57 +0000 Subject: [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb In-Reply-To: References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> <1534475441-15543-5-git-send-email-jsimmons@infradead.org> <87a7plsjmz.fsf@notabene.neil.brown.name> Message-ID: On Aug 17, 2018, at 18:35, James Simmons wrote: > >> >> On Thu, Aug 16 2018, James Simmons wrote: >> >>> 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. >>> >> .... >> >>> @@ -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). > > 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: From jsimmons at infradead.org Mon Aug 20 02:39:25 2018 From: jsimmons at infradead.org (James Simmons) Date: Sun, 19 Aug 2018 22:39:25 -0400 Subject: [lustre-devel] [PATCH v2 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint Message-ID: <1534732765-22828-1-git-send-email-jsimmons@infradead.org> Rename ldebugfs_[un]register_mountpoint() to ll_debugfs_[un]register_super(). This first aligns the functions name with the major of the llite function prototypes by starting with the ll_* prefix. The use of mountpoint is not the best way to describe the functions who's name are being changed. Since this is managed by struct ll_sb_info, which is the lustre private instance for struct super_block, so rename to *_super() instead. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Changelog) v1) Initial patch v2) Improved changelog message --- drivers/staging/lustre/lustre/llite/llite_internal.h | 6 +++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 6ed7034..b2cdf75 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -675,9 +675,9 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, void cl_put_grouplock(struct ll_grouplock *cg); /* llite/lproc_llite.c */ -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc); -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc); +void ll_debugfs_unregister_super(struct ll_sb_info *sbi); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index fb3bc16..50ea5fb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -573,7 +573,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) kfree(osfs); if (llite_root) { - err = ldebugfs_register_mountpoint(llite_root, sb, dt, md); + err = ll_debugfs_register_super(llite_root, sb, dt, md); if (err < 0) { CERROR("%s: could not register mount in debugfs: " "rc = %d\n", ll_get_fsname(sb, NULL, 0), err); @@ -679,7 +679,7 @@ static void client_common_put_super(struct super_block *sb) obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - ldebugfs_unregister_mountpoint(sbi); + ll_debugfs_unregister_super(sbi); obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 617aabb..996703d 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1175,8 +1175,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -int ldebugfs_register_mountpoint(struct dentry *parent, - struct super_block *sb, char *osc, char *mdc) +int ll_debugfs_register_super(struct dentry *parent, + struct super_block *sb, char *osc, char *mdc) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1285,7 +1285,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent, return err; } -void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi) +void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); kobject_put(&sbi->ll_kobj); -- 1.8.3.1 From jsimmons at infradead.org Mon Aug 20 02:39:49 2018 From: jsimmons at infradead.org (James Simmons) Date: Sun, 19 Aug 2018 22:39:49 -0400 Subject: [lustre-devel] [PATCH v2 04/38] lustre: llite: remove ll_sb Message-ID: <1534732789-22934-1-git-send-email-jsimmons@infradead.org> The only user of ll_sb in struct ll_sb_info is used to query the name locate in the file_system_type. We can get that information from using the super block located in struct path instead. This enables us to use struct ll_sb_info directly for every sysfs or debugfs entry. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 WC-bug-id: https://jira.whamcloud.com/browse/LU-10824 Reviewed-on: https://review.whamcloud.com/33025 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog) v1) initial patch v2) Remove use of ll_mnt in fstype sysfs file drivers/staging/lustre/lustre/llite/llite_internal.h | 1 - drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- drivers/staging/lustre/lustre/llite/lproc_llite.c | 5 +---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 2719bc53..92dc05d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -524,7 +524,6 @@ struct ll_sb_info { __kernel_fsid_t ll_fsid; struct kobject ll_kobj; /* sysfs object */ - struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d16f5d1..d352287 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -62,7 +62,7 @@ #define log2(n) ffz(~(n)) #endif -static struct ll_sb_info *ll_init_sbi(struct super_block *sb) +static struct ll_sb_info *ll_init_sbi(void) { struct ll_sb_info *sbi = NULL; unsigned long pages; @@ -129,8 +129,6 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids); init_rwsem(&sbi->ll_squash.rsi_sem); - sbi->ll_sb = sb; - return sbi; } @@ -912,7 +910,7 @@ int ll_fill_super(struct super_block *sb) try_module_get(THIS_MODULE); /* client additional sb info */ - sbi = ll_init_sbi(sb); + sbi = ll_init_sbi(); lsi->lsi_llsbi = sbi; if (!sbi) { module_put(THIS_MODULE); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a9ad328..858d276 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -212,10 +212,7 @@ static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); - - return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); + return sprintf(buf, "lustre\n"); } LUSTRE_RO_ATTR(fstype); -- 1.8.3.1 From jsimmons at infradead.org Mon Aug 20 02:40:11 2018 From: jsimmons at infradead.org (James Simmons) Date: Sun, 19 Aug 2018 22:40:11 -0400 Subject: [lustre-devel] [PATCH v2 05/38] lustre: llite: change top kobject for llite into a kset Message-ID: <1534732811-23048-1-git-send-email-jsimmons@infradead.org> Currently the top of the sysfs tree for llite is represented by a kobject and each mount instance a kset. Change the top object into a kset and each mount instance into a kobject instead. The reason for this change is in the future lustre_kobj will be changed into a kset and you can't layer two ksets. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 Reviewed-on: https://review.whamcloud.com/24031 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog) v1) Initial patch v2) fstype no longer needs to use kobject .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 112 +++++++++++++-------- 2 files changed, 71 insertions(+), 43 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 92dc05d..5577407 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -523,7 +523,7 @@ struct ll_sb_info { struct path ll_mnt; __kernel_fsid_t ll_fsid; - struct kobject ll_kobj; /* sysfs object */ + struct kset ll_kset; /* sysfs object */ struct completion ll_kobj_unregister; }; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 858d276..f43fc99 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -39,22 +39,42 @@ #include "llite_internal.h" #include "vvp_internal.h" +static struct kobject *llite_kobj; static struct dentry *llite_root; -static struct kset *llite_kset; + +static void class_sysfs_release(struct kobject *kobj) +{ + kfree(kobj); +} + +static struct kobj_type class_ktype = { + .sysfs_ops = &lustre_sysfs_ops, + .release = class_sysfs_release, +}; int llite_tunables_register(void) { + const char *name = "llite"; + struct kobject *kobj; int rc = 0; - llite_kset = kset_create_and_add("llite", NULL, lustre_kobj); - if (!llite_kset) + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return -ENOMEM; + + kobject_init(kobj, &class_ktype); + rc = kobject_add(kobj, lustre_kobj, "%s", name); + if (rc) { + kobject_put(kobj); return -ENOMEM; + } + llite_kobj = kobj; llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; llite_root = NULL; - kset_unregister(llite_kset); + kobject_put(kobj); } return rc; @@ -62,7 +82,8 @@ int llite_tunables_register(void) void llite_tunables_unregister(void) { - kset_unregister(llite_kset); + kobject_put(llite_kobj); + llite_kobj = NULL; debugfs_remove(llite_root); llite_root = NULL; @@ -77,7 +98,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -95,7 +116,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -120,7 +141,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -145,7 +166,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -170,7 +191,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -188,7 +209,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); struct obd_statfs osfs; int rc; @@ -220,7 +241,7 @@ static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid); } @@ -243,7 +264,7 @@ static ssize_t max_read_ahead_mb_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -261,7 +282,7 @@ static ssize_t max_read_ahead_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -290,7 +311,7 @@ static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -308,7 +329,7 @@ static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -335,7 +356,7 @@ static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); long pages_number; int mult; @@ -353,7 +374,7 @@ static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pages_number; @@ -518,7 +539,7 @@ static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0); } @@ -529,7 +550,7 @@ static ssize_t checksum_pages_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -560,7 +581,7 @@ static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); if (sbi->ll_stats_track_type == type) return sprintf(buf, "%d\n", sbi->ll_stats_track_id); @@ -575,7 +596,7 @@ static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer, enum stats_track_type type) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long pid; @@ -644,7 +665,7 @@ static ssize_t statahead_max_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_sa_max); } @@ -655,7 +676,7 @@ static ssize_t statahead_max_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -678,7 +699,7 @@ static ssize_t statahead_agl_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0); } @@ -689,7 +710,7 @@ static ssize_t statahead_agl_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -730,7 +751,7 @@ static ssize_t lazystatfs_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0); } @@ -741,7 +762,7 @@ static ssize_t lazystatfs_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -765,7 +786,7 @@ static ssize_t max_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -794,7 +815,7 @@ static ssize_t default_easize_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned int ealen; int rc; @@ -827,7 +848,7 @@ static ssize_t default_easize_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); unsigned long val; int rc; @@ -873,7 +894,7 @@ static ssize_t xattr_cache_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled); } @@ -884,7 +905,7 @@ static ssize_t xattr_cache_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); int rc; unsigned long val; @@ -909,7 +930,7 @@ static ssize_t fast_read_show(struct kobject *kobj, char *buf) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); return sprintf(buf, "%u\n", !!(sbi->ll_flags & LL_SBI_FAST_READ)); } @@ -920,7 +941,7 @@ static ssize_t fast_read_store(struct kobject *kobj, size_t count) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); bool val; int rc; @@ -1106,7 +1127,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file, static void llite_sb_release(struct kobject *kobj) { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + ll_kset.kobj); complete(&sbi->ll_kobj_unregister); } @@ -1281,17 +1302,22 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb); - sbi->ll_kobj.kset = llite_kset; + /* Yes we also register sysfs mount kset here as well */ + sbi->ll_kset.kobj.parent = llite_kobj; + sbi->ll_kset.kobj.ktype = &llite_ktype; init_completion(&sbi->ll_kobj_unregister); - err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL, - "%s", name); + err = kobject_set_name(&sbi->ll_kset.kobj, "%s", name); + if (err) + goto out; + + err = kset_register(&sbi->ll_kset); if (err) goto out; /* MDC info */ obd = class_name2obd(mdc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); if (err) goto out; @@ -1299,7 +1325,7 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) /* OSC */ obd = class_name2obd(osc); - err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj, + err = sysfs_create_link(&sbi->ll_kset.kobj, &obd->obd_kobj, obd->obd_type->typ_name); out: if (err) { @@ -1313,8 +1339,10 @@ int ll_debugfs_register_super(struct super_block *sb, char *osc, char *mdc) void ll_debugfs_unregister_super(struct ll_sb_info *sbi) { debugfs_remove_recursive(sbi->ll_debugfs_entry); - kobject_put(&sbi->ll_kobj); + + kset_unregister(&sbi->ll_kset); wait_for_completion(&sbi->ll_kobj_unregister); + lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } -- 1.8.3.1 From jsimmons at infradead.org Mon Aug 20 02:40:23 2018 From: jsimmons at infradead.org (James Simmons) Date: Sun, 19 Aug 2018 22:40:23 -0400 Subject: [lustre-devel] [PATCH v2 32/38] lustre: osc: restore cl_loi_list_lock Message-ID: <1534732823-23115-1-git-send-email-jsimmons@infradead.org> Access to struct client_obd should be protected with the spinlock cl_loi_list_lock. This was dropped during the port to sysfs so restore the proper locking. Signed-off-by: James Simmons --- Changelog) v1) Initial patch v2) remove unneeded spin lock for max_rpcs_in_flight_show drivers/staging/lustre/lustre/osc/lproc_osc.c | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 3c31e98..5fb7a16 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -136,7 +141,10 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj, long val; int mult; + spin_lock(&cli->cl_loi_list_lock); val = cli->cl_dirty_max_pages; + spin_unlock(&cli->cl_loi_list_lock); + mult = 1 << (20 - PAGE_SHIFT); return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } @@ -247,9 +255,13 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT); + spin_unlock(&cli->cl_loi_list_lock); + return len; } LUSTRE_RO_ATTR(cur_dirty_bytes); @@ -260,8 +272,13 @@ static ssize_t cur_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } static ssize_t cur_grant_bytes_store(struct kobject *kobj, @@ -280,8 +297,12 @@ static ssize_t cur_grant_bytes_store(struct kobject *kobj, return rc; /* this is only for shrinking grant */ - if (val >= cli->cl_avail_grant) + spin_lock(&cli->cl_loi_list_lock); + if (val >= cli->cl_avail_grant) { + spin_unlock(&cli->cl_loi_list_lock); return -EINVAL; + } + spin_unlock(&cli->cl_loi_list_lock); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); @@ -298,8 +319,13 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, struct obd_device *dev = container_of(kobj, struct obd_device, obd_kset.kobj); struct client_obd *cli = &dev->u.cli; + ssize_t len; - return sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_lock(&cli->cl_loi_list_lock); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); + spin_unlock(&cli->cl_loi_list_lock); + + return len; } LUSTRE_RO_ATTR(cur_lost_grant_bytes); -- 1.8.3.1 From neilb at suse.com Mon Aug 20 04:10:12 2018 From: neilb at suse.com (NeilBrown) Date: Mon, 20 Aug 2018 14:10:12 +1000 Subject: [lustre-devel] [PATCH v2 04/38] lustre: llite: remove ll_sb In-Reply-To: <1534732789-22934-1-git-send-email-jsimmons@infradead.org> References: <1534732789-22934-1-git-send-email-jsimmons@infradead.org> Message-ID: <87woslptjv.fsf@notabene.neil.brown.name> On Sun, Aug 19 2018, James Simmons wrote: > 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. The above no longer matches the below (and I do like the change in the below). So I've changed the above to: -------- The only user of ll_sb in struct ll_sb_info is used to query the name locate in the file_system_type. That information is now constant (always "lustre") so are can use a constant instead. This enables us to use struct ll_sb_info directly for every sysfs or debugfs entry. --------- Thanks, NeilBrown > > Signed-off-by: James Simmons > WC-bug-id: https://jira.whamcloud.com/browse/LU-8066 > Reviewed-on: https://review.whamcloud.com/24031 > WC-bug-id: https://jira.whamcloud.com/browse/LU-10824 > Reviewed-on: https://review.whamcloud.com/33025 > Reviewed-by: Bobi Jam > Reviewed-by: Andreas Dilger > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > Changelog) > v1) initial patch > v2) Remove use of ll_mnt in fstype sysfs file > > drivers/staging/lustre/lustre/llite/llite_internal.h | 1 - > drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++---- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 5 +---- > 3 files changed, 3 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h > index 2719bc53..92dc05d 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_internal.h > +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h > @@ -524,7 +524,6 @@ struct ll_sb_info { > > __kernel_fsid_t ll_fsid; > struct kobject ll_kobj; /* sysfs object */ > - struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ > struct completion ll_kobj_unregister; > }; > > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index d16f5d1..d352287 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -62,7 +62,7 @@ > #define log2(n) ffz(~(n)) > #endif > > -static struct ll_sb_info *ll_init_sbi(struct super_block *sb) > +static struct ll_sb_info *ll_init_sbi(void) > { > struct ll_sb_info *sbi = NULL; > unsigned long pages; > @@ -129,8 +129,6 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) > INIT_LIST_HEAD(&sbi->ll_squash.rsi_nosquash_nids); > init_rwsem(&sbi->ll_squash.rsi_sem); > > - sbi->ll_sb = sb; > - > return sbi; > } > > @@ -912,7 +910,7 @@ int ll_fill_super(struct super_block *sb) > try_module_get(THIS_MODULE); > > /* client additional sb info */ > - sbi = ll_init_sbi(sb); > + sbi = ll_init_sbi(); > lsi->lsi_llsbi = sbi; > if (!sbi) { > module_put(THIS_MODULE); > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index a9ad328..858d276 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -212,10 +212,7 @@ static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, > static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr, > char *buf) > { > - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, > - ll_kobj); > - > - return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name); > + return sprintf(buf, "lustre\n"); > } > LUSTRE_RO_ATTR(fstype); > > -- > 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: From neilb at suse.com Mon Aug 20 04:28:08 2018 From: neilb at suse.com (NeilBrown) Date: Mon, 20 Aug 2018 14:28:08 +1000 Subject: [lustre-devel] [PATCH 00/38] lustre: fixes for sysfs handling In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> References: <1534475441-15543-1-git-send-email-jsimmons@infradead.org> Message-ID: <87sh39pspz.fsf@notabene.neil.brown.name> On Thu, Aug 16 2018, James Simmons wrote: > 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 > > 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 > > -- > 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: