Commit 079b805782f94f4b278132286a8c9bc4655d1c51

Authored by Sunil Mushran
Committed by Joel Becker
1 parent db0f6ce697

ocfs2: Plugs race between the dc thread and an unlock ast message

This patch plugs a race between the downconvert thread and an unlock ast message.
Specifically, after the downconvert worker has done its task, the dc thread needs
to check whether an unlock ast made the downconvert moot.

Reported-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Acked-by: Mark Fasheh <mfasheh@sus.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

... ... @@ -3384,6 +3384,7 @@
3384 3384 unsigned long flags;
3385 3385 int blocking;
3386 3386 int new_level;
  3387 + int level;
3387 3388 int ret = 0;
3388 3389 int set_lvb = 0;
3389 3390 unsigned int gen;
... ... @@ -3503,6 +3504,7 @@
3503 3504 * may sleep, so we save off a copy of what we're blocking as
3504 3505 * it may change while we're not holding the spin lock. */
3505 3506 blocking = lockres->l_blocking;
  3507 + level = lockres->l_level;
3506 3508 spin_unlock_irqrestore(&lockres->l_lock, flags);
3507 3509  
3508 3510 ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking);
... ... @@ -3511,7 +3513,7 @@
3511 3513 goto leave;
3512 3514  
3513 3515 spin_lock_irqsave(&lockres->l_lock, flags);
3514   - if (blocking != lockres->l_blocking) {
  3516 + if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) {
3515 3517 /* If this changed underneath us, then we can't drop
3516 3518 * it just yet. */
3517 3519 goto recheck;