Whamcloud - gitweb
LU-9166 mdt: Add trailing newlines to proc files
[fs/lustre-release.git] / lustre / mdd / mdd_lproc.c
index 1990ae1..92982eb 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -94,6 +90,7 @@ static int mdd_changelog_mask_seq_show(struct seq_file *m, void *data)
                        seq_printf(m, "%s ", changelog_type2str(i));
                i++;
        }
+       seq_putc(m, '\n');
        return 0;
 }
 
@@ -107,9 +104,9 @@ mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer,
        int rc;
        ENTRY;
 
-       if (count >= PAGE_CACHE_SIZE)
+       if (count >= PAGE_SIZE)
                RETURN(-EINVAL);
-       OBD_ALLOC(kernbuf, PAGE_CACHE_SIZE);
+       OBD_ALLOC(kernbuf, PAGE_SIZE);
        if (kernbuf == NULL)
                RETURN(-ENOMEM);
        if (copy_from_user(kernbuf, buffer, count))
@@ -121,7 +118,7 @@ mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer,
        if (rc == 0)
                rc = count;
 out:
-       OBD_FREE(kernbuf, PAGE_CACHE_SIZE);
+       OBD_FREE(kernbuf, PAGE_SIZE);
        return rc;
 }
 LPROC_SEQ_FOPS(mdd_changelog_mask);
@@ -137,7 +134,7 @@ static int lprocfs_changelog_users_cb(const struct lu_env *env,
 
        rec = (struct llog_changelog_user_rec *)hdr;
 
-       seq_printf(m, CHANGELOG_USER_PREFIX"%-3d "LPU64"\n",
+       seq_printf(m, CHANGELOG_USER_PREFIX"%-3d %llu\n",
                   rec->cur_id, rec->cur_endrec);
        return 0;
 }
@@ -166,7 +163,7 @@ static int mdd_changelog_users_seq_show(struct seq_file *m, void *data)
        cur = mdd->mdd_cl.mc_index;
        spin_unlock(&mdd->mdd_cl.mc_lock);
 
-       seq_printf(m, "current index: "LPU64"\n", cur);
+       seq_printf(m, "current index: %llu\n", cur);
        seq_printf(m, "%-5s %s\n", "ID", "index");
 
        llog_cat_process(&env, ctxt->loc_handle, lprocfs_changelog_users_cb,
@@ -223,7 +220,7 @@ static int mdd_changelog_size_seq_show(struct seq_file *m, void *data)
        rc = mdd_changelog_size_ctxt(&env, mdd, LLOG_CHANGELOG_USER_ORIG_CTXT,
                                     &tmp);
 
-       seq_printf(m, LPU64"\n", tmp);
+       seq_printf(m, "%llu\n", tmp);
        lu_env_fini(&env);
        return rc;
 }
@@ -244,15 +241,17 @@ mdd_sync_perm_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
-        int val, rc;
+       int rc;
+       __s64 val;
 
-        LASSERT(mdd != NULL);
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
+       LASSERT(mdd != NULL);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
 
-        mdd->mdd_sync_permission = !!val;
-        return count;
+       mdd->mdd_sync_permission = !!val;
+
+       return count;
 }
 LPROC_SEQ_FOPS(mdd_sync_perm);
 
@@ -270,13 +269,15 @@ mdd_lfsck_speed_limit_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
-       __u32 val;
+       __s64 val;
        int rc;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc != 0)
                return rc;
+       if (val < 0 || val > INT_MAX)
+               return -ERANGE;
 
        rc = lfsck_set_speed(mdd->mdd_bottom, val);
        return rc != 0 ? rc : count;
@@ -297,13 +298,17 @@ mdd_lfsck_async_windows_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file   *m = file->private_data;
        struct mdd_device *mdd = m->private;
-       __u32              val;
+       __s64              val;
        int                rc;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc == 0)
-               rc = lfsck_set_windows(mdd->mdd_bottom, val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc)
+               return rc;
+       if (val < 0 || val > INT_MAX)
+               return -ERANGE;
+
+       rc = lfsck_set_windows(mdd->mdd_bottom, val);
 
        return rc != 0 ? rc : count;
 }