]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.12/raw-fsync-method-is-now-required.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.12 / raw-fsync-method-is-now-required.patch
1 From 55ab3a1ff843e3f0e24d2da44e71bffa5d853010 Mon Sep 17 00:00:00 2001
2 From: Anton Blanchard <anton@samba.org>
3 Date: Tue, 6 Apr 2010 14:34:58 -0700
4 Subject: raw: fsync method is now required
5
6 From: Anton Blanchard <anton@samba.org>
7
8 commit 55ab3a1ff843e3f0e24d2da44e71bffa5d853010 upstream.
9
10 Commit 148f948ba877f4d3cdef036b1ff6d9f68986706a (vfs: Introduce new
11 helpers for syncing after writing to O_SYNC file or IS_SYNC inode) broke
12 the raw driver.
13
14 We now call through generic_file_aio_write -> generic_write_sync ->
15 vfs_fsync_range. vfs_fsync_range has:
16
17 if (!fop || !fop->fsync) {
18 ret = -EINVAL;
19 goto out;
20 }
21
22 But drivers/char/raw.c doesn't set an fsync method.
23
24 We have two options: fix it or remove the raw driver completely. I'm
25 happy to do either, the fact this has been broken for so long suggests it
26 is rarely used.
27
28 The patch below adds an fsync method to the raw driver. My knowledge of
29 the block layer is pretty sketchy so this could do with a once over.
30
31 If we instead decide to remove the raw driver, this patch might still be
32 useful as a backport to 2.6.33 and 2.6.32.
33
34 Signed-off-by: Anton Blanchard <anton@samba.org>
35 Reviewed-by: Jan Kara <jack@suse.cz>
36 Cc: Christoph Hellwig <hch@lst.de>
37 Cc: Alexander Viro <viro@zeniv.linux.org.uk>
38 Cc: Jens Axboe <jens.axboe@oracle.com>
39 Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
40 Tested-by: Jeff Moyer <jmoyer@redhat.com>
41 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
42 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
43 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
44
45 ---
46 drivers/char/raw.c | 1 +
47 fs/block_dev.c | 3 ++-
48 include/linux/fs.h | 1 +
49 3 files changed, 4 insertions(+), 1 deletion(-)
50
51 --- a/drivers/char/raw.c
52 +++ b/drivers/char/raw.c
53 @@ -247,6 +247,7 @@ static const struct file_operations raw_
54 .aio_read = generic_file_aio_read,
55 .write = do_sync_write,
56 .aio_write = blkdev_aio_write,
57 + .fsync = block_fsync,
58 .open = raw_open,
59 .release= raw_release,
60 .ioctl = raw_ioctl,
61 --- a/fs/block_dev.c
62 +++ b/fs/block_dev.c
63 @@ -404,7 +404,7 @@ static loff_t block_llseek(struct file *
64 * NULL first argument is nfsd_sync_dir() and that's not a directory.
65 */
66
67 -static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
68 +int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
69 {
70 return sync_blockdev(I_BDEV(filp->f_mapping->host));
71 }
72 @@ -423,6 +423,7 @@ static struct inode *bdev_alloc_inode(st
73 return NULL;
74 return &ei->vfs_inode;
75 }
76 +EXPORT_SYMBOL(block_fsync);
77
78 static void bdev_destroy_inode(struct inode *inode)
79 {
80 --- a/include/linux/fs.h
81 +++ b/include/linux/fs.h
82 @@ -2225,6 +2225,7 @@ extern int generic_segment_checks(const
83 /* fs/block_dev.c */
84 extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
85 unsigned long nr_segs, loff_t pos);
86 +extern int block_fsync(struct file *filp, struct dentry *dentry, int datasync);
87
88 /* fs/splice.c */
89 extern ssize_t generic_file_splice_read(struct file *, loff_t *,