Whamcloud - gitweb
LU-9671 nodemap: restore client's IDs for OST_WRITE 80/27680/4
authorNiu Yawei <yawei.niu@intel.com>
Fri, 16 Jun 2017 04:52:50 +0000 (00:52 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Jul 2017 03:28:26 +0000 (03:28 +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.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I375847fa734237f9bcea10fa676e09c471a0fcfb
Reviewed-on: https://review.whamcloud.com/27680
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@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;