diff options
author | Anton Blanchard <anton@samba.org> | 2010-04-06 17:34:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-04-07 11:38:04 -0400 |
commit | 55ab3a1ff843e3f0e24d2da44e71bffa5d853010 (patch) | |
tree | 092f383aab3dc57d6780348aa9638d01e99041cf | |
parent | da258016293f5e82b36db67ac3db3931a4fbbc4d (diff) |
raw: fsync method is now required
Commit 148f948ba877f4d3cdef036b1ff6d9f68986706a (vfs: Introduce new
helpers for syncing after writing to O_SYNC file or IS_SYNC inode) broke
the raw driver.
We now call through generic_file_aio_write -> generic_write_sync ->
vfs_fsync_range. vfs_fsync_range has:
if (!fop || !fop->fsync) {
ret = -EINVAL;
goto out;
}
But drivers/char/raw.c doesn't set an fsync method.
We have two options: fix it or remove the raw driver completely. I'm
happy to do either, the fact this has been broken for so long suggests it
is rarely used.
The patch below adds an fsync method to the raw driver. My knowledge of
the block layer is pretty sketchy so this could do with a once over.
If we instead decide to remove the raw driver, this patch might still be
useful as a backport to 2.6.33 and 2.6.32.
Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <jens.axboe@oracle.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Tested-by: Jeff Moyer <jmoyer@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/char/raw.c | 1 | ||||
-rw-r--r-- | fs/block_dev.c | 3 | ||||
-rw-r--r-- | include/linux/fs.h | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index d331c59b571c..f5a32317b751 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -248,6 +248,7 @@ static const struct file_operations raw_fops = { | |||
248 | .aio_read = generic_file_aio_read, | 248 | .aio_read = generic_file_aio_read, |
249 | .write = do_sync_write, | 249 | .write = do_sync_write, |
250 | .aio_write = blkdev_aio_write, | 250 | .aio_write = blkdev_aio_write, |
251 | .fsync = block_fsync, | ||
251 | .open = raw_open, | 252 | .open = raw_open, |
252 | .release= raw_release, | 253 | .release= raw_release, |
253 | .ioctl = raw_ioctl, | 254 | .ioctl = raw_ioctl, |
diff --git a/fs/block_dev.c b/fs/block_dev.c index d11d0289f3d2..8db62b2b6df8 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -404,7 +404,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin) | |||
404 | * NULL first argument is nfsd_sync_dir() and that's not a directory. | 404 | * NULL first argument is nfsd_sync_dir() and that's not a directory. |
405 | */ | 405 | */ |
406 | 406 | ||
407 | static int block_fsync(struct file *filp, struct dentry *dentry, int datasync) | 407 | int block_fsync(struct file *filp, struct dentry *dentry, int datasync) |
408 | { | 408 | { |
409 | struct block_device *bdev = I_BDEV(filp->f_mapping->host); | 409 | struct block_device *bdev = I_BDEV(filp->f_mapping->host); |
410 | int error; | 410 | int error; |
@@ -418,6 +418,7 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync) | |||
418 | error = 0; | 418 | error = 0; |
419 | return error; | 419 | return error; |
420 | } | 420 | } |
421 | EXPORT_SYMBOL(block_fsync); | ||
421 | 422 | ||
422 | /* | 423 | /* |
423 | * pseudo-fs | 424 | * pseudo-fs |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 10b8dedcd18b..5d9c7e27c5a4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2212,6 +2212,7 @@ extern int generic_segment_checks(const struct iovec *iov, | |||
2212 | /* fs/block_dev.c */ | 2212 | /* fs/block_dev.c */ |
2213 | extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, | 2213 | extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, |
2214 | unsigned long nr_segs, loff_t pos); | 2214 | unsigned long nr_segs, loff_t pos); |
2215 | extern int block_fsync(struct file *filp, struct dentry *dentry, int datasync); | ||
2215 | 2216 | ||
2216 | /* fs/splice.c */ | 2217 | /* fs/splice.c */ |
2217 | extern ssize_t generic_file_splice_read(struct file *, loff_t *, | 2218 | extern ssize_t generic_file_splice_read(struct file *, loff_t *, |