]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/f2fs/namei.c
Merge tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / fs / f2fs / namei.c
index d479b91f9ca0b4f7c6ee963f4e686e60ee04dbf2..2aa035422c0fac63a51e60d1a5dce93a37482dc6 100644 (file)
@@ -906,7 +906,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct f2fs_dir_entry *old_dir_entry = NULL;
        struct f2fs_dir_entry *old_entry;
        struct f2fs_dir_entry *new_entry;
-       bool is_old_inline = f2fs_has_inline_dentry(old_dir);
        int err;
 
        if (unlikely(f2fs_cp_error(sbi)))
@@ -919,6 +918,20 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        F2FS_I(old_dentry->d_inode)->i_projid)))
                return -EXDEV;
 
+       /*
+        * If new_inode is null, the below renaming flow will
+        * add a link in old_dir which can conver inline_dir.
+        * After then, if we failed to get the entry due to other
+        * reasons like ENOMEM, we had to remove the new entry.
+        * Instead of adding such the error handling routine, let's
+        * simply convert first here.
+        */
+       if (old_dir == new_dir && !new_inode) {
+               err = f2fs_try_convert_inline_dir(old_dir, new_dentry);
+               if (err)
+                       return err;
+       }
+
        if (flags & RENAME_WHITEOUT) {
                err = f2fs_create_whiteout(old_dir, &whiteout);
                if (err)
@@ -1006,28 +1019,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
                if (old_dir_entry)
                        f2fs_i_links_write(new_dir, true);
-
-               /*
-                * old entry and new entry can locate in the same inline
-                * dentry in inode, when attaching new entry in inline dentry,
-                * it could force inline dentry conversion, after that,
-                * old_entry and old_page will point to wrong address, in
-                * order to avoid this, let's do the check and update here.
-                */
-               if (is_old_inline && !f2fs_has_inline_dentry(old_dir)) {
-                       f2fs_put_page(old_page, 0);
-                       old_page = NULL;
-
-                       old_entry = f2fs_find_entry(old_dir,
-                                               &old_dentry->d_name, &old_page);
-                       if (!old_entry) {
-                               err = -ENOENT;
-                               if (IS_ERR(old_page))
-                                       err = PTR_ERR(old_page);
-                               f2fs_unlock_op(sbi);
-                               goto out_dir;
-                       }
-               }
        }
 
        down_write(&F2FS_I(old_inode)->i_sem);