diff options
author | Christoph Hellwig <hch@lst.de> | 2008-12-22 15:11:15 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-01-05 11:54:28 -0500 |
commit | 4c728ef583b3d82266584da5cb068294c09df31e (patch) | |
tree | 1252fa82b5a7cf60c0898c3da810228b4c34ebb3 /fs/ecryptfs/file.c | |
parent | 6110e3abbff8b785907d4db50240e63c1be726e3 (diff) |
add a vfs_fsync helper
Fsync currently has a fdatawrite/fdatawait pair around the method call,
and a mutex_lock/unlock of the inode mutex. All callers of fsync have
to duplicate this, but we have a few and most of them don't quite get
it right. This patch adds a new vfs_fsync that takes care of this.
It's a little more complicated as usual as ->fsync might get a NULL file
pointer and just a dentry from nfsd, but otherwise gets afile and we
want to take the mapping and file operations from it when it is there.
Notes on the fsync callers:
- ecryptfs wasn't calling filemap_fdatawrite / filemap_fdatawait on the
lower file
- coda wasn't calling filemap_fdatawrite / filemap_fdatawait on the host
file, and returning 0 when ->fsync was missing
- shm wasn't calling either filemap_fdatawrite / filemap_fdatawait nor
taking i_mutex. Now given that shared memory doesn't have disk
backing not doing anything in fsync seems fine and I left it out of
the vfs_fsync conversion for now, but in that case we might just
not pass it through to the lower file at all but just call the no-op
simple_sync_file directly.
[and now actually export vfs_fsync]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs/file.c')
-rw-r--r-- | fs/ecryptfs/file.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index eb3dc4c7ac06..713834371229 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -275,18 +275,9 @@ static int ecryptfs_release(struct inode *inode, struct file *file) | |||
275 | static int | 275 | static int |
276 | ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 276 | ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) |
277 | { | 277 | { |
278 | struct file *lower_file = ecryptfs_file_to_lower(file); | 278 | return vfs_fsync(ecryptfs_file_to_lower(file), |
279 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); | 279 | ecryptfs_dentry_to_lower(dentry), |
280 | struct inode *lower_inode = lower_dentry->d_inode; | 280 | datasync); |
281 | int rc = -EINVAL; | ||
282 | |||
283 | if (lower_inode->i_fop->fsync) { | ||
284 | mutex_lock(&lower_inode->i_mutex); | ||
285 | rc = lower_inode->i_fop->fsync(lower_file, lower_dentry, | ||
286 | datasync); | ||
287 | mutex_unlock(&lower_inode->i_mutex); | ||
288 | } | ||
289 | return rc; | ||
290 | } | 281 | } |
291 | 282 | ||
292 | static int ecryptfs_fasync(int fd, struct file *file, int flag) | 283 | static int ecryptfs_fasync(int fd, struct file *file, int flag) |