fuse: update backing_dev_info congestion state
authorMiklos Szeredi <mszeredi@suse.cz>
Wed, 17 Oct 2007 06:30:59 +0000 (23:30 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 17 Oct 2007 15:43:03 +0000 (08:43 -0700)
Set the read and write congestion state if the request queue is close to
blocking, and clear it when it's not.

This prevents unnecessary blocking in readahead and (when writable mmaps are
allowed) writeback.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/fuse/dev.c
fs/fuse/fuse_i.h

index 3ad22beb24c2ed3adf973099e4ed8dc87c9e48be..ebc36f525eeedbf26b83e75d1d172556c8965125 100644 (file)
@@ -224,6 +224,10 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
                        fc->blocked = 0;
                        wake_up_all(&fc->blocked_waitq);
                }
+               if (fc->num_background == FUSE_CONGESTION_THRESHOLD) {
+                       clear_bdi_congested(&fc->bdi, READ);
+                       clear_bdi_congested(&fc->bdi, WRITE);
+               }
                fc->num_background--;
        }
        spin_unlock(&fc->lock);
@@ -378,6 +382,10 @@ static void request_send_nowait(struct fuse_conn *fc, struct fuse_req *req)
                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);
                spin_unlock(&fc->lock);
index 68ae87cbafab556a8b3843681274f7ac911ceae8..9f4603beb9e835cd3ba328ee228c6723c66b1f8e 100644 (file)
 #define FUSE_MAX_PAGES_PER_REQ 32
 
 /** Maximum number of outstanding background requests */
-#define FUSE_MAX_BACKGROUND 10
+#define FUSE_MAX_BACKGROUND 12
+
+/** Congestion starts at 75% of maximum */
+#define FUSE_CONGESTION_THRESHOLD (FUSE_MAX_BACKGROUND * 75 / 100)
 
 /** It could be as large as PATH_MAX, but would that have any uses? */
 #define FUSE_NAME_MAX 1024