]> git.hungrycats.org Git - linux/commitdiff
NFS: In 2.4, NFS O_DIRECT used the VFS's O_DIRECT logic to provide
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:15:13 +0000 (10:15 -0400)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:15:13 +0000 (10:15 -0400)
   direct I/O support for NFS files.  The 2.4 VFS O_DIRECT logic was
   block based, thus the NFS client had to provide a minimum
   allowable blocksize for O_DIRECT reads and writes on NFS files.
   For various reasons we chose 512 bytes. In 2.6, there is no
   requirement for a minimum blocksize.  NFS O_DIRECT reads and
   writes can go to any byte at any offset in a file.  Thus we revert
   the blocksize setting for NFS file systems to the previous
   behavior, which was to advertise the "wsize" setting as the
   optimal I/O block size.  This improves the performance of
   applications like 'cp' which use this value as their transfer
   size.

This patch also exposes the server's reported disk block size in the
   f_frsize of the vfsstat structure.

Signed-off-by: Chuck Lever <cel@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
fs/nfs/inode.c
include/linux/nfs_fs_sb.h

index 729b3da03865b7b1836f6b7ceeab4772bf0e03c6..cbbfb4b82196f8c4d0cfd7dea16d336e8cc99d40 100644 (file)
@@ -270,14 +270,6 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
                server->rsize = nfs_block_size(fsinfo.rtpref, NULL);
        if (server->wsize == 0)
                server->wsize = nfs_block_size(fsinfo.wtpref, NULL);
-       if (sb->s_blocksize == 0) {
-               if (fsinfo.wtmult == 0) {
-                       sb->s_blocksize = 512;
-                       sb->s_blocksize_bits = 9;
-               } else
-                       sb->s_blocksize = nfs_block_bits(fsinfo.wtmult,
-                                                        &sb->s_blocksize_bits);
-       }
 
        if (fsinfo.rtmax >= 512 && server->rsize > fsinfo.rtmax)
                server->rsize = nfs_block_size(fsinfo.rtmax, NULL);
@@ -296,6 +288,11 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
                 server->wsize = server->wpages << PAGE_CACHE_SHIFT;
        }
 
+       if (sb->s_blocksize == 0)
+               sb->s_blocksize = nfs_block_bits(server->wsize,
+                                                        &sb->s_blocksize_bits);
+       server->wtmult = nfs_block_bits(fsinfo.wtmult, NULL);
+
        server->dtsize = nfs_block_size(fsinfo.dtpref, NULL);
        if (server->dtsize > PAGE_CACHE_SIZE)
                server->dtsize = PAGE_CACHE_SIZE;
@@ -482,6 +479,7 @@ nfs_statfs(struct super_block *sb, struct kstatfs *buf)
        if (error < 0)
                goto out_err;
 
+       buf->f_frsize = server->wtmult;
        buf->f_bsize = sb->s_blocksize;
        blockbits = sb->s_blocksize_bits;
        blockres = (1 << blockbits) - 1;
index 428355f8aaf95a32f06b77472fe54ea9446822a6..a43a386079823c608365ff13da619921afefac6f 100644 (file)
@@ -18,6 +18,7 @@ struct nfs_server {
        unsigned int            rpages;         /* read size (in pages) */
        unsigned int            wsize;          /* write size */
        unsigned int            wpages;         /* write size (in pages) */
+       unsigned int            wtmult;         /* server disk block size */
        unsigned int            dtsize;         /* readdir size */
        unsigned int            bsize;          /* server block size */
        unsigned int            acregmin;       /* attr cache timeouts */