LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch 0/3] fuse: update for 2.6.25
@ 2008-01-29 18:17 Miklos Szeredi
2008-01-29 18:17 ` [patch 1/3] fuse: fix attribute caching after create Miklos Szeredi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Miklos Szeredi @ 2008-01-29 18:17 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-fsdevel
Here's one small fix, one cleanup and one in preparation for writable
mmap support (but which makes sense on it's own as well).
Please apply.
Thanks,
Miklos
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch 1/3] fuse: fix attribute caching after create
2008-01-29 18:17 [patch 0/3] fuse: update for 2.6.25 Miklos Szeredi
@ 2008-01-29 18:17 ` Miklos Szeredi
2008-01-29 18:17 ` [patch 2/3] fuse: save space in struct fuse_req Miklos Szeredi
2008-01-29 18:17 ` [patch 3/3] fuse: limit queued background requests Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2008-01-29 18:17 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-fsdevel
[-- Attachment #1: fuse_create_fix.patch --]
[-- Type: text/plain, Size: 727 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Invalidate attributes on create, since st_ctime is updated. Reported
by Szabolcs Szakacsits
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
Index: linux/fs/fuse/dir.c
===================================================================
--- linux.orig/fs/fuse/dir.c 2008-01-29 17:12:56.000000000 +0100
+++ linux/fs/fuse/dir.c 2008-01-29 17:13:04.000000000 +0100
@@ -416,6 +416,7 @@ static int fuse_create_open(struct inode
fuse_put_request(fc, forget_req);
d_instantiate(entry, inode);
fuse_change_entry_timeout(entry, &outentry);
+ fuse_invalidate_attr(dir);
file = lookup_instantiate_filp(nd, entry, generic_file_open);
if (IS_ERR(file)) {
ff->fh = outopen.fh;
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch 2/3] fuse: save space in struct fuse_req
2008-01-29 18:17 [patch 0/3] fuse: update for 2.6.25 Miklos Szeredi
2008-01-29 18:17 ` [patch 1/3] fuse: fix attribute caching after create Miklos Szeredi
@ 2008-01-29 18:17 ` Miklos Szeredi
2008-01-29 18:17 ` [patch 3/3] fuse: limit queued background requests Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2008-01-29 18:17 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-fsdevel
[-- Attachment #1: fuse_move_to_union.patch --]
[-- Type: text/plain, Size: 3091 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Move the fields 'dentry' and 'vfsmount' into the request specific
union, since these are only used for the RELEASE request.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
Index: linux/fs/fuse/file.c
===================================================================
--- linux.orig/fs/fuse/file.c 2008-01-29 17:12:56.000000000 +0100
+++ linux/fs/fuse/file.c 2008-01-29 17:13:06.000000000 +0100
@@ -77,8 +77,8 @@ static struct fuse_file *fuse_file_get(s
static void fuse_release_end(struct fuse_conn *fc, struct fuse_req *req)
{
- dput(req->dentry);
- mntput(req->vfsmount);
+ dput(req->misc.release.dentry);
+ mntput(req->misc.release.vfsmount);
fuse_put_request(fc, req);
}
@@ -86,7 +86,8 @@ static void fuse_file_put(struct fuse_fi
{
if (atomic_dec_and_test(&ff->count)) {
struct fuse_req *req = ff->reserved_req;
- struct fuse_conn *fc = get_fuse_conn(req->dentry->d_inode);
+ struct inode *inode = req->misc.release.dentry->d_inode;
+ struct fuse_conn *fc = get_fuse_conn(inode);
req->end = fuse_release_end;
request_send_background(fc, req);
kfree(ff);
@@ -137,7 +138,7 @@ int fuse_open_common(struct inode *inode
void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode)
{
struct fuse_req *req = ff->reserved_req;
- struct fuse_release_in *inarg = &req->misc.release_in;
+ struct fuse_release_in *inarg = &req->misc.release.in;
inarg->fh = ff->fh;
inarg->flags = flags;
@@ -153,13 +154,14 @@ int fuse_release_common(struct inode *in
struct fuse_file *ff = file->private_data;
if (ff) {
struct fuse_conn *fc = get_fuse_conn(inode);
+ struct fuse_req *req = ff->reserved_req;
fuse_release_fill(ff, get_node_id(inode), file->f_flags,
isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
/* Hold vfsmount and dentry until release is finished */
- ff->reserved_req->vfsmount = mntget(file->f_path.mnt);
- ff->reserved_req->dentry = dget(file->f_path.dentry);
+ req->misc.release.vfsmount = mntget(file->f_path.mnt);
+ req->misc.release.dentry = dget(file->f_path.dentry);
spin_lock(&fc->lock);
list_del(&ff->write_entry);
Index: linux/fs/fuse/fuse_i.h
===================================================================
--- linux.orig/fs/fuse/fuse_i.h 2008-01-29 17:12:56.000000000 +0100
+++ linux/fs/fuse/fuse_i.h 2008-01-29 17:13:06.000000000 +0100
@@ -215,7 +215,11 @@ struct fuse_req {
/** Data for asynchronous requests */
union {
struct fuse_forget_in forget_in;
- struct fuse_release_in release_in;
+ struct {
+ struct fuse_release_in in;
+ struct vfsmount *vfsmount;
+ struct dentry *dentry;
+ } release;
struct fuse_init_in init_in;
struct fuse_init_out init_out;
struct fuse_read_in read_in;
@@ -238,12 +242,6 @@ struct fuse_req {
/** File used in the request (or NULL) */
struct fuse_file *ff;
- /** vfsmount used in release */
- struct vfsmount *vfsmount;
-
- /** dentry used in release */
- struct dentry *dentry;
-
/** Request completion callback */
void (*end)(struct fuse_conn *, struct fuse_req *);
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* [patch 3/3] fuse: limit queued background requests
2008-01-29 18:17 [patch 0/3] fuse: update for 2.6.25 Miklos Szeredi
2008-01-29 18:17 ` [patch 1/3] fuse: fix attribute caching after create Miklos Szeredi
2008-01-29 18:17 ` [patch 2/3] fuse: save space in struct fuse_req Miklos Szeredi
@ 2008-01-29 18:17 ` Miklos Szeredi
2 siblings, 0 replies; 4+ messages in thread
From: Miklos Szeredi @ 2008-01-29 18:17 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-fsdevel
[-- Attachment #1: fuse_background_limit.patch --]
[-- Type: text/plain, Size: 5586 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Libfuse basically creates a new thread for each new request. This is
fine for synchronous requests, which are naturally limited. However
background requests (especially writepage) can cause a thread creation
storm.
To avoid this, limit the number of background requests available to
userspace.
This is done by introducing another queue for background requests, and
a counter for the number of "active" requests, which are currently
available for userspace.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
Index: linux/fs/fuse/dev.c
===================================================================
--- linux.orig/fs/fuse/dev.c 2008-01-29 17:12:56.000000000 +0100
+++ linux/fs/fuse/dev.c 2008-01-29 17:15:15.000000000 +0100
@@ -201,6 +201,55 @@ void fuse_put_request(struct fuse_conn *
}
}
+static unsigned len_args(unsigned numargs, struct fuse_arg *args)
+{
+ unsigned nbytes = 0;
+ unsigned i;
+
+ for (i = 0; i < numargs; i++)
+ nbytes += args[i].size;
+
+ return nbytes;
+}
+
+static u64 fuse_get_unique(struct fuse_conn *fc)
+{
+ fc->reqctr++;
+ /* zero is special */
+ if (fc->reqctr == 0)
+ fc->reqctr = 1;
+
+ return fc->reqctr;
+}
+
+static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
+{
+ req->in.h.unique = fuse_get_unique(fc);
+ req->in.h.len = sizeof(struct fuse_in_header) +
+ len_args(req->in.numargs, (struct fuse_arg *) req->in.args);
+ list_add_tail(&req->list, &fc->pending);
+ req->state = FUSE_REQ_PENDING;
+ if (!req->waiting) {
+ req->waiting = 1;
+ atomic_inc(&fc->num_waiting);
+ }
+ wake_up(&fc->waitq);
+ kill_fasync(&fc->fasync, SIGIO, POLL_IN);
+}
+
+static void flush_bg_queue(struct fuse_conn *fc)
+{
+ while (fc->active_background < FUSE_MAX_BACKGROUND &&
+ !list_empty(&fc->bg_queue)) {
+ struct fuse_req *req;
+
+ req = list_entry(fc->bg_queue.next, struct fuse_req, list);
+ list_del(&req->list);
+ fc->active_background++;
+ queue_request(fc, req);
+ }
+}
+
/*
* This function is called when a request is finished. Either a reply
* has arrived or it was aborted (and not yet sent) or some error
@@ -229,6 +278,8 @@ static void request_end(struct fuse_conn
clear_bdi_congested(&fc->bdi, WRITE);
}
fc->num_background--;
+ fc->active_background--;
+ flush_bg_queue(fc);
}
spin_unlock(&fc->lock);
wake_up(&req->waitq);
@@ -320,42 +371,6 @@ static void request_wait_answer(struct f
}
}
-static unsigned len_args(unsigned numargs, struct fuse_arg *args)
-{
- unsigned nbytes = 0;
- unsigned i;
-
- for (i = 0; i < numargs; i++)
- nbytes += args[i].size;
-
- return nbytes;
-}
-
-static u64 fuse_get_unique(struct fuse_conn *fc)
- {
- fc->reqctr++;
- /* zero is special */
- if (fc->reqctr == 0)
- fc->reqctr = 1;
-
- return fc->reqctr;
-}
-
-static void queue_request(struct fuse_conn *fc, struct fuse_req *req)
-{
- req->in.h.unique = fuse_get_unique(fc);
- req->in.h.len = sizeof(struct fuse_in_header) +
- len_args(req->in.numargs, (struct fuse_arg *) req->in.args);
- list_add_tail(&req->list, &fc->pending);
- req->state = FUSE_REQ_PENDING;
- if (!req->waiting) {
- req->waiting = 1;
- atomic_inc(&fc->num_waiting);
- }
- wake_up(&fc->waitq);
- kill_fasync(&fc->fasync, SIGIO, POLL_IN);
-}
-
void request_send(struct fuse_conn *fc, struct fuse_req *req)
{
req->isreply = 1;
@@ -375,20 +390,26 @@ void request_send(struct fuse_conn *fc,
spin_unlock(&fc->lock);
}
+static void request_send_nowait_locked(struct fuse_conn *fc,
+ struct fuse_req *req)
+{
+ req->background = 1;
+ fc->num_background++;
+ if (fc->num_background == FUSE_MAX_BACKGROUND)
+ fc->blocked = 1;
+ if (fc->num_background == FUSE_CONGESTION_THRESHOLD) {
+ set_bdi_congested(&fc->bdi, READ);
+ set_bdi_congested(&fc->bdi, WRITE);
+ }
+ list_add_tail(&req->list, &fc->bg_queue);
+ flush_bg_queue(fc);
+}
+
static void request_send_nowait(struct fuse_conn *fc, struct fuse_req *req)
{
spin_lock(&fc->lock);
if (fc->connected) {
- req->background = 1;
- fc->num_background++;
- if (fc->num_background == FUSE_MAX_BACKGROUND)
- fc->blocked = 1;
- if (fc->num_background == FUSE_CONGESTION_THRESHOLD) {
- set_bdi_congested(&fc->bdi, READ);
- set_bdi_congested(&fc->bdi, WRITE);
- }
-
- queue_request(fc, req);
+ request_send_nowait_locked(fc, req);
spin_unlock(&fc->lock);
} else {
req->out.h.error = -ENOTCONN;
Index: linux/fs/fuse/fuse_i.h
===================================================================
--- linux.orig/fs/fuse/fuse_i.h 2008-01-29 17:13:06.000000000 +0100
+++ linux/fs/fuse/fuse_i.h 2008-01-29 17:14:23.000000000 +0100
@@ -296,6 +296,12 @@ struct fuse_conn {
/** Number of requests currently in the background */
unsigned num_background;
+ /** Number of background requests currently queued for userspace */
+ unsigned active_background;
+
+ /** The list of background requests set aside for later queuing */
+ struct list_head bg_queue;
+
/** Pending interrupts */
struct list_head interrupts;
Index: linux/fs/fuse/inode.c
===================================================================
--- linux.orig/fs/fuse/inode.c 2008-01-29 17:12:56.000000000 +0100
+++ linux/fs/fuse/inode.c 2008-01-29 17:14:23.000000000 +0100
@@ -465,6 +465,7 @@ static struct fuse_conn *new_conn(struct
INIT_LIST_HEAD(&fc->processing);
INIT_LIST_HEAD(&fc->io);
INIT_LIST_HEAD(&fc->interrupts);
+ INIT_LIST_HEAD(&fc->bg_queue);
atomic_set(&fc->num_waiting, 0);
fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
fc->bdi.unplug_io_fn = default_unplug_io_fn;
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-29 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-29 18:17 [patch 0/3] fuse: update for 2.6.25 Miklos Szeredi
2008-01-29 18:17 ` [patch 1/3] fuse: fix attribute caching after create Miklos Szeredi
2008-01-29 18:17 ` [patch 2/3] fuse: save space in struct fuse_req Miklos Szeredi
2008-01-29 18:17 ` [patch 3/3] fuse: limit queued background requests Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).