linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sachin Prabhu <sprabhu@redhat.com>
To: Linux NFS mailing list <linux-nfs@vger.kernel.org>
Cc: Trond Myklebust <trond.myklebust@netapp.com>
Subject: [PATCH 2/2] Simplify check for size of ACL returned in __nfs4_get_acl_uncached
Date: Wed,  1 Aug 2012 14:29:31 +0100	[thread overview]
Message-ID: <1343827771-6258-3-git-send-email-sprabhu@redhat.com> (raw)
In-Reply-To: <1343827771-6258-1-git-send-email-sprabhu@redhat.com>

Rename flag ACL_LEN_REQEST to NFS4_ACL_LEN_ONLY. Apart from using this
flag during a request to indicate that the user is only interested in
the length of the ACL, we now also use it in the response stage to
indicate that the data returned holds the complete ACL or just the
length.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 fs/nfs/nfs4proc.c       | 4 ++--
 fs/nfs/nfs4xdr.c        | 4 +++-
 include/linux/nfs_xdr.h | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index be03b95..aaa98f0 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3760,7 +3760,7 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
 	/* Let decode_getfacl know not to fail if the ACL data is larger than
 	 * the page we send as a guess */
 	if (buf == NULL)
-		res.acl_flags |= NFS4_ACL_LEN_REQUEST;
+		res.acl_flags |= NFS4_ACL_LEN_ONLY;
 
 	dprintk("%s  buf %p buflen %zu npages %d args.acl_len %zu\n",
 		__func__, buf, buflen, npages, args.acl_len);
@@ -3770,7 +3770,7 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
 		goto out_free;
 
 	acl_len = res.acl_len - res.acl_data_offset;
-	if (res.acl_len > args.acl_len)
+	if (res.acl_flags & NFS4_ACL_LEN_ONLY)
 		nfs4_write_cached_acl(inode, NULL, 0, acl_len);
 	else
 		nfs4_write_cached_acl(inode, pages, res.acl_data_offset,
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 18fae29..a88fcd0 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -5101,7 +5101,7 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
 		hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
 		attrlen += res->acl_data_offset;
 		if (attrlen > page_len) {
-			if (res->acl_flags & NFS4_ACL_LEN_REQUEST) {
+			if (res->acl_flags & NFS4_ACL_LEN_ONLY) {
 				/* getxattr interface called with a NULL buf */
 				res->acl_len = attrlen;
 				goto out;
@@ -5110,6 +5110,8 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
 					attrlen, page_len);
 			return -EINVAL;
 		}
+		/* At this stage we have the complete ACL */
+		res->acl_flags &= ~NFS4_ACL_LEN_ONLY;
 		xdr_read_pages(xdr, attrlen);
 		res->acl_len = attrlen;
 	} else
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index d3b7c18..c2d77d5 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -648,7 +648,7 @@ struct nfs_getaclargs {
 };
 
 /* getxattr ACL interface flags */
-#define NFS4_ACL_LEN_REQUEST	0x0001	/* zero length getxattr buffer */
+#define NFS4_ACL_LEN_ONLY	0x0001	/* zero length getxattr buffer */
 struct nfs_getaclres {
 	size_t				acl_len;
 	size_t				acl_data_offset;
-- 
1.7.11.2


  parent reply	other threads:[~2012-08-01 13:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01 13:29 [PATCH 0/2] Fix bugs and clean code in __nfs4_get_acl_uncached Sachin Prabhu
2012-08-01 13:29 ` [PATCH 1/2] Fix array overflow " Sachin Prabhu
2012-08-01 13:29 ` Sachin Prabhu [this message]
2012-08-01 17:56   ` [PATCH 2/2] Simplify check for size of ACL returned " Myklebust, Trond
2012-08-02 11:13     ` Sachin Prabhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343827771-6258-3-git-send-email-sprabhu@redhat.com \
    --to=sprabhu@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).