From 07ee41661fec73addd3c73bea3d516a99d92d5c8 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Mon, 22 Oct 2012 13:38:11 -0700 Subject: [PATCH] LU-2139 osc: Track number of "unstable" pages per osc This change adds simple accounting hooks for "unstable" pages on a per OSC basis. Now, in addition to the per filesystem tracking, each OSC will maintain a running total of its unstable pages. These counters are exported through the proc interface, and can be read using the lctl command. For example: # Read number of unstable pages contained by each OSC lctl get_param osc.*.unstable_stats The motivation for this change is in anticipation of implementing a "soft sync" functionality, urging servers to commit these unstable pages to stable storage. The per OSC accounting allows a client to limit the soft sync request to only the OSCs which have outstanding unstable pages. Signed-off-by: Prakash Surya Change-Id: Ife1f90515cb60ba9f85daba5d50483562f2697d1 Reviewed-on: http://review.whamcloud.com/4374 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/obd.h | 1 + lustre/ldlm/ldlm_lib.c | 1 + lustre/osc/lproc_osc.c | 18 ++++++++++++++++++ lustre/osc/osc_cache.c | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index bf14b7d..121063a 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -401,6 +401,7 @@ struct client_obd { cfs_atomic_t cl_lru_in_list; cfs_list_t cl_lru_list; /* lru page list */ client_obd_lock_t cl_lru_list_lock; /* page list protector */ + cfs_atomic_t cl_unstable_count; /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ cfs_atomic_t cl_destroy_in_flight; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 961faea..4e042bb 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -370,6 +370,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cfs_atomic_set(&cli->cl_lru_in_list, 0); CFS_INIT_LIST_HEAD(&cli->cl_lru_list); client_obd_list_lock_init(&cli->cl_lru_list_lock); + cfs_atomic_set(&cli->cl_unstable_count, 0); init_waitqueue_head(&cli->cl_destroy_waitq); cfs_atomic_set(&cli->cl_destroy_in_flight, 0); diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index b43dd5b..0ea5719 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -496,6 +496,22 @@ static int lprocfs_osc_wr_max_pages_per_rpc(struct file *file, return count; } +static int osc_rd_unstable_stats(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; + int pages, mb; + + pages = cfs_atomic_read(&cli->cl_unstable_count); + mb = (pages * PAGE_CACHE_SIZE) >> 20; + + return snprintf(page, count, + "unstable_pages: %8d\n" + "unstable_mb: %8d\n", + pages, mb); +} + static struct lprocfs_vars lprocfs_osc_obd_vars[] = { { "uuid", lprocfs_rd_uuid, 0, 0 }, { "ping", 0, lprocfs_wr_ping, 0, 0, 0222 }, @@ -536,6 +552,8 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = { { "state", lprocfs_rd_state, 0, 0 }, { "pinger_recov", lprocfs_rd_pinger_recov, lprocfs_wr_pinger_recov, 0, 0 }, + { "unstable_stats", osc_rd_unstable_stats, 0, 0}, + { 0 } }; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index df3dec4..1b35afd 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -1804,6 +1804,9 @@ void osc_dec_unstable_pages(struct ptlrpc_request *req) cfs_atomic_sub(page_count, &cli->cl_cache->ccc_unstable_nr); LASSERT(cfs_atomic_read(&cli->cl_cache->ccc_unstable_nr) >= 0); + cfs_atomic_sub(page_count, &cli->cl_unstable_count); + LASSERT(cfs_atomic_read(&cli->cl_unstable_count) >= 0); + cfs_atomic_sub(page_count, &obd_unstable_pages); LASSERT(cfs_atomic_read(&obd_unstable_pages) >= 0); @@ -1835,6 +1838,9 @@ void osc_inc_unstable_pages(struct ptlrpc_request *req) LASSERT(cfs_atomic_read(&cli->cl_cache->ccc_unstable_nr) >= 0); cfs_atomic_add(page_count, &cli->cl_cache->ccc_unstable_nr); + LASSERT(cfs_atomic_read(&cli->cl_unstable_count) >= 0); + cfs_atomic_add(page_count, &cli->cl_unstable_count); + LASSERT(cfs_atomic_read(&obd_unstable_pages) >= 0); cfs_atomic_add(page_count, &obd_unstable_pages); -- 1.8.3.1