From: Niu Yawei Date: Fri, 16 Jun 2017 04:52:50 +0000 (-0400) Subject: LU-9671 nodemap: restore client's IDs for OST_WRITE X-Git-Tag: 2.10.1-RC1~74 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0bef1fb84d6d93c36db90f92f8f9fc2e68baaa97;p=fs%2Flustre-release.git LU-9671 nodemap: restore client's IDs for OST_WRITE Client sets overquota flags for certain UID/GID based on the IDs & flags in OST_WRITE reply, so we need to reply client IDs instead of mapped IDs. Lustre-change: https://review.whamcloud.com/27680 Lustre-commit: e207f9f96fc51f3b6d219193cca3d83aaa99b3e8 Signed-off-by: Niu Yawei Change-Id: I375847fa734237f9bcea10fa676e09c471a0fcfb Reviewed-by: Fan Yong Reviewed-by: Stephan Thiell Reviewed-by: Andreas Dilger Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/28221 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond --- diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 2ddd44d..5ccdca5 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -42,6 +42,7 @@ #include #include "ofd_internal.h" +#include struct ofd_inconsistency_item { struct list_head oii_list; @@ -1202,6 +1203,8 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, LASSERT(npages > 0); if (cmd == OBD_BRW_WRITE) { + struct lu_nodemap *nodemap; + /* Don't update timestamps if this write is older than a * setattr which modifies the timestamps. b=10150 */ @@ -1260,6 +1263,20 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, oa->o_valid |= OBD_MD_FLFLAGS; oa->o_valid |= OBD_MD_FLALLQUOTA; } + + /* Convert back to client IDs. LU-9671. + * nodemap_get_from_exp() may fail due to nodemap deactivated, + * server ID will be returned back to client in that case. */ + nodemap = nodemap_get_from_exp(exp); + if (nodemap != NULL && !IS_ERR(nodemap)) { + oa->o_uid = nodemap_map_id(nodemap, NODEMAP_UID, + NODEMAP_FS_TO_CLIENT, + oa->o_uid); + oa->o_gid = nodemap_map_id(nodemap, NODEMAP_GID, + NODEMAP_FS_TO_CLIENT, + oa->o_gid); + nodemap_putref(nodemap); + } } else if (cmd == OBD_BRW_READ) { struct ldlm_namespace *ns = ofd->ofd_namespace;