diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-08-17 12:12:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:06 -0400 |
commit | f2322b1c652add8bcd64b10843d76b0211ab1fc6 (patch) | |
tree | e8857d62692dc9a606b5e6b6a859ba5298377df2 /fs/btrfs | |
parent | 49593bfa575b7e3fda073b6d1033ee273bdaf97c (diff) |
Btrfs: Optimise NFS readdir hack slightly; don't call readdir() again when done
Date: Sun, 17 Aug 2008 17:12:56 +0100
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c7b7095634da..10f26f445328 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2040,6 +2040,7 @@ struct nfshack_dirent { | |||
2040 | struct nfshack_readdir { | 2040 | struct nfshack_readdir { |
2041 | char *dirent; | 2041 | char *dirent; |
2042 | size_t used; | 2042 | size_t used; |
2043 | int full; | ||
2043 | }; | 2044 | }; |
2044 | 2045 | ||
2045 | 2046 | ||
@@ -2052,8 +2053,10 @@ static int btrfs_nfshack_filldir(void *__buf, const char *name, int namlen, | |||
2052 | unsigned int reclen; | 2053 | unsigned int reclen; |
2053 | 2054 | ||
2054 | reclen = ALIGN(sizeof(struct nfshack_dirent) + namlen, sizeof(u64)); | 2055 | reclen = ALIGN(sizeof(struct nfshack_dirent) + namlen, sizeof(u64)); |
2055 | if (buf->used + reclen > PAGE_SIZE) | 2056 | if (buf->used + reclen > PAGE_SIZE) { |
2057 | buf->full = 1; | ||
2056 | return -EINVAL; | 2058 | return -EINVAL; |
2059 | } | ||
2057 | 2060 | ||
2058 | de->namlen = namlen; | 2061 | de->namlen = namlen; |
2059 | de->offset = offset; | 2062 | de->offset = offset; |
@@ -2080,11 +2083,11 @@ static int btrfs_nfshack_readdir(struct file *file, void *dirent, | |||
2080 | 2083 | ||
2081 | offset = file->f_pos; | 2084 | offset = file->f_pos; |
2082 | 2085 | ||
2083 | while (1) { | 2086 | do { |
2084 | unsigned int reclen; | 2087 | unsigned int reclen; |
2085 | 2088 | ||
2086 | buf.used = 0; | 2089 | buf.used = 0; |
2087 | 2090 | buf.full = 0; | |
2088 | err = btrfs_real_readdir(file, &buf, btrfs_nfshack_filldir); | 2091 | err = btrfs_real_readdir(file, &buf, btrfs_nfshack_filldir); |
2089 | if (err) | 2092 | if (err) |
2090 | break; | 2093 | break; |
@@ -2108,7 +2111,7 @@ static int btrfs_nfshack_readdir(struct file *file, void *dirent, | |||
2108 | size -= reclen; | 2111 | size -= reclen; |
2109 | de = (struct nfshack_dirent *)((char *)de + reclen); | 2112 | de = (struct nfshack_dirent *)((char *)de + reclen); |
2110 | } | 2113 | } |
2111 | } | 2114 | } while (buf.full); |
2112 | 2115 | ||
2113 | done: | 2116 | done: |
2114 | free_page((unsigned long)buf.dirent); | 2117 | free_page((unsigned long)buf.dirent); |