linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
To: linux-nfs@vger.kernel.org, linux-ext4@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, yong.fan@whamcloud.com,
	"J. Bruce Fields" <bfields@redhat.com>,
	sandeen@redhat.com, adilger@whamcloud.com
Subject: [PATCH 5 4/4] nfsd: vfs_llseek() with 32 or 64 bit offsets (hashes)
Date: Mon, 09 Jan 2012 14:21:58 +0100	[thread overview]
Message-ID: <20120109132158.2616029.30467.stgit@localhost.localdomain> (raw)
In-Reply-To: <20120109132137.2616029.76288.stgit@localhost.localdomain>

Use 32-bit or 64-bit llseek() hashes for directory offsets depending on
the NFS version. NFSv2 gets 32-bit hashes only.

NOTE: This patch got rather complex as Christoph asked to set the
filp->f_mode flag in the open call or immediatly after dentry_open()
in nfsd_open() to avoid races.
Personally I still do not see a reason for that and in my opinion
FMODE_32BITHASH/FMODE_64BITHASH flags could be set nfsd_readdir(), as it
follows directly after nfsd_open() without a chance of races.


Signed-off-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Acked-by: J. Bruce Fields<bfields@redhat.com>
---
 fs/nfsd/vfs.c |   15 +++++++++++++--
 fs/nfsd/vfs.h |    2 ++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 20fa252..f162dc3 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -785,9 +785,15 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
 			    flags, current_cred());
 	if (IS_ERR(*filp))
 		host_err = PTR_ERR(*filp);
-	else
+	else {
 		host_err = ima_file_check(*filp, may_flags);
 
+		if (may_flags & NFSD_MAY_64BIT_COOKIE)
+			(*filp)->f_mode |= FMODE_64BITHASH;
+		else
+			(*filp)->f_mode |= FMODE_32BITHASH;
+	}
+
 out_nfserr:
 	err = nfserrno(host_err);
 out:
@@ -2011,8 +2017,13 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
 	__be32		err;
 	struct file	*file;
 	loff_t		offset = *offsetp;
+	int             may_flags = NFSD_MAY_READ;
+
+	/* NFSv2 only supports 32 bit cookies */
+	if (rqstp->rq_vers > 2)
+		may_flags |= NFSD_MAY_64BIT_COOKIE;
 
-	err = nfsd_open(rqstp, fhp, S_IFDIR, NFSD_MAY_READ, &file);
+	err = nfsd_open(rqstp, fhp, S_IFDIR, may_flags, &file);
 	if (err)
 		goto out;
 
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 1dcd238..ec0611b 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -27,6 +27,8 @@
 #define NFSD_MAY_BYPASS_GSS		0x400
 #define NFSD_MAY_READ_IF_EXEC		0x800
 
+#define NFSD_MAY_64BIT_COOKIE		0x1000 /* 64 bit readdir cookies for >= NFSv3 */
+
 #define NFSD_MAY_CREATE		(NFSD_MAY_EXEC|NFSD_MAY_WRITE)
 #define NFSD_MAY_REMOVE		(NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
 


  parent reply	other threads:[~2012-01-09 13:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 13:21 [PATCH 0/4] [RESEND] 32/64 bit llseek hashes (v5) Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 1/4] Add new FMODE flags: FMODE_32bithash and FMODE_64bithash Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 2/4] Return 32/64-bit dir name hash according to usage type Bernd Schubert
2012-03-05 15:59   ` Ted Ts'o
2012-03-06  0:40     ` Bernd Schubert
2012-03-06  2:28       ` Ted Ts'o
2012-03-06  9:59         ` Bernd Schubert
2012-03-06 15:15           ` Ted Ts'o
2012-03-07  9:01             ` Bernd Schubert
2012-04-20 20:04   ` Eric Sandeen
2012-04-22 12:51     ` Bernd Schubert
2012-04-23 20:37       ` Eric Sandeen
2012-04-23 20:52         ` Bernd Schubert
2012-04-23 21:22           ` Eric Sandeen
2012-04-23 22:23           ` Eric Sandeen
2012-04-23 22:42             ` Andreas Dilger
2012-04-24 16:10               ` Bernd Schubert
2012-01-09 13:21 ` [PATCH 5 3/4] nfsd_open(): rename 'int access' to 'int may_flags' in nfsd_open() Bernd Schubert
2012-03-06  0:08   ` Ted Ts'o
2012-03-06  2:08     ` J. Bruce Fields
2012-03-06 15:18       ` Ted Ts'o
2012-03-06 15:28         ` J. Bruce Fields
2012-03-09 20:51           ` Ted Ts'o
2012-03-12 15:09             ` Ted Ts'o
2012-03-12 15:49               ` J. Bruce Fields
2012-03-12 22:22                 ` J. Bruce Fields
2012-03-13 20:01                   ` J. Bruce Fields
2012-03-13 20:03                     ` Bernd Schubert
2012-03-13 20:34                       ` J. Bruce Fields
2012-03-13 21:09                         ` Bernd Schubert
2012-03-13 21:29                           ` J. Bruce Fields
2012-03-14 14:32                             ` Bernd Schubert
2012-03-14 16:05                               ` J. Bruce Fields
2012-03-16 21:22                                 ` Bernd Schubert
2012-03-19  2:54                                   ` Ted Ts'o
2012-03-19 20:00                                     ` J. Bruce Fields
2012-03-20  0:10                                       ` Ted Ts'o
2012-04-12 20:49                               ` J. Bruce Fields
2012-04-12 21:22                                 ` Bernd Schubert
2012-04-12 21:25                                   ` J. Bruce Fields
2012-03-13 21:10                         ` Ted Ts'o
2012-03-13 21:27                           ` J. Bruce Fields
2012-01-09 13:21 ` Bernd Schubert [this message]
2012-01-10 11:27 ` [PATCH 0/4] [RESEND] 32/64 bit llseek hashes (v5) Andreas Dilger
2012-01-11 14:48   ` J. Bruce Fields
2012-01-11 15:31     ` Ted Ts'o
2012-03-05 12:23       ` Bernd Schubert

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=20120109132158.2616029.30467.stgit@localhost.localdomain \
    --to=bernd.schubert@itwm.fraunhofer.de \
    --cc=adilger@whamcloud.com \
    --cc=bfields@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=yong.fan@whamcloud.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).