Commit e6df3a663a5d1ee68aeae7f007197f272700d9cc

Authored by Joel Becker
Committed by Mark Fasheh
1 parent 16c6a4f24d

ocfs2: Wake up a starting region if it gets killed in the background.

Tell o2cb_region_dev_write() to wake up if rmdir(2) happens on the
heartbeat region while it is starting up.  Then o2hb_region_dev_write()
can check to see if it is alive and act accordingly.  This prevents a hang
(not being woken) and a crash (if it's woken by a signal).

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

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

fs/ocfs2/cluster/heartbeat.c
... ... @@ -1335,6 +1335,7 @@
1335 1335 ret = wait_event_interruptible(o2hb_steady_queue,
1336 1336 atomic_read(&reg->hr_steady_iterations) == 0);
1337 1337 if (ret) {
  1338 + /* We got interrupted (hello ptrace!). Clean up */
1338 1339 spin_lock(&o2hb_live_lock);
1339 1340 hb_task = reg->hr_task;
1340 1341 reg->hr_task = NULL;
... ... @@ -1345,7 +1346,16 @@
1345 1346 goto out;
1346 1347 }
1347 1348  
1348   - ret = count;
  1349 + /* Ok, we were woken. Make sure it wasn't by drop_item() */
  1350 + spin_lock(&o2hb_live_lock);
  1351 + hb_task = reg->hr_task;
  1352 + spin_unlock(&o2hb_live_lock);
  1353 +
  1354 + if (hb_task)
  1355 + ret = count;
  1356 + else
  1357 + ret = -EIO;
  1358 +
1349 1359 out:
1350 1360 if (filp)
1351 1361 fput(filp);
... ... @@ -1522,6 +1532,15 @@
1522 1532  
1523 1533 if (hb_task)
1524 1534 kthread_stop(hb_task);
  1535 +
  1536 + /*
  1537 + * If we're racing a dev_write(), we need to wake them. They will
  1538 + * check reg->hr_task
  1539 + */
  1540 + if (atomic_read(&reg->hr_steady_iterations) != 0) {
  1541 + atomic_set(&reg->hr_steady_iterations, 0);
  1542 + wake_up(&o2hb_steady_queue);
  1543 + }
1525 1544  
1526 1545 config_item_put(item);
1527 1546 }