Add write throttling to NFS client
PATCH 1/1 Add write throttling to NFS client
Hi,
The attached patch implements write throttling for the NFS client. In the stock client, a streaming write will hog all the request slots blocking out other access to the same mount point. For example, running a single dd in my NFS home directory completely blocks my X session until the dd process exits. With the patch, I have tested running 4 dd's without causing a completely lock out. Please consider it for inclusion.
Thanks,
Shantanu
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
fs/nfs/inode.c +3 -0
@@ -364,6 +364,9 @@if (sb->s_maxbytes >MAX_LFS_FILESIZE ) sb->s_maxbytes =MAX_LFS_FILESIZE ; + server->wactive =0 ; +init_waitqueue_head (&server->writerq); +/* We're airborne Set socket buffersize */ rpc_setbufsize (server->client, server->wsize +100 , server->rsize +100 );return 0 ;
fs/nfs/pagelist.c +27 -3
@@ -249,6 +249,8 @@* @file: if set, ensure we match requests from this file * @idx_start: lower bound of page->index to scan * @npages: idx_start + npages sets the upper bound to scan. +* @max_req: if set, stop after this many coalesced requests. +* @wpages: if max_req is set, max # pages per coalesced request. * * Moves elements from one of the inode request lists. * If the number of requests is set to 0, the entire address_space
@@ -259,18 +261,22 @@int nfs_scan_list (struct list_head *head,struct list_head *dst,struct file *file, -unsigned long idx_start,unsigned int npages) +unsigned long idx_start,unsigned int npages, +unsigned int max_req,unsigned int wpages) {struct list_head *pos, *tmp; -struct nfs_page *req; +struct nfs_page *req, *prev;unsigned long idx_end; -int res; +int res, is_contig; +unsigned int nreq, pages; res =0 ;if (npages ==0 ) idx_end = ~0 ;else idx_end = idx_start + npages -1 ; + nreq = pages =0 ; + prev =NULL ;list_for_each_safe (pos, tmp, head) {
@@ -284,11 +290,29 @@if (req->wb_index > idx_end)break ; + is_contig = (max_req && + prev && + pages < wpages && + req->wb_pgbase ==0 && + prev->wb_pgbase + prev->wb_bytes ==PAGE_CACHE_SIZE && + req->wb_index == prev->wb_index +1 && + req->wb_cred == prev->wb_cred); + +if (max_req && !is_contig && nreq == max_req) +break ; +if (!nfs_lock_request (req))continue ;nfs_list_remove_request (req);nfs_list_add_request (req, dst); res++; + +if (!is_contig) { + nreq++; + pages =1 ; + }else + pages++; + prev = req; }return res; }
fs/nfs/write.c +112 -14
204 lines not on this page · raw message
include/linux/nfs_fs_sb.h +2 -0
@@ -28,6 +28,8 @@char * hostname;/* remote hostname */ struct nfs_fh fh;struct sockaddr_in addr; +unsigned int wactive;/* # write requests in progress */ +wait_queue_head_t writerq;/* writers waiting to write */ #ifdef CONFIG_NFS_V4 /* Our own IP address, as a null-terminated string. * This is used to generate the clientid, and the callback address.
include/linux/nfs_page.h +2 -1
@@ -53,7 +53,8 @@extern void nfs_list_add_request (struct nfs_page *,struct list_head *);extern int nfs_scan_list (struct list_head *,struct list_head *, -struct file *,unsigned long ,unsigned int ); +struct file *,unsigned long ,unsigned int , +unsigned int ,unsigned int );extern int nfs_coalesce_requests (struct list_head *,struct list_head *,unsigned int );extern int nfs_wait_on_request (struct nfs_page *);