Whamcloud - gitweb
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 4289266..414d918 100644 (file)
@@ -143,16 +143,14 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj,
 {
        struct obd_device *dev = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
-        struct client_obd *cli = &dev->u.cli;
-        long val;
-        int mult;
+       struct client_obd *cli = &dev->u.cli;
+       unsigned long val;
 
        spin_lock(&cli->cl_loi_list_lock);
-       val = cli->cl_dirty_max_pages;
+       val = PAGES_TO_MiB(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);
+       return sprintf(buf, "%lu\n", val);
 }
 
 static ssize_t max_dirty_mb_store(struct kobject *kobj,
@@ -163,18 +161,17 @@ 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;
-       unsigned long pages_number;
+       unsigned long pages_number, max_dirty_mb;
        int rc;
 
-       rc = kstrtoul(buffer, 10, &pages_number);
+       rc = kstrtoul(buffer, 10, &max_dirty_mb);
        if (rc)
                return rc;
 
-       pages_number *= 1 << (20 - PAGE_SHIFT); /* MB -> pages */
+       pages_number = MiB_TO_PAGES(max_dirty_mb);
 
-       if (pages_number <= 0 ||
-           pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_SHIFT) ||
-           pages_number > totalram_pages / 4) /* 1/4 of RAM */
+       if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
+           pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
                return -ERANGE;
 
        spin_lock(&cli->cl_loi_list_lock);
@@ -189,7 +186,7 @@ LUSTRE_RW_ATTR(max_dirty_mb);
 LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
 LUSTRE_RO_ATTR(conn_uuid);
 
-LUSTRE_WO_ATTR(ping);
+LUSTRE_RW_ATTR(ping);
 
 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
 {
@@ -362,6 +359,8 @@ static ssize_t grant_shrink_interval_store(struct kobject *kobj,
                return -ERANGE;
 
        obd->u.cli.cl_grant_shrink_interval = val;
+       osc_update_next_shrink(&obd->u.cli);
+       osc_schedule_grant_work();
 
        return count;
 }
@@ -426,28 +425,34 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
        int i;
        DECLARE_CKSUM_NAME;
        char kernbuf[10];
+       int rc = -EINVAL;
 
-        if (obd == NULL)
-                return 0;
+       if (obd == NULL)
+               return 0;
 
-        if (count > sizeof(kernbuf) - 1)
-                return -EINVAL;
+       if (count > sizeof(kernbuf) - 1)
+               return -EINVAL;
        if (copy_from_user(kernbuf, buffer, count))
-                return -EFAULT;
-        if (count > 0 && kernbuf[count - 1] == '\n')
-                kernbuf[count - 1] = '\0';
-        else
-                kernbuf[count] = '\0';
-
-        for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
-                if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
-                        continue;
-                if (!strcmp(kernbuf, cksum_name[i])) {
-                       obd->u.cli.cl_cksum_type = 1 << i;
-                       return count;
-                }
-        }
-        return -EINVAL;
+               return -EFAULT;
+
+       if (count > 0 && kernbuf[count - 1] == '\n')
+               kernbuf[count - 1] = '\0';
+       else
+               kernbuf[count] = '\0';
+
+       for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
+               if (strcmp(kernbuf, cksum_name[i]) == 0) {
+                       obd->u.cli.cl_preferred_cksum_type = BIT(i);
+                       if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
+                               obd->u.cli.cl_cksum_type = BIT(i);
+                               rc = count;
+                       } else {
+                               rc = -ENOTSUPP;
+                       }
+                       break;
+               }
+       }
+       return rc;
 }
 LPROC_SEQ_FOPS(osc_checksum_type);
 
@@ -969,31 +974,9 @@ static struct attribute *osc_attrs[] = {
 
 int osc_tunables_init(struct obd_device *obd)
 {
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
-       struct obd_type *type;
-#endif
        int rc;
 
        obd->obd_vars = lprocfs_osc_obd_vars;
-#if defined(CONFIG_PROC_FS) && defined(HAVE_SERVER_SUPPORT)
-       /* If this is true then both client (osc) and server (osp) are on the
-        * same node. The osp layer if loaded first will register the osc proc
-        * directory. In that case this obd_device will be attached its proc
-        * tree to type->typ_procsym instead of obd->obd_type->typ_procroot.
-        */
-       type = class_search_type(LUSTRE_OSP_NAME);
-       if (type && type->typ_procsym) {
-               obd->obd_proc_entry = lprocfs_register(obd->obd_name,
-                                                      type->typ_procsym,
-                                                      obd->obd_vars, obd);
-               if (IS_ERR(obd->obd_proc_entry)) {
-                       rc = PTR_ERR(obd->obd_proc_entry);
-                       CERROR("error %d setting up lprocfs for %s\n", rc,
-                              obd->obd_name);
-                       obd->obd_proc_entry = NULL;
-               }
-       }
-#endif
        obd->obd_ktype.default_attrs = osc_attrs;
        rc = lprocfs_obd_setup(obd, false);
        if (rc)