Whamcloud - gitweb
LU-6142 lustre: don't take spinlock to read a 'long'.
[fs/lustre-release.git] / lustre / osc / lproc_osc.c
index 498e03f..a497228 100644 (file)
@@ -85,12 +85,8 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
-       ssize_t len;
 
-       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;
+       return  scnprintf(buf, PAGE_SIZE, "%u\n", cli->cl_max_rpcs_in_flight);
 }
 
 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
@@ -142,13 +138,9 @@ static ssize_t max_dirty_mb_show(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
-       unsigned long val;
 
-       spin_lock(&cli->cl_loi_list_lock);
-       val = PAGES_TO_MiB(cli->cl_dirty_max_pages);
-       spin_unlock(&cli->cl_loi_list_lock);
-
-       return sprintf(buf, "%lu\n", val);
+       return scnprintf(buf, PAGE_SIZE, "%lu\n",
+                        PAGES_TO_MiB(cli->cl_dirty_max_pages));
 }
 
 static ssize_t max_dirty_mb_store(struct kobject *kobj,
@@ -254,13 +246,9 @@ static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
-       ssize_t len;
-
-       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;
+       return scnprintf(buf, PAGE_SIZE, "%lu\n",
+                        cli->cl_dirty_pages << PAGE_SHIFT);
 }
 LUSTRE_RO_ATTR(cur_dirty_bytes);
 
@@ -269,9 +257,7 @@ static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
        struct obd_device *obd = m->private;
        struct client_obd *cli = &obd->u.cli;
 
-       spin_lock(&cli->cl_loi_list_lock);
        seq_printf(m, "%lu\n", cli->cl_avail_grant);
-       spin_unlock(&cli->cl_loi_list_lock);
        return 0;
 }
 
@@ -302,13 +288,8 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
                return rc;
 
        /* this is only for shrinking grant */
-       spin_lock(&cli->cl_loi_list_lock);
-       if (val >= cli->cl_avail_grant) {
-               spin_unlock(&cli->cl_loi_list_lock);
+       if (val >= cli->cl_avail_grant)
                return 0;
-       }
-
-       spin_unlock(&cli->cl_loi_list_lock);
 
        with_imp_locked(obd, imp, rc)
                if (imp->imp_state == LUSTRE_IMP_FULL)
@@ -325,12 +306,8 @@ static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
        struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
-       ssize_t len;
 
-       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;
+       return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_lost_grant);
 }
 LUSTRE_RO_ATTR(cur_lost_grant_bytes);