Skip to content

Commit be64f88

Browse files
Boaz Harroshtorvalds
authored andcommitted
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>
1 parent 0e3b210 commit be64f88

9 files changed

Lines changed: 9 additions & 64 deletions

File tree

‎fs/ext2/ext2.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ extern int ext2_fsync(struct file *file, loff_t start, loff_t end,
793793
int datasync);
794794
extern const struct inode_operations ext2_file_inode_operations;
795795
extern const struct file_operations ext2_file_operations;
796-
extern const struct file_operations ext2_dax_file_operations;
797796

798797
/* inode.c */
799798
extern const struct address_space_operations ext2_aops;

‎fs/ext2/file.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,6 @@ const struct file_operations ext2_file_operations = {
109109
.splice_write = iter_file_splice_write,
110110
};
111111

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-
130112
const struct inode_operations ext2_file_inode_operations = {
131113
#ifdef CONFIG_EXT2_FS_XATTR
132114
.setxattr = generic_setxattr,

‎fs/ext2/inode.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,10 +1388,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
13881388

13891389
if (S_ISREG(inode->i_mode)) {
13901390
inode->i_op = &ext2_file_inode_operations;
1391-
if (test_opt(inode->i_sb, DAX)) {
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)) {
1391+
if (test_opt(inode->i_sb, NOBH)) {
13951392
inode->i_mapping->a_ops = &ext2_nobh_aops;
13961393
inode->i_fop = &ext2_file_operations;
13971394
} else {

‎fs/ext2/namei.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode
104104
return PTR_ERR(inode);
105105

106106
inode->i_op = &ext2_file_inode_operations;
107-
if (test_opt(inode->i_sb, DAX)) {
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)) {
107+
if (test_opt(inode->i_sb, NOBH)) {
111108
inode->i_mapping->a_ops = &ext2_nobh_aops;
112109
inode->i_fop = &ext2_file_operations;
113110
} else {
@@ -125,10 +122,7 @@ static int ext2_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
125122
return PTR_ERR(inode);
126123

127124
inode->i_op = &ext2_file_inode_operations;
128-
if (test_opt(inode->i_sb, DAX)) {
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)) {
125+
if (test_opt(inode->i_sb, NOBH)) {
132126
inode->i_mapping->a_ops = &ext2_nobh_aops;
133127
inode->i_fop = &ext2_file_operations;
134128
} else {

‎fs/ext4/ext4.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,6 @@ extern const struct file_operations ext4_dir_operations;
25932593
/* file.c */
25942594
extern const struct inode_operations ext4_file_inode_operations;
25952595
extern const struct file_operations ext4_file_operations;
2596-
extern const struct file_operations ext4_dax_file_operations;
25972596
extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin);
25982597

25992598
/* inline.c */

‎fs/ext4/file.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -625,26 +625,6 @@ const struct file_operations ext4_file_operations = {
625625
.fallocate = ext4_fallocate,
626626
};
627627

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-
648628
const struct inode_operations ext4_file_inode_operations = {
649629
.setattr = ext4_setattr,
650630
.getattr = ext4_getattr,

‎fs/ext4/inode.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,10 +4090,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
40904090

40914091
if (S_ISREG(inode->i_mode)) {
40924092
inode->i_op = &ext4_file_inode_operations;
4093-
if (test_opt(inode->i_sb, DAX))
4094-
inode->i_fop = &ext4_dax_file_operations;
4095-
else
4096-
inode->i_fop = &ext4_file_operations;
4093+
inode->i_fop = &ext4_file_operations;
40974094
ext4_set_aops(inode);
40984095
} else if (S_ISDIR(inode->i_mode)) {
40994096
inode->i_op = &ext4_dir_inode_operations;

‎fs/ext4/namei.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,10 +2235,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
22352235
err = PTR_ERR(inode);
22362236
if (!IS_ERR(inode)) {
22372237
inode->i_op = &ext4_file_inode_operations;
2238-
if (test_opt(inode->i_sb, DAX))
2239-
inode->i_fop = &ext4_dax_file_operations;
2240-
else
2241-
inode->i_fop = &ext4_file_operations;
2238+
inode->i_fop = &ext4_file_operations;
22422239
ext4_set_aops(inode);
22432240
err = ext4_add_nondir(handle, dentry, inode);
22442241
if (!err && IS_DIRSYNC(dir))
@@ -2302,10 +2299,7 @@ static int ext4_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
23022299
err = PTR_ERR(inode);
23032300
if (!IS_ERR(inode)) {
23042301
inode->i_op = &ext4_file_inode_operations;
2305-
if (test_opt(inode->i_sb, DAX))
2306-
inode->i_fop = &ext4_dax_file_operations;
2307-
else
2308-
inode->i_fop = &ext4_file_operations;
2302+
inode->i_fop = &ext4_file_operations;
23092303
ext4_set_aops(inode);
23102304
d_tmpfile(dentry, inode);
23112305
err = ext4_orphan_add(handle, inode);

‎fs/splice.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
523523
loff_t isize, left;
524524
int ret;
525525

526+
if (IS_DAX(in->f_mapping->host))
527+
return default_file_splice_read(in, ppos, pipe, len, flags);
528+
526529
isize = i_size_read(in->f_mapping->host);
527530
if (unlikely(*ppos >= isize))
528531
return 0;

0 commit comments

Comments
 (0)