Whamcloud - gitweb
LU-8066 llite: move /proc/fs/lustre/llite/checksum_pages to sysfs
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index 29d7f78..66d0f11 100644 (file)
@@ -242,26 +242,22 @@ static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RO_ATTR(client_type);
 
-static int ll_fstype_seq_show(struct seq_file *m, void *v)
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+                          char *buf)
 {
-       struct super_block *sb = m->private;
-       struct ll_sb_info *sbi = ll_s2sbi(sb);
-
-       LASSERT(sb != NULL);
-       seq_printf(m, "%s\n", sbi->ll_mnt.mnt->mnt_sb->s_type->name);
-       return 0;
+       return sprintf(buf, "lustre\n");
 }
-LPROC_SEQ_FOPS_RO(ll_fstype);
+LUSTRE_RO_ATTR(fstype);
 
-static int ll_sb_uuid_seq_show(struct seq_file *m, void *v)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+                        char *buf)
 {
-       struct super_block *sb = m->private;
+       struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+                                             ll_kset.kobj);
 
-       LASSERT(sb != NULL);
-       seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
-       return 0;
+       return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid);
 }
-LPROC_SEQ_FOPS_RO(ll_sb_uuid);
+LUSTRE_RO_ATTR(uuid);
 
 static int ll_xattr_cache_seq_show(struct seq_file *m, void *v)
 {
@@ -584,21 +580,22 @@ out:
 }
 LPROC_SEQ_FOPS(ll_max_cached_mb);
 
-static int ll_checksum_seq_show(struct seq_file *m, void *v)
+static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr,
+                                  char *buf)
 {
-       struct super_block *sb = m->private;
-       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+                                             ll_kset.kobj);
 
-       seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
-       return 0;
+       return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
 }
 
-static ssize_t ll_checksum_seq_write(struct file *file,
-                                    const char __user *buffer,
-                                    size_t count, loff_t *off)
+static ssize_t checksum_pages_store(struct kobject *kobj,
+                                   struct attribute *attr,
+                                   const char *buffer,
+                                   size_t count)
 {
-       struct seq_file *m = file->private_data;
-       struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+       struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+                                             ll_kset.kobj);
        bool val;
        int tmp;
        int rc;
@@ -607,7 +604,7 @@ static ssize_t ll_checksum_seq_write(struct file *file,
                /* Not set up yet */
                return -EAGAIN;
 
-       rc = kstrtobool_from_user(buffer, count, &val);
+       rc = kstrtobool(buffer, &val);
        if (rc)
                return rc;
        if (val)
@@ -623,7 +620,7 @@ static ssize_t ll_checksum_seq_write(struct file *file,
 
        return count;
 }
-LPROC_SEQ_FOPS(ll_checksum);
+LUSTRE_RW_ATTR(checksum_pages);
 
 static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type)
 {
@@ -1175,10 +1172,6 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file,
 LPROC_SEQ_FOPS(ll_nosquash_nids);
 
 struct lprocfs_vars lprocfs_llite_obd_vars[] = {
-       { .name =       "uuid",
-         .fops =       &ll_sb_uuid_fops                        },
-       { .name =       "fstype",
-         .fops =       &ll_fstype_fops                         },
        { .name =       "site",
          .fops =       &ll_site_stats_fops                     },
        { .name =       "stat_blocksize",
@@ -1191,8 +1184,6 @@ struct lprocfs_vars lprocfs_llite_obd_vars[] = {
          .fops =       &ll_max_read_ahead_whole_mb_fops        },
        { .name =       "max_cached_mb",
          .fops =       &ll_max_cached_mb_fops                  },
-       { .name =       "checksum_pages",
-         .fops =       &ll_checksum_fops                       },
        { .name =       "stats_track_pid",
          .fops =       &ll_track_pid_fops                      },
        { .name =       "stats_track_ppid",
@@ -1240,6 +1231,9 @@ static struct attribute *llite_attrs[] = {
        &lustre_attr_filestotal.attr,
        &lustre_attr_filesfree.attr,
        &lustre_attr_client_type.attr,
+       &lustre_attr_fstype.attr,
+       &lustre_attr_uuid.attr,
+       &lustre_attr_checksum_pages.attr,
        &lustre_attr_statahead_running_max.attr,
        NULL,
 };