--- x/fs/f2fs/dir.c +++ y/fs/f2fs/dir.c @@ -776,6 +776,8 @@ int f2fs_add_dentry(struct inode *dir, c int err = -EAGAIN; if (f2fs_has_inline_dentry(dir)) { + if (inode) + f2fs_down_write(&F2FS_I(inode)->i_sem); /* * Should get i_xattr_sem to keep the lock order: * i_xattr_sem -> inode_page lock used by f2fs_setxattr. @@ -783,6 +785,8 @@ int f2fs_add_dentry(struct inode *dir, c f2fs_down_read(&F2FS_I(dir)->i_xattr_sem); err = f2fs_add_inline_entry(dir, fname, inode, ino, mode); f2fs_up_read(&F2FS_I(dir)->i_xattr_sem); + if (inode) + f2fs_up_write(&F2FS_I(inode)->i_sem); } if (err == -EAGAIN) err = f2fs_add_regular_entry(dir, fname, inode, ino, mode); --- x/fs/f2fs/inline.c +++ y/fs/f2fs/inline.c @@ -624,6 +624,9 @@ int f2fs_add_inline_entry(struct inode * struct page *page = NULL; int err = 0; + if (inode) + lockdep_assert_held(&F2FS_I(inode)->i_sem); + ipage = f2fs_get_node_page(sbi, dir->i_ino); if (IS_ERR(ipage)) return PTR_ERR(ipage); @@ -641,11 +644,10 @@ int f2fs_add_inline_entry(struct inode * } if (inode) { - f2fs_down_write(&F2FS_I(inode)->i_sem); page = f2fs_init_inode_metadata(inode, dir, fname, ipage); if (IS_ERR(page)) { err = PTR_ERR(page); - goto fail; + goto out; } } @@ -668,9 +670,6 @@ int f2fs_add_inline_entry(struct inode * } f2fs_update_parent_metadata(dir, inode, 0); -fail: - if (inode) - f2fs_up_write(&F2FS_I(inode)->i_sem); out: f2fs_put_page(ipage, 1); return err;