]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfsd/vfs.c
[PATCH] Optimise NFS readdir hack slightly.
[linux-2.6-omap-h63xx.git] / fs / nfsd / vfs.c
index 93b22f661d9da05c658cf064d1e12ea8cfb38785..49d4b8725ca374e778b1cca112ffa4bc5ac791f1 100644 (file)
@@ -1831,6 +1831,7 @@ struct buffered_dirent {
 struct readdir_data {
        char            *dirent;
        size_t          used;
+       int             full;
 };
 
 static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
@@ -1841,8 +1842,10 @@ static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
        unsigned int reclen;
 
        reclen = ALIGN(sizeof(struct buffered_dirent) + namlen, sizeof(u64));
-       if (buf->used + reclen > PAGE_SIZE)
+       if (buf->used + reclen > PAGE_SIZE) {
+               buf->full = 1;
                return -EINVAL;
+       }
 
        de->namlen = namlen;
        de->offset = offset;
@@ -1874,9 +1877,13 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
                unsigned int reclen;
 
                buf.used = 0;
+               buf.full = 0;
 
                host_err = vfs_readdir(file, nfsd_buffered_filldir, &buf);
-               if (host_err)
+               if (buf.full)
+                       host_err = 0;
+
+               if (host_err < 0)
                        break;
 
                size = buf.used;
@@ -1884,7 +1891,6 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
                if (!size)
                        break;
 
-
                de = (struct buffered_dirent *)buf.dirent;
                while (size > 0) {
                        offset = de->offset;
@@ -1901,7 +1907,9 @@ static int nfsd_buffered_readdir(struct file *file, filldir_t func,
                        size -= reclen;
                        de = (struct buffered_dirent *)((char *)de + reclen);
                }
-               offset = vfs_llseek(file, 0, 1);
+               offset = vfs_llseek(file, 0, SEEK_CUR);
+               if (!buf.full)
+                       break;
        }
 
  done: