Linux NFS development
 help / color / mirror / Atom feed
From: Bob Bell <b_linuxnfs-Y/+76LoPTq9wBoktGHYdvgC/G2K4zDHf@public.gmane.org>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 2/3] NFS: Add NFS_MOUNT_NONEGDE flag to avoid caching negative dentries
Date: Tue, 15 Jan 2008 11:30:14 -0500	[thread overview]
Message-ID: <20080115163013.GC18911@newbie.thebellsplace.net> (raw)
In-Reply-To: <20080115162658.GA18911-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>

From: Bob Bell <bell_robert@emc.com>

Add NFS_MOUNT_NONEGDE mount flag.  When this flag is set on a mounted
NFS filesystem, negative dentries for that filesystem will not be 
cached.  This can help address cache coherency when the NFS server does 
not provide sufficiently fine-grained timestamps to consistently 
distinguish when a directory has been modified, though performance when 
repeatedly accessing filenames for files that do not exist may be 
impacted.

Signed-off-by: Bob Bell <bell_robert@emc.com>
---
 fs/nfs/dir.c              |    5 +++++
 fs/nfs/nfsroot.c          |   10 +++++++++-
 fs/nfs/super.c            |    9 +++++++++
 include/linux/nfs_mount.h |   35 ++++++++++++++++++-----------------
 4 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 410449d..9419f55 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -851,6 +851,11 @@ static int nfs_dentry_delete(struct dentry *dentry)
 		 * files will be cleaned up during umount */
 		return 1;
 	}
+	if (dentry->d_inode == NULL &&
+	    (NFS_SB(dentry->d_sb)->flags & NFS_MOUNT_NONEGDE)) {
+		/* Unhash it, so that negative dentries won't be cached */
+		return 1;
+	}
 	return 0;
 
 }
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index 4b03345..1c8e7ee 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -124,7 +124,7 @@ enum {
 	Opt_soft, Opt_hard, Opt_intr,
 	Opt_nointr, Opt_posix, Opt_noposix, Opt_cto, Opt_nocto, Opt_ac, 
 	Opt_noac, Opt_lock, Opt_nolock, Opt_v2, Opt_v3, Opt_udp, Opt_tcp,
-	Opt_acl, Opt_noacl,
+	Opt_acl, Opt_noacl, Opt_negde, Opt_nonegde,
 	/* Error token */
 	Opt_err
 };
@@ -161,6 +161,8 @@ static match_table_t __initdata tokens = {
 	{Opt_tcp, "tcp"},
 	{Opt_acl, "acl"},
 	{Opt_noacl, "noacl"},
+	{Opt_negde, "negde"},
+	{Opt_nonegde, "nonegde"},
 	{Opt_err, NULL}
 	
 };
@@ -275,6 +277,12 @@ static int __init root_nfs_parse(char *name, char *buf)
 			case Opt_noacl:
 				nfs_data.flags |= NFS_MOUNT_NOACL;
 				break;
+			case Opt_negde:
+				nfs_data.flags &= ~NFS_MOUNT_NONEGDE;
+				break;
+			case Opt_nonegde:
+				nfs_data.flags |= NFS_MOUNT_NONEGDE;
+				break;
 			default:
 				printk(KERN_WARNING "Root-NFS: unknown "
 					"option: %s\n", p);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0d1bc61..7043a07 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -75,6 +75,7 @@ enum {
 	Opt_acl, Opt_noacl,
 	Opt_rdirplus, Opt_nordirplus,
 	Opt_sharecache, Opt_nosharecache,
+	Opt_negde, Opt_nonegde,
 
 	/* Mount options that take integer arguments */
 	Opt_port,
@@ -124,6 +125,8 @@ static match_table_t nfs_mount_option_tokens = {
 	{ Opt_nordirplus, "nordirplus" },
 	{ Opt_sharecache, "sharecache" },
 	{ Opt_nosharecache, "nosharecache" },
+	{ Opt_negde, "negde" },
+	{ Opt_nonegde, "nonegde" },
 
 	{ Opt_port, "port=%u" },
 	{ Opt_rsize, "rsize=%u" },
@@ -455,6 +458,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
 		{ NFS_MOUNT_NOACL, ",noacl", "" },
 		{ NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
 		{ NFS_MOUNT_UNSHARED, ",nosharecache", ""},
+		{ NFS_MOUNT_NONEGDE, ",nonegde", ""},
 		{ 0, NULL, NULL }
 	};
 	const struct proc_nfs_info *nfs_infop;
@@ -779,6 +783,11 @@ static int nfs_parse_mount_options(char *raw,
 		case Opt_nosharecache:
 			mnt->flags |= NFS_MOUNT_UNSHARED;
 			break;
+		case Opt_negde:
+			mnt->flags &= ~NFS_MOUNT_NONEGDE;
+			break;
+		case Opt_nonegde:
+			mnt->flags |= NFS_MOUNT_NONEGDE;
 
 		case Opt_port:
 			if (match_int(args, &option))
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index a3ade89..44ffb60 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -47,22 +47,23 @@ struct nfs_mount_data {
 
 /* bits in the flags field */
 
-#define NFS_MOUNT_SOFT		0x0001	/* 1 */
-#define NFS_MOUNT_INTR		0x0002	/* 1 */
-#define NFS_MOUNT_SECURE	0x0004	/* 1 */
-#define NFS_MOUNT_POSIX		0x0008	/* 1 */
-#define NFS_MOUNT_NOCTO		0x0010	/* 1 */
-#define NFS_MOUNT_NOAC		0x0020	/* 1 */
-#define NFS_MOUNT_TCP		0x0040	/* 2 */
-#define NFS_MOUNT_VER3		0x0080	/* 3 */
-#define NFS_MOUNT_KERBEROS	0x0100	/* 3 */
-#define NFS_MOUNT_NONLM		0x0200	/* 3 */
-#define NFS_MOUNT_BROKEN_SUID	0x0400	/* 4 */
-#define NFS_MOUNT_NOACL		0x0800	/* 4 */
-#define NFS_MOUNT_STRICTLOCK	0x1000	/* reserved for NFSv4 */
-#define NFS_MOUNT_SECFLAVOUR	0x2000	/* 5 */
-#define NFS_MOUNT_NORDIRPLUS	0x4000	/* 5 */
-#define NFS_MOUNT_UNSHARED	0x8000	/* 5 */
-#define NFS_MOUNT_FLAGMASK	0xFFFF
+#define NFS_MOUNT_SOFT		0x00001	/* 1 */
+#define NFS_MOUNT_INTR		0x00002	/* 1 */
+#define NFS_MOUNT_SECURE	0x00004	/* 1 */
+#define NFS_MOUNT_POSIX		0x00008	/* 1 */
+#define NFS_MOUNT_NOCTO		0x00010	/* 1 */
+#define NFS_MOUNT_NOAC		0x00020	/* 1 */
+#define NFS_MOUNT_TCP		0x00040	/* 2 */
+#define NFS_MOUNT_VER3		0x00080	/* 3 */
+#define NFS_MOUNT_KERBEROS	0x00100	/* 3 */
+#define NFS_MOUNT_NONLM		0x00200	/* 3 */
+#define NFS_MOUNT_BROKEN_SUID	0x00400	/* 4 */
+#define NFS_MOUNT_NOACL		0x00800	/* 4 */
+#define NFS_MOUNT_STRICTLOCK	0x01000	/* reserved for NFSv4 */
+#define NFS_MOUNT_SECFLAVOUR	0x02000	/* 5 */
+#define NFS_MOUNT_NORDIRPLUS	0x04000	/* 5 */
+#define NFS_MOUNT_UNSHARED	0x08000	/* 5 */
+#define NFS_MOUNT_NONEGDE	0x10000	/* 5 */
+#define NFS_MOUNT_FLAGMASK	0x1FFFF
 
 #endif

  parent reply	other threads:[~2008-01-15 16:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 16:27 [PATCH 0/3] Intro: Better handling coarse-grained timestamps Bob Bell
     [not found] ` <20080115162658.GA18911-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-15 16:29   ` [PATCH 1/3] NFS: Check nlinks count Bob Bell
2008-01-15 16:30   ` Bob Bell [this message]
     [not found]     ` <20080115163013.GC18911-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-15 16:52       ` [PATCH 2/3] NFS: Add NFS_MOUNT_NONEGDE flag to avoid caching negative dentries Trond Myklebust
     [not found]         ` <1200415972.7702.7.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-15 17:04           ` Chuck Lever
2008-01-15 17:14             ` Trond Myklebust
2008-01-16  1:22             ` Bob Bell
     [not found]               ` <20080116012209.GB26010-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-16  2:42                 ` Trond Myklebust
     [not found]                   ` <1200451350.28088.43.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-16 12:49                     ` Steve Dickson
     [not found]                       ` <478DFD5A.1040501-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-01-16 19:43                         ` Muntz, Daniel
     [not found]                           ` <01AE8AF878612047A442668306EAEB05018178E7-Ye0EzW0T4yEQ4vjYWPuN5KYtpRd4g51m@public.gmane.org>
2008-01-16 20:43                             ` Trond Myklebust
     [not found]                               ` <1200516219.6932.22.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-16 20:49                                 ` Chuck Lever
2008-01-16 21:12                                   ` Risto Bell
     [not found]                                     ` <478E7345.8080003-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org>
2008-01-16 21:56                                       ` Trond Myklebust
     [not found]                                         ` <1200520574.15282.24.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-16 22:09                                           ` Chuck Lever
2008-01-16 23:21                                             ` Trond Myklebust
2008-01-18 15:29                                   ` Bob Bell
     [not found]                                     ` <20080118152902.GF7128-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-18 20:00                                       ` Muntz, Daniel
     [not found]                                         ` <01AE8AF878612047A442668306EAEB0501817BA4-Ye0EzW0T4yEQ4vjYWPuN5KYtpRd4g51m@public.gmane.org>
2008-01-19  1:28                                           ` Bob Bell
2008-01-18 21:12                                       ` Chuck Lever
2008-01-18 21:17                                         ` Trond Myklebust
2008-01-15 16:31   ` [PATCH 3/3] nfs-utils: Add nonegde mount option Bob Bell
     [not found]     ` <20080115163130.GD18911-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-15 16:42       ` Chuck Lever
2008-01-16  1:13         ` Bob Bell
     [not found]           ` <20080116011305.GA26010-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-16 20:45             ` Chuck Lever
2008-01-16  1:55   ` [PATCH 0/3] Intro: Better handling coarse-grained timestamps Bob Bell
     [not found]     ` <20080116015526.GC26010-y89O8yXFYpDSsb2jM9SCN5/hYUUxywnI@public.gmane.org>
2008-01-16  2:18       ` Trond Myklebust
     [not found]         ` <1200449912.28088.22.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-16 17:16           ` david m. richter
2008-01-16 19:47             ` Trond Myklebust
     [not found]               ` <1200512872.6932.8.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-16 20:09                 ` david m. richter

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=20080115163013.GC18911@newbie.thebellsplace.net \
    --to=b_linuxnfs-y/+76loptq9wboktghydvgc/g2k4zdhf@public.gmane.org \
    --cc=linux-nfs@vger.kernel.org \
    /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