diff options
author | Boaz Harrosh <boaz@plexistor.com> | 2015-04-15 19:15:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:20 -0400 |
commit | be64f884bed729b5d127db6a737155a4e514d286 (patch) | |
tree | e6a8204f14b497cbfb845cc30920955dc7671527 | |
parent | 0e3b210ce1722168227cb3bc7746256d0c0afece (diff) |
dax: unify ext2/4_{dax,}_file_operations
The original dax patchset split the ext2/4_file_operations because of the
two NULL splice_read/splice_write in the dax case.
In the vfs if splice_read/splice_write are NULL we then call
default_splice_read/write.
What we do here is make generic_file_splice_read aware of IS_DAX() so the
original ext2/4_file_operations can be used as is.
For write it appears that iter_file_splice_write is just fine. It uses
the regular f_op->write(file,..) or new_sync_write(file, ...).
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ext2/ext2.h | 1 | ||||
-rw-r--r-- | fs/ext2/file.c | 18 | ||||
-rw-r--r-- | fs/ext2/inode.c | 5 | ||||
-rw-r--r-- | fs/ext2/namei.c | 10 | ||||
-rw-r--r-- | fs/ext4/ext4.h | 1 | ||||
-rw-r--r-- | fs/ext4/file.c | 20 | ||||
-rw-r--r-- | fs/ext4/inode.c | 5 | ||||
-rw-r--r-- | fs/ext4/namei.c | 10 | ||||
-rw-r--r-- | fs/splice.c | 3 |
9 files changed, 9 insertions, 64 deletions
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 678f9ab08c48..8d15febd0aa3 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
@@ -793,7 +793,6 @@ extern int ext2_fsync(struct file *file, loff_t start, loff_t end, | |||
793 | int datasync); | 793 | int datasync); |
794 | extern const struct inode_operations ext2_file_inode_operations; | 794 | extern const struct inode_operations ext2_file_inode_operations; |
795 | extern const struct file_operations ext2_file_operations; | 795 | extern const struct file_operations ext2_file_operations; |
796 | extern const struct file_operations ext2_dax_file_operations; | ||
797 | 796 | ||
798 | /* inode.c */ | 797 | /* inode.c */ |
799 | extern const struct address_space_operations ext2_aops; | 798 | extern const struct address_space_operations ext2_aops; |
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 866a3ce3f864..19cac93a65d3 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
@@ -109,24 +109,6 @@ const struct file_operations ext2_file_operations = { | |||
109 | .splice_write = iter_file_splice_write, | 109 | .splice_write = iter_file_splice_write, |
110 | }; | 110 | }; |
111 | 111 | ||
112 | #ifdef CONFIG_FS_DAX | ||
113 | const struct file_operations ext2_dax_file_operations = { | ||
114 | .llseek = generic_file_llseek, | ||
115 | .read = new_sync_read, | ||
116 | .write = new_sync_write, | ||
117 | .read_iter = generic_file_read_iter, | ||
118 | .write_iter = generic_file_write_iter, | ||
119 | .unlocked_ioctl = ext2_ioctl, | ||
120 | #ifdef CONFIG_COMPAT | ||
121 | .compat_ioctl = ext2_compat_ioctl, | ||
122 | #endif | ||
123 | .mmap = ext2_file_mmap, | ||
124 | .open = dquot_file_open, | ||
125 | .release = ext2_release_file, | ||
126 | .fsync = ext2_fsync, | ||
127 | }; | ||
128 | #endif | ||
129 | |||
130 | const struct inode_operations ext2_file_inode_operations = { | 112 | const struct inode_operations ext2_file_inode_operations = { |
131 | #ifdef CONFIG_EXT2_FS_XATTR | 113 | #ifdef CONFIG_EXT2_FS_XATTR |
132 | .setxattr = generic_setxattr, | 114 | .setxattr = generic_setxattr, |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index df9d6afbc5d5..b29eb6747116 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1388,10 +1388,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino) | |||
1388 | 1388 | ||
1389 | if (S_ISREG(inode->i_mode)) { | 1389 | if (S_ISREG(inode->i_mode)) { |
1390 | inode->i_op = &ext2_file_inode_operations; | 1390 | inode->i_op = &ext2_file_inode_operations; |
1391 | if (test_opt(inode->i_sb, DAX)) { | 1391 | if (test_opt(inode->i_sb, NOBH)) { |
1392 | inode->i_mapping->a_ops = &ext2_aops; | ||
1393 | inode->i_fop = &ext2_dax_file_operations; | ||
1394 | } else if (test_opt(inode->i_sb, NOBH)) { | ||
1395 | inode->i_mapping->a_ops = &ext2_nobh_aops; | 1392 | inode->i_mapping->a_ops = &ext2_nobh_aops; |
1396 | inode->i_fop = &ext2_file_operations; | 1393 | inode->i_fop = &ext2_file_operations; |
1397 | } else { | 1394 | } else { |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 148f6e3789ea..ce422931f411 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -104,10 +104,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode | |||
104 | return PTR_ERR(inode); | 104 | return PTR_ERR(inode); |
105 | 105 | ||
106 | inode->i_op = &ext2_file_inode_operations; | 106 | inode->i_op = &ext2_file_inode_operations; |
107 | if (test_opt(inode->i_sb, DAX)) { | 107 | if (test_opt(inode->i_sb, NOBH)) { |
108 | inode->i_mapping->a_ops = &ext2_aops; | ||
109 | inode->i_fop = &ext2_dax_file_operations; | ||
110 | } else if (test_opt(inode->i_sb, NOBH)) { | ||
111 | inode->i_mapping->a_ops = &ext2_nobh_aops; | 108 | inode->i_mapping->a_ops = &ext2_nobh_aops; |
112 | inode->i_fop = &ext2_file_operations; | 109 | inode->i_fop = &ext2_file_operations; |
113 | } else { | 110 | } else { |
@@ -125,10 +122,7 @@ static int ext2_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
125 | return PTR_ERR(inode); | 122 | return PTR_ERR(inode); |
126 | 123 | ||
127 | inode->i_op = &ext2_file_inode_operations; | 124 | inode->i_op = &ext2_file_inode_operations; |
128 | if (test_opt(inode->i_sb, DAX)) { | 125 | if (test_opt(inode->i_sb, NOBH)) { |
129 | inode->i_mapping->a_ops = &ext2_aops; | ||
130 | inode->i_fop = &ext2_dax_file_operations; | ||
131 | } else if (test_opt(inode->i_sb, NOBH)) { | ||
132 | inode->i_mapping->a_ops = &ext2_nobh_aops; | 126 | inode->i_mapping->a_ops = &ext2_nobh_aops; |
133 | inode->i_fop = &ext2_file_operations; | 127 | inode->i_fop = &ext2_file_operations; |
134 | } else { | 128 | } else { |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index f63c3d5805c4..8a3981ea35d8 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2593,7 +2593,6 @@ extern const struct file_operations ext4_dir_operations; | |||
2593 | /* file.c */ | 2593 | /* file.c */ |
2594 | extern const struct inode_operations ext4_file_inode_operations; | 2594 | extern const struct inode_operations ext4_file_inode_operations; |
2595 | extern const struct file_operations ext4_file_operations; | 2595 | extern const struct file_operations ext4_file_operations; |
2596 | extern const struct file_operations ext4_dax_file_operations; | ||
2597 | extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin); | 2596 | extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin); |
2598 | 2597 | ||
2599 | /* inline.c */ | 2598 | /* inline.c */ |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index aa78c70553f4..e6d4280d66be 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -625,26 +625,6 @@ const struct file_operations ext4_file_operations = { | |||
625 | .fallocate = ext4_fallocate, | 625 | .fallocate = ext4_fallocate, |
626 | }; | 626 | }; |
627 | 627 | ||
628 | #ifdef CONFIG_FS_DAX | ||
629 | const struct file_operations ext4_dax_file_operations = { | ||
630 | .llseek = ext4_llseek, | ||
631 | .read = new_sync_read, | ||
632 | .write = new_sync_write, | ||
633 | .read_iter = generic_file_read_iter, | ||
634 | .write_iter = ext4_file_write_iter, | ||
635 | .unlocked_ioctl = ext4_ioctl, | ||
636 | #ifdef CONFIG_COMPAT | ||
637 | .compat_ioctl = ext4_compat_ioctl, | ||
638 | #endif | ||
639 | .mmap = ext4_file_mmap, | ||
640 | .open = ext4_file_open, | ||
641 | .release = ext4_release_file, | ||
642 | .fsync = ext4_sync_file, | ||
643 | /* Splice not yet supported with DAX */ | ||
644 | .fallocate = ext4_fallocate, | ||
645 | }; | ||
646 | #endif | ||
647 | |||
648 | const struct inode_operations ext4_file_inode_operations = { | 628 | const struct inode_operations ext4_file_inode_operations = { |
649 | .setattr = ext4_setattr, | 629 | .setattr = ext4_setattr, |
650 | .getattr = ext4_getattr, | 630 | .getattr = ext4_getattr, |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a3f451370bef..035b7a06f1c3 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4090,10 +4090,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4090 | 4090 | ||
4091 | if (S_ISREG(inode->i_mode)) { | 4091 | if (S_ISREG(inode->i_mode)) { |
4092 | inode->i_op = &ext4_file_inode_operations; | 4092 | inode->i_op = &ext4_file_inode_operations; |
4093 | if (test_opt(inode->i_sb, DAX)) | 4093 | inode->i_fop = &ext4_file_operations; |
4094 | inode->i_fop = &ext4_dax_file_operations; | ||
4095 | else | ||
4096 | inode->i_fop = &ext4_file_operations; | ||
4097 | ext4_set_aops(inode); | 4094 | ext4_set_aops(inode); |
4098 | } else if (S_ISDIR(inode->i_mode)) { | 4095 | } else if (S_ISDIR(inode->i_mode)) { |
4099 | inode->i_op = &ext4_dir_inode_operations; | 4096 | inode->i_op = &ext4_dir_inode_operations; |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 28fe71a2904c..2291923dae4e 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2235,10 +2235,7 @@ retry: | |||
2235 | err = PTR_ERR(inode); | 2235 | err = PTR_ERR(inode); |
2236 | if (!IS_ERR(inode)) { | 2236 | if (!IS_ERR(inode)) { |
2237 | inode->i_op = &ext4_file_inode_operations; | 2237 | inode->i_op = &ext4_file_inode_operations; |
2238 | if (test_opt(inode->i_sb, DAX)) | 2238 | inode->i_fop = &ext4_file_operations; |
2239 | inode->i_fop = &ext4_dax_file_operations; | ||
2240 | else | ||
2241 | inode->i_fop = &ext4_file_operations; | ||
2242 | ext4_set_aops(inode); | 2239 | ext4_set_aops(inode); |
2243 | err = ext4_add_nondir(handle, dentry, inode); | 2240 | err = ext4_add_nondir(handle, dentry, inode); |
2244 | if (!err && IS_DIRSYNC(dir)) | 2241 | if (!err && IS_DIRSYNC(dir)) |
@@ -2302,10 +2299,7 @@ retry: | |||
2302 | err = PTR_ERR(inode); | 2299 | err = PTR_ERR(inode); |
2303 | if (!IS_ERR(inode)) { | 2300 | if (!IS_ERR(inode)) { |
2304 | inode->i_op = &ext4_file_inode_operations; | 2301 | inode->i_op = &ext4_file_inode_operations; |
2305 | if (test_opt(inode->i_sb, DAX)) | 2302 | inode->i_fop = &ext4_file_operations; |
2306 | inode->i_fop = &ext4_dax_file_operations; | ||
2307 | else | ||
2308 | inode->i_fop = &ext4_file_operations; | ||
2309 | ext4_set_aops(inode); | 2303 | ext4_set_aops(inode); |
2310 | d_tmpfile(dentry, inode); | 2304 | d_tmpfile(dentry, inode); |
2311 | err = ext4_orphan_add(handle, inode); | 2305 | err = ext4_orphan_add(handle, inode); |
diff --git a/fs/splice.c b/fs/splice.c index 41cbb16299e0..476024bb6546 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -523,6 +523,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, | |||
523 | loff_t isize, left; | 523 | loff_t isize, left; |
524 | int ret; | 524 | int ret; |
525 | 525 | ||
526 | if (IS_DAX(in->f_mapping->host)) | ||
527 | return default_file_splice_read(in, ppos, pipe, len, flags); | ||
528 | |||
526 | isize = i_size_read(in->f_mapping->host); | 529 | isize = i_size_read(in->f_mapping->host); |
527 | if (unlikely(*ppos >= isize)) | 530 | if (unlikely(*ppos >= isize)) |
528 | return 0; | 531 | return 0; |