Whamcloud - gitweb
LU-8066 osd: migrate from proc to sysfs 10/32810/18
authorJames Simmons <uja.ornl@yahoo.com>
Fri, 1 Feb 2019 16:26:45 +0000 (11:26 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 Feb 2019 02:01:16 +0000 (02:01 +0000)
Move the osd based modules, osd-ldiskfs and osd-zfs, from using
proc for most single value files to sysfs. Also update MGS as
well since it had symlinks into the osd proc tree originally.

Change-Id: Ib3838038299937d7e9ae68130d50ec2afb84e996
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32810
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lustre/include/lustre_lfsck.h
lustre/lfsck/lfsck_lib.c
lustre/mdd/mdd_lproc.c
lustre/mgs/lproc_mgs.c
lustre/mgs/mgs_internal.h
lustre/obdclass/genops.c
lustre/ofd/lproc_ofd.c
lustre/ofd/ofd_dev.c
lustre/ofd/ofd_internal.h
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_handler.c
lustre/osd-zfs/osd_lproc.c

index 11409b9..64b0d55 100644 (file)
@@ -101,7 +101,7 @@ int lfsck_query(const struct lu_env *env, struct dt_device *key,
                struct lfsck_request *req, struct lfsck_reply *rep,
                struct lfsck_query *que);
 
-int lfsck_get_speed(struct seq_file *m, char *buf, struct dt_device *key);
+int lfsck_get_speed(char *buf, struct dt_device *key);
 int lfsck_set_speed(struct dt_device *key, __u32 val);
 int lfsck_get_windows(char *buf, struct dt_device *key);
 int lfsck_set_windows(struct dt_device *key, unsigned int val);
index 5f5860f..0581be4 100644 (file)
@@ -2745,7 +2745,7 @@ int lfsck_load_sub_trace_files(const struct lu_env *env,
 }
 
 /* external interfaces */
-int lfsck_get_speed(struct seq_file *m, char *buf, struct dt_device *key)
+int lfsck_get_speed(char *buf, struct dt_device *key)
 {
        struct lu_env           env;
        struct lfsck_instance  *lfsck;
@@ -2757,14 +2757,9 @@ int lfsck_get_speed(struct seq_file *m, char *buf, struct dt_device *key)
                RETURN(rc);
 
        lfsck = lfsck_instance_find(key, true, false);
-       if (likely(lfsck != NULL)) {
-               if (m) {
-                       seq_printf(m, "%u\n",
-                                  lfsck->li_bookmark_ram.lb_speed_limit);
-               } else if (buf) {
-                       rc = sprintf(buf, "%u\n",
-                                    lfsck->li_bookmark_ram.lb_speed_limit);
-               }
+       if (lfsck && buf) {
+               rc = sprintf(buf, "%u\n",
+                            lfsck->li_bookmark_ram.lb_speed_limit);
                lfsck_instance_put(&env, lfsck);
        } else {
                rc = -ENXIO;
index fe3ddaa..e53283b 100644 (file)
@@ -463,7 +463,7 @@ static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
        struct mdd_device *mdd = container_of(kobj, struct mdd_device,
                                              mdd_kobj);
 
-       return lfsck_get_speed(NULL, buf, mdd->mdd_bottom);
+       return lfsck_get_speed(buf, mdd->mdd_bottom);
 }
 
 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
index 4a95b02..c575d36 100644 (file)
@@ -219,14 +219,55 @@ static struct lprocfs_vars lprocfs_mgs_obd_vars[] = {
        { NULL }
 };
 
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev);
+       struct kobject *osd_kobj;
+
+       if (!mgs || !mgs->mgs_fstype || !mgs->mgs_bottom)
+               return -ENODEV;
+
+       osd_kobj = &mgs->mgs_bottom->dd_kobj;
+       return lustre_attr_show(osd_kobj, mgs->mgs_fstype, buf);
+}
+LUSTRE_RO_ATTR(fstype);
+
+static ssize_t mntdev_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev);
+       struct kobject *osd_kobj;
+
+       if (!mgs || !mgs->mgs_mntdev || !mgs->mgs_bottom)
+               return -ENODEV;
+
+       osd_kobj = &mgs->mgs_bottom->dd_kobj;
+       return lustre_attr_show(osd_kobj, mgs->mgs_mntdev, buf);
+}
+LUSTRE_RO_ATTR(mntdev);
+
+static struct attribute *mgs_attrs[] = {
+       &lustre_attr_fstype.attr,
+       &lustre_attr_mntdev.attr,
+       NULL,
+};
+
 int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 {
+       int osd_len = strlen(osd_name) - strlen("-osd");
        struct obd_device *obd = mgs->mgs_obd;
-       struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd;
-       int                osd_len = strlen(osd_name) - strlen("-osd");
-       int                rc;
+       struct kobj_type *bottom_type;
+       struct obd_device *osd_obd;
+       int rc;
+       int i;
 
        obd->obd_vars = lprocfs_mgs_obd_vars;
+       obd->obd_ktype.default_attrs = mgs_attrs;
        rc = lprocfs_obd_setup(obd, true);
        if (rc != 0)
                GOTO(out, rc);
@@ -258,6 +299,32 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
                GOTO(out, rc);
         }
 
+       rc = sysfs_create_link(&obd->obd_kset.kobj, &mgs->mgs_bottom->dd_kobj,
+                              "osd");
+       if (rc) {
+               CWARN("%s: failed to create symlink osd -> %s, rc = %d\n",
+                     kobject_name(&obd->obd_kset.kobj),
+                     kobject_name(&mgs->mgs_bottom->dd_kobj), rc);
+               rc = 0;
+       }
+
+       bottom_type = get_ktype(&mgs->mgs_bottom->dd_kobj);
+
+       for (i = 0; bottom_type->default_attrs[i]; i++) {
+               if (strcmp(bottom_type->default_attrs[i]->name, "fstype") == 0) {
+                       mgs->mgs_fstype = bottom_type->default_attrs[i];
+                       break;
+               }
+       }
+
+       for (i = 0; bottom_type->default_attrs[i]; i++) {
+               if (strcmp(bottom_type->default_attrs[i]->name, "mntdev") == 0) {
+                       mgs->mgs_mntdev = bottom_type->default_attrs[i];
+                       break;
+               }
+       }
+
+       osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd;
        mgs->mgs_proc_osd = lprocfs_add_symlink("osd",
                                                obd->obd_proc_entry,
                                                "../../%s/%.*s",
@@ -265,20 +332,7 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
                                                osd_len, /* Strip "-osd". */
                                                osd_name);
        if (mgs->mgs_proc_osd == NULL)
-               GOTO(out, rc = -ENOMEM);
-
-       mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev",
-                                                  obd->obd_proc_entry,
-                                                  "osd/mntdev");
-       if (mgs->mgs_proc_mntdev == NULL)
-               GOTO(out, rc = -ENOMEM);
-
-       mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype",
-                                                  obd->obd_proc_entry,
-                                                  "osd/fstype");
-       if (mgs->mgs_proc_fstype == NULL)
-               GOTO(out, rc = -ENOMEM);
-
+               rc = -ENOMEM;
 out:
        if (rc != 0)
                lproc_mgs_cleanup(mgs);
@@ -296,11 +350,7 @@ void lproc_mgs_cleanup(struct mgs_device *mgs)
        if (mgs->mgs_proc_osd != NULL)
                lprocfs_remove(&mgs->mgs_proc_osd);
 
-       if (mgs->mgs_proc_fstype != NULL)
-               lprocfs_remove(&mgs->mgs_proc_fstype);
-
-       if (mgs->mgs_proc_mntdev != NULL)
-               lprocfs_remove(&mgs->mgs_proc_mntdev);
+       sysfs_remove_link(&obd->obd_kset.kobj, "osd");
 
        if (mgs->mgs_proc_live != NULL) {
                /* Should be no live entries */
index d4de273..8f19130 100644 (file)
@@ -175,8 +175,8 @@ struct mgs_device {
        spinlock_t                       mgs_lock; /* covers mgs_fs_db_list */
        struct proc_dir_entry           *mgs_proc_live;
        struct proc_dir_entry           *mgs_proc_osd;
-       struct proc_dir_entry           *mgs_proc_fstype;
-       struct proc_dir_entry           *mgs_proc_mntdev;
+       struct attribute                *mgs_fstype;
+       struct attribute                *mgs_mntdev;
        time64_t                         mgs_start_time;
        struct obd_device               *mgs_obd;
        struct local_oid_storage        *mgs_los;
index 2bfa781..ebed3cc 100644 (file)
@@ -239,7 +239,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
        if (enable_proc) {
                type->typ_procroot = lprocfs_register(type->typ_name,
                                                      proc_lustre_root,
-                                                     vars, type);
+                                                     NULL, type);
                if (IS_ERR(type->typ_procroot)) {
                        rc = PTR_ERR(type->typ_procroot);
                        type->typ_procroot = NULL;
@@ -262,7 +262,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 
        type->typ_debugfs_entry = ldebugfs_register(type->typ_name,
                                                    debugfs_lustre_root,
-                                                   NULL, type);
+                                                   vars, type);
        if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
                rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
                                             : -ENOMEM;
index c8f6d5d..bd07ca9 100644 (file)
@@ -639,7 +639,7 @@ static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
                                              obd_kset.kobj);
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return lfsck_get_speed(NULL, buf, ofd->ofd_osd);
+       return lfsck_get_speed(buf, ofd->ofd_osd);
 }
 
 /**
@@ -827,6 +827,132 @@ static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(checksum_t10pi_enforce);
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
+static bool max_file_warned;
+static bool rd_cache_warned;
+static bool wr_cache_warned;
+
+static ssize_t read_cache_enable_show(struct kobject *kobj,
+                                     struct attribute *attr,
+                                     char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!rd_cache_warned) {
+               rd_cache_warned = true;
+               pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
+       }
+
+       if (!ofd->ofd_read_cache_enable)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
+                               ofd->ofd_read_cache_enable, buf);
+}
+
+static ssize_t read_cache_enable_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);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!rd_cache_warned) {
+               rd_cache_warned = true;
+               pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
+       }
+
+       if (!ofd->ofd_read_cache_enable)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
+                                ofd->ofd_read_cache_enable, buffer, count);
+}
+LUSTRE_RW_ATTR(read_cache_enable);
+
+static ssize_t readcache_max_filesize_show(struct kobject *kobj,
+                                          struct attribute *attr,
+                                          char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!max_file_warned) {
+               max_file_warned = true;
+               pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
+       }
+
+       if (!ofd->ofd_read_cache_max_filesize)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
+                               ofd->ofd_read_cache_max_filesize, buf);
+}
+
+static ssize_t readcache_max_filesize_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);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!max_file_warned) {
+               max_file_warned = true;
+               pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
+       }
+
+       if (!ofd->ofd_read_cache_max_filesize)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
+                                ofd->ofd_read_cache_max_filesize,
+                                buffer, count);
+}
+LUSTRE_RW_ATTR(readcache_max_filesize);
+
+static ssize_t writethrough_cache_enable_show(struct kobject *kobj,
+                                             struct attribute *attr,
+                                             char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!wr_cache_warned) {
+               wr_cache_warned = true;
+               pr_info("ofd: 'obdfilter.*.writethrough_cache_enabled' is deprecated, use 'osd-*.writethrough_cache_enabled' instead\n");
+       }
+
+       if (!ofd->ofd_write_cache_enable)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
+                               ofd->ofd_write_cache_enable, buf);
+}
+
+static ssize_t writethrough_cache_enable_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);
+       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+       if (!ofd->ofd_write_cache_enable)
+               return -EOPNOTSUPP;
+
+       return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
+                                ofd->ofd_write_cache_enable,
+                                buffer, count);
+}
+LUSTRE_RW_ATTR(writethrough_cache_enable);
+#endif
+
 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft);
 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard);
@@ -932,6 +1058,11 @@ static struct attribute *ofd_attrs[] = {
        &lustre_attr_soft_sync_limit.attr,
        &lustre_attr_lfsck_speed_limit.attr,
        &lustre_attr_checksum_t10pi_enforce.attr,
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
+       &lustre_attr_read_cache_enable.attr,
+       &lustre_attr_readcache_max_filesize.attr,
+       &lustre_attr_writethrough_cache_enable.attr,
+#endif
        NULL,
 };
 
index a246be6..03f8893 100644 (file)
@@ -320,13 +320,7 @@ static bool match_symlink_param(char *param)
                sval = strchr(param, '=');
                if (sval != NULL) {
                        paramlen = sval - param;
-                       if (strncmp(param, "writethrough_cache_enable",
-                                   paramlen) == 0 ||
-                           strncmp(param, "readcache_max_filesize",
-                                   paramlen) == 0 ||
-                           strncmp(param, "read_cache_enable",
-                                   paramlen) == 0 ||
-                           strncmp(param, "brw_stats", paramlen) == 0)
+                       if (strncmp(param, "brw_stats", paramlen) == 0)
                                return true;
                }
        }
@@ -715,8 +709,31 @@ static struct lu_device_operations ofd_lu_ops = {
  */
 static void ofd_procfs_add_brw_stats_symlink(struct ofd_device *ofd)
 {
-       struct obd_device       *obd = ofd_obd(ofd);
-       struct obd_device       *osd_obd = ofd->ofd_osd_exp->exp_obd;
+       struct obd_device *obd = ofd_obd(ofd);
+       struct obd_device *osd_obd = ofd->ofd_osd_exp->exp_obd;
+       struct kobj_type *osd_type;
+       int i;
+
+       osd_type = get_ktype(&ofd->ofd_osd->dd_kobj);
+       for (i = 0; osd_type->default_attrs[i]; i++) {
+               if (strcmp(osd_type->default_attrs[i]->name,
+                          "read_cache_enable") == 0) {
+                       ofd->ofd_read_cache_enable =
+                               osd_type->default_attrs[i];
+               }
+
+               if (strcmp(osd_type->default_attrs[i]->name,
+                          "readcache_max_filesize") == 0) {
+                       ofd->ofd_read_cache_max_filesize =
+                               osd_type->default_attrs[i];
+               }
+
+               if (strcmp(osd_type->default_attrs[i]->name,
+                          "writethrough_cache_enable") == 0) {
+                       ofd->ofd_write_cache_enable =
+                               osd_type->default_attrs[i];
+               }
+       }
 
        if (obd->obd_proc_entry == NULL)
                return;
@@ -724,20 +741,6 @@ static void ofd_procfs_add_brw_stats_symlink(struct ofd_device *ofd)
        lprocfs_add_symlink("brw_stats", obd->obd_proc_entry,
                            "../../%s/%s/brw_stats",
                            osd_obd->obd_type->typ_name, obd->obd_name);
-
-       lprocfs_add_symlink("read_cache_enable", obd->obd_proc_entry,
-                           "../../%s/%s/read_cache_enable",
-                           osd_obd->obd_type->typ_name, obd->obd_name);
-
-       lprocfs_add_symlink("readcache_max_filesize",
-                           obd->obd_proc_entry,
-                           "../../%s/%s/readcache_max_filesize",
-                           osd_obd->obd_type->typ_name, obd->obd_name);
-
-       lprocfs_add_symlink("writethrough_cache_enable",
-                           obd->obd_proc_entry,
-                           "../../%s/%s/writethrough_cache_enable",
-                           osd_obd->obd_type->typ_name, obd->obd_name);
 }
 #endif
 
index 794901e..c76124b 100644 (file)
@@ -159,6 +159,10 @@ struct ofd_device {
        struct ptlrpc_thread     ofd_inconsistency_thread;
        struct list_head         ofd_inconsistency_list;
        spinlock_t               ofd_inconsistency_lock;
+       /* Backwards compatibility */
+       struct attribute        *ofd_read_cache_enable;
+       struct attribute        *ofd_read_cache_max_filesize;
+       struct attribute        *ofd_write_cache_enable;
 };
 
 static inline struct ofd_device *ofd_dev(struct lu_device *d)
index 73d0f02..eb36066 100644 (file)
@@ -7878,6 +7878,7 @@ static int osd_process_config(const struct lu_env *env,
                              struct lu_device *d, struct lustre_cfg *cfg)
 {
        struct osd_device *o = osd_dev(d);
+       ssize_t count;
        int rc;
 
        ENTRY;
@@ -7897,15 +7898,12 @@ static int osd_process_config(const struct lu_env *env,
                break;
        case LCFG_PARAM:
                LASSERT(&o->od_dt_dev);
-               rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars,
-                                             cfg, &o->od_dt_dev);
-               if (rc > 0 || rc == -ENOSYS) {
-                       rc = class_process_proc_param(PARAM_OST,
-                                                     lprocfs_osd_obd_vars,
-                                                     cfg, &o->od_dt_dev);
-                       if (rc > 0)
-                               rc = 0;
-               }
+               count  = class_modify_config(cfg, PARAM_OSD,
+                                            &o->od_dt_dev.dd_kobj);
+               if (count < 0)
+                       count = class_modify_config(cfg, PARAM_OST,
+                                                   &o->od_dt_dev.dd_kobj);
+               rc = count > 0 ? 0 : count;
                break;
        case LCFG_PRE_CLEANUP:
                osd_scrub_stop(o);
@@ -8105,8 +8103,33 @@ static struct obd_ops osd_obd_device_ops = {
        .o_health_check = osd_health_check,
 };
 
+static ssize_t track_declares_assert_show(struct kobject *kobj,
+                                  struct attribute *attr,
+                                  char *buf)
+{
+       return sprintf(buf, "%d\n", ldiskfs_track_declares_assert);
+}
+
+static ssize_t track_declares_assert_store(struct kobject *kobj,
+                                          struct attribute *attr,
+                                          const char *buffer, size_t count)
+{
+       bool track_declares_assert;
+       int rc;
+
+       rc = kstrtobool(buffer, &track_declares_assert);
+       if (rc)
+               return rc;
+
+       ldiskfs_track_declares_assert = track_declares_assert;
+
+       return count;
+}
+LUSTRE_RW_ATTR(track_declares_assert);
+
 static int __init osd_init(void)
 {
+       struct kobject *kobj;
        int rc;
 
        CLASSERT(BH_DXLock < sizeof(((struct buffer_head *)0)->b_state) * 8);
@@ -8127,16 +8150,36 @@ static int __init osd_init(void)
                (void *)kallsyms_lookup_name("dev_check_rdonly");
 #endif
 
-       rc = class_register_type(&osd_obd_device_ops, NULL, true,
-                                lprocfs_osd_module_vars,
+       rc = class_register_type(&osd_obd_device_ops, NULL, true, NULL,
                                 LUSTRE_OSD_LDISKFS_NAME, &osd_device_type);
-       if (rc)
+       if (rc) {
                lu_kmem_fini(ldiskfs_caches);
+               return rc;
+       }
+
+       kobj = kset_find_obj(lustre_kset, LUSTRE_OSD_LDISKFS_NAME);
+       if (kobj) {
+               rc = sysfs_create_file(kobj,
+                                      &lustre_attr_track_declares_assert.attr);
+               kobject_put(kobj);
+               if (rc) {
+                       CWARN("osd-ldiskfs: track_declares_assert failed to register with sysfs\n");
+                       rc = 0;
+               }
+       }
        return rc;
 }
 
 static void __exit osd_exit(void)
 {
+       struct kobject *kobj;
+
+       kobj = kset_find_obj(lustre_kset, LUSTRE_OSD_LDISKFS_NAME);
+       if (kobj) {
+               sysfs_remove_file(kobj,
+                                 &lustre_attr_track_declares_assert.attr);
+               kobject_put(kobj);
+       }
        class_unregister_type(LUSTRE_OSD_LDISKFS_NAME);
        lu_kmem_fini(ldiskfs_caches);
 }
index 606c69c..accc6bf 100644 (file)
@@ -719,7 +719,6 @@ static inline int __osd_xattr_set(struct osd_thread_info *info,
 #ifdef CONFIG_PROC_FS
 /* osd_lproc.c */
 extern struct lprocfs_vars lprocfs_osd_obd_vars[];
-extern struct lprocfs_vars lprocfs_osd_module_vars[];
 int osd_procfs_init(struct osd_device *osd, const char *name);
 int osd_procfs_fini(struct osd_device *osd);
 void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf);
index d1708a3..9a2e12a 100644 (file)
@@ -230,137 +230,142 @@ out:
         RETURN(result);
 }
 
-static int ldiskfs_osd_fstype_seq_show(struct seq_file *m, void *data)
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
 {
-       struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
-
-       LASSERT(osd != NULL);
-       seq_puts(m, "ldiskfs\n");
-       return 0;
+       return sprintf(buf, "ldiskfs\n");
 }
-LPROC_SEQ_FOPS_RO(ldiskfs_osd_fstype);
+LUSTRE_RO_ATTR(fstype);
 
-static int ldiskfs_osd_mntdev_seq_show(struct seq_file *m, void *data)
+static ssize_t mntdev_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
 {
-       struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%s\n", osd->od_mntdev);
-       return 0;
+       return sprintf(buf, "%s\n", osd->od_mntdev);
 }
-LPROC_SEQ_FOPS_RO(ldiskfs_osd_mntdev);
+LUSTRE_RO_ATTR(mntdev);
 
-static int ldiskfs_osd_cache_seq_show(struct seq_file *m, void *data)
+static ssize_t read_cache_enable_show(struct kobject *kobj,
+                                     struct attribute *attr,
+                                     char *buf)
 {
-       struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%u\n", osd->od_read_cache);
-       return 0;
+       return sprintf(buf, "%u\n", osd->od_read_cache);
 }
 
-static ssize_t
-ldiskfs_osd_cache_seq_write(struct file *file, const char __user *buffer,
-                           size_t count, loff_t *off)
+static ssize_t read_cache_enable_store(struct kobject *kobj,
+                                      struct attribute *attr,
+                                      const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *osd = osd_dt_dev(dt);
        bool val;
        int rc;
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtobool_from_user(buffer, count, &val);
+       rc = kstrtobool(buffer, &val);
        if (rc)
                return rc;
 
        osd->od_read_cache = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_cache);
+LUSTRE_RW_ATTR(read_cache_enable);
 
-static int ldiskfs_osd_wcache_seq_show(struct seq_file *m, void *data)
+static ssize_t writethrough_cache_enable_show(struct kobject *kobj,
+                                             struct attribute *attr,
+                                             char *buf)
 {
-       struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%u\n", osd->od_writethrough_cache);
-       return 0;
+       return sprintf(buf, "%u\n", osd->od_writethrough_cache);
 }
 
-static ssize_t
-ldiskfs_osd_wcache_seq_write(struct file *file, const char __user *buffer,
-                               size_t count, loff_t *off)
+static ssize_t writethrough_cache_enable_store(struct kobject *kobj,
+                                              struct attribute *attr,
+                                              const char *buffer,
+                                              size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *osd = osd_dt_dev(dt);
        bool val;
        int rc;
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtobool_from_user(buffer, count, &val);
+       rc = kstrtobool(buffer, &val);
        if (rc)
                return rc;
 
        osd->od_writethrough_cache = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_wcache);
+LUSTRE_RW_ATTR(writethrough_cache_enable);
 
-static ssize_t
-lprocfs_osd_force_sync_seq_write(struct file *file, const char __user *buffer,
-                                       size_t count, loff_t *off)
+ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
+                        const char *buffer, size_t count)
 {
-       struct seq_file   *m = file->private_data;
-       struct dt_device  *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *osd = osd_dt_dev(dt);
-       struct lu_env      env;
-       int                rc;
+       struct lu_env env;
+       int rc;
 
-       LASSERT(osd != NULL);
-       if (unlikely(osd->od_mnt == NULL))
+       LASSERT(osd);
+       if (unlikely(!osd->od_mnt))
                return -EINPROGRESS;
 
        rc = lu_env_init(&env, LCT_LOCAL);
        if (rc)
                return rc;
+
        rc = dt_sync(&env, dt);
        lu_env_fini(&env);
 
        return rc == 0 ? count : rc;
 }
-LPROC_SEQ_FOPS_WR_ONLY(ldiskfs, osd_force_sync);
+LUSTRE_WO_ATTR(force_sync);
 
-static int ldiskfs_osd_pdo_seq_show(struct seq_file *m, void *data)
+static ssize_t pdo_show(struct kobject *kobj, struct attribute *attr,
+                       char *buf)
 {
-       seq_printf(m, "%s\n", ldiskfs_pdo ? "ON" : "OFF");
-       return 0;
+       return sprintf(buf, "%s\n", ldiskfs_pdo ? "ON" : "OFF");
 }
 
-static ssize_t
-ldiskfs_osd_pdo_seq_write(struct file *file, const char __user *buffer,
-                               size_t count, loff_t *off)
+static ssize_t pdo_store(struct kobject *kobj, struct attribute *attr,
+                        const char *buffer, size_t count)
 {
        bool pdo;
        int rc;
 
-       rc = kstrtobool_from_user(buffer, count, &pdo);
+       rc = kstrtobool(buffer, &pdo);
        if (rc != 0)
                return rc;
 
@@ -368,72 +373,75 @@ ldiskfs_osd_pdo_seq_write(struct file *file, const char __user *buffer,
 
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_pdo);
+LUSTRE_RW_ATTR(pdo);
 
-static int ldiskfs_osd_auto_scrub_seq_show(struct seq_file *m, void *data)
+static ssize_t auto_scrub_show(struct kobject *kobj, struct attribute *attr,
+                              char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%lld\n", dev->od_auto_scrub_interval);
-       return 0;
+       return sprintf(buf, "%lld\n", dev->od_auto_scrub_interval);
 }
 
-static ssize_t
-ldiskfs_osd_auto_scrub_seq_write(struct file *file, const char __user *buffer,
-                                       size_t count, loff_t *off)
+static ssize_t auto_scrub_store(struct kobject *kobj, struct attribute *attr,
+                               const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        s64 val;
        int rc;
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtoll_from_user(buffer, count, 0, &val);
+       rc = kstrtoll(buffer, 0, &val);
        if (rc)
                return rc;
 
        dev->od_auto_scrub_interval = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_auto_scrub);
+LUSTRE_RW_ATTR(auto_scrub);
 
-static int ldiskfs_osd_full_scrub_ratio_seq_show(struct seq_file *m, void *data)
+static ssize_t full_scrub_ratio_show(struct kobject *kobj,
+                                    struct attribute *attr,
+                                    char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%llu\n", dev->od_full_scrub_ratio);
-       return 0;
+       return sprintf(buf, "%llu\n", dev->od_full_scrub_ratio);
 }
 
-static ssize_t
-ldiskfs_osd_full_scrub_ratio_seq_write(struct file *file,
-                                      const char __user *buffer,
-                                      size_t count, loff_t *off)
+static ssize_t full_scrub_ratio_store(struct kobject *kobj,
+                                     struct attribute *attr,
+                                     const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        s64 val;
        int rc;
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtoll_from_user(buffer, count, 0, &val);
-       if (rc != 0)
+       rc = kstrtoll(buffer, 0, &val);
+       if (rc)
                return rc;
 
        if (val < 0)
@@ -442,70 +450,46 @@ ldiskfs_osd_full_scrub_ratio_seq_write(struct file *file,
        dev->od_full_scrub_ratio = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_full_scrub_ratio);
+LUSTRE_RW_ATTR(full_scrub_ratio);
 
-static int ldiskfs_osd_full_scrub_threshold_rate_seq_show(struct seq_file *m,
-                                                         void *data)
+static ssize_t full_scrub_threshold_rate_show(struct kobject *kobj,
+                                             struct attribute *attr,
+                                             char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%llu (bad OI mappings/minute)\n",
-                  dev->od_full_scrub_threshold_rate);
-       return 0;
+       return sprintf(buf, "%llu (bad OI mappings/minute)\n",
+                      dev->od_full_scrub_threshold_rate);
 }
 
-static ssize_t
-ldiskfs_osd_full_scrub_threshold_rate_seq_write(struct file *file,
-                                               const char __user *buffer,
-                                               size_t count, loff_t *off)
+static ssize_t full_scrub_threshold_rate_store(struct kobject *kobj,
+                                              struct attribute *attr,
+                                              const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        u64 val;
        int rc;
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtoull_from_user(buffer, count, 0, &val);
+       rc = kstrtoull(buffer, 0, &val);
        if (rc != 0)
                return rc;
 
        dev->od_full_scrub_threshold_rate = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_full_scrub_threshold_rate);
-
-static int
-ldiskfs_osd_track_declares_assert_seq_show(struct seq_file *m, void *data)
-{
-       seq_printf(m, "%d\n", ldiskfs_track_declares_assert);
-       return 0;
-}
-
-static ssize_t
-ldiskfs_osd_track_declares_assert_seq_write(struct file *file,
-                                               const char __user *buffer,
-                                               size_t count, loff_t *off)
-{
-       bool track_declares_assert;
-       int rc;
-
-       rc = kstrtobool_from_user(buffer, count, &track_declares_assert);
-       if (rc)
-               return rc;
-
-       ldiskfs_track_declares_assert = track_declares_assert;
-
-       return count;
-}
-LPROC_SEQ_FOPS(ldiskfs_osd_track_declares_assert);
+LUSTRE_RW_ATTR(full_scrub_threshold_rate);
 
 static int ldiskfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data)
 {
@@ -518,7 +502,8 @@ static int ldiskfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data)
        osd_scrub_dump(m, dev);
        return 0;
 }
-LPROC_SEQ_FOPS_RO(ldiskfs_osd_oi_scrub);
+
+LDEBUGFS_SEQ_FOPS_RO(ldiskfs_osd_oi_scrub);
 
 static int ldiskfs_osd_readcache_seq_show(struct seq_file *m, void *data)
 {
@@ -556,40 +541,42 @@ ldiskfs_osd_readcache_seq_write(struct file *file, const char __user *buffer,
                                         OSD_MAX_CACHE_SIZE : val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_readcache);
+
+LDEBUGFS_SEQ_FOPS(ldiskfs_osd_readcache);
 
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 52, 0)
-static int ldiskfs_osd_index_in_idif_seq_show(struct seq_file *m, void *data)
+static ssize_t index_in_idif_show(struct kobject *kobj, struct attribute *attr,
+                                 char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%d\n", (int)(dev->od_index_in_idif));
-       return 0;
+       return sprintf(buf, "%d\n", (int)(dev->od_index_in_idif));
 }
 
-static ssize_t
-ldiskfs_osd_index_in_idif_seq_write(struct file *file,
-                                   const char __user *buffer,
-                                   size_t count, loff_t *off)
+static ssize_t index_in_idif_store(struct kobject *kobj,
+                                  struct attribute *attr,
+                                  const char *buffer, size_t count)
 {
-       struct lu_env env;
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        struct lu_target *tgt;
+       struct lu_env env;
        bool val;
        int rc;
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtobool_from_user(buffer, count, &val);
-       if (rc != 0)
+       rc = kstrtobool(buffer, &val);
+       if (rc)
                return rc;
 
        if (dev->od_index_in_idif) {
@@ -605,7 +592,7 @@ ldiskfs_osd_index_in_idif_seq_write(struct file *file,
                return count;
 
        rc = lu_env_init(&env, LCT_DT_THREAD);
-       if (rc != 0)
+       if (rc)
                return rc;
 
        tgt = dev->od_dt_dev.dd_lu_dev.ld_site->ls_tgt;
@@ -621,131 +608,106 @@ ldiskfs_osd_index_in_idif_seq_write(struct file *file,
        dev->od_index_in_idif = 1;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_index_in_idif);
+LUSTRE_RW_ATTR(index_in_idif);
 
 int osd_register_proc_index_in_idif(struct osd_device *osd)
 {
-       struct proc_dir_entry *proc;
-
-       proc = proc_create_data("index_in_idif", 0, osd->od_proc_entry,
-                               &ldiskfs_osd_index_in_idif_fops,
-                               &osd->od_dt_dev);
-       if (proc == NULL)
-               return -ENOMEM;
+       struct dt_device *dt = &osd->od_dt_dev;
 
-       return 0;
+       return sysfs_create_file(&dt->dd_kobj, &lustre_attr_index_in_idif.attr);
 }
 #endif
 
-static int ldiskfs_osd_index_backup_seq_show(struct seq_file *m, void *data)
+static ssize_t index_backup_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       seq_printf(m, "%d\n", dev->od_index_backup_policy);
-       return 0;
+       return sprintf(buf, "%d\n", dev->od_index_backup_policy);
 }
 
-static ssize_t ldiskfs_osd_index_backup_seq_write(struct file *file,
-                                                 const char __user *buffer,
-                                                 size_t count, loff_t *off)
+ssize_t index_backup_store(struct kobject *kobj, struct attribute *attr,
+                          const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                          dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        int val;
        int rc;
 
-       LASSERT(dev != NULL);
-       if (unlikely(dev->od_mnt == NULL))
+       LASSERT(dev);
+       if (unlikely(!dev->od_mnt))
                return -EINPROGRESS;
 
-       rc = kstrtoint_from_user(buffer, count, 0, &val);
+       rc = kstrtoint(buffer, 0, &val);
        if (rc)
                return rc;
 
        dev->od_index_backup_policy = val;
        return count;
 }
-LPROC_SEQ_FOPS(ldiskfs_osd_index_backup);
-
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_blksize);
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filesfree);
+LUSTRE_RW_ATTR(index_backup);
 
 struct lprocfs_vars lprocfs_osd_obd_vars[] = {
-       { .name =       "blocksize",
-         .fops =       &ldiskfs_dt_blksize_fops        },
-       { .name =       "kbytestotal",
-         .fops =       &ldiskfs_dt_kbytestotal_fops    },
-       { .name =       "kbytesfree",
-         .fops =       &ldiskfs_dt_kbytesfree_fops     },
-       { .name =       "kbytesavail",
-         .fops =       &ldiskfs_dt_kbytesavail_fops    },
-       { .name =       "filestotal",
-         .fops =       &ldiskfs_dt_filestotal_fops     },
-       { .name =       "filesfree",
-         .fops =       &ldiskfs_dt_filesfree_fops      },
-       { .name =       "fstype",
-         .fops =       &ldiskfs_osd_fstype_fops        },
-       { .name =       "mntdev",
-         .fops =       &ldiskfs_osd_mntdev_fops        },
-       { .name =       "force_sync",
-         .fops =       &ldiskfs_osd_force_sync_fops    },
-       { .name =       "pdo",
-         .fops =       &ldiskfs_osd_pdo_fops           },
-       { .name =       "auto_scrub",
-         .fops =       &ldiskfs_osd_auto_scrub_fops    },
-       { .name =       "full_scrub_ratio",
-         .fops =       &ldiskfs_osd_full_scrub_ratio_fops      },
-       { .name =       "full_scrub_threshold_rate",
-         .fops =       &ldiskfs_osd_full_scrub_threshold_rate_fops     },
        { .name =       "oi_scrub",
          .fops =       &ldiskfs_osd_oi_scrub_fops      },
-       { .name =       "read_cache_enable",
-         .fops =       &ldiskfs_osd_cache_fops         },
-       { .name =       "writethrough_cache_enable",
-         .fops =       &ldiskfs_osd_wcache_fops        },
        { .name =       "readcache_max_filesize",
          .fops =       &ldiskfs_osd_readcache_fops     },
-       { .name =       "index_backup",
-         .fops =       &ldiskfs_osd_index_backup_fops  },
        { NULL }
 };
 
-struct lprocfs_vars lprocfs_osd_module_vars[] = {
-       { .name =       "track_declares_assert",
-         .fops =       &ldiskfs_osd_track_declares_assert_fops         },
-       { NULL }
+static struct attribute *ldiskfs_attrs[] = {
+       &lustre_attr_read_cache_enable.attr,
+       &lustre_attr_writethrough_cache_enable.attr,
+       &lustre_attr_fstype.attr,
+       &lustre_attr_mntdev.attr,
+       &lustre_attr_force_sync.attr,
+       &lustre_attr_index_backup.attr,
+       &lustre_attr_auto_scrub.attr,
+       &lustre_attr_pdo.attr,
+       &lustre_attr_full_scrub_ratio.attr,
+       &lustre_attr_full_scrub_threshold_rate.attr,
+       NULL,
 };
 
-
 int osd_procfs_init(struct osd_device *osd, const char *name)
 {
        struct obd_type *type;
-       int             rc;
-       ENTRY;
+       int rc;
 
-       if (osd->od_proc_entry)
-               RETURN(0);
+       ENTRY;
 
        /* at the moment there is no linkage between lu_type
-        * and obd_type, so we lookup obd_type this way */
+        * and obd_type, so we lookup obd_type this way
+        */
        type = class_search_type(LUSTRE_OSD_LDISKFS_NAME);
 
-       LASSERT(name != NULL);
-       LASSERT(type != NULL);
+       LASSERT(name);
+       LASSERT(type);
+
+       LCONSOLE_INFO("osd-ldiskfs create tunables for %s\n", name);
+
+       osd->od_dt_dev.dd_ktype.default_attrs = ldiskfs_attrs;
+       rc = dt_tunables_init(&osd->od_dt_dev, type, name,
+                             lprocfs_osd_obd_vars);
+       if (rc) {
+               CERROR("%s: cannot setup sysfs / debugfs entry: %d\n",
+                      name, rc);
+               GOTO(out, rc);
+       }
+
+       if (osd->od_proc_entry)
+               RETURN(0);
 
        /* Find the type procroot and add the proc entry for this device */
        osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
-                                             lprocfs_osd_obd_vars,
-                                             &osd->od_dt_dev);
+                                             NULL, &osd->od_dt_dev);
        if (IS_ERR(osd->od_proc_entry)) {
                rc = PTR_ERR(osd->od_proc_entry);
                CERROR("Error %d setting up lprocfs for %s\n",
@@ -770,6 +732,7 @@ int osd_procfs_fini(struct osd_device *osd)
 
        if (osd->od_proc_entry)
                lprocfs_remove(&osd->od_proc_entry);
-       RETURN(0);
+
+       return dt_tunables_fini(&osd->od_dt_dev);
 }
 #endif
index c7d890b..1d82e98 100644 (file)
@@ -1388,10 +1388,11 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d,
 static int osd_process_config(const struct lu_env *env,
                              struct lu_device *d, struct lustre_cfg *cfg)
 {
-       struct osd_device       *o = osd_dev(d);
-       int                     rc;
-       ENTRY;
+       struct osd_device *o = osd_dev(d);
+       ssize_t count;
+       int rc;
 
+       ENTRY;
        switch(cfg->lcfg_command) {
        case LCFG_SETUP:
                rc = osd_mount(env, o, cfg);
@@ -1404,15 +1405,12 @@ static int osd_process_config(const struct lu_env *env,
                break;
        case LCFG_PARAM: {
                LASSERT(&o->od_dt_dev);
-               rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars,
-                                             cfg, &o->od_dt_dev);
-               if (rc > 0 || rc == -ENOSYS) {
-                       rc = class_process_proc_param(PARAM_OST,
-                                                     lprocfs_osd_obd_vars,
-                                                     cfg, &o->od_dt_dev);
-                       if (rc > 0)
-                               rc = 0;
-               }
+               count  = class_modify_config(cfg, PARAM_OSD,
+                                            &o->od_dt_dev.dd_kobj);
+               if (count < 0)
+                       count = class_modify_config(cfg, PARAM_OST,
+                                                   &o->od_dt_dev.dd_kobj);
+               rc = count > 0 ? 0 : count;
                break;
        }
        case LCFG_PRE_CLEANUP:
index 895eb13..b3360ad 100644 (file)
@@ -207,7 +207,7 @@ out:
        RETURN(result);
 }
 
-static int zfs_osd_auto_scrub_seq_show(struct seq_file *m, void *data)
+static int zfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data)
 {
        struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
 
@@ -215,116 +215,121 @@ static int zfs_osd_auto_scrub_seq_show(struct seq_file *m, void *data)
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       seq_printf(m, "%lld\n", dev->od_auto_scrub_interval);
+       scrub_dump(m, &dev->od_scrub);
        return 0;
 }
+LDEBUGFS_SEQ_FOPS_RO(zfs_osd_oi_scrub);
 
-static ssize_t
-zfs_osd_auto_scrub_seq_write(struct file *file, const char __user *buffer,
-                            size_t count, loff_t *off)
+static ssize_t auto_scrub_show(struct kobject *kobj, struct attribute *attr,
+                             char *buf)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
-       int rc;
-       __s64 val;
 
-       LASSERT(dev != NULL);
+       LASSERT(dev);
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       rc = kstrtoull_from_user(buffer, count, 0, &val);
-       if (rc)
-               return rc;
-
-       dev->od_auto_scrub_interval = val;
-       return count;
+       return sprintf(buf, "%lld\n", dev->od_auto_scrub_interval);
 }
-LPROC_SEQ_FOPS(zfs_osd_auto_scrub);
 
-static int zfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data)
+static ssize_t auto_scrub_store(struct kobject *kobj, struct attribute *attr,
+                               const char *buffer, size_t count)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
+       s64 val;
+       int rc;
 
-       LASSERT(dev != NULL);
+       LASSERT(dev);
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       scrub_dump(m, &dev->od_scrub);
-       return 0;
+       rc = kstrtoull(buffer, 0, &val);
+       if (rc)
+               return rc;
+
+       dev->od_auto_scrub_interval = val;
+       return count;
 }
-LPROC_SEQ_FOPS_RO(zfs_osd_oi_scrub);
+LUSTRE_RW_ATTR(auto_scrub);
 
-static int zfs_osd_fstype_seq_show(struct seq_file *m, void *data)
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+                         char *buf)
 {
-       seq_puts(m, "zfs\n");
-       return 0;
+       return sprintf(buf, "zfs\n");
 }
-LPROC_SEQ_FOPS_RO(zfs_osd_fstype);
+LUSTRE_RO_ATTR(fstype);
 
-static int zfs_osd_mntdev_seq_show(struct seq_file *m, void *data)
+static ssize_t mntdev_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
 {
-       struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *osd = osd_dt_dev(dt);
 
-       LASSERT(osd != NULL);
-       seq_printf(m, "%s\n", osd->od_mntdev);
-       return 0;
+       LASSERT(osd);
+
+       return sprintf(buf, "%s\n", osd->od_mntdev);
 }
-LPROC_SEQ_FOPS_RO(zfs_osd_mntdev);
+LUSTRE_RO_ATTR(mntdev);
 
-static ssize_t
-lprocfs_osd_force_sync_seq_write(struct file *file, const char __user *buffer,
-                               size_t count, loff_t *off)
+ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
+                        const char *buffer, size_t count)
 {
-       struct seq_file   *m = file->private_data;
-       struct dt_device  *dt = m->private;
-       struct lu_env      env;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct lu_env env;
        int rc;
 
        rc = lu_env_init(&env, LCT_LOCAL);
        if (rc)
                return rc;
+
        rc = dt_sync(&env, dt);
        lu_env_fini(&env);
 
        return rc == 0 ? count : rc;
 }
-LPROC_SEQ_FOPS_WR_ONLY(zfs, osd_force_sync);
+LUSTRE_WO_ATTR(force_sync);
 
-static int zfs_osd_index_backup_seq_show(struct seq_file *m, void *data)
+static ssize_t index_backup_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
 {
-       struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private);
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
+       struct osd_device *dev = osd_dt_dev(dt);
 
-       LASSERT(dev != NULL);
+       LASSERT(dev);
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       seq_printf(m, "%d\n", dev->od_index_backup_policy);
-       return 0;
+       return sprintf(buf, "%d\n", dev->od_index_backup_policy);
 }
 
-static ssize_t zfs_osd_index_backup_seq_write(struct file *file,
-                                             const char __user *buffer,
-                                             size_t count, loff_t *off)
+ssize_t index_backup_store(struct kobject *kobj, struct attribute *attr,
+                          const char *buffer, size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct dt_device *dt = m->private;
+       struct dt_device *dt = container_of(kobj, struct dt_device,
+                                           dd_kobj);
        struct osd_device *dev = osd_dt_dev(dt);
        int val;
        int rc;
 
-       LASSERT(dev != NULL);
+       LASSERT(dev);
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       rc = kstrtoint_from_user(buffer, count, 0, &val);
+       rc = kstrtoint(buffer, 0, &val);
        if (rc)
                return rc;
 
        dev->od_index_backup_policy = val;
        return count;
 }
-LPROC_SEQ_FOPS(zfs_osd_index_backup);
+LUSTRE_RW_ATTR(index_backup);
 
 static int zfs_osd_readcache_seq_show(struct seq_file *m, void *data)
 {
@@ -362,64 +367,54 @@ zfs_osd_readcache_seq_write(struct file *file, const char __user *buffer,
                                         OSD_MAX_CACHE_SIZE : val;
        return count;
 }
-LPROC_SEQ_FOPS(zfs_osd_readcache);
-
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_blksize);
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filesfree);
+LDEBUGFS_SEQ_FOPS(zfs_osd_readcache);
+
+static struct attribute *zfs_attrs[] = {
+       &lustre_attr_fstype.attr,
+       &lustre_attr_mntdev.attr,
+       &lustre_attr_force_sync.attr,
+       &lustre_attr_index_backup.attr,
+       &lustre_attr_auto_scrub.attr,
+       NULL,
+};
 
 struct lprocfs_vars lprocfs_osd_obd_vars[] = {
-       { .name =       "blocksize",
-         .fops =       &zfs_dt_blksize_fops            },
-       { .name =       "kbytestotal",
-         .fops =       &zfs_dt_kbytestotal_fops        },
-       { .name =       "kbytesfree",
-         .fops =       &zfs_dt_kbytesfree_fops         },
-       { .name =       "kbytesavail",
-         .fops =       &zfs_dt_kbytesavail_fops        },
-       { .name =       "filestotal",
-         .fops =       &zfs_dt_filestotal_fops         },
-       { .name =       "filesfree",
-         .fops =       &zfs_dt_filesfree_fops          },
-       { .name =       "auto_scrub",
-         .fops =       &zfs_osd_auto_scrub_fops        },
        { .name =       "oi_scrub",
          .fops =       &zfs_osd_oi_scrub_fops          },
-       { .name =       "fstype",
-         .fops =       &zfs_osd_fstype_fops            },
-       { .name =       "mntdev",
-         .fops =       &zfs_osd_mntdev_fops            },
-       { .name =       "force_sync",
-         .fops =       &zfs_osd_force_sync_fops        },
-       { .name =       "index_backup",
-         .fops =       &zfs_osd_index_backup_fops      },
-       { .name =       "readcache_max_filesize",
-         .fops =       &zfs_osd_readcache_fops },
+       { .name =       "readcache_max_filesize",
+         .fops =       &zfs_osd_readcache_fops         },
        { 0 }
 };
 
 int osd_procfs_init(struct osd_device *osd, const char *name)
 {
        struct obd_type *type;
-       int              rc;
-       ENTRY;
+       int rc;
 
-       if (osd->od_proc_entry)
-               RETURN(0);
+       ENTRY;
 
        /* at the moment there is no linkage between lu_type
-        * and obd_type, so we lookup obd_type this way */
+        * and obd_type, so we lookup obd_type this way
+        */
        type = class_search_type(LUSTRE_OSD_ZFS_NAME);
 
-       LASSERT(name != NULL);
-       LASSERT(type != NULL);
+       LASSERT(type);
+       LASSERT(name);
+
+       osd->od_dt_dev.dd_ktype.default_attrs = zfs_attrs;
+       rc = dt_tunables_init(&osd->od_dt_dev, type, name,
+                             lprocfs_osd_obd_vars);
+       if (rc) {
+               CERROR("%s: cannot setup sysfs / debugfs entry: %d\n",
+                      name, rc);
+               GOTO(out, rc);
+       }
+
+       if (osd->od_proc_entry)
+               RETURN(0);
 
        osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
-                                             lprocfs_osd_obd_vars,
-                                             &osd->od_dt_dev);
+                                             NULL, &osd->od_dt_dev);
        if (IS_ERR(osd->od_proc_entry)) {
                rc = PTR_ERR(osd->od_proc_entry);
                CERROR("Error %d setting up lprocfs for %s\n", rc, name);
@@ -448,7 +443,7 @@ int osd_procfs_fini(struct osd_device *osd)
                osd->od_proc_entry = NULL;
        }
 
-       RETURN(0);
+       return dt_tunables_fini(&osd->od_dt_dev);
 }
 
 #endif