--- x/fs/f2fs/data.c +++ y/fs/f2fs/data.c @@ -2833,18 +2833,21 @@ write: /* Dentry/quota blocks are controlled by checkpoint */ if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) { + int locked = 0; /* * We need to wait for node_write to avoid block allocation during * checkpoint. This can only happen to quota writes which can cause * the below discard race condition. */ - if (IS_NOQUOTA(inode)) + if (IS_NOQUOTA(inode)) { f2fs_down_read(&sbi->node_write); + locked = 1; + } fio.need_lock = LOCK_DONE; err = f2fs_do_write_data_page(&fio); - if (IS_NOQUOTA(inode)) + if (locked) f2fs_up_read(&sbi->node_write); goto done;