diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 18aa6a12e805..5b948c92f981 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1453,8 +1453,16 @@ static int move_data_block(struct inode *inode, block_t bidx, goto up_out; } + /* + * If newaddr is in a sequential zone, it must be written once it is + * allocated, otherwise it leaves a hole in the zone, and the following + * write to the zone will fail as an unaligned write, so don't fail + * here. + */ tentry = f2fs_grab_cache(META_CACHE(fio.sbi), newaddr, - F2FS_CACHE_LOCK_CREATE); + F2FS_CACHE_LOCK_CREATE | + (f2fs_is_sequential_zone_area(fio.sbi, newaddr) ? + F2FS_CACHE_NOFAIL : 0)); if (IS_ERR(tentry)) { err = PTR_ERR(tentry); f2fs_put_cache(sentry, true);