From 8225f96cca29ee360d039f9e58982adea020e66b Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 22 Aug 2005 14:28:25 +0000 Subject: [PATCH] - added missed fix to osc_exit_cache() from 1_4. It updates lost_grant mor carefuly what is important for cases when blocksize is not equal to page size. - fixed warning about init of var in llog test stuff. --- lustre/obdclass/llog_test.c | 5 +++-- lustre/osc/osc_request.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index afbe973..c2bceee 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -231,13 +231,14 @@ static int llog_test_4(struct obd_device *obd) char name[10]; int rc, i, buflen; struct llog_mini_rec lmr; - struct llog_cookie cookie={0}; + struct llog_cookie cookie; struct llog_ctxt *ctxt; int num_recs = 0; char *buf; struct llog_rec_hdr rec; ENTRY; - + + memset(&cookie, 0, sizeof(cookie)); ctxt = llog_get_context(&obd->obd_llogs, LLOG_TEST_ORIG_CTXT); lmr.lmr_hdr.lrh_len = lmr.lmr_tail.lrt_len = LLOG_MIN_REC_SIZE; lmr.lmr_hdr.lrh_type = 0xf00f00; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index de0f529..8fbfb61 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1938,6 +1938,7 @@ out: static void osc_exit_cache(struct client_obd *cli, struct osc_async_page *oap, int sent) { + int blocksize = cli->cl_import->imp_obd->obd_osfs.os_bsize ? : 4096; ENTRY; if (!(oap->oap_brw_flags & OBD_BRW_FROM_GRANT)) { @@ -1969,6 +1970,20 @@ static void osc_exit_cache(struct client_obd *cli, struct osc_async_page *oap, cli->cl_lost_grant += PAGE_SIZE; CDEBUG(D_CACHE, "lost grant: %lu avail grant: %lu dirty: %lu\n", cli->cl_lost_grant, cli->cl_avail_grant, cli->cl_dirty); + } else if (PAGE_SIZE != blocksize && oap->oap_count != PAGE_SIZE) { + /* For short writes we shouldn't count parts of pages that span + * a whole block on the OST side, or our accounting goes wrong. + * Should match the code in filter_grant_check. */ + int offset = (oap->oap_obj_off + oap->oap_page_off) & ~PAGE_MASK; + int count = oap->oap_count + (offset & (blocksize - 1)); + int end = (offset + oap->oap_count) & (blocksize - 1); + if (end) + count += blocksize - end; + + cli->cl_lost_grant += PAGE_SIZE - count; + CDEBUG(D_CACHE, "lost %lu grant: %lu avail: %lu dirty: %lu\n", + PAGE_SIZE - count, cli->cl_lost_grant, + cli->cl_avail_grant, cli->cl_dirty); } EXIT; -- 1.8.3.1