Whamcloud - gitweb
LU-11851 ldiskfs: reschedule for htree thread.
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ubuntu14+16 / ext4-pdirop-001.patch
index ad8800f..e111d4b 100644 (file)
@@ -126,7 +126,7 @@ new file mode 100644
 index 0000000..99e7375
 --- /dev/null
 +++ b/fs/ext4/htree_lock.c
-@@ -0,0 +1,880 @@
+@@ -0,0 +1,891 @@
 +/*
 + * fs/ext4/htree_lock.c
 + *
@@ -768,12 +768,23 @@ index 0000000..99e7375
 +              lck->lk_task = current;
 +              list_add_tail(&lck->lk_blocked_list, &lhead->lh_blocked_list);
 +
++retry:
 +              set_current_state(TASK_UNINTERRUPTIBLE);
 +              htree_spin_unlock(lhead, HTREE_DEP_ROOT);
 +              /* wait to be given the lock */
 +              if (lck->lk_task != NULL)
 +                      schedule();
-+              /* granted, no doubt. wake up will set me RUNNING */
++              /* granted, no doubt. wake up will set me RUNNING.
++               * Since thread would be waken up accidentally,
++               * so we need check lock whether granted or not again. */
++              if (!list_empty(&lck->lk_blocked_list)) {
++                      htree_spin_lock(lhead, HTREE_DEP_ROOT);
++                      if (list_empty(&lck->lk_blocked_list)) {
++                              htree_spin_unlock(lhead, HTREE_DEP_ROOT);
++                              return 0;
++                      }
++                      goto retry;
++              }
 +              return 0; /* without lh_lock */
 +      }
 +      lhead->lh_ngranted[lck->lk_mode]++;
@@ -1668,7 +1679,7 @@ index 2543b8f..e70b61a 100644
                            dx_get_limit((frame - 1)->entries)) {
 @@ -2472,8 +2818,32 @@ again:
                        restart = 1;
-                       goto cleanup;
+                       goto journal_error;
                }
 +      } else if (!ext4_htree_dx_locked(lck)) {
 +              struct ext4_dir_lock_data *ld = ext4_htree_lock_data(lck);
@@ -1702,7 +1713,7 @@ index 2543b8f..e70b61a 100644
                goto cleanup;
 @@ -2484,6 +2854,8 @@ again:
  journal_error:
-       ext4_std_error(dir->i_sb, err);
+       ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */
  cleanup:
 +      ext4_htree_dx_unlock(lck);
 +      ext4_htree_de_unlock(lck);