From: Mikhal Pershin Date: Mon, 30 Oct 2017 16:45:42 +0000 (+0300) Subject: LU-10055 mdt: use max_mdsize in reply for layout intent X-Git-Tag: 2.10.58~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F04%2F30004%2F10;p=fs%2Flustre-release.git LU-10055 mdt: use max_mdsize in reply for layout intent The LAYOUT intent reply LVB buffer size is set to a current file layout, meanwhile it is not working when layout is changed and the mdt_max_mdsize is better to use as size of reply buffer. This buffer will be shrinked to the new layout size after all. Without that change the new layout size may be bigger and layout is not returned back, causing extra RPC from client. The mdt_lvbo_fill() is changed also to update mdt_max_mdsize if larger layout is found. The related message level is decreased from D_ERROR to D_INFO. Signed-off-by: Mikhal Pershin Change-Id: Iaac5dcb8b4c5aa2c050dddb5b3fb2662c59f133b Reviewed-on: https://review.whamcloud.com/30004 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 2c1c530..7b0c612 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -3796,13 +3796,22 @@ static int mdt_intent_layout(enum mdt_it_code opcode, if (IS_ERR(obj)) GOTO(out, rc = PTR_ERR(obj)); + if (mdt_object_exists(obj) && !mdt_object_remote(obj)) { - layout_size = mdt_attr_get_eabuf_size(info, obj); - if (layout_size < 0) - GOTO(out_obj, rc = layout_size); + /* if layout is going to be changed don't use the current EA + * size but the maximum one. That buffer will be shrinked + * to the actual size in req_capsule_shrink() before reply. + */ + if (layout.mlc_opc == MD_LAYOUT_WRITE) { + layout_size = info->mti_mdt->mdt_max_mdsize; + } else { + layout_size = mdt_attr_get_eabuf_size(info, obj); + if (layout_size < 0) + GOTO(out_obj, rc = layout_size); - if (layout_size > info->mti_mdt->mdt_max_mdsize) - info->mti_mdt->mdt_max_mdsize = layout_size; + if (layout_size > info->mti_mdt->mdt_max_mdsize) + info->mti_mdt->mdt_max_mdsize = layout_size; + } } /* @@ -3856,7 +3865,6 @@ static int mdt_intent_layout(enum mdt_it_code opcode, if (buf->lb_len > 0) mdt_fix_lov_magic(info, buf->lb_buf); } - /* * Instantiate some layout components, if @buf contains * lovea, then it's a replay of the layout intent write diff --git a/lustre/mdt/mdt_lvb.c b/lustre/mdt/mdt_lvb.c index d3fdb51..6859d42 100644 --- a/lustre/mdt/mdt_lvb.c +++ b/lustre/mdt/mdt_lvb.c @@ -384,11 +384,22 @@ static int mdt_lvbo_fill(struct ldlm_lock *lock, void *lvb, int lvblen) if (rc > 0) { struct lu_buf *lmm = NULL; if (lvblen < rc) { - CERROR("%s: expected %d actual %d.\n", - mdt_obd_name(mdt), rc, lvblen); - /* if layout size is bigger then update max_mdsize */ - if (rc > info->mti_mdt->mdt_max_mdsize) + int level; + + /* The layout EA may be larger than mdt_max_mdsize + * and in that case mdt_max_mdsize is just updated + * but if EA size is less than mdt_max_mdsize then + * it is an error in lvblen value provided. */ + if (rc > info->mti_mdt->mdt_max_mdsize) { info->mti_mdt->mdt_max_mdsize = rc; + level = D_INFO; + } else { + level = D_ERROR; + } + CDEBUG_LIMIT(level, "%s: small buffer size %d for EA " + "%d (max_mdsize %d): rc = %d\n", + mdt_obd_name(mdt), lvblen, rc, + info->mti_mdt->mdt_max_mdsize, -ERANGE); GOTO(out, rc = -ERANGE); } lmm = &info->mti_buf;