2006-03-01 02:28:35

by Jeff Dike

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Jeff Dike <[email protected]>

Index: host-2.6.15-fuse/fs/fuse/dev.c
===================================================================
--- host-2.6.15-fuse.orig/fs/fuse/dev.c 2006-02-28 21:00:00.000000000 -0500
+++ host-2.6.15-fuse/fs/fuse/dev.c 2006-02-28 21:04:36.000000000 -0500
@@ -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)


2006-03-01 09:51:57

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [PATCH] Add O_NONBLOCK support to FUSE

Thanks. Queued both patches.

Miklos

2006-03-02 18:04:13

by Jeff Dike

[permalink] [raw]
Subject: Re: [PATCH] Add O_NONBLOCK support to FUSE

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.

Signed-off-by: Jeff Dike <[email protected]>

Index: host-2.6.15-fuse/fs/fuse/dev.c
===================================================================
--- host-2.6.15-fuse.orig/fs/fuse/dev.c 2006-03-01 14:08:40.000000000 -0500
+++ host-2.6.15-fuse/fs/fuse/dev.c 2006-03-01 14:09:04.000000000 -0500
@@ -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;

2006-03-02 19:56:41

by Miklos Szeredi

[permalink] [raw]
Subject: Re: [PATCH] Add O_NONBLOCK support to FUSE

> 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