Whamcloud - gitweb
LU-6142 lustre: don't take spinlock to read a 'long'.
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index 3bb3de6..f6a7699 100644 (file)
@@ -324,13 +324,9 @@ static ssize_t max_read_ahead_mb_show(struct kobject *kobj,
 {
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
-       unsigned long ra_max_mb;
 
-       spin_lock(&sbi->ll_lock);
-       ra_max_mb = PAGES_TO_MiB(sbi->ll_ra_info.ra_max_pages);
-       spin_unlock(&sbi->ll_lock);
-
-       return snprintf(buf, PAGE_SIZE, "%lu\n", ra_max_mb);
+       return scnprintf(buf, PAGE_SIZE, "%lu\n",
+                       PAGES_TO_MiB(sbi->ll_ra_info.ra_max_pages));
 }
 
 static ssize_t max_read_ahead_mb_store(struct kobject *kobj,
@@ -371,13 +367,9 @@ static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj,
 {
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
-       unsigned long ra_max_file_mb;
-
-       spin_lock(&sbi->ll_lock);
-       ra_max_file_mb = PAGES_TO_MiB(sbi->ll_ra_info.ra_max_pages_per_file);
-       spin_unlock(&sbi->ll_lock);
 
-       return snprintf(buf, PAGE_SIZE, "%lu\n", ra_max_file_mb);
+       return scnprintf(buf, PAGE_SIZE, "%lu\n",
+                        PAGES_TO_MiB(sbi->ll_ra_info.ra_max_pages_per_file));
 }
 
 static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj,
@@ -415,13 +407,9 @@ static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj,
 {
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
-       unsigned long ra_max_whole_mb;
-
-       spin_lock(&sbi->ll_lock);
-       ra_max_whole_mb = PAGES_TO_MiB(sbi->ll_ra_info.ra_max_read_ahead_whole_pages);
-       spin_unlock(&sbi->ll_lock);
 
-       return snprintf(buf, PAGE_SIZE, "%lu\n", ra_max_whole_mb);
+       return scnprintf(buf, PAGE_SIZE, "%lu\n",
+                        PAGES_TO_MiB(sbi->ll_ra_info.ra_max_read_ahead_whole_pages));
 }
 
 static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj,
@@ -1463,9 +1451,9 @@ out_free_kernbuff:
        OBD_FREE(kernbuf, count + 1);
        return rc ? rc : count;
 }
-LPROC_SEQ_FOPS(ll_pcc);
+LDEBUGFS_SEQ_FOPS(ll_pcc);
 
-struct lprocfs_vars lprocfs_llite_obd_vars[] = {
+struct ldebugfs_vars lprocfs_llite_obd_vars[] = {
        { .name =       "site",
          .fops =       &ll_site_stats_fops                     },
        { .name =       "max_cached_mb",
@@ -1537,18 +1525,14 @@ static struct kobj_type sbi_ktype = {
        .release        = sbi_kobj_release,
 };
 
-#define LPROCFS_TYPE_LATENCY \
-       (LPROCFS_TYPE_USEC | LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV)
 static const struct llite_file_opcode {
        __u32           opcode;
        __u32           type;
        const char      *opname;
 } llite_opcode_table[LPROC_LL_FILE_OPCODES] = {
        /* file operation */
-       { LPROC_LL_READ_BYTES,  LPROCFS_CNTR_AVGMINMAX | LPROCFS_TYPE_BYTES,
-               "read_bytes" },
-       { LPROC_LL_WRITE_BYTES, LPROCFS_CNTR_AVGMINMAX | LPROCFS_TYPE_BYTES,
-               "write_bytes" },
+       { LPROC_LL_READ_BYTES,  LPROCFS_TYPE_BYTES_FULL, "read_bytes" },
+       { LPROC_LL_WRITE_BYTES, LPROCFS_TYPE_BYTES_FULL, "write_bytes" },
        { LPROC_LL_READ,        LPROCFS_TYPE_LATENCY,   "read" },
        { LPROC_LL_WRITE,       LPROCFS_TYPE_LATENCY,   "write" },
        { LPROC_LL_IOCTL,       LPROCFS_TYPE_REQS,      "ioctl" },
@@ -1565,6 +1549,7 @@ static const struct llite_file_opcode {
        { LPROC_LL_TRUNC,       LPROCFS_TYPE_LATENCY,   "truncate" },
        { LPROC_LL_FLOCK,       LPROCFS_TYPE_LATENCY,   "flock" },
        { LPROC_LL_GETATTR,     LPROCFS_TYPE_LATENCY,   "getattr" },
+       { LPROC_LL_FALLOCATE,   LPROCFS_TYPE_LATENCY, "fallocate"},
        /* dir inode operation */
        { LPROC_LL_CREATE,      LPROCFS_TYPE_LATENCY,   "create" },
        { LPROC_LL_LINK,        LPROCFS_TYPE_LATENCY,   "link" },
@@ -1659,24 +1644,21 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name)
        /* do counter init */
        for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
                u32 type = llite_opcode_table[id].type;
-               void *ptr = NULL;
+               void *ptr = "unknown";
 
                if (type & LPROCFS_TYPE_REQS)
                        ptr = "reqs";
                else if (type & LPROCFS_TYPE_BYTES)
                        ptr = "bytes";
-               else if (type & LPROCFS_TYPE_PAGES)
-                       ptr = "pages";
                else if (type & LPROCFS_TYPE_USEC)
                        ptr = "usec";
                lprocfs_counter_init(sbi->ll_stats,
-                                    llite_opcode_table[id].opcode,
-                                    (type & LPROCFS_CNTR_AVGMINMAX),
+                                    llite_opcode_table[id].opcode, type,
                                     llite_opcode_table[id].opname, ptr);
        }
 
        debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry,
-                           sbi->ll_stats, &lprocfs_stats_seq_fops);
+                           sbi->ll_stats, &ldebugfs_stats_seq_fops);
 
        sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
                                               LPROCFS_STATS_FLAG_NONE);
@@ -1688,7 +1670,7 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name)
                                     ra_stat_string[id], "pages");
 
        debugfs_create_file("read_ahead_stats", 0644, sbi->ll_debugfs_entry,
-                           sbi->ll_ra_stats, &lprocfs_stats_seq_fops);
+                           sbi->ll_ra_stats, &ldebugfs_stats_seq_fops);
 
 out_ll_kset:
        /* Yes we also register sysfs mount kset here as well */
@@ -1759,26 +1741,26 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
                 write_tot += pp_info->pp_w_hist.oh_buckets[i];
         }
 
-        for(i = 0; i < LL_HIST_MAX; i++) {
-                r = pp_info->pp_r_hist.oh_buckets[i];
-                w = pp_info->pp_w_hist.oh_buckets[i];
-                read_cum += r;
-                write_cum += w;
-               end = BIT(i + LL_HIST_START - units);
+       for(i = 0; i < LL_HIST_MAX; i++) {
+               r = pp_info->pp_r_hist.oh_buckets[i];
+               w = pp_info->pp_w_hist.oh_buckets[i];
+               read_cum += r;
+               write_cum += w;
+               end = 1 << (i + LL_HIST_START - units);
                seq_printf(seq, "%4lu%c - %4lu%c%c: %14lu %4u %4u  | "
                           "%14lu %4u %4u\n", start, *unitp, end, *unitp,
-                           (i == LL_HIST_MAX - 1) ? '+' : ' ',
-                           r, pct(r, read_tot), pct(read_cum, read_tot),
-                           w, pct(w, write_tot), pct(write_cum, write_tot));
-                start = end;
-               if (start == BIT(10)) {
-                        start = 1;
-                        units += 10;
-                        unitp++;
-                }
-                if (read_cum == read_tot && write_cum == write_tot)
-                        break;
-        }
+                          (i == LL_HIST_MAX - 1) ? '+' : ' ',
+                          r, pct(r, read_tot), pct(read_cum, read_tot),
+                          w, pct(w, write_tot), pct(write_cum, write_tot));
+               start = end;
+               if (start == (1 << 10)) {
+                       start = 1;
+                       units += 10;
+                       unitp++;
+               }
+               if (read_cum == read_tot && write_cum == write_tot)
+                       break;
+       }
 }
 
 static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
@@ -1939,7 +1921,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
                 lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_w_hist);
         }
 
-       for (i = 0; (count >= BIT(LL_HIST_START + i)) &&
+       for (i = 0; (count >= 1 << (LL_HIST_START + i)) &&
             (i < (LL_HIST_MAX - 1)); i++);
        if (rw == 0) {
                io_extents->pp_extents[cur].pp_r_hist.oh_buckets[i]++;