aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-07-07 20:59:11 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:24:07 -0400
commita6ccbbb8865101d83c2e716f08feae1da1c48584 (patch)
tree0b55b0673704dcae39d614cb1495cf47590628fb /fs
parent463090294e1e460cf97f5ade376d4b1e62bc5263 (diff)
[PATCH] nfsd4: fix sync'ing of recovery directory
We need to fsync the recovery directory after writing to it, but we weren't doing this correctly. (For example, we weren't taking the i_sem when calling ->fsync().) Just reuse the existing nfsd fsync code instead. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4recover.c29
-rw-r--r--fs/nfsd/vfs.c2
2 files changed, 9 insertions, 22 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 095f1740f3ae..bb40083b6b7d 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -119,25 +119,12 @@ out:
119 return status; 119 return status;
120} 120}
121 121
122static int 122static void
123nfsd4_rec_fsync(struct dentry *dentry) 123nfsd4_sync_rec_dir(void)
124{ 124{
125 struct file *filp; 125 down(&rec_dir.dentry->d_inode->i_sem);
126 int status = nfs_ok; 126 nfsd_sync_dir(rec_dir.dentry);
127 127 up(&rec_dir.dentry->d_inode->i_sem);
128 dprintk("NFSD: nfs4_fsync_rec_dir\n");
129 filp = dentry_open(dget(dentry), mntget(rec_dir.mnt), O_RDWR);
130 if (IS_ERR(filp)) {
131 status = PTR_ERR(filp);
132 goto out;
133 }
134 if (filp->f_op && filp->f_op->fsync)
135 status = filp->f_op->fsync(filp, filp->f_dentry, 0);
136 fput(filp);
137out:
138 if (status)
139 printk("nfsd4: unable to sync recovery directory\n");
140 return status;
141} 128}
142 129
143int 130int
@@ -176,7 +163,7 @@ out_unlock:
176 up(&rec_dir.dentry->d_inode->i_sem); 163 up(&rec_dir.dentry->d_inode->i_sem);
177 if (status == 0) { 164 if (status == 0) {
178 clp->cl_firststate = 1; 165 clp->cl_firststate = 1;
179 status = nfsd4_rec_fsync(rec_dir.dentry); 166 nfsd4_sync_rec_dir();
180 } 167 }
181 nfs4_reset_user(uid, gid); 168 nfs4_reset_user(uid, gid);
182 dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status); 169 dprintk("NFSD: nfsd4_create_clid_dir returns %d\n", status);
@@ -331,7 +318,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
331 status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1); 318 status = nfsd4_unlink_clid_dir(clp->cl_recdir, HEXDIR_LEN-1);
332 nfs4_reset_user(uid, gid); 319 nfs4_reset_user(uid, gid);
333 if (status == 0) 320 if (status == 0)
334 status = nfsd4_rec_fsync(rec_dir.dentry); 321 nfsd4_sync_rec_dir();
335 if (status) 322 if (status)
336 printk("NFSD: Failed to remove expired client state directory" 323 printk("NFSD: Failed to remove expired client state directory"
337 " %.*s\n", HEXDIR_LEN, clp->cl_recdir); 324 " %.*s\n", HEXDIR_LEN, clp->cl_recdir);
@@ -362,7 +349,7 @@ nfsd4_recdir_purge_old(void) {
362 return; 349 return;
363 status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old); 350 status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old);
364 if (status == 0) 351 if (status == 0)
365 status = nfsd4_rec_fsync(rec_dir.dentry); 352 nfsd4_sync_rec_dir();
366 if (status) 353 if (status)
367 printk("nfsd4: failed to purge old clients from recovery" 354 printk("nfsd4: failed to purge old clients from recovery"
368 " directory %s\n", rec_dir.dentry->d_name.name); 355 " directory %s\n", rec_dir.dentry->d_name.name);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index be24ead89d94..5e0bf3917607 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -733,7 +733,7 @@ nfsd_sync(struct file *filp)
733 up(&inode->i_sem); 733 up(&inode->i_sem);
734} 734}
735 735
736static void 736void
737nfsd_sync_dir(struct dentry *dp) 737nfsd_sync_dir(struct dentry *dp)
738{ 738{
739 nfsd_dosync(NULL, dp, dp->d_inode->i_fop); 739 nfsd_dosync(NULL, dp, dp->d_inode->i_fop);