Exemplo n.º 1
0
int LL_PROC_PROTO(proc_alloc_fail_rate)
{
	int rc	  = 0;
	DECLARE_LL_PROC_PPOS_DECL;

	if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
		*lenp = 0;
		return 0;
	}
	if (write) {
		rc = lprocfs_write_frac_helper(buffer, *lenp,
					       (unsigned int*)table->data,
					       OBD_ALLOC_FAIL_MULT);
	} else {
		char buf[21];
		int  len;

		len = lprocfs_read_frac_helper(buf, 21,
					       *(unsigned int*)table->data,
					       OBD_ALLOC_FAIL_MULT);
		if (len > *lenp)
			len = *lenp;
		buf[len] = '\0';
		if (copy_to_user(buffer, buf, len))
			return -EFAULT;
		*lenp = len;
	}
	*ppos += *lenp;
	return rc;
}
Exemplo n.º 2
0
int proc_alloc_fail_rate(struct ctl_table *table, int write,
			 void __user *buffer, size_t *lenp, loff_t *ppos)
{
        int rc          = 0;

        if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
                *lenp = 0;
                return 0;
        }
        if (write) {
                rc = lprocfs_write_frac_helper(buffer, *lenp,
                                               (unsigned int*)table->data,
                                               OBD_ALLOC_FAIL_MULT);
        } else {
                char buf[21];
                int  len;

                len = lprocfs_read_frac_helper(buf, 21,
                                               *(unsigned int*)table->data,
                                               OBD_ALLOC_FAIL_MULT);
                if (len > *lenp)
                        len = *lenp;
                buf[len] = '\0';
		if (copy_to_user(buffer, buf, len))
                        return -EFAULT;
                *lenp = len;
        }
        *ppos += *lenp;
        return rc;
}
Exemplo n.º 3
0
static int osc_rd_max_dirty_mb(char *page, char **start, off_t off, int count,
                               int *eof, void *data)
{
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
        long val;
        int mult;

        client_obd_list_lock(&cli->cl_loi_list_lock);
        val = cli->cl_dirty_max;
        client_obd_list_unlock(&cli->cl_loi_list_lock);

        mult = 1 << 20;
        return lprocfs_read_frac_helper(page, count, val, mult);
}
Exemplo n.º 4
0
static int
proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
			   void __user *buffer, size_t *lenp, loff_t *ppos)
{
	__u64 val;
	int rc = 0;

	if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
		*lenp = 0;
		return 0;
	}
	if (write) {
		rc = lprocfs_write_frac_u64_helper(buffer, *lenp, &val,
					       1 << (20 - PAGE_CACHE_SHIFT));

		/* Don't allow them to let dirty pages exceed 90% of system
		 * memory and set a hard minimum of 4MB. */
		if (val > ((totalram_pages / 10) * 9)) {
			CERROR("Refusing to set max dirty pages to "LPU64", "
			       "which is more than 90%% of available RAM; "
			       "setting to %lu\n", val,
			       ((totalram_pages / 10) * 9));
			obd_max_dirty_pages = ((totalram_pages / 10) * 9);
		} else if (val < 4 << (20 - PAGE_CACHE_SHIFT)) {
			obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
		} else {
			obd_max_dirty_pages = val;
		}
	} else {
		char buf[21];
		int len;

		len = lprocfs_read_frac_helper(buf, sizeof(buf),
					       *(unsigned long *)table->data,
					       1 << (20 - PAGE_CACHE_SHIFT));
		if (len > *lenp)
			len = *lenp;
		buf[len] = '\0';
		if (copy_to_user(buffer, buf, len))
			return -EFAULT;
		*lenp = len;
	}
	*ppos += *lenp;
	return rc;
}
Exemplo n.º 5
0
int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
{
	int rc = 0;
	DECLARE_LL_PROC_PPOS_DECL;

	if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
		*lenp = 0;
		return 0;
	}
	if (write) {
		rc = lprocfs_write_frac_helper(buffer, *lenp,
					       (unsigned int*)table->data,
					       1 << (20 - PAGE_CACHE_SHIFT));
		/* Don't allow them to let dirty pages exceed 90% of system
		 * memory and set a hard minimum of 4MB. */
		if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
			CERROR("Refusing to set max dirty pages to %u, which "
			       "is more than 90%% of available RAM; setting "
			       "to %lu\n", obd_max_dirty_pages,
			       ((totalram_pages / 10) * 9));
			obd_max_dirty_pages = ((totalram_pages / 10) * 9);
		} else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
			obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
		}
	} else {
		char buf[21];
		int len;

		len = lprocfs_read_frac_helper(buf, sizeof(buf),
					       *(unsigned int*)table->data,
					       1 << (20 - PAGE_CACHE_SHIFT));
		if (len > *lenp)
			len = *lenp;
		buf[len] = '\0';
		if (copy_to_user(buffer, buf, len))
			return -EFAULT;
		*lenp = len;
	}
	*ppos += *lenp;
	return rc;
}