diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-15 13:52:59 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 04:46:46 -0400 |
commit | 5c0ba4e0762e6dabd14a5c276652e2defec38de7 (patch) | |
tree | cc2c94d81a631b0656782e1f8299da3267871964 /fs/nfsd | |
parent | 83a8761142cb38536e9e88dfc2432d331ea4e257 (diff) |
[readdir] introduce iterate_dir() and dir_context
iterate_dir(): new helper, replacing vfs_readdir().
struct dir_context: contains the readdir callback (and will get more stuff
in it), embedded into whatever data that callback wants to deal with;
eventually, we'll be passing it to ->readdir() replacement instead of
(data,filldir) pair.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4recover.c | 13 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 4e9a21db867a..4f8cc6ba7c28 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
@@ -263,7 +263,10 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn) | |||
263 | { | 263 | { |
264 | const struct cred *original_cred; | 264 | const struct cred *original_cred; |
265 | struct dentry *dir = nn->rec_file->f_path.dentry; | 265 | struct dentry *dir = nn->rec_file->f_path.dentry; |
266 | LIST_HEAD(names); | 266 | struct { |
267 | struct dir_context ctx; | ||
268 | struct list_head names; | ||
269 | } ctx; | ||
267 | int status; | 270 | int status; |
268 | 271 | ||
269 | status = nfs4_save_creds(&original_cred); | 272 | status = nfs4_save_creds(&original_cred); |
@@ -276,11 +279,13 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn) | |||
276 | return status; | 279 | return status; |
277 | } | 280 | } |
278 | 281 | ||
279 | status = vfs_readdir(nn->rec_file, nfsd4_build_namelist, &names); | 282 | INIT_LIST_HEAD(&ctx.names); |
283 | ctx.ctx.actor = nfsd4_build_namelist; | ||
284 | status = iterate_dir(nn->rec_file, &ctx.ctx); | ||
280 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); | 285 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); |
281 | while (!list_empty(&names)) { | 286 | while (!list_empty(&ctx.names)) { |
282 | struct name_list *entry; | 287 | struct name_list *entry; |
283 | entry = list_entry(names.next, struct name_list, list); | 288 | entry = list_entry(ctx.names.next, struct name_list, list); |
284 | if (!status) { | 289 | if (!status) { |
285 | struct dentry *dentry; | 290 | struct dentry *dentry; |
286 | dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1); | 291 | dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1); |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 84ce601d8063..f939ba9bf8e8 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1912,6 +1912,7 @@ struct buffered_dirent { | |||
1912 | }; | 1912 | }; |
1913 | 1913 | ||
1914 | struct readdir_data { | 1914 | struct readdir_data { |
1915 | struct dir_context ctx; | ||
1915 | char *dirent; | 1916 | char *dirent; |
1916 | size_t used; | 1917 | size_t used; |
1917 | int full; | 1918 | int full; |
@@ -1949,6 +1950,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func, | |||
1949 | int size; | 1950 | int size; |
1950 | loff_t offset; | 1951 | loff_t offset; |
1951 | 1952 | ||
1953 | buf.ctx.actor = nfsd_buffered_filldir; | ||
1952 | buf.dirent = (void *)__get_free_page(GFP_KERNEL); | 1954 | buf.dirent = (void *)__get_free_page(GFP_KERNEL); |
1953 | if (!buf.dirent) | 1955 | if (!buf.dirent) |
1954 | return nfserrno(-ENOMEM); | 1956 | return nfserrno(-ENOMEM); |
@@ -1963,7 +1965,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func, | |||
1963 | buf.used = 0; | 1965 | buf.used = 0; |
1964 | buf.full = 0; | 1966 | buf.full = 0; |
1965 | 1967 | ||
1966 | host_err = vfs_readdir(file, nfsd_buffered_filldir, &buf); | 1968 | host_err = iterate_dir(file, &buf.ctx); |
1967 | if (buf.full) | 1969 | if (buf.full) |
1968 | host_err = 0; | 1970 | host_err = 0; |
1969 | 1971 | ||