From: Niu Yawei Date: Mon, 6 Feb 2012 06:02:07 +0000 (-0800) Subject: LU-1051 osd: reserve less credits for llog unlink X-Git-Tag: 2.1.58~28 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4000adc51d76e329b0ba941a7524f9c77780fd4c LU-1051 osd: reserve less credits for llog unlink Reserve less credits for the llog write and catalog header udpate. Since we can't get the llog inode in osd declare function, we use a temporary solution: hack the 'size' parameter to indicate a llog write or catalog header udpate. Signed-off-by: Niu Yawei Change-Id: Ic5df00a878cdbf64a44b22b684e2c6b2dff83b07 Reviewed-on: http://review.whamcloud.com/2100 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index cd52a7d..f7b23d9 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -62,6 +62,10 @@ #include #include +/* LU-1051, temperary solution to reduce llog credits */ +#define DECLARE_LLOG_REWRITE 0 +#define DECLARE_LLOG_WRITE INT_MAX + struct md_device; struct md_device_operations; struct md_object; diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 2c1ffec..c7e2486 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -581,14 +581,29 @@ int mdd_declare_llog_record(const struct lu_env *env, struct mdd_device *mdd, LASSERT(mdd->mdd_capa); + /* XXX: Since we use the 'mdd_capa' as fake llog object here, we + * have to set the parameter 'size' as INT_MAX or 0 to inform + * OSD that this record write is for a llog write or catalog + * header update, and osd declare function will reserve less + * credits for optimization purpose. + * + * Reserve 6 blocks for a llog write, since the llog file is + * usually small, reserve 2 blocks for catalog header update, + * because we know for sure that catalog header is already + * allocated. + * + * This hack should be removed in 2.3. + */ + /* record itself */ - rc = dt_declare_record_write(env, mdd->mdd_capa, reclen, 0, handle); + rc = dt_declare_record_write(env, mdd->mdd_capa, + DECLARE_LLOG_WRITE, 0, handle); if (rc) return rc; /* header will be updated as well */ - rc = dt_declare_record_write(env, mdd->mdd_capa, LLOG_CHUNK_SIZE, - 0, handle); + rc = dt_declare_record_write(env, mdd->mdd_capa, + DECLARE_LLOG_WRITE, 0, handle); if (rc) return rc; @@ -599,13 +614,13 @@ int mdd_declare_llog_record(const struct lu_env *env, struct mdd_device *mdd, /* new record referencing new plain llog */ rc = dt_declare_record_write(env, mdd->mdd_capa, - sizeof(struct llog_logid_rec), 0, handle); + DECLARE_LLOG_WRITE, 0, handle); if (rc) return rc; /* catalog's header will be updated as well */ - rc = dt_declare_record_write(env, mdd->mdd_capa, LLOG_CHUNK_SIZE, - 0, handle); + rc = dt_declare_record_write(env, mdd->mdd_capa, + DECLARE_LLOG_REWRITE, 0, handle); return rc; } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index aedf8dd..4f41e1f 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -3052,14 +3052,27 @@ static ssize_t osd_declare_write(const struct lu_env *env, struct dt_object *dt, struct thandle *handle) { struct osd_thandle *oh; + int credits; LASSERT(handle != NULL); oh = container_of0(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); + /* XXX: size == 0 or INT_MAX indicating a catalog header update or + * llog write, see comment in mdd_declare_llog_record(). + * + * This hack should be removed in 2.3 + */ + if (size == DECLARE_LLOG_REWRITE) + credits = 2; + else if (size == DECLARE_LLOG_WRITE) + credits = 6; + else + credits = osd_dto_credits_noquota[DTO_WRITE_BLOCK]; + OSD_DECLARE_OP(oh, write); - oh->ot_credits += osd_dto_credits_noquota[DTO_WRITE_BLOCK]; + oh->ot_credits += credits; if (osd_dt_obj(dt)->oo_inode == NULL) return 0;