Whamcloud - gitweb
LU-9325 obd: replace lprocfs_str_to_s64 39/30539/16
authorJames Simmons <uja.ornl@yahoo.com>
Fri, 9 Feb 2018 23:46:39 +0000 (18:46 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 3 Mar 2018 04:29:54 +0000 (04:29 +0000)
The original goal of lprocfs_str_to_s64[_with_units] was to allow
passing in values of different unit sizes i.e 64K to a proc file.
Their are a few problems with the implementation that prevents its
direct use with sysfs/debugfs. The first problem is that
lprocfs_str_to_s64() was used for a lot of cases where it doesn't
make sense to use it. Often it was used for bool values passing
in or after retrieving a value as signed 64 bit it ensures its in
range of some other unit size. For these cases we can simply move
to kstrtoXXX_from_user(). To handle the case of bool values we
add in supoort for kstrtobool_from_user().

Replace the lprocfs_rd_uint() and lprocfs_wr_uint() generic callbacks
with a simpler, more direct implementation of ldlm_rw_uint_fops.

There's a slight change in lustre debugfs write semantics: Using kstrtox
causes EINVAL when the written number is followed by other (garbage)
characters, whereas previously the garbage would be ignored and such a
write would succeed.

Linux-commit: 8b23093269c84b0da1201e1949c91d0beb9892ef

Change-Id: I39f0ba3dc72685fe6e29c7077f37ad4e69a20b4a
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Signed-off-by: Mathias Rav <mathiasrav@gmail.com>
Reviewed-on: https://review.whamcloud.com/30539
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
33 files changed:
contrib/scripts/spelling.txt
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/linux/linux-prim.c
lustre/fid/lproc_fid.c
lustre/include/lprocfs_status.h
lustre/include/lustre_lfsck.h
lustre/ldlm/ldlm_resource.c
lustre/lfsck/lfsck_lib.c
lustre/llite/lproc_llite.c
lustre/lod/lproc_lod.c
lustre/lov/lproc_lov.c
lustre/mdc/lproc_mdc.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lproc.c
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/mgs/mgs_nids.c
lustre/obdclass/lprocfs_jobstats.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/lprocfs_status_server.c
lustre/ofd/lproc_ofd.c
lustre/osc/lproc_osc.c
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_lproc.c
lustre/osp/lproc_osp.c
lustre/ptlrpc/gss/lproc_gss.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/quota/qmt_pool.c
lustre/quota/qsd_lib.c
lustre/target/tgt_grant.c

index a740266..7c46e43 100644 (file)
@@ -122,6 +122,7 @@ LPLD||%ld
 LPLX||%#lx
 LPPID||%d
 LPROCFS||CONFIG_PROC_FS
+lprocfs_str_to_s64||kstrtoxxx_from_user
 mktemp||mkstemp
 sprintf||snprintf
 strcpy||strncpy
index 1231e90..39fc152 100644 (file)
@@ -688,6 +688,23 @@ LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
 ]) # LIBCFS_FPU_API
 
 #
+# Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
+# introduced kstrtobool and kstrtobool_from_user.
+#
+AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
+LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
+kstrtobool_from_user, [
+       #include <linux/kernel.h>
+],[
+       bool result;
+       return kstrtobool_from_user(NULL, 0, &result);
+],[
+       AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
+               [kernel has kstrtobool_from_user])
+])
+]) # LIBCFS_KSTRTOBOOL_FROM_USER
+
+#
 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
 # added crypto hash helpers
 #
@@ -899,6 +916,8 @@ LIBCFS_KERNEL_PARAM_LOCK
 # 4.2
 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
 LIBCFS_FPU_API
+# 4.4
+LIBCFS_KSTRTOBOOL_FROM_USER
 # 4.5
 LIBCFS_CRYPTO_HASH_HELPERS
 LIBCFS_EXPORT_KSET_FIND_OBJ
index 57ebfea..68f37ec 100644 (file)
@@ -160,4 +160,10 @@ static inline int kstrtoul(const char *s, unsigned int base, unsigned long *res)
 }
 #endif /* !HAVE_KSTRTOUL */
 
+#ifndef HAVE_KSTRTOBOOL_FROM_USER
+
+#define kstrtobool strtobool
+
+int kstrtobool_from_user(const char __user *s, size_t count, bool *res);
+#endif
 #endif
index 6c10376..c78d886 100644 (file)
@@ -121,6 +121,21 @@ struct kobject *kset_find_obj(struct kset *kset, const char *name)
 EXPORT_SYMBOL_GPL(kset_find_obj);
 #endif
 
+#ifndef HAVE_KSTRTOBOOL_FROM_USER
+int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
+{
+       /* Longest string needed to differentiate, newline, terminator */
+       char buf[4];
+
+       count = min(count, sizeof(buf) - 1);
+       if (copy_from_user(buf, s, count))
+               return -EFAULT;
+       buf[count] = '\0';
+       return strtobool(buf, res);
+}
+EXPORT_SYMBOL(kstrtobool_from_user);
+#endif /* !HAVE_KSTRTOBOOL_FROM_USER */
+
 sigset_t
 cfs_block_allsigs(void)
 {
index 96c13e4..15a5c74 100644 (file)
@@ -162,30 +162,22 @@ static ssize_t
 lprocfs_server_fid_width_seq_write(struct file *file, const char __user *buffer,
                                        size_t count, loff_t *off)
 {
-       struct lu_server_seq *seq = ((struct seq_file *)file->private_data)->private;
+       struct seq_file *m = file->private_data;
+       struct lu_server_seq *seq = m->private;
        int rc;
-       __s64 val;
        ENTRY;
 
        LASSERT(seq != NULL);
 
        mutex_lock(&seq->lss_mutex);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &seq->lss_width);
        if (rc) {
                CERROR("%s: invalid FID sequence width: rc = %d\n",
                       seq->lss_name, rc);
                GOTO(out_unlock, count = rc);
        }
 
-       if (val < 0) {
-               CERROR("%s: invalid FID sequence width: rc = %d\n",
-                      seq->lss_name, -ERANGE);
-               GOTO(out_unlock, count = -ERANGE);
-       }
-
-       seq->lss_width = val;
-
        CDEBUG(D_INFO, "%s: Width: %llu\n",
               seq->lss_name, seq->lss_width);
 out_unlock:
@@ -549,17 +541,18 @@ static ssize_t
 lprocfs_client_fid_width_seq_write(struct file *file, const char __user *buffer,
                                   size_t count, loff_t *off)
 {
-       struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
-       __u64 max;
+       struct seq_file *m = file->private_data;
+       struct lu_client_seq *seq = m->private;
+       u64 val;
+       u64 max;
        int rc;
-       __s64 val;
-       ENTRY;
 
+       ENTRY;
        LASSERT(seq != NULL);
 
        mutex_lock(&seq->lcs_mutex);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &val);
        if (rc) {
                GOTO(out_unlock, count = rc);
        }
@@ -569,7 +562,7 @@ lprocfs_client_fid_width_seq_write(struct file *file, const char __user *buffer,
        else
                max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
 
-       if (val <= max && val > 0) {
+       if (val <= max) {
                seq->lcs_width = val;
 
                CDEBUG(D_INFO, "%s: Sequence size: %llu\n",
index f253f68..87e8e5a 100644 (file)
@@ -573,17 +573,6 @@ extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
                                  void *data);
 
 /* Generic callbacks */
-extern int lprocfs_u64_seq_show(struct seq_file *m, void *data);
-extern int lprocfs_atomic_seq_show(struct seq_file *m, void *data);
-extern ssize_t lprocfs_atomic_seq_write(struct file *file,
-                                       const char __user *buffer,
-                                       size_t count, loff_t *off);
-extern int lprocfs_uint_seq_show(struct seq_file *m, void *data);
-extern ssize_t lprocfs_uint_seq_write(struct file *file,
-                                     const char __user *buffer,
-                                     size_t count, loff_t *off);
-extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
-                          unsigned long count, void *data);
 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
@@ -620,8 +609,6 @@ lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
                                     long val, int mult);
-extern int lprocfs_str_to_s64(const char __user *buffer, unsigned long count,
-                             __s64 *val);
 extern int lprocfs_str_with_units_to_s64(const char __user *buffer,
                                         unsigned long count, __s64 *val,
                                         char defunit);
index 9aeba0d..fca7f45 100644 (file)
@@ -104,7 +104,7 @@ int lfsck_query(const struct lu_env *env, struct dt_device *key,
 int lfsck_get_speed(struct seq_file *m, struct dt_device *key);
 int lfsck_set_speed(struct dt_device *key, __u32 val);
 int lfsck_get_windows(struct seq_file *m, struct dt_device *key);
-int lfsck_set_windows(struct dt_device *key, int val);
+int lfsck_set_windows(struct dt_device *key, unsigned int val);
 
 int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type);
 
index 8241dc8..bf45a6d 100644 (file)
@@ -77,7 +77,26 @@ lprocfs_dump_ns_seq_write(struct file *file, const char __user *buffer,
 }
 LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
 
-LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
+static int ldlm_rw_uint_seq_show(struct seq_file *m, void *v)
+{
+       seq_printf(m, "%u\n", *(unsigned int *)m->private);
+       return 0;
+}
+
+static ssize_t
+ldlm_rw_uint_seq_write(struct file *file, const char __user *buffer,
+                      size_t count, loff_t *off)
+{
+       struct seq_file *seq = file->private_data;
+
+       if (!count)
+               return 0;
+
+       return kstrtouint_from_user(buffer, count, 0,
+                                   (unsigned int *)seq->private);
+}
+
+LPROC_SEQ_FOPS(ldlm_rw_uint);
 
 #ifdef HAVE_SERVER_SUPPORT
 
index a99434f..3de52cd 100644 (file)
@@ -2814,7 +2814,7 @@ int lfsck_get_windows(struct seq_file *m, struct dt_device *key)
 }
 EXPORT_SYMBOL(lfsck_get_windows);
 
-int lfsck_set_windows(struct dt_device *key, int val)
+int lfsck_set_windows(struct dt_device *key, unsigned int val)
 {
        struct lu_env           env;
        struct lfsck_instance  *lfsck;
index e00664a..d3bb8a0 100644 (file)
@@ -81,10 +81,10 @@ static ssize_t ll_stat_blksize_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
-       __s64 val;
+       unsigned int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -233,17 +233,14 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val != 0 && val != 1)
-               return -ERANGE;
-
-       if (val == 1 && !(sbi->ll_flags & LL_SBI_XATTR_CACHE))
+       if (val && !(sbi->ll_flags & LL_SBI_XATTR_CACHE))
                return -ENOTSUPP;
 
        sbi->ll_xattr_cache_enabled = val;
@@ -558,23 +555,25 @@ static ssize_t ll_checksum_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+       bool val;
+       int tmp;
        int rc;
-       __s64 val;
 
        if (!sbi->ll_dt_exp)
                /* Not set up yet */
                return -EAGAIN;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
        if (val)
                sbi->ll_flags |= LL_SBI_CHECKSUM;
        else
                sbi->ll_flags &= ~LL_SBI_CHECKSUM;
+       tmp = val;
 
        rc = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CHECKSUM),
-                               KEY_CHECKSUM, sizeof(val), &val, NULL);
+                               KEY_CHECKSUM, sizeof(tmp), &tmp, NULL);
        if (rc)
                CWARN("Failed to set OSC checksum flags: %d\n", rc);
 
@@ -601,14 +600,12 @@ static int ll_wr_track_id(const char __user *buffer, unsigned long count,
                          void *data, enum stats_track_type type)
 {
        struct super_block *sb = data;
+       unsigned int pid;
        int rc;
-       __s64 pid;
 
-       rc = lprocfs_str_to_s64(buffer, count, &pid);
+       rc = kstrtouint_from_user(buffer, count, 0, &pid);
        if (rc)
                return rc;
-       if (pid > INT_MAX || pid < 0)
-               return -ERANGE;
 
        ll_s2sbi(sb)->ll_stats_track_id = pid;
        if (pid == 0)
@@ -676,17 +673,17 @@ static ssize_t ll_statahead_max_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+       unsigned int val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val >= 0 && val <= LL_SA_RPC_MAX)
+       if (val <= LL_SA_RPC_MAX)
                sbi->ll_sa_max = val;
        else
-               CERROR("Bad statahead_max value %lld. Valid values are in "
+               CERROR("Bad statahead_max value %u. Valid values are in "
                       "the range [0, %d]\n", val, LL_SA_RPC_MAX);
 
        return count;
@@ -709,10 +706,10 @@ static ssize_t ll_statahead_agl_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
@@ -756,10 +753,10 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
@@ -837,17 +834,15 @@ static ssize_t ll_default_easize_seq_write(struct file *file,
        struct seq_file *seq = file->private_data;
        struct super_block *sb = (struct super_block *)seq->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
-       __s64 val;
+       unsigned int val;
        int rc;
 
        if (count == 0)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        rc = ll_set_default_mdsize(sbi, val);
        if (rc)
@@ -897,15 +892,15 @@ ll_fast_read_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
        spin_lock(&sbi->ll_lock);
-       if (val == 1)
+       if (val)
                sbi->ll_flags |= LL_SBI_FAST_READ;
        else
                sbi->ll_flags &= ~LL_SBI_FAST_READ;
@@ -930,15 +925,15 @@ static ssize_t ll_pio_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
        spin_lock(&sbi->ll_lock);
-       if (val == 1)
+       if (val)
                sbi->ll_flags |= LL_SBI_PIO;
        else
                sbi->ll_flags &= ~LL_SBI_PIO;
@@ -973,8 +968,8 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file,
        struct seq_file *seq = file->private_data;
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)seq->private);
        char kernbuf[128];
+       bool val;
        int rc;
-       __s64 val;
 
        if (count == 0)
                return 0;
@@ -987,13 +982,13 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file,
 
        buffer += lprocfs_find_named_value(kernbuf, "unstable_check:", &count) -
                  kernbuf;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc < 0)
                return rc;
 
        /* borrow lru lock to set the value */
        spin_lock(&sbi->ll_cache->ccc_lru_lock);
-       sbi->ll_cache->ccc_unstable_check = !!val;
+       sbi->ll_cache->ccc_unstable_check = val;
        spin_unlock(&sbi->ll_cache->ccc_lru_lock);
 
        return count;
@@ -1756,12 +1751,11 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file,
  */
 static __s64 ll_stats_pid_write(const char __user *buf, size_t len)
 {
-       __s64 value = 1;
+       unsigned long long value = 1;
        int rc;
        char kernbuf[16];
 
-       rc = lprocfs_str_to_s64(buf, len, &value);
-
+       rc = kstrtoull_from_user(buf, len, 0, &value);
        if (rc < 0 && len < sizeof(kernbuf)) {
 
                if (copy_from_user(kernbuf, buf, len))
index d707617..429b9fe 100644 (file)
@@ -60,7 +60,7 @@ static int lod_dom_stripesize_seq_show(struct seq_file *m, void *v)
        struct lod_device *lod;
 
        LASSERT(dev != NULL);
-       lod  = lu2lod_dev(dev->obd_lu_dev);
+       lod = lu2lod_dev(dev->obd_lu_dev);
        seq_printf(m, "%u\n", lod->lod_dom_max_stripesize);
        return 0;
 }
@@ -85,18 +85,18 @@ lod_dom_stripesize_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val;
+       s64 val;
        int rc;
 
        LASSERT(dev != NULL);
-       lod  = lu2lod_dev(dev->obd_lu_dev);
+       lod = lu2lod_dev(dev->obd_lu_dev);
        rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
        if (rc)
                return rc;
        if (val < 0)
                return -ERANGE;
 
-       /* */
+       /* 1GB is the limit */
        if (val > (1ULL << 30))
                return -ERANGE;
        else if (val > 0)
@@ -149,7 +149,7 @@ lod_stripesize_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val;
+       s64 val;
        int rc;
 
        LASSERT(dev != NULL);
@@ -208,15 +208,15 @@ lod_stripeoffset_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val;
+       long val;
        int rc;
 
        LASSERT(dev != NULL);
        lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtol_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < -1)
+       if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
                return -ERANGE;
 
        lod->lod_desc.ld_default_stripe_offset = val;
@@ -264,19 +264,15 @@ lod_stripetype_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       u32 pattern;
        int rc;
-       __u32 pattern;
-       __s64 val;
 
        LASSERT(dev != NULL);
        lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &pattern);
        if (rc)
                return rc;
-       if (val < 0)
-               return -ERANGE;
 
-       pattern = val;
        lod_fix_desc_pattern(&pattern);
        lod->lod_desc.ld_pattern = pattern;
 
@@ -324,19 +320,15 @@ lod_stripecount_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       u32 stripe_count;
        int rc;
-       __s64 val;
-       __u32 stripe_count;
 
        LASSERT(dev != NULL);
-       lod  = lu2lod_dev(dev->obd_lu_dev);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       lod = lu2lod_dev(dev->obd_lu_dev);
+       rc = kstrtouint_from_user(buffer, count, 0, &stripe_count);
        if (rc)
                return rc;
-       if (val < -1)
-               return -ERANGE;
 
-       stripe_count = val;
        lod_fix_desc_stripe_count(&stripe_count);
        lod->lod_desc.ld_default_stripe_count = stripe_count;
 
@@ -455,17 +447,17 @@ lod_qos_priofree_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > 100)
+       if (val > 100)
                return -EINVAL;
        lod->lod_qos.lq_prio_free = (val << 8) / 100;
        lod->lod_qos.lq_dirty = 1;
@@ -585,12 +577,12 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer,
        char str[32];
        unsigned int i;
        int rc;
-       __s64 val;
+       u32 val;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -602,7 +594,7 @@ lod_qos_maxage_seq_write(struct file *file, const char __user *buffer,
         * propogate the value down to OSPs
         */
        lustre_cfg_bufs_reset(&bufs, NULL);
-       snprintf(str, 32, "%smaxage=%u", PARAM_OSP, (__u32)val);
+       snprintf(str, 32, "%smaxage=%u", PARAM_OSP, val);
        lustre_cfg_bufs_set_string(&bufs, 1, str);
        OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
        if (lcfg == NULL)
@@ -781,17 +773,17 @@ lod_lmv_failout_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct lod_device *lod;
-       __s64 val = 0;
+       bool val = 0;
        int rc;
 
        LASSERT(dev != NULL);
        lod = lu2lod_dev(dev->obd_lu_dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       lod->lod_lmv_failout = !!val;
+       lod->lod_lmv_failout = val;
 
        return count;
 }
index 77cab15..f8e6d54 100644 (file)
@@ -57,12 +57,12 @@ static ssize_t lov_stripesize_seq_write(struct file *file,
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct lov_desc *desc;
-       __s64 val;
+       s64 val;
        int rc;
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
        if (rc)
                return rc;
        if (val < 0)
@@ -92,15 +92,15 @@ static ssize_t lov_stripeoffset_seq_write(struct file *file,
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct lov_desc *desc;
-       __s64 val;
+       long val;
        int rc;
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtol_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < -1)
+       if (val < -1 || val > LOV_MAX_STRIPE_COUNT)
                return -ERANGE;
 
        desc->ld_default_stripe_offset = val;
@@ -126,18 +126,15 @@ static ssize_t lov_stripetype_seq_write(struct file *file,
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct lov_desc *desc;
-       int pattern, rc;
-       __s64 val;
+       u32 pattern;
+       int rc;
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &pattern);
        if (rc)
                return rc;
-       if (val < INT_MIN || val > INT_MAX)
-               return -ERANGE;
 
-       pattern = val;
        lov_fix_desc_pattern(&pattern);
        desc->ld_pattern = pattern;
 
@@ -163,19 +160,18 @@ static ssize_t lov_stripecount_seq_write(struct file *file,
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct lov_desc *desc;
+       int stripe_count;
        int rc;
-       __u32 stripe_count;
-       __s64 val;
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &stripe_count);
        if (rc)
                return rc;
-       if (val < -1)
+
+       if (stripe_count < -1)
                return -ERANGE;
 
-       stripe_count = val;
        lov_fix_desc_stripe_count(&stripe_count);
        desc->ld_default_stripe_count = stripe_count;
 
index 8bd9285..5ad2dff 100644 (file)
@@ -56,21 +56,19 @@ static ssize_t mdc_active_seq_write(struct file *file,
                                    size_t count, loff_t *off)
 {
        struct obd_device *dev;
+       bool val;
        int rc;
-       __s64 val;
 
        dev = ((struct seq_file *)file->private_data)->private;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > 1)
-               return -ERANGE;
 
        /* opposite senses */
        if (dev->u.cli.cl_import->imp_deactive == val)
                rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
        else
-               CDEBUG(D_CONFIG, "activate %llu: ignoring repeat request\n",
+               CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
                       val);
 
        return count;
@@ -201,14 +199,12 @@ static ssize_t mdc_contention_seconds_seq_write(struct file *file,
        struct seq_file *sfl = file->private_data;
        struct obd_device *obd = sfl->private;
        struct osc_device *od  = obd2osc_dev(obd);
+       time64_t val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        od->od_contention_time = val;
 
@@ -248,17 +244,14 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
                                                size_t count, loff_t *off)
 {
        struct obd_device *dev;
-       __s64 val;
+       unsigned int val;
        int rc;
 
        dev = ((struct seq_file *)file->private_data)->private;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > UINT_MAX)
-               return -ERANGE;
-
        rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
        if (rc)
                return rc;
@@ -283,17 +276,14 @@ static ssize_t mdc_max_mod_rpcs_in_flight_seq_write(struct file *file,
                                                    size_t count, loff_t *off)
 {
        struct obd_device *dev;
-       __s64 val;
+       u16 val;
        int rc;
 
        dev =  ((struct seq_file *)file->private_data)->private;
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtou16_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > USHRT_MAX)
-               return -ERANGE;
-
        rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
        if (rc)
                count = rc;
index cc43611..f438eb7 100644 (file)
@@ -133,11 +133,11 @@ struct mdd_device {
        struct proc_dir_entry            *mdd_proc_entry;
         struct mdd_changelog             mdd_cl;
        unsigned int                     mdd_changelog_gc;
-       unsigned int                     mdd_changelog_max_idle_time;
+       time64_t                         mdd_changelog_max_idle_time;
        unsigned long                    mdd_changelog_max_idle_indexes;
-       unsigned int                     mdd_changelog_min_gc_interval;
+       time64_t                         mdd_changelog_min_gc_interval;
        unsigned int                     mdd_changelog_min_free_cat_entries;
-        unsigned long                    mdd_atime_diff;
+       time64_t                         mdd_atime_diff;
         struct mdd_object               *mdd_dot_lustre;
         struct mdd_dot_lustre_objs       mdd_dot_lustre_objs;
        unsigned int                     mdd_sync_permission;
index 6d6af2f..f04a2cb 100644 (file)
@@ -51,20 +51,12 @@ mdd_atime_diff_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
-       char kernbuf[20], *end;
-       unsigned long diff = 0;
-
-        if (count > (sizeof(kernbuf) - 1))
-                return -EINVAL;
-
-       if (copy_from_user(kernbuf, buffer, count))
-                return -EFAULT;
-
-        kernbuf[count] = '\0';
+       time64_t diff = 0;
+       int rc;
 
-        diff = simple_strtoul(kernbuf, &end, 0);
-        if (kernbuf == end)
-                return -EINVAL;
+       rc = kstrtoll_from_user(buffer, count, 0, &diff);
+       if (rc)
+               return rc;
 
         mdd->mdd_atime_diff = diff;
         return count;
@@ -74,7 +66,7 @@ static int mdd_atime_diff_seq_show(struct seq_file *m, void *data)
 {
        struct mdd_device *mdd = m->private;
 
-       seq_printf(m, "%lu\n", mdd->mdd_atime_diff);
+       seq_printf(m, "%lld\n", mdd->mdd_atime_diff);
        return 0;
 }
 LPROC_SEQ_FOPS(mdd_atime_diff);
@@ -242,15 +234,15 @@ mdd_changelog_gc_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       mdd->mdd_changelog_gc = !!val;
+       mdd->mdd_changelog_gc = val;
 
        return count;
 }
@@ -261,7 +253,7 @@ static int mdd_changelog_max_idle_time_seq_show(struct seq_file *m, void *data)
        struct mdd_device *mdd = m->private;
 
        LASSERT(mdd != NULL);
-       seq_printf(m, "%u\n", mdd->mdd_changelog_max_idle_time);
+       seq_printf(m, "%lld\n", mdd->mdd_changelog_max_idle_time);
        return 0;
 }
 
@@ -272,16 +264,17 @@ mdd_changelog_max_idle_time_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
+       time64_t val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
        /* XXX may need to limit with reasonable elapsed/idle times */
-       if (val < 1 || val > INT_MAX)
+       if (val < 1)
                return -ERANGE;
 
        mdd->mdd_changelog_max_idle_time = val;
@@ -307,11 +300,11 @@ mdd_changelog_max_idle_indexes_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
+       unsigned long val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoul_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -330,7 +323,7 @@ static int mdd_changelog_min_gc_interval_seq_show(struct seq_file *m,
        struct mdd_device *mdd = m->private;
 
        LASSERT(mdd != NULL);
-       seq_printf(m, "%u\n", mdd->mdd_changelog_min_gc_interval);
+       seq_printf(m, "%lld\n", mdd->mdd_changelog_min_gc_interval);
        return 0;
 }
 
@@ -341,16 +334,16 @@ mdd_changelog_min_gc_interval_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
+       time64_t val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
        /* XXX may need to limit with reasonable elapsed/interval times */
-       if (val < 1 || val > UINT_MAX)
+       if (val < 1)
                return -ERANGE;
 
        mdd->mdd_changelog_min_gc_interval = val;
@@ -376,16 +369,16 @@ mdd_changelog_min_free_cat_entries_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
        /* XXX may need to limit with more reasonable number of free entries */
-       if (val < 1 || (__u64)val > UINT_MAX)
+       if (val < 1)
                return -ERANGE;
 
        mdd->mdd_changelog_min_free_cat_entries = val;
@@ -444,15 +437,15 @@ 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;
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       mdd->mdd_sync_permission = !!val;
+       mdd->mdd_sync_permission = val;
 
        return count;
 }
@@ -472,15 +465,13 @@ 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;
-       __s64 val;
+       unsigned int val;
        int rc;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &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;
@@ -499,17 +490,15 @@ static ssize_t
 mdd_lfsck_async_windows_seq_write(struct file *file, const char __user *buffer,
                                  size_t count, loff_t *off)
 {
-       struct seq_file   *m = file->private_data;
+       struct seq_file *m = file->private_data;
        struct mdd_device *mdd = m->private;
-       __s64              val;
-       int                rc;
+       unsigned int val;
+       int rc;
 
        LASSERT(mdd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        rc = lfsck_set_windows(mdd->mdd_bottom, val);
 
index 6a7782e..a91bd97 100644 (file)
@@ -2087,14 +2087,15 @@ mdt_hsm_##VAR##_seq_write(struct file *file, const char __user *buffer, \
        struct seq_file         *m = file->private_data;                \
        struct mdt_device       *mdt = m->private;                      \
        struct coordinator      *cdt = &mdt->mdt_coordinator;           \
-       __s64                    val;                                   \
-       int                      rc;                                    \
-       ENTRY;                                                          \
+       unsigned int val;                                               \
+       int rc;                                                         \
                                                                        \
-       rc = lprocfs_str_to_s64(buffer, count, &val);                   \
+       ENTRY;                                                          \
+       rc = kstrtouint_from_user(buffer, count, 0, &val);              \
        if (rc)                                                         \
                RETURN(rc);                                             \
-       if (val > 0 && val < INT_MAX) {                                 \
+                                                                       \
+       if (val !=  0) {                                                \
                cdt->VAR = val;                                         \
                RETURN(count);                                          \
        }                                                               \
@@ -2364,11 +2365,11 @@ mdt_hsm_cdt_raolu_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct mdt_device *mdt = m->private;
        struct coordinator *cdt = &mdt->mdt_coordinator;
-       __s64 val;
+       bool val;
        int rc;
-       ENTRY;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       ENTRY;
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc < 0)
                RETURN(rc);
 
index 267f469..5829d1f 100644 (file)
@@ -6706,12 +6706,12 @@ struct lu_ucred *mdt_ucred_check(const struct mdt_thread_info *info)
  * \param mdt mdt device
  * \param val 0 disables COS, other values enable COS
  */
-void mdt_enable_cos(struct mdt_device *mdt, int val)
+void mdt_enable_cos(struct mdt_device *mdt, bool val)
 {
         struct lu_env env;
         int rc;
 
-        mdt->mdt_opts.mo_cos = !!val;
+       mdt->mdt_opts.mo_cos = val;
         rc = lu_env_init(&env, LCT_LOCAL);
        if (unlikely(rc != 0)) {
                CWARN("%s: lu_env initialization failed, cannot "
index 75e159e..8289384 100644 (file)
@@ -1149,7 +1149,7 @@ int mdt_dom_lvb_is_valid(struct ldlm_resource *res);
 int mdt_dom_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
                        struct ptlrpc_request *req, bool increase_only);
 
-void mdt_enable_cos(struct mdt_device *, int);
+void mdt_enable_cos(struct mdt_device *dev, bool enable);
 int mdt_cos_is_enabled(struct mdt_device *);
 
 /* lprocfs stuff */
index 8c8f50b..ab85005 100644 (file)
@@ -227,11 +227,11 @@ mdt_identity_expire_seq_write(struct file *file, const char __user *buffer,
        time64_t val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > INT_MAX)
+       if (val < 0)
                return -ERANGE;
 
        mdt->mdt_identity_cache->uc_entry_expire = val;
@@ -260,7 +260,7 @@ mdt_identity_acquire_expire_seq_write(struct file *file,
        time64_t val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -338,14 +338,12 @@ lprocfs_identity_flush_seq_write(struct file *file, const char __user *buffer,
        struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       int uid;
        int rc;
-       __s64 uid;
 
-       rc = lprocfs_str_to_s64(buffer, count, &uid);
+       rc = kstrtoint_from_user(buffer, count, 0, &uid);
        if (rc)
                return rc;
-       if (uid < INT_MIN || uid > INT_MAX)
-               return -ERANGE;
 
        mdt_flush_identity(mdt->mdt_identity_cache, uid);
        return count;
@@ -501,13 +499,14 @@ mdt_evict_tgt_nids_seq_write(struct file *file, const char __user *buffer,
        struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       mdt->mdt_opts.mo_evict_tgt_nids = !!val;
+
+       mdt->mdt_opts.mo_evict_tgt_nids = val;
        return count;
 }
 LPROC_SEQ_FOPS(mdt_evict_tgt_nids);
@@ -528,14 +527,12 @@ mdt_cos_seq_write(struct file *file, const char __user *buffer,
        struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < INT_MIN || val > INT_MAX)
-               return -ERANGE;
 
        mdt_enable_cos(mdt, val);
        return count;
@@ -617,16 +614,13 @@ mdt_enable_remote_dir_seq_write(struct file *file, const char __user *buffer,
        struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val > 1 || val < 0)
-               return -ERANGE;
-
        mdt->mdt_enable_remote_dir = val;
        return count;
 }
@@ -650,10 +644,10 @@ mdt_enable_remote_dir_gid_seq_write(struct file *file,
        struct seq_file   *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       __s64 val;
+       int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -707,16 +701,13 @@ mdt_async_commit_count_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       __s64 val;
+       int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < INT_MIN || val > INT_MAX)
-               return -ERANGE;
-
        atomic_set(&mdt->mdt_async_commit_count, val);
 
        return count;
@@ -748,16 +739,13 @@ mdt_sync_count_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct lu_target *tgt = obd->u.obt.obt_lut;
-       __s64 val;
+       int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < INT_MIN || val > INT_MAX)
-               return -ERANGE;
-
        atomic_set(&tgt->lut_sync_count, val);
 
        return count;
@@ -780,14 +768,14 @@ mdt_dom_lock_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       mdt->mdt_opts.mo_dom_lock = !!val;
+       mdt->mdt_opts.mo_dom_lock = val;
        return count;
 }
 LPROC_SEQ_FOPS(mdt_dom_lock);
index b9b2b4b..7f73d86 100644 (file)
@@ -831,14 +831,15 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data)
 
 int lprocfs_ir_timeout_seq_show(struct seq_file *m, void *data)
 {
-       return lprocfs_u64_seq_show(m, &ir_timeout);
+       seq_printf(m, "%lld\n", ir_timeout);
+       return 0;
 }
 
 ssize_t lprocfs_ir_timeout_seq_write(struct file *file,
                                     const char __user *buffer,
                                     size_t count, loff_t *off)
 {
-        return lprocfs_wr_uint(file, buffer, count, &ir_timeout);
+       return kstrtoll_from_user(buffer, count, 0, &ir_timeout);
 }
 
 /* --------------- Handle non IR support clients --------------- */
index fd25e74..518d9c3 100644 (file)
@@ -645,8 +645,8 @@ lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
 {
        struct obd_device *obd;
        struct obd_job_stats *stats;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        obd = ((struct seq_file *)file->private_data)->private;
        if (obd == NULL)
@@ -654,11 +654,9 @@ lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
 
        stats = &obd->u.obt.obt_jobstats;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > UINT_MAX)
-               return -ERANGE;
 
        stats->ojs_cleanup_interval = val;
        lprocfs_job_cleanup(stats, stats->ojs_cleanup_interval);
index 967f788..3e9eed2 100644 (file)
@@ -346,93 +346,6 @@ lprocfs_register(const char *name, struct proc_dir_entry *parent,
 EXPORT_SYMBOL(lprocfs_register);
 
 /* Generic callbacks */
-int lprocfs_uint_seq_show(struct seq_file *m, void *data)
-{
-       seq_printf(m, "%u\n", *(unsigned int *)data);
-       return 0;
-}
-EXPORT_SYMBOL(lprocfs_uint_seq_show);
-
-int lprocfs_wr_uint(struct file *file, const char __user *buffer,
-                    unsigned long count, void *data)
-{
-       unsigned        *p = data;
-       char             dummy[MAX_STRING_SIZE + 1];
-       char            *end;
-       unsigned long    tmp;
-
-       if (count >= sizeof(dummy))
-               return -EINVAL;
-
-       if (count == 0)
-               return 0;
-
-       if (copy_from_user(dummy, buffer, count))
-               return -EFAULT;
-
-       dummy[count] = 0;
-
-       tmp = simple_strtoul(dummy, &end, 0);
-       if (dummy == end)
-               return -EINVAL;
-
-       *p = (unsigned int)tmp;
-       return count;
-}
-EXPORT_SYMBOL(lprocfs_wr_uint);
-
-ssize_t lprocfs_uint_seq_write(struct file *file, const char __user *buffer,
-                              size_t count, loff_t *off)
-{
-       int *data = ((struct seq_file *)file->private_data)->private;
-       int rc;
-       __s64 val = 0;
-
-       rc = lprocfs_str_to_s64(buffer, count, &val);
-       if (rc < 0)
-               return rc;
-
-       return lprocfs_wr_uint(file, buffer, count, data);
-}
-EXPORT_SYMBOL(lprocfs_uint_seq_write);
-
-int lprocfs_u64_seq_show(struct seq_file *m, void *data)
-{
-       LASSERT(data != NULL);
-       seq_printf(m, "%llu\n", *(__u64 *)data);
-       return 0;
-}
-EXPORT_SYMBOL(lprocfs_u64_seq_show);
-
-int lprocfs_atomic_seq_show(struct seq_file *m, void *data)
-{
-       atomic_t *atom = data;
-       LASSERT(atom != NULL);
-       seq_printf(m, "%d\n", atomic_read(atom));
-       return 0;
-}
-EXPORT_SYMBOL(lprocfs_atomic_seq_show);
-
-ssize_t
-lprocfs_atomic_seq_write(struct file *file, const char __user *buffer,
-                       size_t count, loff_t *off)
-{
-       atomic_t *atm = ((struct seq_file *)file->private_data)->private;
-       __s64 val = 0;
-       int rc;
-
-       rc = lprocfs_str_to_s64(buffer, count, &val);
-       if (rc < 0)
-               return rc;
-
-       if (val <= 0 || val > INT_MAX)
-               return -ERANGE;
-
-       atomic_set(atm, val);
-       return count;
-}
-EXPORT_SYMBOL(lprocfs_atomic_seq_write);
-
 int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = data;
@@ -2170,26 +2083,6 @@ static int str_to_s64_internal(const char __user *buffer, unsigned long count,
 
 /**
  * Convert a user string into a signed 64 bit number. This function produces
- * an error when the value parsed from the string underflows or
- * overflows. This function accepts strings which contain digits and
- * optionally a decimal or hex strings which are prefixed with "0x".
- *
- * \param[in] buffer   string consisting of numbers and optionally a decimal
- * \param[in] count    buffer length
- * \param[in] val      if successful, the value represented by the string
- *
- * \retval             0 on success
- * \retval             negative number on error
- */
-int lprocfs_str_to_s64(const char __user *buffer, unsigned long count,
-                      __s64 *val)
-{
-       return str_to_s64_internal(buffer, count, val, 1, false);
-}
-EXPORT_SYMBOL(lprocfs_str_to_s64);
-
-/**
- * Convert a user string into a signed 64 bit number. This function produces
  * an error when the value parsed from the string times multiplier underflows or
  * overflows. This function only accepts strings that contains digits, an
  * optional decimal, and a char representing a unit at the end. If a unit is
@@ -2401,7 +2294,7 @@ ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
        struct client_obd *cli = &dev->u.cli;
        struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
        int chunk_mask, rc;
-       __s64 val;
+       s64 val;
 
        rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
        if (rc)
@@ -2445,7 +2338,6 @@ int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data)
 }
 EXPORT_SYMBOL(lprocfs_obd_short_io_bytes_seq_show);
 
-
 /* Used to catch people who think they're specifying pages. */
 #define MIN_SHORT_IO_BYTES 64
 
@@ -2456,16 +2348,16 @@ ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
        struct obd_device *dev = ((struct seq_file *)
                                                file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
+       int val;
        int rc;
-       __u64 val;
 
        LPROCFS_CLIMP_CHECK(dev);
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                GOTO(out, rc);
 
-       if (val > OBD_MAX_SHORT_IO_BYTES || val < MIN_SHORT_IO_BYTES)
+       if (val < MIN_SHORT_IO_BYTES || val > OBD_MAX_SHORT_IO_BYTES)
                GOTO(out, rc = -ERANGE);
 
        rc = count;
index 08f3f18..0e07dd6 100644 (file)
@@ -772,11 +772,11 @@ lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 10, &val);
        if (rc)
                return rc;
 
@@ -804,15 +804,15 @@ lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       obd->obd_checksum_dump = !!val;
+       obd->obd_checksum_dump = val;
        return count;
 }
 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
@@ -834,15 +834,13 @@ lprocfs_recovery_time_soft_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        obd->obd_recovery_timeout = val;
        return count;
@@ -866,15 +864,13 @@ lprocfs_recovery_time_hard_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        obd->obd_recovery_time_hard = val;
        return count;
index 74a0095..032e9a5 100644 (file)
@@ -127,14 +127,14 @@ ofd_precreate_batch_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64 val;
+       unsigned int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1 || val > INT_MAX)
+       if (val < 1 || val > 65536)
                return -EINVAL;
 
        spin_lock(&ofd->ofd_batch_lock);
@@ -217,14 +217,14 @@ ofd_fmd_max_num_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64 val;
+       int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val > 65536 || val < 1)
+       if (val < 1 || val > 65536)
                return -EINVAL;
 
        ofd->ofd_fmd_max_num = val;
@@ -270,14 +270,14 @@ ofd_fmd_max_age_seq_write(struct file *file, const char __user *buffer,
        struct seq_file         *m = file->private_data;
        struct obd_device       *obd = m->private;
        struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64                    val;
-       int                      rc;
+       time64_t val;
+       int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val > 65536 || val < 1)
+       if (val < 1 || val > 65536) /* ~ 18 hour max */
                return -EINVAL;
 
        ofd->ofd_fmd_max_age = val;
@@ -333,15 +333,15 @@ ofd_degraded_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
        spin_lock(&ofd->ofd_flags_lock);
-       ofd->ofd_raid_degraded = !!val;
+       ofd->ofd_raid_degraded = val;
        spin_unlock(&ofd->ofd_flags_lock);
        return count;
 }
@@ -416,18 +416,15 @@ ofd_syncjournal_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 0)
-               return -EINVAL;
-
        spin_lock(&ofd->ofd_flags_lock);
-       ofd->ofd_syncjournal = !!val;
+       ofd->ofd_syncjournal = val;
        ofd_slc_set(ofd);
        spin_unlock(&ofd->ofd_flags_lock);
 
@@ -528,7 +525,7 @@ ofd_sync_lock_cancel_seq_write(struct file *file, const char __user *buffer,
        struct obd_device *obd = m->private;
        struct lu_target *tgt = obd->u.obt.obt_lut;
        char kernbuf[SYNC_STATES_MAXLEN];
-       __s64 val = -1;
+       int val = -1;
        int i;
 
        if (count == 0 || count >= sizeof(kernbuf))
@@ -550,7 +547,7 @@ ofd_sync_lock_cancel_seq_write(struct file *file, const char __user *buffer,
 
        /* Legacy numeric codes */
        if (val == -1) {
-               int rc = lprocfs_str_to_s64(buffer, count, &val);
+               int rc = kstrtoint_from_user(buffer, count, 0, &val);
                if (rc)
                        return rc;
        }
@@ -582,7 +579,8 @@ static int ofd_soft_sync_limit_seq_show(struct seq_file *m, void *data)
        struct obd_device       *obd = m->private;
        struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return lprocfs_uint_seq_show(m, &ofd->ofd_soft_sync_limit);
+       seq_printf(m, "%u\n", ofd->ofd_soft_sync_limit);
+       return 0;
 }
 
 /**
@@ -605,12 +603,18 @@ static ssize_t
 ofd_soft_sync_limit_seq_write(struct file *file, const char __user *buffer,
                              size_t count, loff_t *off)
 {
-       struct seq_file   *m = file->private_data;
+       struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+       unsigned int val;
+       int rc;
 
-       return lprocfs_uint_seq_write(file, buffer, count,
-                                     (loff_t *) &ofd->ofd_soft_sync_limit);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
+       if (rc < 0)
+               return rc;
+
+       ofd->ofd_soft_sync_limit = val;
+       return 0;
 }
 LPROC_SEQ_FOPS(ofd_soft_sync_limit);
 
@@ -653,16 +657,13 @@ ofd_lfsck_speed_limit_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64 val;
+       unsigned long long val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &val);
        if (rc != 0)
                return rc;
 
-       if (val < 0)
-               return -ERANGE;
-
        rc = lfsck_set_speed(ofd->ofd_osd, val);
 
        return rc != 0 ? rc : count;
@@ -731,14 +732,14 @@ ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
-       if (rc != 0)
+       rc = kstrtobool_from_user(buffer, count, &val);
+       if (rc)
                return rc;
 
-       ofd->ofd_lfsck_verify_pfid = !!val;
+       ofd->ofd_lfsck_verify_pfid = val;
        if (!ofd->ofd_lfsck_verify_pfid) {
                ofd->ofd_inconsistency_self_detected = 0;
                ofd->ofd_inconsistency_self_repaired = 0;
index 3eaba3e..b233343 100644 (file)
@@ -57,14 +57,12 @@ static ssize_t osc_active_seq_write(struct file *file,
                                    size_t count, loff_t *off)
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > 1)
-               return -ERANGE;
 
        /* opposite senses */
        if (dev->u.cli.cl_import->imp_deactive == val)
@@ -94,14 +92,15 @@ static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
 {
        struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
        int adding, added, req_count;
-       __s64 val;
+       unsigned int val;
+       int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 1 || val > OSC_MAX_RIF_MAX)
+
+       if (val == 0 || val > OSC_MAX_RIF_MAX)
                return -ERANGE;
 
        LPROCFS_CLIMP_CHECK(dev);
@@ -265,8 +264,8 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
        struct client_obd *cli = &obd->u.cli;
-       int                rc;
-       __s64              val;
+       s64 val;
+       int rc;
 
        if (obd == NULL)
                return 0;
@@ -336,17 +335,17 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
                                                   size_t count, loff_t *off)
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        if (obd == NULL)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val <= 0 || val > INT_MAX)
+       if (val == 0)
                return -ERANGE;
 
        obd->u.cli.cl_grant_shrink_interval = val;
@@ -371,17 +370,17 @@ static ssize_t osc_checksum_seq_write(struct file *file,
                                      size_t count, loff_t *off)
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       bool val;
        int rc;
-       __s64 val;
 
        if (obd == NULL)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       obd->u.cli.cl_checksum = !!val;
+       obd->u.cli.cl_checksum = val;
 
        return count;
 }
@@ -454,16 +453,13 @@ static ssize_t osc_resend_count_seq_write(struct file *file,
                                          size_t count, loff_t *off)
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 0 || val > INT_MAX)
-               return -EINVAL;
-
        atomic_set(&obd->u.cli.cl_resends, val);
 
        return count;
@@ -486,18 +482,18 @@ static ssize_t osc_checksum_dump_seq_write(struct file *file,
                                           size_t count, loff_t *off)
 {
        struct obd_device *obd;
+       bool val;
        int rc;
-       __s64 val;
 
        obd = ((struct seq_file *)file->private_data)->private;
        if (obd == NULL)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       obd->u.cli.cl_checksum_dump = (val ? 1 : 0);
+       obd->u.cli.cl_checksum_dump = val;
 
        return count;
 }
@@ -518,10 +514,10 @@ static ssize_t osc_contention_seconds_seq_write(struct file *file,
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
        struct osc_device *od  = obd2osc_dev(obd);
+       unsigned int val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
        if (val < 0 || val > INT_MAX)
@@ -548,16 +544,14 @@ static ssize_t osc_lockless_truncate_seq_write(struct file *file,
 {
        struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
         struct osc_device *od  = obd2osc_dev(obd);
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < 0)
-               return -ERANGE;
 
-       od->od_lockless_truncate = !!val;
+       od->od_lockless_truncate = val;
 
        return count;
 }
index 0c93d27..89cdfee 100644 (file)
@@ -277,18 +277,18 @@ ldiskfs_osd_cache_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *osd = osd_dt_dev(dt);
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(osd != NULL);
        if (unlikely(osd->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       osd->od_read_cache = !!val;
+       osd->od_read_cache = val;
        return count;
 }
 LPROC_SEQ_FOPS(ldiskfs_osd_cache);
@@ -312,18 +312,18 @@ ldiskfs_osd_wcache_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *osd = osd_dt_dev(dt);
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(osd != NULL);
        if (unlikely(osd->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       osd->od_writethrough_cache = !!val;
+       osd->od_writethrough_cache = val;
        return count;
 }
 LPROC_SEQ_FOPS(ldiskfs_osd_wcache);
@@ -362,14 +362,14 @@ static ssize_t
 ldiskfs_osd_pdo_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
+       bool pdo;
        int rc;
-       __s64 pdo;
 
-       rc = lprocfs_str_to_s64(buffer, count, &pdo);
+       rc = kstrtobool_from_user(buffer, count, &pdo);
        if (rc != 0)
                return rc;
 
-       ldiskfs_pdo = !!pdo;
+       ldiskfs_pdo = pdo;
 
        return count;
 }
@@ -394,14 +394,14 @@ ldiskfs_osd_auto_scrub_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
+       s64 val;
        int rc;
-       __s64 val;
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -430,14 +430,14 @@ ldiskfs_osd_full_scrub_ratio_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
+       s64 val;
        int rc;
-       __s64 val;
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoll_from_user(buffer, count, 0, &val);
        if (rc != 0)
                return rc;
 
@@ -471,20 +471,17 @@ ldiskfs_osd_full_scrub_threshold_rate_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
+       u64 val;
        int rc;
-       __s64 val;
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &val);
        if (rc != 0)
                return rc;
 
-       if (val < 0)
-               return -EINVAL;
-
        dev->od_full_scrub_threshold_rate = val;
        return count;
 }
@@ -502,14 +499,14 @@ ldiskfs_osd_track_declares_assert_seq_write(struct file *file,
                                                const char __user *buffer,
                                                size_t count, loff_t *off)
 {
-       __s64 track_declares_assert;
+       bool track_declares_assert;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &track_declares_assert);
-       if (rc != 0)
+       rc = kstrtobool_from_user(buffer, count, &track_declares_assert);
+       if (rc)
                return rc;
 
-       ldiskfs_track_declares_assert = !!track_declares_assert;
+       ldiskfs_track_declares_assert = track_declares_assert;
 
        return count;
 }
@@ -547,7 +544,7 @@ ldiskfs_osd_readcache_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *osd = osd_dt_dev(dt);
-       __s64 val;
+       s64 val;
        int rc;
 
        LASSERT(osd != NULL);
@@ -589,19 +586,19 @@ ldiskfs_osd_index_in_idif_seq_write(struct file *file,
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
        struct lu_target *tgt;
-       __s64 val;
+       bool val;
        int rc;
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc != 0)
                return rc;
 
        if (dev->od_index_in_idif) {
-               if (val != 0)
+               if (val)
                        return count;
 
                LCONSOLE_WARN("%s: OST-index in IDIF has been enabled, "
@@ -609,7 +606,7 @@ ldiskfs_osd_index_in_idif_seq_write(struct file *file,
                return -EPERM;
        }
 
-       if (val == 0)
+       if (!val)
                return count;
 
        rc = lu_env_init(&env, LCT_DT_THREAD);
@@ -664,14 +661,14 @@ static ssize_t ldiskfs_osd_index_backup_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
-       __s64 val;
+       int val;
        int rc;
 
        LASSERT(dev != NULL);
        if (unlikely(dev->od_mnt == NULL))
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
index 8e426de..0997a4b 100644 (file)
@@ -237,7 +237,7 @@ zfs_osd_auto_scrub_seq_write(struct file *file, const char __user *buffer,
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -314,14 +314,14 @@ static ssize_t zfs_osd_index_backup_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct dt_device *dt = m->private;
        struct osd_device *dev = osd_dt_dev(dt);
-       __s64 val;
+       int val;
        int rc;
 
        LASSERT(dev != NULL);
        if (!dev->od_os)
                return -EINPROGRESS;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
index b74c25e..f320818 100644 (file)
@@ -75,21 +75,19 @@ osp_active_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > 1)
-               return -ERANGE;
 
        LPROCFS_CLIMP_CHECK(dev);
        /* opposite senses */
        if (dev->u.cli.cl_import->imp_deactive == val)
                rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
        else
-               CDEBUG(D_CONFIG, "activate %lld: ignoring repeat request\n",
+               CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
                       val);
 
        LPROCFS_CLIMP_EXIT(dev);
@@ -227,17 +225,17 @@ osp_max_rpcs_in_flight_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
        int rc;
-       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1 || val > INT_MAX)
+       if (val == 0)
                return -ERANGE;
 
        osp->opd_sync_max_rpcs_in_flight = val;
@@ -282,17 +280,17 @@ osp_max_rpcs_in_progress_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
        int rc;
-       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1 || val > INT_MAX)
+       if (val == 0)
                return -ERANGE;
 
        osp->opd_sync_max_rpcs_in_progress = val;
@@ -338,13 +336,13 @@ osp_create_count_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       unsigned int val;
        int rc, i;
-       __s64 val;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -408,13 +406,13 @@ osp_max_create_count_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       unsigned int val;
        int rc;
-       __s64 val;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
@@ -599,17 +597,17 @@ osp_maxage_seq_write(struct file *file, const char __user *buffer,
        struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
        struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       unsigned int val;
        int rc;
-       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
 
-       if (val < 1 || val > INT_MAX)
+       if (val == 0)
                return -ERANGE;
 
        osp->opd_statfs_maxage = val;
@@ -727,18 +725,14 @@ osp_lfsck_max_rpcs_in_flight_seq_write(struct file *file,
 {
        struct seq_file   *m = file->private_data;
        struct obd_device *dev = m->private;
-       __s64 val;
+       unsigned int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
-       if (rc == 0) {
-               if (val < 0)
-                       return -ERANGE;
-
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
+       if (!rc)
                rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
-       } else {
+       else
                count = rc;
-       }
 
        return count;
 }
index b210604..b5403ad 100644 (file)
@@ -158,14 +158,14 @@ static ssize_t
 gss_lk_proc_dl_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
+       unsigned int val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc < 0)
                return rc;
 
-       if (val < 0 || val > 4)
+       if (val > 4)
                return -ERANGE;
 
        gss_lk_debug_level = val;
index 1c3aab7..4418f86 100644 (file)
@@ -305,11 +305,11 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ptlrpc_service *svc = m->private;
+       unsigned long long val;
        int bufpages;
-       __s64 val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoull_from_user(buffer, count, 0, &val);
        if (rc < 0)
                return rc;
 
@@ -358,16 +358,13 @@ ptlrpc_lprocfs_req_buffers_max_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct ptlrpc_service *svc = m->private;
-       __s64 val;
+       int val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 0, &val);
        if (rc < 0)
                return rc;
 
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
-
        if (val < svc->srv_nbuf_per_group)
                return -ERANGE;
 
@@ -1414,16 +1411,13 @@ lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
        struct obd_device *obd = m->private;
        struct client_obd *cli = &obd->u.cli;
        struct obd_import *imp = cli->cl_import;
+       bool val;
        int rc;
-       __s64 val;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc < 0)
                return rc;
 
-       if (val != 0 && val != 1)
-               return -ERANGE;
-
        LPROCFS_CLIMP_CHECK(obd);
        spin_lock(&imp->imp_lock);
        imp->imp_no_pinger_recover = !val;
index d1eb1fa..14ee846 100644 (file)
@@ -184,9 +184,9 @@ static ssize_t
 qpi_soft_least_qunit_seq_write(struct file *file, const char __user *buffer,
                               size_t count, loff_t *off)
 {
-       struct qmt_pool_info    *pool;
-       int     qunit, rc;
-       s64     least_qunit;
+       struct qmt_pool_info *pool;
+       long long least_qunit;
+       int qunit, rc;
 
        pool = ((struct seq_file *)file->private_data)->private;
        LASSERT(pool != NULL);
@@ -195,7 +195,7 @@ qpi_soft_least_qunit_seq_write(struct file *file, const char __user *buffer,
        if (pool->qpi_key >> 16 != LQUOTA_RES_DT)
                return -EINVAL;
 
-       rc = lprocfs_str_to_s64(buffer, count, &least_qunit);
+       rc = kstrtoll_from_user(buffer, count, 0, &least_qunit);
        if (rc)
                return rc;
 
index 1042d3b..c906cea 100644 (file)
@@ -246,14 +246,15 @@ qsd_timeout_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
        struct qsd_instance *qsd = ((struct seq_file *)file->private_data)->private;
+       time64_t timeout;
        int rc;
-       __s64 timeout;
-       LASSERT(qsd != NULL);
 
-       rc = lprocfs_str_to_s64(buffer, count, &timeout);
+       LASSERT(qsd != NULL);
+       rc = kstrtoll_from_user(buffer, count, 0, &timeout);
        if (rc)
                return rc;
-       if (timeout < 0 || timeout > INT_MAX)
+
+       if (timeout < 0)
                return -EINVAL;
 
        qsd->qsd_timeout = timeout;
index 659afb3..17da424 100644 (file)
@@ -1629,17 +1629,14 @@ ssize_t tgt_grant_compat_disable_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 0)
-               return -EINVAL;
-
-       tgd->tgd_grant_compat_disable = !!val;
+       tgd->tgd_grant_compat_disable = val;
 
        return count;
 }