*
* 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
*/
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
static const struct file_operations ll_rw_extents_stats_fops;
static const struct file_operations ll_rw_extents_stats_pp_fops;
static const struct file_operations ll_rw_offset_stats_fops;
+static __s64 ll_stats_pid_write(const char __user *buf, size_t len);
static int ll_blksize_seq_show(struct seq_file *m, void *v)
{
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, LPU64"\n", result);
+ seq_printf(m, "%llu\n", result);
}
return rc;
}
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, LPU64"\n", osfs.os_files);
+ seq_printf(m, "%llu\n", osfs.os_files);
return rc;
}
LPROC_SEQ_FOPS_RO(ll_filestotal);
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, LPU64"\n", osfs.os_ffree);
+ seq_printf(m, "%llu\n", osfs.os_ffree);
return rc;
}
LPROC_SEQ_FOPS_RO(ll_filesfree);
LASSERT(sbi != NULL);
- if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
- seq_puts(m, "remote client\n");
- else
- seq_puts(m, "local client\n");
+ seq_puts(m, "local client\n");
return 0;
}
LPROC_SEQ_FOPS_RO(ll_client_type);
pages_number = sbi->ll_ra_info.ra_max_pages;
spin_unlock(&sbi->ll_lock);
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
+ mult = 1 << (20 - PAGE_SHIFT);
return lprocfs_seq_read_frac_helper(m, pages_number, mult);
}
if (rc)
return rc;
- pages_number >>= PAGE_CACHE_SHIFT;
+ pages_number >>= PAGE_SHIFT;
if (pages_number < 0 || pages_number > totalram_pages / 2) {
/* 1/2 of RAM */
CERROR("%s: can't set max_readahead_mb=%lu > %luMB\n",
ll_get_fsname(sb, NULL, 0),
- (unsigned long)pages_number >> (20 - PAGE_CACHE_SHIFT),
- totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1));
+ (unsigned long)pages_number >> (20 - PAGE_SHIFT),
+ totalram_pages >> (20 - PAGE_SHIFT + 1));
return -ERANGE;
}
pages_number = sbi->ll_ra_info.ra_max_pages_per_file;
spin_unlock(&sbi->ll_lock);
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
+ mult = 1 << (20 - PAGE_SHIFT);
return lprocfs_seq_read_frac_helper(m, pages_number, mult);
}
if (rc)
return rc;
- pages_number >>= PAGE_CACHE_SHIFT;
+ pages_number >>= PAGE_SHIFT;
if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) {
CERROR("%s: can't set max_readahead_per_file_mb=%lu > "
"max_read_ahead_mb=%lu\n", ll_get_fsname(sb, NULL, 0),
- (unsigned long)pages_number >> (20 - PAGE_CACHE_SHIFT),
- sbi->ll_ra_info.ra_max_pages >> (20 - PAGE_CACHE_SHIFT));
+ (unsigned long)pages_number >> (20 - PAGE_SHIFT),
+ sbi->ll_ra_info.ra_max_pages >> (20 - PAGE_SHIFT));
return -ERANGE;
}
pages_number = sbi->ll_ra_info.ra_max_read_ahead_whole_pages;
spin_unlock(&sbi->ll_lock);
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
+ mult = 1 << (20 - PAGE_SHIFT);
return lprocfs_seq_read_frac_helper(m, pages_number, mult);
}
if (rc)
return rc;
- pages_number >>= PAGE_CACHE_SHIFT;
+ pages_number >>= PAGE_SHIFT;
/* Cap this at the current max readahead window size, the readahead
* algorithm does this anyway so it's pointless to set it larger. */
if (pages_number < 0 ||
pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
- int pages_shift = 20 - PAGE_CACHE_SHIFT;
+ int pages_shift = 20 - PAGE_SHIFT;
CERROR("%s: can't set max_read_ahead_whole_mb=%lu > "
"max_read_ahead_per_file_mb=%lu\n",
ll_get_fsname(sb, NULL, 0),
struct super_block *sb = m->private;
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct cl_client_cache *cache = sbi->ll_cache;
- int shift = 20 - PAGE_CACHE_SHIFT;
+ int shift = 20 - PAGE_SHIFT;
long max_cached_mb;
long unused_mb;
if (rc)
RETURN(rc);
- pages_number >>= PAGE_CACHE_SHIFT;
+ pages_number >>= PAGE_SHIFT;
if (pages_number < 0 || pages_number > totalram_pages) {
CERROR("%s: can't set max cache more than %lu MB\n",
ll_get_fsname(sb, NULL, 0),
- totalram_pages >> (20 - PAGE_CACHE_SHIFT));
+ totalram_pages >> (20 - PAGE_SHIFT));
RETURN(-ERANGE);
}
/* Allow enough cache so clients can make well-formed RPCs */
if (val >= 0 && val <= LL_SA_RPC_MAX)
sbi->ll_sa_max = val;
else
- CERROR("Bad statahead_max value "LPD64". Valid values are in "
+ CERROR("Bad statahead_max value %lld. Valid values are in "
"the range [0, %d]\n", val, LL_SA_RPC_MAX);
return count;
int mb;
pages = atomic_long_read(&cache->ccc_unstable_nr);
- mb = (pages * PAGE_CACHE_SIZE) >> 20;
+ mb = (pages * PAGE_SIZE) >> 20;
seq_printf(m, "unstable_check: %8d\n"
"unstable_pages: %12ld\n"
do_gettimeofday(&now);
if (!sbi->ll_rw_stats_on) {
- seq_puts(seq, "disabled\n write anything in this file to activate, then 0 or \[D/d]isabled\" to deactivate\n");
- return 0;
- }
+ seq_puts(seq, "disabled\n write anything to this file to activate, then '0' or 'disable' to deactivate\n");
+ return 0;
+ }
seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
now.tv_sec, now.tv_usec);
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
struct ll_sb_info *sbi = seq->private;
struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
int i;
- __s64 value = 1;
- int rc = 0;
+ __s64 value;
if (len == 0)
return -EINVAL;
- rc = lprocfs_str_to_s64(buf, len, &value);
- if (rc < 0 && len < 16) {
- char kernbuf[16];
-
- if (copy_from_user(kernbuf, buf, len))
- return -EFAULT;
- kernbuf[len] = 0;
-
- if (kernbuf[len - 1] == '\n')
- kernbuf[len - 1] = 0;
-
- if (strcmp(kernbuf, "disabled") == 0 ||
- strcmp(kernbuf, "Disabled") == 0)
- value = 0;
- }
+ value = ll_stats_pid_write(buf, len);
if (value == 0)
sbi->ll_rw_stats_on = 0;
do_gettimeofday(&now);
if (!sbi->ll_rw_stats_on) {
- seq_puts(seq, "disabled\n write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n");
+ seq_puts(seq, "disabled\n write anything to this file to activate, then '0' or 'disable' to deactivate\n");
return 0;
}
seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
struct ll_sb_info *sbi = seq->private;
struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
int i;
- __s64 value = 1;
- int rc = 0;
+ __s64 value;
if (len == 0)
return -EINVAL;
- rc = lprocfs_str_to_s64(buf, len, &value);
- if (rc < 0 && len < 16) {
- char kernbuf[16];
-
- if (copy_from_user(kernbuf, buf, len))
- return -EFAULT;
- kernbuf[len] = 0;
-
- if (kernbuf[len - 1] == '\n')
- kernbuf[len - 1] = 0;
-
- if (strcmp(kernbuf, "disabled") == 0 ||
- strcmp(kernbuf, "Disabled") == 0)
- value = 0;
- }
+ value = ll_stats_pid_write(buf, len);
if (value == 0)
sbi->ll_rw_stats_on = 0;
do_gettimeofday(&now);
if (!sbi->ll_rw_stats_on) {
- seq_puts(seq, "disabled\n write anything in this file to activate, then 0 or \"[D/d]isabled\" to deactivate\n");
+ seq_puts(seq, "disabled\n write anything to this file to activate, then '0' or 'disable' to deactivate\n");
return 0;
}
spin_lock(&sbi->ll_process_lock);
struct ll_sb_info *sbi = seq->private;
struct ll_rw_process_info *process_info = sbi->ll_rw_process_info;
struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info;
- __s64 value = 1;
- int rc = 0;
+ __s64 value;
if (len == 0)
return -EINVAL;
- rc = lprocfs_str_to_s64(buf, len, &value);
-
- if (rc < 0 && len < 16) {
- char kernbuf[16];
-
- if (copy_from_user(kernbuf, buf, len))
- return -EFAULT;
- kernbuf[len] = 0;
-
- if (kernbuf[len - 1] == '\n')
- kernbuf[len - 1] = 0;
-
- if (strcmp(kernbuf, "disabled") == 0 ||
- strcmp(kernbuf, "Disabled") == 0)
- value = 0;
- }
+ value = ll_stats_pid_write(buf, len);
if (value == 0)
sbi->ll_rw_stats_on = 0;
return len;
}
+/**
+ * ll_stats_pid_write() - Determine if stats collection should be enabled
+ * @buf: Buffer containing the data written
+ * @len: Number of bytes in the buffer
+ *
+ * Several proc files begin collecting stats when a value is written, and stop
+ * collecting when either '0' or 'disable' is written. This function checks the
+ * written value to see if collection should be enabled or disabled.
+ *
+ * Return: If '0' or 'disable' is provided, 0 is returned. If the text
+ * equivalent of a number is written, that number is returned. Otherwise,
+ * 1 is returned. Non-zero return values indicate collection should be enabled.
+ */
+static __s64 ll_stats_pid_write(const char __user *buf, size_t len)
+{
+ __s64 value = 1;
+ int rc;
+ char kernbuf[16];
+
+ rc = lprocfs_str_to_s64(buf, len, &value);
+
+ if (rc < 0 && len < sizeof(kernbuf)) {
+
+ if (copy_from_user(kernbuf, buf, len))
+ return -EFAULT;
+ kernbuf[len] = 0;
+
+ if (kernbuf[len - 1] == '\n')
+ kernbuf[len - 1] = 0;
+
+ if (strncasecmp(kernbuf, "disable", 7) == 0)
+ value = 0;
+ }
+
+ return value;
+}
+
LPROC_SEQ_FOPS(ll_rw_offset_stats);
#endif /* CONFIG_PROC_FS */