12a457
From 1b683e5e26f91cb55c23e07cf6e33ce3ef62283b Mon Sep 17 00:00:00 2001
12a457
From: Jiffin Tony Thottan <jthottan@redhat.com>
12a457
Date: Mon, 6 Jun 2016 18:10:09 +0530
12a457
Subject: [PATCH 191/192] nfs : store sattr properly in nfs3_setattr() call
12a457
12a457
nfs3_setattr stores the input arguments in cs->stbuf.
12a457
However, inode/entry resolution code overwrites cs->stbuf
12a457
after a successful resolution, thereby overwriting the
12a457
input arguments with iatt values stored on backend.
12a457
Hence operations like chmod/chown turns out to be a NOP.
12a457
Specifically following are the functions that overwrite
12a457
cs->stbuf:
12a457
12a457
    nfs3_fh_resolve_inode_lookup_cbk
12a457
    nfs3_fh_resolve_entry_lookup_cbk
12a457
12a457
Since we resort to inode resolution only when inode is not
12a457
found in inode table and lru limit guards the number of
12a457
inodes in itable, we run into this issue only when the data
12a457
set is bigger than lru limit of itable.
12a457
12a457
Fix is to store input arguments in a member other than
12a457
cs->stbuf.
12a457
12a457
Thanks Du for suggesting the fix
12a457
12a457
        Backport of http://review.gluster.org/#/c/14657/
12a457
12a457
> Change-Id: I7caef48839d4f177c3557d7823fc1d35c8294939
12a457
> BUG: 1318204
12a457
> Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
12a457
> Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com>
12a457
12a457
Change-Id: I7caef48839d4f177c3557d7823fc1d35c8294939
12a457
BUG: 1336753
12a457
Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com>
12a457
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/76053
12a457
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
12a457
Tested-by: Kaleb Keithley <kkeithle@redhat.com>
12a457
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
12a457
---
12a457
 xlators/nfs/server/src/nfs3.c |    9 +++++----
12a457
 xlators/nfs/server/src/nfs3.h |    1 +
12a457
 2 files changed, 6 insertions(+), 4 deletions(-)
12a457
12a457
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
12a457
index aa7af31..2bcf85b 100644
12a457
--- a/xlators/nfs/server/src/nfs3.c
12a457
+++ b/xlators/nfs/server/src/nfs3.c
12a457
@@ -1024,10 +1024,11 @@ nfs3svc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
12a457
          */
12a457
         if ((gf_attr_size_set (cs->setattr_valid)) &&
12a457
             (!IA_ISDIR (postop->ia_type)) &&
12a457
-            (preop->ia_size != cs->stbuf.ia_size)) {
12a457
+            (preop->ia_size != cs->attr_in.ia_size)) {
12a457
                 nfs_request_user_init (&nfu, cs->req);
12a457
                 ret = nfs_truncate (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc,
12a457
-                                    cs->stbuf.ia_size, nfs3svc_truncate_cbk,cs);
12a457
+                                    cs->attr_in.ia_size, nfs3svc_truncate_cbk,
12a457
+                                    cs);
12a457
 
12a457
                 if (ret < 0)
12a457
                         stat = nfs3_errno_to_nfsstat3 (-ret);
12a457
@@ -1110,7 +1111,7 @@ nfs3_setattr_resume (void *carg)
12a457
         nfs3_check_fh_resolve_status (cs, stat, nfs3err);
12a457
         nfs_request_user_init (&nfu, cs->req);
12a457
         ret = nfs_setattr (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc,
12a457
-                           &cs->stbuf, cs->setattr_valid,
12a457
+                           &cs->attr_in, cs->setattr_valid,
12a457
                            nfs3svc_setattr_cbk, cs);
12a457
 
12a457
         if (ret < 0)
12a457
@@ -1152,7 +1153,7 @@ nfs3_setattr (rpcsvc_request_t *req, struct nfs3_fh *fh, sattr3 *sattr,
12a457
         nfs3_check_rw_volaccess (nfs3, fh->exportid, stat, nfs3err);
12a457
         nfs3_handle_call_state_init (nfs3, cs, req, vol, stat, nfs3err);
12a457
 
12a457
-        cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->stbuf,
12a457
+        cs->setattr_valid = nfs3_sattr3_to_setattr_valid (sattr, &cs->attr_in,
12a457
                                                           NULL);
12a457
         if (guard->check) {
12a457
                 gf_msg_trace (GF_NFS3, 0, "Guard check required");
12a457
diff --git a/xlators/nfs/server/src/nfs3.h b/xlators/nfs/server/src/nfs3.h
12a457
index f1b89fe..fd7cc0d 100644
12a457
--- a/xlators/nfs/server/src/nfs3.h
12a457
+++ b/xlators/nfs/server/src/nfs3.h
12a457
@@ -230,6 +230,7 @@ struct nfs3_local {
12a457
         cookie3                 cookie;
12a457
         struct iovec            datavec;
12a457
         mode_t                  mode;
12a457
+        struct iatt             attr_in;
12a457
 
12a457
         /* NFSv3 FH resolver state */
12a457
         int                     hardresolved;
12a457
-- 
12a457
1.7.1
12a457