Whamcloud - gitweb
LU-3935 scrub: support dryrun mode OI scrub
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_compat.c
index f86da33..c6ac60c 100644 (file)
@@ -1120,12 +1120,30 @@ int osd_obj_map_recover(struct osd_thread_info *info,
                 *
                 *      So keep it there before we have suitable solution. */
                brelse(bh);
+               mutex_unlock(&dir->i_mutex);
 
+               rc = -EEXIST;
                /* If the src object has never been modified, then remove it. */
                if (inode->i_size == 0 && inode->i_mode & S_ISUID &&
-                   inode->i_mode & S_ISGID)
-                       vfs_unlink(src_parent, src_child);
-               GOTO(unlock_src, rc = 0);
+                   inode->i_mode & S_ISGID) {
+                       bh = osd_ldiskfs_find_entry(src_parent, src_child, &de,
+                                                   NULL);
+                       if (unlikely(bh == NULL)) {
+                               mutex_unlock(&src_parent->i_mutex);
+                               ldiskfs_journal_stop(jh);
+                               RETURN(0);
+                       }
+
+                       rc = ldiskfs_delete_entry(jh, src_parent, de, bh);
+                       brelse(bh);
+                       if (rc == 0) {
+                               drop_nlink(inode);
+                               ll_dirty_inode(inode, I_DIRTY_DATASYNC);
+                       }
+               }
+               mutex_unlock(&src_parent->i_mutex);
+               ldiskfs_journal_stop(jh);
+               RETURN(rc);
        }
 
        bh = osd_ldiskfs_find_entry(src_parent, src_child, &de, NULL);
@@ -1143,8 +1161,6 @@ int osd_obj_map_recover(struct osd_thread_info *info,
 
 unlock:
        mutex_unlock(&dir->i_mutex);
-
-unlock_src:
        mutex_unlock(&src_parent->i_mutex);
        ldiskfs_journal_stop(jh);
        return rc;