From: bobijam Date: Tue, 5 Aug 2008 03:56:20 +0000 (+0000) Subject: Branch b1_6 X-Git-Tag: GIT_EPOCH_B_RELEASE_1_6_7~2^3~393 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=24a97de1a7ef84a1eff95a614f85e9fe0ebfef64;p=fs%2Flustre-release.git Branch b1_6 b=16205 i=joahnn, adilger make obd_max_dirty_pages tunable. --- diff --git a/lustre/obdclass/linux/linux-sysctl.c b/lustre/obdclass/linux/linux-sysctl.c index bb530f2..d79e762 100644 --- a/lustre/obdclass/linux/linux-sysctl.c +++ b/lustre/obdclass/linux/linux-sysctl.c @@ -75,6 +75,7 @@ enum { OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */ OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */ OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */ + OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */ }; int LL_PROC_PROTO(proc_fail_loc) @@ -98,6 +99,46 @@ int LL_PROC_PROTO(proc_set_timeout) return rc; } +int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) +{ + 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, + 1 << (20 - CFS_PAGE_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 > ((num_physpages / 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, ((num_physpages / 10) * 9)); + obd_max_dirty_pages = ((num_physpages / 10) * 9); + } else if (obd_max_dirty_pages < 4 << (20 - CFS_PAGE_SHIFT)) { + obd_max_dirty_pages = 4 << (20 - CFS_PAGE_SHIFT); + } + } else { + char buf[21]; + int len; + + len = lprocfs_read_frac_helper(buf, sizeof(buf), + *(unsigned int*)table->data, + 1 << (20 - CFS_PAGE_SHIFT)); + if (len > *lenp) + len = *lenp; + buf[len] = '\0'; + if (copy_to_user(buffer, buf, len)) + return -EFAULT; + *lenp = len; + } + *ppos += *lenp; + return rc; +} + #ifdef RANDOM_FAIL_ALLOC int LL_PROC_PROTO(proc_alloc_fail_rate) { @@ -109,7 +150,7 @@ int LL_PROC_PROTO(proc_alloc_fail_rate) return 0; } if (write) { - rc = lprocfs_write_frac_helper(buffer, *lenp, + rc = lprocfs_write_frac_helper(buffer, *lenp, (unsigned int*)table->data, OBD_ALLOC_FAIL_MULT); } else { @@ -141,9 +182,9 @@ int LL_PROC_PROTO(proc_memory_alloc) *lenp = 0; return 0; } - if (write) + if (write) return -EINVAL; - + len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum()); if (len > *lenp) len = *lenp; @@ -326,6 +367,14 @@ static cfs_sysctl_table_t obd_table[] = { .proc_handler = &proc_alloc_fail_rate }, #endif + { + .ctl_name = OBD_MAX_DIRTY_PAGES, + .procname = "max_dirty_mb", + .data = &obd_max_dirty_pages, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_max_dirty_pages_in_mb + }, { 0 } };