[PATCH] fuse: add number of waiting requests attribute
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 17 Jan 2006 06:14:38 +0000 (22:14 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 17 Jan 2006 07:15:30 +0000 (23:15 -0800)
This patch adds the 'waiting' attribute which indicates how many filesystem
requests are currently waiting to be completed.  A non-zero value without any
filesystem activity indicates a hung or deadlocked filesystem.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/fuse/dev.c
fs/fuse/fuse_i.h
fs/fuse/inode.c

index de4a0a0bda8a6bd55a792a492c8ce1acb6eda20b..c72e44b58d098b197b740ec720389e2ae7c63583 100644 (file)
@@ -109,18 +109,24 @@ struct fuse_req *fuse_get_request(struct fuse_conn *fc)
        int intr;
        sigset_t oldset;
 
+       atomic_inc(&fc->num_waiting);
        block_sigs(&oldset);
        intr = down_interruptible(&fc->outstanding_sem);
        restore_sigs(&oldset);
-       return intr ? NULL : do_get_request(fc);
+       if (intr) {
+               atomic_dec(&fc->num_waiting);
+               return NULL;
+       }
+       return do_get_request(fc);
 }
 
 static void fuse_putback_request(struct fuse_conn *fc, struct fuse_req *req)
 {
        spin_lock(&fuse_lock);
-       if (req->preallocated)
+       if (req->preallocated) {
+               atomic_dec(&fc->num_waiting);
                list_add(&req->list, &fc->unused_list);
-       else
+       else
                fuse_request_free(req);
 
        /* If we are in debt decrease that first */
index 6ef1e5f5873ba4b9c0a985c1aee735dcad936cad..bcb453f681119373b88a1a2894bb4820b3f0f170 100644 (file)
@@ -280,6 +280,9 @@ struct fuse_conn {
        /** Is create not implemented by fs? */
        unsigned no_create : 1;
 
+       /** The number of requests waiting for completion */
+       atomic_t num_waiting;
+
        /** Negotiated minor version */
        unsigned minor;
 
index 514b700c863da8a324b88b57f3b6c7378a935fbd..182235923cdda95d8ff9526bd3ebefbd731266a9 100644 (file)
@@ -555,7 +555,16 @@ static struct file_system_type fuse_fs_type = {
        .kill_sb        = kill_anon_super,
 };
 
+static ssize_t fuse_conn_waiting_show(struct fuse_conn *fc, char *page)
+{
+       return sprintf(page, "%i\n", atomic_read(&fc->num_waiting));
+}
+
+static struct fuse_conn_attr fuse_conn_waiting =
+       __ATTR(waiting, 0400, fuse_conn_waiting_show, NULL);
+
 static struct attribute *fuse_conn_attrs[] = {
+       &fuse_conn_waiting.attr,
        NULL,
 };