Whamcloud - gitweb
LU-2139 osc: Track number of "unstable" pages per osc 74/4374/10
authorPrakash Surya <surya1@llnl.gov>
Mon, 22 Oct 2012 20:38:11 +0000 (13:38 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 4 Nov 2013 03:09:46 +0000 (03:09 +0000)
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 <surya1@llnl.gov>
Change-Id: Ife1f90515cb60ba9f85daba5d50483562f2697d1
Reviewed-on: http://review.whamcloud.com/4374
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/osc/lproc_osc.c
lustre/osc/osc_cache.c

index bf14b7d..121063a 100644 (file)
@@ -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;
index 961faea..4e042bb 100644 (file)
@@ -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);
index b43dd5b..0ea5719 100644 (file)
@@ -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 }
 };
 
index df3dec4..1b35afd 100644 (file)
@@ -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);