Re: [patch 03/11] fuse: add reference counting to fuse_file
From: Ingo Oeser
Date: Sat Aug 04 2007 - 07:35:28 EST
Hi Miklos,
On Friday 03 August 2007, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi@xxxxxxx>
>
> Make lifetime of 'struct fuse_file' independent from 'struct file' by
> adding a reference counter and destructor.
What about using krefs to implement that?
see include/linux/kref.h
and lib/kref.c
Just embed that "struct kref" inside your struct fuse_file
struct fuse_file {
...
struct kref ref;
...
}
init in struct fuse_file *fuse_file_alloc(void) where you added the counter.
...
kref_init(&ff->ref);
...
and implement the release function like:
static void fuse_file_release(struct kref *ff_ref)
{
struct fuse_file *ff = container_of(ff_ref, struct fuse_file, ref);
struct fuse_req *req = ff->reserved_req;
struct fuse_conn *fc = get_fuse_conn(req->dentry->d_inode);
request_send_background(fc, req);
kfree(ff);
}
This will also fix the missing smp_barriers, is very simple, saves code,
makes your life easier and is a well known known kernel infrastructure :-)
BTW: FUSE rocks! :-)
You can add my "Signed-off-by: Ingo Oeser <ioe-lkml@xxxxxxxxxx>",
if you want to use that suggestion.
Best Regards
Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/