From 155a2b900f9bec8001474a025ce7ebc75f625a4e Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 8 Oct 2018 11:17:55 -0400 Subject: [PATCH] LU-8066 llite: make llite/lov and lmv symlinks old proc code had /proc/sys/fs/lustre/llite/.../lov and lmv dirs that contained name of the dir in lustre/lov and lustre/lmv to better be able to find correct obd device there, but I imagine a better solution would be to just create a symlink with the same name. The name is then pointless and the target dir would have uuid file just as if it was the old-style dir. This is a modified version of Linux-commit : d8ede3f1d5d94618442a61067c6b98a2afbb0962 Change-Id: I90bc1b75e07f0aaa4c3119671f6d097b0e7353b3 Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/32516 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/include/lprocfs_status.h | 3 --- lustre/llite/llite_internal.h | 3 ++- lustre/llite/llite_lib.c | 53 +++++++++++++++++++++--------------- lustre/llite/lproc_llite.c | 60 ++++++----------------------------------- 4 files changed, 41 insertions(+), 78 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index d0bd2af..64658f8 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -571,7 +571,6 @@ extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name, /* Generic callbacks */ extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data); -extern int lprocfs_name_seq_show(struct seq_file *m, void *data); extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data); extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data); ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf); @@ -958,8 +957,6 @@ static inline int lprocfs_obd_cleanup(struct obd_device *dev) { return 0; } static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data) { return 0; } -static inline int lprocfs_name_seq_show(struct seq_file *m, void *data) -{ return 0; } static inline int lprocfs_server_seq_show(struct seq_file *m, void *data) { return 0; } static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index b832fd3..a97d806 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -486,6 +486,8 @@ 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 proc_dir_entry* ll_proc_root; struct lu_fid ll_root_fid; /* root object fid */ @@ -719,7 +721,6 @@ void cl_put_grouplock(struct ll_grouplock *lg); /* llite/lproc_llite.c */ #ifdef CONFIG_PROC_FS -int lprocfs_ll_register_obd(struct super_block *sb, const char *obdname); void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); extern struct lprocfs_vars lprocfs_llite_obd_vars[]; #else diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 8c82dd8..5e8d0ac 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -169,20 +169,19 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct vfsmount *mnt) { 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; - struct obd_uuid *uuid; - struct md_op_data *op_data; - struct lustre_md lmd; + struct ll_sb_info *sbi = ll_s2sbi(sb); + struct obd_statfs *osfs = NULL; + struct ptlrpc_request *request = NULL; + struct obd_connect_data *data = NULL; + struct obd_uuid *uuid; + struct md_op_data *op_data; + struct lustre_md lmd; u64 valid; - int size, err, checksum; - ENTRY; + int size, err, checksum; - obd = class_name2obd(md); - if (!obd) { + ENTRY; + sbi->ll_md_obd = class_name2obd(md); + if (!sbi->ll_md_obd) { CERROR("MD %s: not setup or attached\n", md); RETURN(-EINVAL); } @@ -278,7 +277,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 " @@ -391,8 +391,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, } } - 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); GOTO(out_md_fid, err = -ENODEV); } @@ -459,13 +459,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, "ocd_grant: %d\n", 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 " @@ -622,14 +622,21 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (osfs != NULL) OBD_FREE_PTR(osfs); - if (sbi->ll_proc_root != NULL) { - err = lprocfs_ll_register_obd(sb, dt); + if (sbi->ll_dt_obd) { + err = sysfs_create_link(&sbi->ll_kset.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", dt, ll_get_fsname(sb, NULL, 0), err); err = 0; } - err = lprocfs_ll_register_obd(sb, md); + } + + if (sbi->ll_md_obd) { + err = sysfs_create_link(&sbi->ll_kset.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", md, ll_get_fsname(sb, NULL, 0), err); @@ -646,11 +653,13 @@ out_lock_cn_cb: 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: obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; + sbi->ll_md_obd = NULL; out: if (data != NULL) OBD_FREE_PTR(data); diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index bab7613..30c7cea 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -1345,9 +1345,6 @@ static const char *ra_stat_string[] = { [RA_STAT_FAILED_REACH_END] = "failed to reach end" }; -LPROC_SEQ_FOPS_RO_TYPE(llite, name); -LPROC_SEQ_FOPS_RO_TYPE(llite, uuid); - int ll_debugfs_register_super(struct super_block *sb, const char *name) { struct lustre_sb_info *lsi = s2lsi(sb); @@ -1457,60 +1454,19 @@ out_proc: RETURN(err); } -int lprocfs_ll_register_obd(struct super_block *sb, const char *obdname) -{ - struct lprocfs_vars lvars[2]; - struct ll_sb_info *sbi = ll_s2sbi(sb); - struct obd_device *obd; - struct proc_dir_entry *dir; - char name[MAX_STRING_SIZE + 1]; - int err; - ENTRY; - - memset(lvars, 0, sizeof(lvars)); - - name[MAX_STRING_SIZE] = '\0'; - lvars[0].name = name; - - LASSERT(sbi != NULL); - LASSERT(obdname != NULL); - - obd = class_name2obd(obdname); - - LASSERT(obd != NULL); - LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - LASSERT(obd->obd_type->typ_name != NULL); - - dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); - if (dir == NULL) - GOTO(out, err = -ENOMEM); - - snprintf(name, MAX_STRING_SIZE, "common_name"); - lvars[0].fops = &llite_name_fops; - err = lprocfs_add_vars(dir, lvars, obd); - if (err) - GOTO(out, err); - - snprintf(name, MAX_STRING_SIZE, "uuid"); - lvars[0].fops = &llite_uuid_fops; - err = lprocfs_add_vars(dir, lvars, obd); - if (err) - GOTO(out, err); - -out: - if (err) { - lprocfs_remove(&sbi->ll_proc_root); - lprocfs_free_stats(&sbi->ll_ra_stats); - lprocfs_free_stats(&sbi->ll_stats); - } - RETURN(err); -} - void ll_debugfs_unregister_super(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); + 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); + kobject_put(lsi->lsi_kobj); kset_unregister(&sbi->ll_kset); -- 1.8.3.1