Commit 7bc0f46d418a ("f2fs: fix out-place-update DIO write")
added a parameter map.m_may_create to replace @create for
triggering OPU allocation correctly.

But we find it is still in-place-update when used AndroBench
to test this feature.In f2fs_map_blocks(), @create has been
overwritten by the code below. So the function can not allocate
new block address and directly go out.
code:
create = dio->op == REQ_OP_WRITE;
if (dio->flags & DIO_SKIP_HOLES) {
        if (fs_startblk <= ((i_size_read(dio->inode) -1) >>i_blkbits))
                create = 0;
                }

This patch use @map.m_may_create to replace @create to avoid
this problem.

Signed-off-by: Jia Zhu <[email protected]>
---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8780f3d..9b61cba 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1034,7 +1034,7 @@ int f2fs_map_blocks(struct inode *inode, struct 
f2fs_map_blocks *map,
        pgofs = (pgoff_t)map->m_lblk;
        end = pgofs + maxblocks;
 
-       if (!create && f2fs_lookup_extent_cache(inode, pgofs, &ei)) {
+       if (!map->m_may_create && f2fs_lookup_extent_cache(inode, pgofs, &ei)) {
                map->m_pblk = ei.blk + pgofs - ei.fofs;
                map->m_len = min((pgoff_t)maxblocks, ei.fofs + ei.len - pgofs);
                map->m_flags = F2FS_MAP_MAPPED;
@@ -1093,7 +1093,7 @@ int f2fs_map_blocks(struct inode *inode, struct 
f2fs_map_blocks *map,
                                set_inode_flag(inode, FI_APPEND_WRITE);
                }
        } else {
-               if (create) {
+               if (map->m_may_create) {
                        if (unlikely(f2fs_cp_error(sbi))) {
                                err = -EIO;
                                goto sync_out;
-- 
2.10.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to