From 5fa49dff33e3df03e8a061c87d61afda3b8c01a5 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Fri, 1 Feb 2013 21:46:17 +0800 Subject: [PATCH] LU-2679 grant: OFD grant as client requested upon reconnect Part of the patch in bz20278 is lost in OFD implementation, add it back: * besides recovery, grant client requested amount on normal reconnect. Signed-off-by: Lai Siyao Change-Id: I9e06316d0bd8602663eef4ba661a4ebfebb6e1bd Reviewed-on: http://review.whamcloud.com/5255 Reviewed-by: Mike Pershin Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/ofd/ofd_dev.c | 3 ++- lustre/ofd/ofd_grant.c | 25 +++++++++++++++++-------- lustre/ofd/ofd_internal.h | 2 +- lustre/ofd/ofd_obd.c | 10 ++++++---- lustre/osc/osc_request.c | 12 ++++++------ 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 3ffba91..29206b3 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -383,7 +383,8 @@ static int ofd_recovery_complete(const struct lu_env *env, * precreate request size (see ofd_grant_create() */ ofd_grant_connect(env, dev->ld_obd->obd_self_export, - OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace); + OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace, + false); rc = next->ld_ops->ldo_recovery_complete(env, next); RETURN(rc); } diff --git a/lustre/ofd/ofd_grant.c b/lustre/ofd/ofd_grant.c index 6a675cc..a0f5cdc 100644 --- a/lustre/ofd/ofd_grant.c +++ b/lustre/ofd/ofd_grant.c @@ -585,9 +585,11 @@ static void ofd_grant_check(const struct lu_env *env, struct obd_export *exp, * \param curgrant - is the current grant claimed by the client * \param want - is how much grant space the client would like to have * \param left - is the remaining free space with granted space taken out + * \param conservative - is how server grants, if true, a certain amount, else + * server will grant as client requested. */ static long ofd_grant(struct obd_export *exp, obd_size curgrant, - obd_size want, obd_size left) + obd_size want, obd_size left, bool conservative) { struct obd_device *obd = exp->exp_obd; struct ofd_device *ofd = ofd_exp(exp); @@ -624,7 +626,10 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, if (curgrant >= want || curgrant >= fed->fed_grant + grant_chunk) RETURN(0); - if (!obd->obd_recovering) + if (obd->obd_recovering) + conservative = false; + + if (conservative) /* don't grant more than 1/8th of the remaining free space in * one chunk */ left >>= 3; @@ -635,8 +640,8 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, if (!grant) RETURN(0); - /* Limit to ofd_grant_chunk() if client is not reconnecting */ - if ((grant > grant_chunk) && (!obd->obd_recovering)) + /* Limit to ofd_grant_chunk() if not reconnect/recovery */ + if ((grant > grant_chunk) && conservative) grant = grant_chunk; ofd->ofd_tot_granted += grant; @@ -669,9 +674,12 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, * \param env - is the lu environment provided by the caller * \param exp - is the client's export which is reconnecting * \param want - is how much the client would like to get + * \param conservative - is how server grants to client, if true server will + * only grant certain amount, else server will grant client requested + * amount. */ long ofd_grant_connect(const struct lu_env *env, struct obd_export *exp, - obd_size want) + obd_size want, bool conservative) { struct ofd_device *ofd = ofd_exp(exp); struct filter_export_data *fed = &exp->exp_filter_data; @@ -703,7 +711,7 @@ refresh: } ofd_grant(exp, ofd_grant_to_cli(exp, ofd, (obd_size)fed->fed_grant), - want, left); + want, left, conservative); /* return to client its current grant */ grant = ofd_grant_to_cli(exp, ofd, (obd_size)fed->fed_grant); @@ -902,7 +910,8 @@ refresh: ofd_grant_shrink(exp, oa, left); else /* grant more space back to the client if possible */ - oa->o_grant = ofd_grant(exp, oa->o_grant, oa->o_undirty, left); + oa->o_grant = ofd_grant(exp, oa->o_grant, oa->o_undirty, left, + true); spin_unlock(&ofd->ofd_grant_lock); } @@ -987,7 +996,7 @@ int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr) /* grant more space (twice as much as needed for this request) for * precreate purpose if possible */ - ofd_grant(exp, fed->fed_grant, wanted * 2, left); + ofd_grant(exp, fed->fed_grant, wanted * 2, left, true); spin_unlock(&ofd->ofd_grant_lock); RETURN(0); } diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index f4ac047..4632151 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -458,7 +458,7 @@ static inline int ofd_grant_prohibit(struct obd_export *exp, void ofd_grant_sanity_check(struct obd_device *obd, const char *func); long ofd_grant_connect(const struct lu_env *env, struct obd_export *exp, - obd_size want); + obd_size want, bool conservative); void ofd_grant_discard(struct obd_export *exp); void ofd_grant_prepare_read(const struct lu_env *env, struct obd_export *exp, struct obdo *oa); diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index ba5ff4d..88943af 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -108,7 +108,8 @@ clean: static int ofd_parse_connect_data(const struct lu_env *env, struct obd_export *exp, - struct obd_connect_data *data) + struct obd_connect_data *data, + bool new_connection) { struct ofd_device *ofd = ofd_exp(exp); struct filter_export_data *fed = &exp->exp_filter_data; @@ -155,7 +156,8 @@ static int ofd_parse_connect_data(const struct lu_env *env, } if (exp_connect_flags(exp) & OBD_CONNECT_GRANT) - data->ocd_grant = ofd_grant_connect(env, exp, data->ocd_grant); + data->ocd_grant = ofd_grant_connect(env, exp, data->ocd_grant, + new_connection); if (data->ocd_connect_flags & OBD_CONNECT_INDEX) { struct lr_server_data *lsd = &ofd->ofd_lut.lut_lsd; @@ -260,7 +262,7 @@ static int ofd_obd_reconnect(const struct lu_env *env, struct obd_export *exp, } ofd_info_init(env, exp); - rc = ofd_parse_connect_data(env, exp, data); + rc = ofd_parse_connect_data(env, exp, data, false); if (rc == 0) ofd_export_stats_init(ofd, exp, localdata); @@ -297,7 +299,7 @@ static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp, ofd_info_init(env, exp); - rc = ofd_parse_connect_data(env, exp, data); + rc = ofd_parse_connect_data(env, exp, data, true); if (rc) GOTO(out, rc); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 4422249..43f0c7e 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1061,12 +1061,12 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) cli->cl_avail_grant = ocd->ocd_grant - cli->cl_dirty; if (cli->cl_avail_grant < 0) { - CWARN("%s: available grant < 0, the OSS is probably not running" - " with patch from bug20278 (%ld) \n", - cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant); - /* workaround for 1.6 servers which do not have - * the patch from bug20278 */ - cli->cl_avail_grant = ocd->ocd_grant; + CWARN("%s: available grant < 0: avail/ocd/dirty %ld/%u/%ld\n", + cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant, + ocd->ocd_grant, cli->cl_dirty); + /* workaround for servers which do not have the patch from + * LU-2679 */ + cli->cl_avail_grant = ocd->ocd_grant; } /* determine the appropriate chunk size used by osc_extent. */ -- 1.8.3.1