Whamcloud - gitweb
Need to include mount_utils.h in the _SOURCES for the tools that use it.
[fs/lustre-release.git] / lustre / lov / lproc_lov.c
index ed79fc4..d95b1f0 100644 (file)
@@ -25,9 +25,7 @@
 #define DEBUG_SUBSYSTEM S_CLASS
 
 #include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
 #include <asm/statfs.h>
-#endif
 #include <lprocfs_status.h>
 #include <obd_class.h>
 #include <linux/seq_file.h>
@@ -60,8 +58,8 @@ static int lov_wr_stripesize(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
+        lov_fix_desc_stripe_size(&val);
         desc->ld_default_stripe_size = val;
-        lov_fix_desc(desc);
         return count;
 }
 
@@ -92,7 +90,6 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer,
                 return rc;
 
         desc->ld_default_stripe_offset = val;
-        lov_fix_desc(desc);
         return count;
 }
 
@@ -121,8 +118,8 @@ static int lov_wr_stripetype(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
+        lov_fix_desc_pattern(&val);
         desc->ld_pattern = val;
-        lov_fix_desc(desc);
         return count;
 }
 
@@ -135,7 +132,8 @@ static int lov_rd_stripecount(char *page, char **start, off_t off, int count,
         LASSERT(dev != NULL);
         desc = &dev->u.lov.desc;
         *eof = 1;
-        return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
+        return snprintf(page, count, "%ld\n",
+                        (long)(desc->ld_default_stripe_count + 1) - 1);
 }
 
 static int lov_wr_stripecount(struct file *file, const char *buffer,
@@ -151,8 +149,8 @@ static int lov_wr_stripecount(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
+        lov_fix_desc_stripe_count(&val);
         desc->ld_default_stripe_count = val;
-        lov_fix_desc(desc);
         return count;
 }
 
@@ -264,8 +262,12 @@ static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
         struct obd_device *dev = p->private;
         struct lov_obd *lov = &dev->u.lov;
 
-        return (*pos >= lov->desc.ld_tgt_count) ? NULL : lov->lov_tgts[*pos];
-
+        while (*pos < lov->desc.ld_tgt_count) {
+                if (lov->lov_tgts[*pos])
+                        return lov->lov_tgts[*pos];
+                ++*pos;
+        }
+        return NULL;
 }
 
 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
@@ -277,8 +279,7 @@ static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
         struct obd_device *dev = p->private;
         struct lov_obd *lov = &dev->u.lov;
 
-        while (*pos < lov->desc.ld_tgt_count) {
-                ++*pos;
+        while (++*pos < lov->desc.ld_tgt_count) {
                 if (lov->lov_tgts[*pos])
                         return lov->lov_tgts[*pos];
         }
@@ -318,7 +319,7 @@ static int lov_target_seq_open(struct inode *inode, struct file *file)
         return 0;
 }
 
-struct lprocfs_vars lprocfs_obd_vars[] = {
+struct lprocfs_vars lprocfs_lov_obd_vars[] = {
         { "uuid",         lprocfs_rd_uuid,        0, 0 },
         { "stripesize",   lov_rd_stripesize,      lov_wr_stripesize, 0 },
         { "stripeoffset", lov_rd_stripeoffset,    lov_wr_stripeoffset, 0 },
@@ -339,11 +340,17 @@ struct lprocfs_vars lprocfs_obd_vars[] = {
         { 0 }
 };
 
-static struct lprocfs_vars lprocfs_module_vars[] = {
+static struct lprocfs_vars lprocfs_lov_module_vars[] = {
         { "num_refs",     lprocfs_rd_numrefs,     0, 0 },
         { 0 }
 };
 
+void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
+{
+    lvars->module_vars  = lprocfs_lov_module_vars;
+    lvars->obd_vars     = lprocfs_lov_obd_vars;
+}
+
 struct file_operations lov_proc_target_fops = {
         .owner   = THIS_MODULE,
         .open    = lov_target_seq_open,
@@ -351,6 +358,5 @@ struct file_operations lov_proc_target_fops = {
         .llseek  = seq_lseek,
         .release = lprocfs_seq_release,
 };
-
-LPROCFS_INIT_VARS(lov, lprocfs_module_vars, lprocfs_obd_vars)
 #endif /* LPROCFS */
+