Skip to content

Commit 55e20bd

Browse files
committed
Revert "btrfs: switch to iomap_dio_rw() for dio"
This reverts commit a43a67a. This patch reverts the main part of switching direct io implementation to iomap infrastructure. There's a problem in invalidate page that couldn't be solved as regression in this development cycle. The problem occurs when buffered and direct io are mixed, and the ranges overlap. Although this is not recommended, filesystems implement measures or fallbacks to make it somehow work. In this case, fallback to buffered IO would be an option for btrfs (this already happens when direct io is done on compressed data), but the change would be needed in the iomap code, bringing new semantics to other filesystems. Another problem arises when again the buffered and direct ios are mixed, invalidation fails, then -EIO is set on the mapping and fsync will fail, though there's no real error. There have been discussions how to fix that, but revert seems to be the least intrusive option. Link: https://lore.kernel.org/linux-btrfs/20200528192103.xm45qoxqmkw7i5yl@fiona/ Signed-off-by: David Sterba <[email protected]>
1 parent f1084bc commit 55e20bd

File tree

4 files changed

+169
-166
lines changed

4 files changed

+169
-166
lines changed

fs/btrfs/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ config BTRFS_FS
1414
select LZO_DECOMPRESS
1515
select ZSTD_COMPRESS
1616
select ZSTD_DECOMPRESS
17-
select FS_IOMAP
1817
select RAID6_PQ
1918
select XOR_BLOCKS
2019
select SRCU

fs/btrfs/ctree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,6 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end);
29332933
void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start,
29342934
u64 end, int uptodate);
29352935
extern const struct dentry_operations btrfs_dentry_operations;
2936-
ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter);
29372936

29382937
/* ioctl.c */
29392938
long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);

fs/btrfs/file.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
18191819
loff_t endbyte;
18201820
int err;
18211821

1822-
written = btrfs_direct_IO(iocb, from);
1822+
written = generic_file_direct_write(iocb, from);
18231823

18241824
if (written < 0 || !iov_iter_count(from))
18251825
return written;
@@ -3476,26 +3476,9 @@ static int btrfs_file_open(struct inode *inode, struct file *filp)
34763476
return generic_file_open(inode, filp);
34773477
}
34783478

3479-
static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
3480-
{
3481-
ssize_t ret = 0;
3482-
3483-
if (iocb->ki_flags & IOCB_DIRECT) {
3484-
struct inode *inode = file_inode(iocb->ki_filp);
3485-
3486-
inode_lock_shared(inode);
3487-
ret = btrfs_direct_IO(iocb, to);
3488-
inode_unlock_shared(inode);
3489-
if (ret < 0)
3490-
return ret;
3491-
}
3492-
3493-
return generic_file_buffered_read(iocb, to, ret);
3494-
}
3495-
34963479
const struct file_operations btrfs_file_operations = {
34973480
.llseek = btrfs_file_llseek,
3498-
.read_iter = btrfs_file_read_iter,
3481+
.read_iter = generic_file_read_iter,
34993482
.splice_read = generic_file_splice_read,
35003483
.write_iter = btrfs_file_write_iter,
35013484
.mmap = btrfs_file_mmap,

0 commit comments

Comments
 (0)