[openib-general] [PATCH] signal driven io support for ib_uverbs

Gleb Natapov glebn at voltaire.com
Wed Jul 6 05:17:11 PDT 2005


Hello, 

Included patch adds O_ASYNC support for uverbs event handling.

Signed-off-by: Gleb Natapov <glebn at voltaire.com>

Index: trunk/src/linux-kernel/infiniband/core/uverbs_main.c
===================================================================
--- trunk/src/linux-kernel/infiniband/core/uverbs_main.c	(revision 2810)
+++ trunk/src/linux-kernel/infiniband/core/uverbs_main.c	(working copy)
@@ -258,10 +258,28 @@
 	spin_unlock_irq(&file->lock);
 }
 
+static int ib_uverbs_event_async (int fd, struct file *filp, int on)
+{
+	int ret;
+	struct ib_uverbs_event_file *file = filp->private_data;
+
+	if (!file)
+		return -EBADFD;
+
+	if ((ret = fasync_helper(fd, filp, on, &file->fasync)) < 0)
+		return ret;
+
+	if (on)
+		ret = f_setown(filp, current->pid, 0);
+	
+	return ret;
+}
+
 static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
 {
 	struct ib_uverbs_event_file *file = filp->private_data;
 
+	ib_uverbs_event_async (-1, filp, 0);
 	ib_uverbs_event_release(file);
 	kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
 
@@ -277,7 +295,8 @@
 	 */
 	.read 	 = ib_uverbs_event_read,
 	.poll    = ib_uverbs_event_poll,
-	.release = ib_uverbs_event_close
+	.release = ib_uverbs_event_close,
+	.fasync  = ib_uverbs_event_async
 };
 
 void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
@@ -317,6 +336,7 @@
 	spin_unlock_irqrestore(&file->async_file.lock, flags);
 
 	wake_up_interruptible(&file->async_file.poll_wait);
+	kill_fasync (&file->async_file.fasync, SIGIO, POLL_IN);
 }
 
 void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
@@ -351,6 +371,7 @@
 	INIT_LIST_HEAD(&file->event_list);
 	init_waitqueue_head(&file->poll_wait);
 	file->uverbs_file = uverbs_file;
+	file->fasync = NULL;
 
 	file->fd = get_unused_fd();
 	if (file->fd < 0)
Index: trunk/src/linux-kernel/infiniband/core/uverbs.h
===================================================================
--- trunk/src/linux-kernel/infiniband/core/uverbs.h	(revision 2810)
+++ trunk/src/linux-kernel/infiniband/core/uverbs.h	(working copy)
@@ -62,6 +62,7 @@
 	int					fd;
 	int					is_async;
 	wait_queue_head_t			poll_wait;
+	struct fasync_struct			*fasync;
 	struct list_head			event_list;
 };
 
--
			Gleb.



More information about the general mailing list