From 440047b8f7af312f34a6e1f8f0bf7e828726dc1a Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Wed, 23 Jun 2010 11:24:43 +0200 Subject: [PATCH] b=22755 more grant fixes i=oleg i=wangdi - 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); - add OBD_FL_MMAP 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 778caf2..a3965bd 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -108,7 +108,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; @@ -395,7 +395,8 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa, 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; spin_unlock(&obd->obd_osfs_lock); } @@ -749,7 +750,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 1adf2d9..2742590 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -890,6 +890,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); } @@ -940,6 +944,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 20acff7..3039c11 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -723,6 +723,7 @@ void lustre_assert_wire_constants(void) CLASSERT(OBD_FL_CKSUM_CRC32 == (0x00001000)); CLASSERT(OBD_FL_CKSUM_ADLER == (0x00002000)); CLASSERT(OBD_FL_SHRINK_GRANT == (0x00020000)); + 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 47bf94b..282c72b 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -330,6 +330,7 @@ check_obdo(void) CHECK_CDEFINE(OBD_FL_CKSUM_CRC32); CHECK_CDEFINE(OBD_FL_CKSUM_ADLER); CHECK_CDEFINE(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 1585b04..4655ca0 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -721,6 +721,7 @@ void lustre_assert_wire_constants(void) CLASSERT(OBD_FL_CKSUM_CRC32 == (0x00001000)); CLASSERT(OBD_FL_CKSUM_ADLER == (0x00002000)); CLASSERT(OBD_FL_SHRINK_GRANT == (0x00020000)); + CLASSERT(OBD_FL_MMAP == (0x00040000)); CLASSERT(OBD_CKSUM_CRC32 == 1); CLASSERT(OBD_CKSUM_ADLER == 2); -- 1.8.3.1