Whamcloud - gitweb
b=23120 eliminate defunct changelog_send_thread processes
[fs/lustre-release.git] / lustre / lov / lproc_lov.c
index 7526bd8..44a35cd 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -62,7 +62,7 @@ static int lov_wr_stripesize(struct file *file, const char *buffer,
         struct lov_desc *desc;
         __u64 val;
         int rc;
-        
+
         LASSERT(dev != NULL);
         desc = &dev->u.lov.desc;
         rc = lprocfs_write_u64_helper(buffer, count, &val);
@@ -93,7 +93,7 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer,
         struct lov_desc *desc;
         __u64 val;
         int rc;
-        
+
         LASSERT(dev != NULL);
         desc = &dev->u.lov.desc;
         rc = lprocfs_write_u64_helper(buffer, count, &val);
@@ -122,7 +122,7 @@ static int lov_wr_stripetype(struct file *file, const char *buffer,
         struct obd_device *dev = (struct obd_device *)data;
         struct lov_desc *desc;
         int val, rc;
-        
+
         LASSERT(dev != NULL);
         desc = &dev->u.lov.desc;
         rc = lprocfs_write_helper(buffer, count, &val);
@@ -153,7 +153,7 @@ static int lov_wr_stripecount(struct file *file, const char *buffer,
         struct obd_device *dev = (struct obd_device *)data;
         struct lov_desc *desc;
         int val, rc;
-        
+
         LASSERT(dev != NULL);
         desc = &dev->u.lov.desc;
         rc = lprocfs_write_helper(buffer, count, &val);
@@ -202,7 +202,7 @@ static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count,
         return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
 }
 
-/* free priority (0-255): how badly user wants to choose empty osts */ 
+/* free priority (0-256): how badly user wants to choose empty osts */
 static int lov_rd_qos_priofree(char *page, char **start, off_t off, int count,
                                int *eof, void *data)
 {
@@ -212,8 +212,9 @@ static int lov_rd_qos_priofree(char *page, char **start, off_t off, int count,
         LASSERT(dev != NULL);
         lov = &dev->u.lov;
         *eof = 1;
-        return snprintf(page, count, "%d%%\n", 
-                        (lov->lov_qos.lq_prio_free * 100) >> 8);
+        /* Round the conversion; see below */
+        return snprintf(page, count, "%d%%\n",
+                        (lov->lov_qos.lq_prio_free * 100 + 128) >> 8);
 }
 
 static int lov_wr_qos_priofree(struct file *file, const char *buffer,
@@ -229,9 +230,12 @@ static int lov_wr_qos_priofree(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
-        if (val > 100)
+        if (val > 100 || val < 0)
                 return -EINVAL;
-        lov->lov_qos.lq_prio_free = (val << 8) / 100;
+        /* We're converting a 0-100% range to 0-256.
+         * Add some rounding so that when we convert back to %
+         * for printout below, we end up with the original value */
+        lov->lov_qos.lq_prio_free = ((val << 8) + 50) / 100;
         lov->lov_qos.lq_dirty = 1;
         lov->lov_qos.lq_reset = 1;
         return count;
@@ -247,7 +251,7 @@ static int lov_rd_qos_thresholdrr(char *page, char **start, off_t off,
         lov = &dev->u.lov;
         *eof = 1;
         return snprintf(page, count, "%d%%\n",
-                        (lov->lov_qos.lq_threshold_rr * 100) >> 8);
+                        ((lov->lov_qos.lq_threshold_rr * 100) + 128) >> 8);
 }
 
 static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer,
@@ -266,7 +270,7 @@ static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer,
         if (val > 100 || val < 0)
                 return -EINVAL;
 
-        lov->lov_qos.lq_threshold_rr = (val << 8) / 100;
+        lov->lov_qos.lq_threshold_rr = ((val << 8) + 50) / 100;
         lov->lov_qos.lq_dirty = 1;
         return count;
 }
@@ -334,8 +338,8 @@ static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
 static int lov_tgt_seq_show(struct seq_file *p, void *v)
 {
         struct lov_tgt_desc *tgt = v;
-        return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index, 
-                          obd_uuid2str(&tgt->ltd_uuid), 
+        return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
+                          obd_uuid2str(&tgt->ltd_uuid),
                           tgt->ltd_active ? "" : "IN");
 }