aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4recover.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index ffb59ef6f82f..29d77f60585b 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -191,52 +191,42 @@ nfsd4_build_namelist(void *arg, const char *name, int namlen,
191} 191}
192 192
193static int 193static int
194nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f) 194nfsd4_list_rec_dir(recdir_func *f)
195{ 195{
196 const struct cred *original_cred; 196 const struct cred *original_cred;
197 struct file *filp; 197 struct dentry *dir = rec_file->f_path.dentry;
198 LIST_HEAD(names); 198 LIST_HEAD(names);
199 struct name_list *entry;
200 struct dentry *dentry;
201 int status; 199 int status;
202 200
203 if (!rec_file)
204 return 0;
205
206 status = nfs4_save_creds(&original_cred); 201 status = nfs4_save_creds(&original_cred);
207 if (status < 0) 202 if (status < 0)
208 return status; 203 return status;
209 204
210 filp = dentry_open(dget(dir), mntget(rec_file->f_path.mnt), O_RDONLY, 205 status = vfs_llseek(rec_file, 0, SEEK_SET);
211 current_cred()); 206 if (status < 0) {
212 status = PTR_ERR(filp); 207 nfs4_reset_creds(original_cred);
213 if (IS_ERR(filp)) 208 return status;
214 goto out; 209 }
215 status = vfs_readdir(filp, nfsd4_build_namelist, &names); 210
216 fput(filp); 211 status = vfs_readdir(rec_file, nfsd4_build_namelist, &names);
217 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 212 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
218 while (!list_empty(&names)) { 213 while (!list_empty(&names)) {
214 struct name_list *entry;
219 entry = list_entry(names.next, struct name_list, list); 215 entry = list_entry(names.next, struct name_list, list);
220 216 if (!status) {
221 dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1); 217 struct dentry *dentry;
222 if (IS_ERR(dentry)) { 218 dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
223 status = PTR_ERR(dentry); 219 if (IS_ERR(dentry)) {
224 break; 220 status = PTR_ERR(dentry);
221 break;
222 }
223 status = f(dir, dentry);
224 dput(dentry);
225 } 225 }
226 status = f(dir, dentry);
227 dput(dentry);
228 if (status)
229 break;
230 list_del(&entry->list); 226 list_del(&entry->list);
231 kfree(entry); 227 kfree(entry);
232 } 228 }
233 mutex_unlock(&dir->d_inode->i_mutex); 229 mutex_unlock(&dir->d_inode->i_mutex);
234out:
235 while (!list_empty(&names)) {
236 entry = list_entry(names.next, struct name_list, list);
237 list_del(&entry->list);
238 kfree(entry);
239 }
240 nfs4_reset_creds(original_cred); 230 nfs4_reset_creds(original_cred);
241 return status; 231 return status;
242} 232}
@@ -322,7 +312,7 @@ nfsd4_recdir_purge_old(void) {
322 status = mnt_want_write(rec_file->f_path.mnt); 312 status = mnt_want_write(rec_file->f_path.mnt);
323 if (status) 313 if (status)
324 goto out; 314 goto out;
325 status = nfsd4_list_rec_dir(rec_file->f_path.dentry, purge_old); 315 status = nfsd4_list_rec_dir(purge_old);
326 if (status == 0) 316 if (status == 0)
327 vfs_fsync(rec_file, 0); 317 vfs_fsync(rec_file, 0);
328 mnt_drop_write(rec_file->f_path.mnt); 318 mnt_drop_write(rec_file->f_path.mnt);
@@ -352,7 +342,7 @@ nfsd4_recdir_load(void) {
352 if (!rec_file) 342 if (!rec_file)
353 return 0; 343 return 0;
354 344
355 status = nfsd4_list_rec_dir(rec_file->f_path.dentry, load_recdir); 345 status = nfsd4_list_rec_dir(load_recdir);
356 if (status) 346 if (status)
357 printk("nfsd4: failed loading clients from recovery" 347 printk("nfsd4: failed loading clients from recovery"
358 " directory %s\n", rec_file->f_path.dentry->d_name.name); 348 " directory %s\n", rec_file->f_path.dentry->d_name.name);