Drop 'size' argument from bio_endio and bi_end_io
[deliverable/linux.git] / fs / ocfs2 / cluster / heartbeat.c
index 2877d468f11510079313621f435ba8ebca7a7328..da2c2b442b4913e768812fa644dd78823979edee 100644 (file)
@@ -217,7 +217,6 @@ static void o2hb_wait_on_io(struct o2hb_region *reg,
 }
 
 static int o2hb_bio_end_io(struct bio *bio,
-                          unsigned int bytes_done,
                           int error)
 {
        struct o2hb_bio_wait_ctxt *wc = bio->bi_private;
@@ -227,9 +226,6 @@ static int o2hb_bio_end_io(struct bio *bio,
                wc->wc_error = error;
        }
 
-       if (bio->bi_size)
-               return 1;
-
        o2hb_bio_wait_dec(wc, 1);
        bio_put(bio);
        return 0;
@@ -1335,6 +1331,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 +1342,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 +1529,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);
 }
 
This page took 0.03517 seconds and 5 git commands to generate.