From: Tom Zanussi <zanussi@us.ibm.com>

This patch cancels and flushes any delayed work when the channel is closed or
reset.

Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 fs/relayfs/relay.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff -puN fs/relayfs/relay.c~relayfs-cancel-work-on-close-reset fs/relayfs/relay.c
--- 25/fs/relayfs/relay.c~relayfs-cancel-work-on-close-reset	Fri Jun 24 16:16:56 2005
+++ 25-akpm/fs/relayfs/relay.c	Fri Jun 24 16:16:56 2005
@@ -155,6 +155,10 @@ static inline void __relay_reset(struct 
 	if (init) {
 		init_waitqueue_head(&buf->read_wait);
 		kref_init(&buf->kref);
+		INIT_WORK(&buf->wake_readers, NULL, NULL);
+	} else {
+		cancel_delayed_work(&buf->wake_readers);
+		flush_scheduled_work();
 	}
 
 	atomic_set(&buf->subbufs_produced, 0);
@@ -171,8 +175,6 @@ static inline void __relay_reset(struct 
 
 	buf->offset = buf->chan->cb->subbuf_start(buf, buf->data, 0, NULL);
 	buf->commit[0] = buf->offset;
-
-	INIT_WORK(&buf->wake_readers, NULL, NULL);
 }
 
 /**
@@ -238,6 +240,8 @@ static inline void relay_close_buf(struc
 {
 	buf->finalized = 1;
 	buf->chan->cb = &default_channel_callbacks;
+	cancel_delayed_work(&buf->wake_readers);
+	flush_scheduled_work();
 	kref_put(&buf->kref, relay_remove_buf);
 }
 
_