Whamcloud - gitweb
LU-4002 hsm: avoid layout lock on unlink and rename onto 92/7792/3
authorJohn L. Hammond <johnlockwoodhammond@gmail.com>
Sat, 28 Sep 2013 00:04:37 +0000 (17:04 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 3 Oct 2013 04:49:15 +0000 (04:49 +0000)
In mdt_reint_unlink() and mdt_reint_rename() do not take a FULL inode
lock on the file to be unlinked or the rename target. This avoids a
potential deadlock when unlinking a file under HSM restore.

Signed-off-by: John L. Hammond <johnlockwoodhammond@gmail.com>
Change-Id: Id6b11b9f5c1433221670d154d65d9cec30e260af
Reviewed-on: http://review.whamcloud.com/7792
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_reint.c

index 909091c..80a7aa7 100644 (file)
@@ -828,11 +828,14 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
                GOTO(put_child, rc);
        }
 
-       rc = mdt_object_lock(info, mc, child_lh, MDS_INODELOCK_FULL,
-                             MDT_CROSS_LOCK);
-       if (rc != 0) {
+       /* We used to acquire MDS_INODELOCK_FULL here but we can't do
+        * this now because a running HSM restore on the child (unlink
+        * victim) will hold the layout lock. See LU-4002. */
+       rc = mdt_object_lock(info, mc, child_lh,
+                            MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE,
+                            MDT_CROSS_LOCK);
+       if (rc != 0)
                GOTO(put_child, rc);
-       }
 
         mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom,
                        OBD_FAIL_MDS_REINT_UNLINK_WRITE);
@@ -1290,8 +1293,14 @@ static int mdt_reint_rename(struct mdt_thread_info *info,
                        GOTO(out_unlock_old, rc = -EXDEV);
                }
 
-                rc = mdt_object_lock(info, mnew, lh_newp,
-                                     MDS_INODELOCK_FULL, MDT_CROSS_LOCK);
+               /* We used to acquire MDS_INODELOCK_FULL here but we
+                * can't do this now because a running HSM restore on
+                * the rename onto victim will hold the layout
+                * lock. See LU-4002. */
+               rc = mdt_object_lock(info, mnew, lh_newp,
+                                    MDS_INODELOCK_LOOKUP |
+                                    MDS_INODELOCK_UPDATE,
+                                    MDT_CROSS_LOCK);
                 if (rc != 0) {
                         mdt_object_put(info->mti_env, mnew);
                         GOTO(out_unlock_old, rc);