From 863de7db65825b5862459127da1140d3ac5bcc41 Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Tue, 4 Jun 2013 17:46:29 +0200 Subject: [PATCH] LU-3421 grant: more aggressively book space for precreate - ofd_grant() should not round sub-block allocation to 0. - ofd_grant_create() should be more aggressive in reserving space. Precreation should try to always have enough grant space to process a very large preallocation request. Signed-off-by: Johann Lombardi Change-Id: I5803b2d5fae216edcaae124d3b50b589c02e7251 Reviewed-on: http://review.whamcloud.com/6546 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- lustre/ofd/ofd_dev.c | 12 ++++++------ lustre/ofd/ofd_grant.c | 23 ++++++++++++++--------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 20e3c59..a9237f7 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -373,17 +373,17 @@ static int ofd_recovery_complete(const struct lu_env *env, { struct ofd_device *ofd = ofd_dev(dev); struct lu_device *next = &ofd->ofd_osd->dd_lu_dev; - int rc = 0; + int rc = 0, max_precreate; ENTRY; /* Grant space for object precreation on the self export. - * This initial reserved space (i.e. 20MB for zfs and 560KB for ldiskfs) - * is enough to create 20k objects. It is then adapted based on the - * precreate request size (see ofd_grant_create() + * This initial reserved space (i.e. 10MB for zfs and 280KB for ldiskfs) + * is enough to create 10k objects. More space is then acquired for + * precreation in ofd_grant_create(). */ - ofd_grant_connect(env, dev->ld_obd->obd_self_export, - OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace, + max_precreate = OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace / 2; + ofd_grant_connect(env, dev->ld_obd->obd_self_export, max_precreate, 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 83a0ecb..a27a73e 100644 --- a/lustre/ofd/ofd_grant.c +++ b/lustre/ofd/ofd_grant.c @@ -72,7 +72,7 @@ static inline obd_size ofd_grant_chunk(struct obd_export *exp, { if (ofd_obd(ofd)->obd_self_export == exp) /* Grant enough space to handle a big precreate request */ - return OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace; + return OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace / 2; if (ofd_grant_compat(exp, ofd)) /* Try to grant enough space to send a full-size RPC */ @@ -610,8 +610,8 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, /* client not supporting OBD_CONNECT_GRANT_PARAM works with a 4KB block * size while the reality is different */ - curgrant = ofd_grant_from_cli(exp, ofd, curgrant); - want = ofd_grant_from_cli(exp, ofd, want); + curgrant = ofd_grant_from_cli(exp, ofd, curgrant); + want = ofd_grant_from_cli(exp, ofd, want); grant_chunk = ofd_grant_chunk(exp, ofd); /* Grant some fraction of the client's requested grant space so that @@ -634,8 +634,9 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, * one chunk */ left >>= 3; grant = min(want, left); - /* align grant on block size */ - grant &= ~((1ULL << ofd->ofd_blockbits) - 1); + /* round grant upt to the next block size */ + grant = (grant + (1 << ofd->ofd_blockbits) - 1) & + ~((1ULL << ofd->ofd_blockbits) - 1); if (!grant) RETURN(0); @@ -931,7 +932,6 @@ int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr) struct filter_export_data *fed = &exp->exp_filter_data; obd_size left = 0; unsigned long wanted; - ENTRY; info->fti_used = 0; @@ -994,9 +994,14 @@ int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr) fed->fed_pending += info->fti_used; ofd->ofd_tot_pending += info->fti_used; - /* 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, true); + /* grant more space for precreate purpose if possible. */ + wanted = OST_MAX_PRECREATE * ofd->ofd_dt_conf.ddp_inodespace / 2; + if (wanted > fed->fed_grant) { + /* always try to book enough space to handle a large precreate + * request */ + wanted -= fed->fed_grant; + ofd_grant(exp, fed->fed_grant, wanted, left, false); + } spin_unlock(&ofd->ofd_grant_lock); RETURN(0); } -- 1.8.3.1