Skip to contentSkip to conversation

Add O_NONBLOCK support to FUSE

PATCH In review Jeff Dike 2 participants 4 messages Mar 1, 2006 – Mar 2, 2006

Subsystems (2)
lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 1/1 Add O_NONBLOCK support to FUSE

This adds O_NONBLOCK support to FUSE.
I don't like duplicating the connected and list_empty tests in fuse_dev_readv, but this seemed cleaner than adding the f_flags test to request_wait.

fs/fuse/dev.c +6 -0
Index: host-2.6.15-fuse/fs/fuse/dev.c
===================================================================
@@ -613,6 +613,12 @@ static ssize_t fuse_dev_readv(struct fil
 	err = -EPERM;
 	if (!fc)
 		goto err_unlock;
+
+	err = -EAGAIN;
+	if((file->f_flags & O_NONBLOCK) && fc->connected &&
+	   list_empty(&fc->pending))
+		goto err_unlock;
+
 	request_wait(fc);
 	err = -ENODEV;
 	if (!fc->connected)
author
#2 lore raw

Found the BUG, patch below. Feel free to merge it with the async patch even though it is signed off on its own.

Jeff

I didn't realize that kobject_put(&fc->kobj) freed fc.

fs/fuse/dev.c +1 -1
Index: host-2.6.15-fuse/fs/fuse/dev.c
===================================================================
@@ -919,9 +919,9 @@ static int fuse_dev_release(struct inode
 	}
 	spin_unlock(&fuse_lock);
 	if (fc) {
-		kobject_put(&fc->kobj);
 		fasync_helper(-1, file, 0, &fc->fasync);
 		fc->fasync = NULL;
+		kobject_put(&fc->kobj);
 	}
 
 	return 0;
maintainer
#3 lore raw
Quoted 2 lines

Found the BUG, patch below. Feel free to merge it with the async patch even though it is signed off on its own.

OK.

And I think the 'fc->fasync = NULL' is redundant, since fasync_helper() should have already set it to NULL (fc->fasync list will contain at most one item).

Committed both changes.

Miklos