Commit 55ab3a1f authored by Anton Blanchard's avatar Anton Blanchard Committed by Linus Torvalds

raw: fsync method is now required

Commit 148f948b (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: default avatarAnton Blanchard <anton@samba.org>
Reviewed-by: default avatarJan 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: default avatarJeff Moyer <jmoyer@redhat.com>
Tested-by: default avatarJeff Moyer <jmoyer@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent da258016
...@@ -248,6 +248,7 @@ static const struct file_operations raw_fops = { ...@@ -248,6 +248,7 @@ static const struct file_operations raw_fops = {
.aio_read = generic_file_aio_read, .aio_read = generic_file_aio_read,
.write = do_sync_write, .write = do_sync_write,
.aio_write = blkdev_aio_write, .aio_write = blkdev_aio_write,
.fsync = block_fsync,
.open = raw_open, .open = raw_open,
.release= raw_release, .release= raw_release,
.ioctl = raw_ioctl, .ioctl = raw_ioctl,
......
...@@ -404,7 +404,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin) ...@@ -404,7 +404,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
* NULL first argument is nfsd_sync_dir() and that's not a directory. * NULL first argument is nfsd_sync_dir() and that's not a directory.
*/ */
static int block_fsync(struct file *filp, struct dentry *dentry, int datasync) int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
{ {
struct block_device *bdev = I_BDEV(filp->f_mapping->host); struct block_device *bdev = I_BDEV(filp->f_mapping->host);
int error; int error;
...@@ -418,6 +418,7 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync) ...@@ -418,6 +418,7 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
error = 0; error = 0;
return error; return error;
} }
EXPORT_SYMBOL(block_fsync);
/* /*
* pseudo-fs * pseudo-fs
......
...@@ -2212,6 +2212,7 @@ extern int generic_segment_checks(const struct iovec *iov, ...@@ -2212,6 +2212,7 @@ extern int generic_segment_checks(const struct iovec *iov,
/* fs/block_dev.c */ /* fs/block_dev.c */
extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos); unsigned long nr_segs, loff_t pos);
extern int block_fsync(struct file *filp, struct dentry *dentry, int datasync);
/* fs/splice.c */ /* fs/splice.c */
extern ssize_t generic_file_splice_read(struct file *, loff_t *, extern ssize_t generic_file_splice_read(struct file *, loff_t *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment