From 236f8549ddabd8a223a726d4a6c468428ab077d2 Mon Sep 17 00:00:00 2001 From: yao zhang1 Date: Tue, 7 May 2024 10:19:26 +0800 Subject: [PATCH] Revert "f2fs: preserve direct write semantics when buffering is forced" This reverts commit 82ab408329a9ad987f3bba843e7581e3235966e4. Change-Id: Ia0ad2463619b391a6589ba637edca394ff7b71eb Signed-off-by: yao zhang1 --- fs/f2fs/file.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 9d181630d489..268c8a76d4ba 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4550,6 +4550,7 @@ static const struct iomap_dio_ops f2fs_iomap_dio_write_ops = { .end_io = f2fs_dio_write_end_io, }; +#if !IS_ENABLED(CONFIG_AMLOGIC_F2FS_OPTIMIZATION) static void f2fs_flush_buffered_write(struct address_space *mapping, loff_t start_pos, loff_t end_pos) { @@ -4562,6 +4563,7 @@ static void f2fs_flush_buffered_write(struct address_space *mapping, start_pos >> PAGE_SHIFT, end_pos >> PAGE_SHIFT); } +#endif static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from, bool *may_need_sync) @@ -4661,9 +4663,20 @@ static ssize_t f2fs_dio_write_iter(struct kiocb *iocb, struct iov_iter *from, ret += ret2; +#if IS_ENABLED(CONFIG_AMLOGIC_F2FS_OPTIMIZATION) + ret2 = filemap_write_and_wait_range(file->f_mapping, + bufio_start_pos, + bufio_end_pos); + if (ret2 < 0) + goto out; + invalidate_mapping_pages(file->f_mapping, + bufio_start_pos >> PAGE_SHIFT, + bufio_end_pos >> PAGE_SHIFT); +#else f2fs_flush_buffered_write(file->f_mapping, bufio_start_pos, bufio_end_pos); +#endif } } else { /* iomap_dio_rw() already handled the generic_write_sync(). */ @@ -4750,6 +4763,7 @@ out: if (ret > 0 && may_need_sync) ret = generic_write_sync(iocb, ret); +#if !IS_ENABLED(CONFIG_AMLOGIC_F2FS_OPTIMIZATION) /* If buffered IO was forced, flush and drop the data from * the page cache to preserve O_DIRECT semantics */ @@ -4757,6 +4771,7 @@ out: f2fs_flush_buffered_write(iocb->ki_filp->f_mapping, orig_pos, orig_pos + ret - 1); +#endif return ret; }