From 5303c139e3cef8ed09b85cf828afbbe24ea0d7db Mon Sep 17 00:00:00 2001 From: Li Xi Date: Mon, 21 Apr 2014 22:20:27 +0800 Subject: [PATCH] LU-4933 osc: Automatically tune the max_dirty_mb When RPC size or the max RPCs in flight is increased, the actual limit might be max_dirty_mb value. This patch automatically set that max_dirty_mb value at connection time and when the related values are tuned manually by proc file system. Signed-off-by: Li Xi Change-Id: I95e3e32294a96c4022bcefe392d375583f879b2e Reviewed-on: http://review.whamcloud.com/10034 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger --- lustre/include/obd.h | 12 ++++++++++++ lustre/ldlm/ldlm_lib.c | 6 +++--- lustre/osc/lproc_osc.c | 2 ++ lustre/ptlrpc/import.c | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index b161c115..3abcc4d 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1450,4 +1450,16 @@ static inline int cli_brw_size(struct obd_device *obd) return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; } +static inline void client_adjust_max_dirty(struct client_obd *cli) +{ + /* initializing */ + if (cli->cl_dirty_max <= 0) + cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024; + else + cli->cl_dirty_max = cli->cl_max_rpcs_in_flight * + (cli->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT); + if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > totalram_pages / 8) + cli->cl_dirty_max = totalram_pages << (PAGE_CACHE_SHIFT - 3); +} + #endif /* __OBD_H */ diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index a3769d5..94e4020 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -349,9 +349,9 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_dirty = 0; cli->cl_avail_grant = 0; /* FIXME: Should limit this for the sum of all cl_dirty_max. */ - cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024; - if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > totalram_pages / 8) - cli->cl_dirty_max = totalram_pages << (PAGE_CACHE_SHIFT - 3); + /* cl_dirty_max may be changed at connect time in + * ptlrpc_connect_interpret(). */ + client_adjust_max_dirty(cli); CFS_INIT_LIST_HEAD(&cli->cl_cache_waiters); CFS_INIT_LIST_HEAD(&cli->cl_loi_ready_list); CFS_INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list); diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index 2f8da8c..1dae975 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -111,6 +111,7 @@ static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_rpcs_in_flight = val; + client_adjust_max_dirty(cli); client_obd_list_unlock(&cli->cl_loi_list_lock); LPROCFS_CLIMP_EXIT(dev); @@ -511,6 +512,7 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, } client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_pages_per_rpc = val; + client_adjust_max_dirty(cli); client_obd_list_unlock(&cli->cl_loi_list_lock); LPROCFS_CLIMP_EXIT(dev); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 81cf710..19de797 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1148,6 +1148,7 @@ finish: LASSERT((cli->cl_max_pages_per_rpc <= PTLRPC_MAX_BRW_PAGES) && (cli->cl_max_pages_per_rpc > 0)); + client_adjust_max_dirty(cli); } out: -- 1.8.3.1