Whamcloud - gitweb
LU-9671 nodemap: restore client's IDs for OST_WRITE 21/28221/2
authorNiu Yawei <yawei.niu@intel.com>
Fri, 16 Jun 2017 04:52:50 +0000 (00:52 -0400)
committerJohn L. Hammond <john.hammond@intel.com>
Thu, 3 Aug 2017 21:40:53 +0000 (21:40 +0000)
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 <yawei.niu@intel.com>
Change-Id: I375847fa734237f9bcea10fa676e09c471a0fcfb
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: https://review.whamcloud.com/28221
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/ofd/ofd_io.c

index 2ddd44d..5ccdca5 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <linux/kthread.h>
 #include "ofd_internal.h"
+#include <lustre_nodemap.h>
 
 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;