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; }