Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e6df3a663a5d1ee68aeae7f007197f272700d9cc
Commit:     e6df3a663a5d1ee68aeae7f007197f272700d9cc
Parent:     16c6a4f24de2933b26477ad5dfb71f518220d641
Author:     Joel Becker <[EMAIL PROTECTED]>
AuthorDate: Tue Feb 6 15:45:39 2007 -0800
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Tue Jul 10 17:19:46 2007 -0700

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/cluster/heartbeat.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 2877d46..2bd7f78 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1335,6 +1335,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region 
*reg,
        ret = wait_event_interruptible(o2hb_steady_queue,
                                atomic_read(&reg->hr_steady_iterations) == 0);
        if (ret) {
+               /* We got interrupted (hello ptrace!).  Clean up */
                spin_lock(&o2hb_live_lock);
                hb_task = reg->hr_task;
                reg->hr_task = NULL;
@@ -1345,7 +1346,16 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region 
*reg,
                goto out;
        }
 
-       ret = count;
+       /* Ok, we were woken.  Make sure it wasn't by drop_item() */
+       spin_lock(&o2hb_live_lock);
+       hb_task = reg->hr_task;
+       spin_unlock(&o2hb_live_lock);
+
+       if (hb_task)
+               ret = count;
+       else
+               ret = -EIO;
+
 out:
        if (filp)
                fput(filp);
@@ -1523,6 +1533,15 @@ static void o2hb_heartbeat_group_drop_item(struct 
config_group *group,
        if (hb_task)
                kthread_stop(hb_task);
 
+       /*
+        * If we're racing a dev_write(), we need to wake them.  They will
+        * check reg->hr_task
+        */
+       if (atomic_read(&reg->hr_steady_iterations) != 0) {
+               atomic_set(&reg->hr_steady_iterations, 0);
+               wake_up(&o2hb_steady_queue);
+       }
+
        config_item_put(item);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to