Commit 8b364fbd authored by Li Dongyang's avatar Li Dongyang Committed by Oleg Drokin
Browse files

LU-11775 osc: reduce atomic ops in osc_enter_cache_try



We can reduce the number of atomic ops performed on
obd_dirty_pages for the common case.
Signed-off-by: default avatarLi Dongyang <dongyangli@ddn.com>
Change-Id: I5526e449d483241d825af18b612ae1d1dff3241e
Reviewed-on: https://review.whamcloud.com/33859


Tested-by: Jenkins
Tested-by: default avatarMaloo <maloo@whamcloud.com>
Reviewed-by: default avatarPatrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: default avatarAlexey Lyashkov <c17817@cray.com>
Reviewed-by: default avatarOleg Drokin <green@whamcloud.com>
parent b7176631
......@@ -1403,7 +1403,6 @@ static void osc_consume_write_grant(struct client_obd *cli,
{
assert_spin_locked(&cli->cl_loi_list_lock);
LASSERT(!(pga->flag & OBD_BRW_FROM_GRANT));
atomic_long_inc(&obd_dirty_pages);
cli->cl_dirty_pages++;
pga->flag |= OBD_BRW_FROM_GRANT;
CDEBUG(D_CACHE, "using %lu grant credits for brw %p page %p\n",
......@@ -1547,19 +1546,23 @@ static int osc_enter_cache_try(struct client_obd *cli,
if (rc < 0)
return 0;
if (cli->cl_dirty_pages < cli->cl_dirty_max_pages &&
1 + atomic_long_read(&obd_dirty_pages) <= obd_max_dirty_pages) {
osc_consume_write_grant(cli, &oap->oap_brw_page);
if (transient) {
cli->cl_dirty_transit++;
atomic_long_inc(&obd_dirty_transit_pages);
oap->oap_brw_flags |= OBD_BRW_NOCACHE;
}
rc = 1;
} else {
__osc_unreserve_grant(cli, bytes, bytes);
rc = 0;
if (cli->cl_dirty_pages < cli->cl_dirty_max_pages) {
if (atomic_long_add_return(1, &obd_dirty_pages) <=
obd_max_dirty_pages) {
osc_consume_write_grant(cli, &oap->oap_brw_page);
if (transient) {
cli->cl_dirty_transit++;
atomic_long_inc(&obd_dirty_transit_pages);
oap->oap_brw_flags |= OBD_BRW_NOCACHE;
}
rc = 1;
goto out;
} else
atomic_long_dec(&obd_dirty_pages);
}
__osc_unreserve_grant(cli, bytes, bytes);
out:
return rc;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment