From 593755f5a990388d152ce593fd576a127154b35a Mon Sep 17 00:00:00 2001 From: Cliff White Date: Tue, 5 Oct 2010 11:08:32 -0700 Subject: [PATCH] b=22755 more shrink grant fixes i=di.wang i=oleg.drokin - filter_preprw_write() should check for OBD_FL_SHRINK_GRANT in o_flags instead of o_valid; - The grant shrink code should not use o_flags w/o setting OBD_MD_FLFLAGS since o_flags can be legitimately reset if OBD_MD_FLFLAGS (e.g. it is done in the checksum code); - OBD_FL_MMAP is added to wiretest & wirecheck --- lustre/obdfilter/filter_io.c | 9 ++++++--- lustre/osc/osc_request.c | 8 ++++++++ lustre/ptlrpc/wiretest.c | 1 + lustre/utils/wirecheck.c | 1 + lustre/utils/wiretest.c | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 45bf870..268dec1 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -109,7 +109,7 @@ void filter_grant_incoming(struct obd_export *exp, struct obdo *oa) fed->fed_grant -= oa->o_dropped; fed->fed_dirty = oa->o_dirty; - if (oa->o_flags & OBD_FL_SHRINK_GRANT) { + if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & OBD_FL_SHRINK_GRANT) { obd_size left_space = filter_grant_space_left(exp); struct filter_obd *filter = &exp->exp_obd->u.filter; @@ -401,7 +401,8 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa, cfs_spin_lock(&obd->obd_osfs_lock); filter_grant_incoming(exp, oa); - if (!(oa->o_flags & OBD_FL_SHRINK_GRANT)) + if (!(oa->o_valid & OBD_MD_FLFLAGS) || + !(oa->o_flags & OBD_FL_SHRINK_GRANT)) oa->o_grant = 0; cfs_spin_unlock(&obd->obd_osfs_lock); } @@ -767,7 +768,9 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa, * so no sense in allocating it some more. We either return the grant * back to the client if we have plenty of space or we don't return * anything if we are short. This was decided in filter_grant_incoming*/ - if (oa->o_valid & OBD_MD_FLGRANT &&!(oa->o_valid & OBD_FL_SHRINK_GRANT)) + if ((oa->o_valid & OBD_MD_FLGRANT) && + (!(oa->o_valid & OBD_MD_FLFLAGS) || + !(oa->o_flags & OBD_FL_SHRINK_GRANT))) oa->o_grant = filter_grant(exp, oa->o_grant, oa->o_undirty, left, 1); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f4c5dd0..17f088c 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -966,6 +966,10 @@ static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa) oa->o_grant = cli->cl_avail_grant / 4; cli->cl_avail_grant -= oa->o_grant; client_obd_list_unlock(&cli->cl_loi_list_lock); + if (!(oa->o_valid & OBD_MD_FLFLAGS)) { + oa->o_valid |= OBD_MD_FLFLAGS; + oa->o_flags = 0; + } oa->o_flags |= OBD_FL_SHRINK_GRANT; osc_update_next_shrink(cli); } @@ -1016,6 +1020,10 @@ int osc_shrink_grant_to_target(struct client_obd *cli, long target) body->oa.o_grant = cli->cl_avail_grant - target; cli->cl_avail_grant = target; client_obd_list_unlock(&cli->cl_loi_list_lock); + if (!(body->oa.o_valid & OBD_MD_FLFLAGS)) { + body->oa.o_valid |= OBD_MD_FLFLAGS; + body->oa.o_flags = 0; + } body->oa.o_flags |= OBD_FL_SHRINK_GRANT; osc_update_next_shrink(cli); diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 9898ae9..e819c88 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -661,6 +661,7 @@ void lustre_assert_wire_constants(void) CLASSERT(OBD_FL_CKSUM_CRC32 == 4096); CLASSERT(OBD_FL_CKSUM_ADLER == 8192); CLASSERT(OBD_FL_SHRINK_GRANT == 131072); + CLASSERT(OBD_FL_MMAP == (0x00040000)); CLASSERT(OBD_CKSUM_CRC32 == 1); CLASSERT(OBD_CKSUM_ADLER == 2); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 09da35d..d574047 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -308,6 +308,7 @@ check_obdo(void) CHECK_CVALUE(OBD_FL_CKSUM_CRC32); CHECK_CVALUE(OBD_FL_CKSUM_ADLER); CHECK_CVALUE(OBD_FL_SHRINK_GRANT); + CHECK_CDEFINE(OBD_FL_MMAP); CHECK_CVALUE(OBD_CKSUM_CRC32); CHECK_CVALUE(OBD_CKSUM_ADLER); } diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 2a4a52a..7da51fd 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -658,6 +658,7 @@ void lustre_assert_wire_constants(void) CLASSERT(OBD_FL_CKSUM_CRC32 == 4096); CLASSERT(OBD_FL_CKSUM_ADLER == 8192); CLASSERT(OBD_FL_SHRINK_GRANT == 131072); + CLASSERT(OBD_FL_MMAP == (0x00040000)); CLASSERT(OBD_CKSUM_CRC32 == 1); CLASSERT(OBD_CKSUM_ADLER == 2); -- 1.8.3.1