Skip to contentSkip to conversation

Introduction

PATCH New NeilBrown 4 participants 9 messages Aug 16, 2004 – Jul 12, 2005

Subsystems (6)
Documentation VFS MIPS NFS client +2 more subsystems
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 Introduction

4 patches for knfsd. in 2.4.28-pre1

1/ improve checking of out-of-range lengths, particularly in write requests. 2/ make CONFIG_NFSD_TCP non-EXPERIMENTAL and select it by default. 3/ Allow a larger blocksize on arch's with large page size.
4/ use llseek instead of explicitly setting f_pos in NFS i/o requests.

Thank,
NeilBrown

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#1 lore raw

PATCH 1/1 Allow larger NFSd MAXBLKSIZE on architectures with larger PAGE_SIZE

This patch makes NFSSVC_MAXBLKSIZE depend on PAGE_SIZE so that machines with large page sizes can take advantage of that feature to serve NFS with larger blocksizes, increasing performance and avoiding a fallback to synchronous traffic between machines with page sizes greater than 8K. Also, documents the actual constraints on NFSSVC_MAXBLKSIZE.

From: Greg Banks <[email protected]>

### Diffstat output

 ./include/linux/nfsd/const.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
include/linux/nfsd/const.h renamed from include/linux/nfsd/const.h~current~ +10 -2
diff ./include/linux/nfsd/const.h~current~ ./include/linux/nfsd/const.h
@@ -12,6 +12,7 @@
 #include <linux/nfs.h>
 #include <linux/nfs2.h>
 #include <linux/nfs3.h>
+#include <asm/page.h>
 
 /*
  * Maximum protocol version supported by knfsd
@@ -19,9 +20,16 @@
 #define NFSSVC_MAXVERS		3
 
 /*
- * Maximum blocksize supported by daemon currently at 8K
+ * Maximum blocksize supported by daemon.  We want the largest
+ * value which 1) fits in a UDP datagram less some headers
+ * 2) is a multiple of page size 3) can be successfully kmalloc()ed
+ * by each nfsd.   
  */
-#define NFSSVC_MAXBLKSIZE	(8*1024)
+#if PAGE_SIZE > (16*1024)
+#define NFSSVC_MAXBLKSIZE	(32*1024)
+#else
+#define NFSSVC_MAXBLKSIZE	(2*PAGE_SIZE)
+#endif
 
 #ifdef __KERNEL__
 

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#2 lore raw

PATCH 1/1 Use llseek instead of f_pos= for directory seeking.

In reply to NeilBrown

nfsd currently just sets f_pos when seeking in a directory. This bypasses any checking and other handling that a filesystem might want to do.

So instead, we use 'llseek' copied out of fs/read_write.c use that, both to seek at the start, and the find the new position at the end.

If it were not too intrusive, would could export llseek as vfs_llseek as was done in 2.6....

Thanks to
"Derrick Schommer" <[email protected]> "Trond Myklebust" <[email protected]>

### Diffstat output

 ./fs/nfsd/vfs.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +28 -7
diff ./fs/nfsd/vfs.c~current~ ./fs/nfsd/vfs.c
@@ -586,6 +586,22 @@ found:
 	return ra;
 }
 
+/* copied from fs/read_write.c */
+static inline loff_t llseek(struct file *file, loff_t offset, int origin)
+{
+	loff_t (*fn)(struct file *, loff_t, int);
+	loff_t retval;
+
+	fn = default_llseek;
+	if (file->f_op && file->f_op->llseek)
+		fn = file->f_op->llseek;
+	lock_kernel();
+	retval = fn(file, offset, origin);
+	unlock_kernel();
+	return retval;
+}
+
+
 /*
  * Read data from a file. count must contain the requested read count
  * on entry. On return, *count contains the number of bytes actually read.
@@ -621,7 +637,7 @@ nfsd_read(struct svc_rqst *rqstp, struct
 		file.f_ralen = ra->p_ralen;
 		file.f_rawin = ra->p_rawin;
 	}
-	file.f_pos = offset;
+	llseek(&file, offset, 0);
 
 	oldfs = get_fs(); set_fs(KERNEL_DS);
 	err = file.f_op->read(&file, buf, *count, &file.f_pos);
@@ -706,7 +722,8 @@ nfsd_write(struct svc_rqst *rqstp, struc
 	if (stable && !EX_WGATHER(exp))
 		file.f_flags |= O_SYNC;
 
-	file.f_pos = offset;		/* set write offset */
+
+	llseek(&file, offset, 0);
 
 	/* Write the data. */
 	oldfs = get_fs(); set_fs(KERNEL_DS);
@@ -1398,10 +1415,12 @@ nfsd_readdir(struct svc_rqst *rqstp, str
 	err = nfsd_open(rqstp, fhp, S_IFDIR, MAY_READ, &file);
 	if (err)
 		goto out;
-	if (offset > ~(u32) 0)
-		goto out_close;
 
-	file.f_pos = offset;
+	offset = llseek(&file, offset, 0);
+	if (offset < 0) {
+		err = nfserrno((int)offset);
+		goto out_close;
+	}
 
 	/* Set up the readdir context */
 	memset(&cd, 0, sizeof(cd));
@@ -1429,11 +1448,13 @@ nfsd_readdir(struct svc_rqst *rqstp, str
 	/* If we didn't fill the buffer completely, we're at EOF */
 	eof = !cd.eob;
 
+
+	offset = llseek(&file, 0LL, 1);
 	if (cd.offset) {
 		if (rqstp->rq_vers == 3)
-			(void)xdr_encode_hyper(cd.offset, file.f_pos);
+			(void)xdr_encode_hyper(cd.offset, offset);
 		else
-			*cd.offset = htonl(file.f_pos);
+			*cd.offset = htonl(offset);
 	}
 
 	p = cd.buffer;

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#3 lore raw

Re: [PATCH kNFSd 4 of 4] Use llseek instead of f_pos= for directory seeking.

Quoted 8 lines · NeilBrown

nfsd currently just sets f_pos when seeking in a directory. This bypasses any checking and other handling that a filesystem might want to do.

So instead, we use 'llseek' copied out of fs/read_write.c use that, both to seek at the start, and the find the new position at the end.

llseek from fs/read_write.c has been renamed to vfs_llseek and you can just use it now.

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#4 lore raw

Re: [PATCH kNFSd 4 of 4] Use llseek instead of f_pos= for directory seeking.

Quoted 6 lines · Christoph Hellwig
Quoted 3 lines

So instead, we use 'llseek' copied out of fs/read_write.c use that, both to seek at the start, and the find the new position at the end.

llseek from fs/read_write.c has been renamed to vfs_llseek and you can just use it now.

Sorry for the noise, I see this is 2.4. But I think the 2.6 variant would be preferable for 2.4 aswell.

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#5 lore raw

PATCH 1/1 mark NFS/TCP not EXPERIMENTAL

In reply to NeilBrown

NFS/TCP has been used widely for a long time now, and is now enabled by many distros and typically recommended for lossy or congested networks. This patch removes the EXPERIMENTAL tag, updates the help text, and changes arch defconfigs to set it by default (note that several already did so).

From: Greg Banks <[email protected]>

### Diffstat output

 ./Documentation/Configure.help |    7 ++++---
 ./arch/i386/defconfig          |    2 +-
 ./arch/ia64/defconfig          |    2 +-
 ./arch/mips/defconfig          |    2 +-
 ./arch/mips64/defconfig        |    2 +-
 ./arch/ppc/defconfig           |    2 +-
 ./arch/ppc64/defconfig         |    2 +-
 ./arch/s390/defconfig          |    2 +-
 ./arch/s390x/defconfig         |    2 +-
 ./arch/sh64/defconfig          |    2 +-
 ./fs/Config.in                 |    2 +-
 11 files changed, 14 insertions(+), 13 deletions(-)
Documentation/Configure.help renamed from Documentation/Configure.help~current~ +4 -3
diff ./Documentation/Configure.help~current~ ./Documentation/Configure.help
@@ -17229,10 +17229,11 @@ CONFIG_NFSD_V3
   If you would like to include the NFSv3 server as well as the NFSv2
   server, say Y here.  If unsure, say Y.
 
-Provide NFS over TCP server support EXPERIMENTAL
+Provide NFS over TCP server support
 CONFIG_NFSD_TCP
-  Enable NFS service over TCP connections.  This the officially
-  still experimental, but seems to work well.
+  If you want your NFS server to support TCP connections, say Y here.
+  TCP connections usually perform better than the default UDP when
+  the network is lossy or congested.  If unsure, say Y.
 
 OS/2 HPFS file system support
 CONFIG_HPFS_FS
arch/i386/defconfig renamed from arch/i386/defconfig~current~ +1 -1
diff ./arch/i386/defconfig~current~ ./arch/i386/defconfig
@@ -758,7 +758,7 @@ CONFIG_NFS_FS=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 # CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 # CONFIG_SMB_FS is not set
arch/ia64/defconfig renamed from arch/ia64/defconfig~current~ +1 -1
diff ./arch/ia64/defconfig~current~ ./arch/ia64/defconfig
@@ -755,7 +755,7 @@ CONFIG_NFS_V3=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
arch/mips/defconfig renamed from arch/mips/defconfig~current~ +1 -1
diff ./arch/mips/defconfig~current~ ./arch/mips/defconfig
@@ -607,7 +607,7 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NFSD=y
 # CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 # CONFIG_SMB_FS is not set
arch/mips64/defconfig renamed from arch/mips64/defconfig~current~ +1 -1
diff ./arch/mips64/defconfig~current~ ./arch/mips64/defconfig
@@ -563,7 +563,7 @@ CONFIG_NFS_V3=y
 CONFIG_ROOT_NFS=y
 # CONFIG_NFSD is not set
 # CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
arch/ppc/defconfig renamed from arch/ppc/defconfig~current~ +1 -1
diff ./arch/ppc/defconfig~current~ ./arch/ppc/defconfig
@@ -812,7 +812,7 @@ CONFIG_NFS_FS=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 # CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 # CONFIG_SMB_FS is not set
arch/ppc64/defconfig renamed from arch/ppc64/defconfig~current~ +1 -1
diff ./arch/ppc64/defconfig~current~ ./arch/ppc64/defconfig
@@ -668,7 +668,7 @@ CONFIG_NFS_V3=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
arch/s390/defconfig renamed from arch/s390/defconfig~current~ +1 -1
diff ./arch/s390/defconfig~current~ ./arch/s390/defconfig
@@ -351,7 +351,7 @@ CONFIG_NFS_V3=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
arch/s390x/defconfig renamed from arch/s390x/defconfig~current~ +1 -1
diff ./arch/s390x/defconfig~current~ ./arch/s390x/defconfig
@@ -291,7 +291,7 @@ CONFIG_NFS_V3=y
 # CONFIG_ROOT_NFS is not set
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
arch/sh64/defconfig renamed from arch/sh64/defconfig~current~ +1 -1
diff ./arch/sh64/defconfig~current~ ./arch/sh64/defconfig
@@ -386,7 +386,7 @@ CONFIG_NFS_V3=y
 CONFIG_ROOT_NFS=y
 # CONFIG_NFSD is not set
 # CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
+CONFIG_NFSD_TCP=y
 CONFIG_SUNRPC=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
fs/Config.in renamed from fs/Config.in~current~ +1 -1
diff ./fs/Config.in~current~ ./fs/Config.in
@@ -121,7 +121,7 @@ if [ "$CONFIG_NET" = "y" ]; then
 
    dep_tristate 'NFS server support' CONFIG_NFSD $CONFIG_INET
    dep_mbool '  Provide NFSv3 server support' CONFIG_NFSD_V3 $CONFIG_NFSD
-   dep_mbool '  Provide NFS server over TCP support (EXPERIMENTAL)' CONFIG_NFSD_TCP $CONFIG_NFSD $CONFIG_EXPERIMENTAL
+   dep_mbool '  Provide NFS server over TCP support' CONFIG_NFSD_TCP $CONFIG_NFSD
 
    if [ "$CONFIG_NFS_FS" = "y" -o "$CONFIG_NFSD" = "y" ]; then
       define_tristate CONFIG_SUNRPC y

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#6 lore raw

PATCH 1/1 Fixed possibly xdr parsing error if write size exceed 2^31

In reply to NeilBrown

xdr_argsize_check needs to cope with the possibility that the pointer has wrapped and could be below buf->base.

### Diffstat output

 ./fs/nfsd/nfs3xdr.c         |    2 +-
 ./include/linux/nfsd/xdr3.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs3xdr.c renamed from fs/nfsd/nfs3xdr.c~current~ +1 -1
diff ./fs/nfsd/nfs3xdr.c~current~ ./fs/nfsd/nfs3xdr.c
@@ -273,7 +273,7 @@ xdr_argsize_check(struct svc_rqst *rqstp
 {
 	struct svc_buf	*buf = &rqstp->rq_argbuf;
 
-	return p - buf->base <= buf->buflen;
+	return p >= buf->base && p <= buf->base + buf->buflen ;
 }
 
 static inline int
include/linux/nfsd/xdr3.h renamed from include/linux/nfsd/xdr3.h~current~ +1 -1
diff ./include/linux/nfsd/xdr3.h~current~ ./include/linux/nfsd/xdr3.h
@@ -41,7 +41,7 @@ struct nfsd3_writeargs {
 	__u32			count;
 	int			stable;
 	__u8 *			data;
-	int			len;
+	__u32			len;
 };
 
 struct nfsd3_createargs {

-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#7 lore raw

Re: [PATCH kNFSd 1 of 4] Fixed possibly xdr parsing error if write size exceed 2^31

Hi all,

what happened to this patch? It never seems to have made it upstream.

Olaf

Quoted 46 lines · NeilBrown

xdr_argsize_check needs to cope with the possibility that the pointer has wrapped and could be below buf->base.

### Diffstat output

 ./fs/nfsd/nfs3xdr.c         |    2 +-
 ./include/linux/nfsd/xdr3.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff ./fs/nfsd/nfs3xdr.c~current~ ./fs/nfsd/nfs3xdr.c

fs/nfsd/nfs3xdr.c renamed from fs/nfsd/nfs3xdr.c~current~ +1 -1
@@ -273,7 +273,7 @@ xdr_argsize_check(struct svc_rqst *rqstp
 {
 	struct svc_buf	*buf = &rqstp->rq_argbuf;
 
-	return p - buf->base <= buf->buflen;
+	return p >= buf->base && p <= buf->base + buf->buflen ;
 }
 
 static inline int

diff ./include/linux/nfsd/xdr3.h~current~ ./include/linux/nfsd/xdr3.h

include/linux/nfsd/xdr3.h renamed from include/linux/nfsd/xdr3.h~current~ +1 -2
@@ -41,7 +41,7 @@ struct nfsd3_writeargs {
 	__u32			count;
 	int			stable;
 	__u8 *			data;
-	int			len;
+	__u32			len;
 };
 
 struct nfsd3_createargs {
 
 
-------------------------------------------------------

SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

Signature · 12 lines
Olaf Kirch   |  --- o --- Nous sommes du soleil we love when we play
[email protected] |    / | \   sol.dhoop.naytheet.ah kin.ir.samse.qurax


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
#8 lore raw

Re: [PATCH kNFSd 1 of 4] Fixed possibly xdr parsing error if write size exceed 2^31

Hi Olaf,

Quoted 4 lines · Olaf Kirch

Hi all,

what happened to this patch? It never seems to have made it upstream.

I think it did, long ago:

nfs3xdr.c 1.10 CSets 11 months neilb Fixed possibly xdr parsing error if write size exceed 2^31

Quoted 39 lines

Olaf

Quoted 35 lines · NeilBrown

xdr_argsize_check needs to cope with the possibility that the pointer has wrapped and could be below buf->base.

### Diffstat output

 ./fs/nfsd/nfs3xdr.c         |    2 +-
 ./include/linux/nfsd/xdr3.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff ./fs/nfsd/nfs3xdr.c~current~ ./fs/nfsd/nfs3xdr.c

fs/nfsd/nfs3xdr.c renamed from fs/nfsd/nfs3xdr.c~current~ +1 -1
@@ -273,7 +273,7 @@ xdr_argsize_check(struct svc_rqst *rqstp
 {
 	struct svc_buf	*buf = &rqstp->rq_argbuf;
 
-	return p - buf->base <= buf->buflen;
+	return p >= buf->base && p <= buf->base + buf->buflen ;
 }
 
 static inline int

diff ./include/linux/nfsd/xdr3.h~current~ ./include/linux/nfsd/xdr3.h

include/linux/nfsd/xdr3.h renamed from include/linux/nfsd/xdr3.h~current~ +1 -1
@@ -41,7 +41,7 @@ struct nfsd3_writeargs {
 	__u32			count;
 	int			stable;
 	__u8 *			data;
-	int			len;
+	__u32			len;
 };
 
Quoted 1 line

include/linux/nfsd/xdr3.h struct nfsd3_writeargs { · line 47

Quoted 1 line
include/linux/nfsd/xdr3.h renamed from include/linux/nfsd/xdr3.h~current~ +0 -0
 struct nfsd3_createargs {

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs