From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758075Ab0LMPPo (ORCPT ); Mon, 13 Dec 2010 10:15:44 -0500 Received: from mga09.intel.com ([134.134.136.24]:24424 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753376Ab0LMPIt (ORCPT ); Mon, 13 Dec 2010 10:08:49 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,336,1288594800"; d="scan'208";a="583219902" Message-Id: <20101213150329.953837345@intel.com> User-Agent: quilt/0.48-1 Date: Mon, 13 Dec 2010 22:47:16 +0800 From: Wu Fengguang To: Andrew Morton CC: Jan Kara , Wu Fengguang CC: Christoph Hellwig CC: Trond Myklebust CC: Dave Chinner CC: "Theodore Ts'o" CC: Chris Mason CC: Peter Zijlstra CC: Mel Gorman CC: Rik van Riel CC: KOSAKI Motohiro CC: Greg Thelen CC: Minchan Kim Cc: linux-mm Cc: Cc: LKML Subject: [PATCH 30/35] nfs: heuristics to avoid commit References: <20101213144646.341970461@intel.com> Content-Disposition: inline; filename=writeback-nfs-should-commit.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The heuristics introduced by commit 420e3646 ("NFS: Reduce the number of unnecessary COMMIT calls") do not work well for large inodes being actively written to. Refine the criterion to - it has gone quiet (all data transfered to server) - has accumulated >= 4MB data to commit (so it will be large IO) - too few active commits (hence active IO) in the server Signed-off-by: Wu Fengguang --- fs/nfs/write.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) --- linux-next.orig/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 +++ linux-next/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 @@ -1518,17 +1518,38 @@ out_mark_dirty: return res; } -static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_control *wbc) +static bool nfs_should_commit(struct inode *inode, + struct writeback_control *wbc) { + struct nfs_server *nfss = NFS_SERVER(inode); struct nfs_inode *nfsi = NFS_I(inode); + unsigned long npages = nfsi->npages; + unsigned long to_commit = nfsi->ncommit; + unsigned long in_commit = atomic_long_read(&nfss->in_commit); + + /* no more active writes */ + if (to_commit == npages) + return true; + + /* big enough */ + if (to_commit >= MIN_WRITEBACK_PAGES) + return true; + + /* active commits drop low: kick more IO for the server disk */ + if (to_commit > in_commit / 2) + return true; + + return false; +} + +static int nfs_commit_unstable_pages(struct inode *inode, + struct writeback_control *wbc) +{ int flags = FLUSH_SYNC; int ret = 0; if (wbc->sync_mode == WB_SYNC_NONE) { - /* Don't commit yet if this is a non-blocking flush and there - * are a lot of outstanding writes for this mapping. - */ - if (nfsi->ncommit <= (nfsi->npages >> 1)) + if (!nfs_should_commit(inode, wbc)) goto out_mark_dirty; /* don't wait for the COMMIT response */ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 30/35] nfs: heuristics to avoid commit Date: Mon, 13 Dec 2010 22:47:16 +0800 Message-ID: <20101213150329.953837345@intel.com> References: <20101213144646.341970461@intel.com> Cc: Jan Kara , Wu Fengguang To: Andrew Morton Return-path: CC: Christoph Hellwig CC: Trond Myklebust CC: Dave Chinner CC: Theodore Ts'o CC: Chris Mason CC: Peter Zijlstra CC: Mel Gorman CC: Rik van Riel CC: KOSAKI Motohiro CC: Greg Thelen CC: Minchan Kim Cc: linux-mm Cc: Cc: LKML Content-Disposition: inline; filename=writeback-nfs-should-commit.patch Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org The heuristics introduced by commit 420e3646 ("NFS: Reduce the number of unnecessary COMMIT calls") do not work well for large inodes being actively written to. Refine the criterion to - it has gone quiet (all data transfered to server) - has accumulated >= 4MB data to commit (so it will be large IO) - too few active commits (hence active IO) in the server Signed-off-by: Wu Fengguang --- fs/nfs/write.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) --- linux-next.orig/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 +++ linux-next/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 @@ -1518,17 +1518,38 @@ out_mark_dirty: return res; } -static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_control *wbc) +static bool nfs_should_commit(struct inode *inode, + struct writeback_control *wbc) { + struct nfs_server *nfss = NFS_SERVER(inode); struct nfs_inode *nfsi = NFS_I(inode); + unsigned long npages = nfsi->npages; + unsigned long to_commit = nfsi->ncommit; + unsigned long in_commit = atomic_long_read(&nfss->in_commit); + + /* no more active writes */ + if (to_commit == npages) + return true; + + /* big enough */ + if (to_commit >= MIN_WRITEBACK_PAGES) + return true; + + /* active commits drop low: kick more IO for the server disk */ + if (to_commit > in_commit / 2) + return true; + + return false; +} + +static int nfs_commit_unstable_pages(struct inode *inode, + struct writeback_control *wbc) +{ int flags = FLUSH_SYNC; int ret = 0; if (wbc->sync_mode == WB_SYNC_NONE) { - /* Don't commit yet if this is a non-blocking flush and there - * are a lot of outstanding writes for this mapping. - */ - if (nfsi->ncommit <= (nfsi->npages >> 1)) + if (!nfs_should_commit(inode, wbc)) goto out_mark_dirty; /* don't wait for the COMMIT response */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 30/35] nfs: heuristics to avoid commit Date: Mon, 13 Dec 2010 22:47:16 +0800 Message-ID: <20101213150329.953837345@intel.com> References: <20101213144646.341970461@intel.com> Return-path: Received: from kanga.kvack.org ([205.233.56.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PSA1i-0001rV-JA for glkm-linux-mm-2@m.gmane.org; Mon, 13 Dec 2010 16:09:22 +0100 Received: from mail202.messagelabs.com (mail202.messagelabs.com [216.82.254.227]) by kanga.kvack.org (Postfix) with SMTP id 878526B009C for ; Mon, 13 Dec 2010 10:08:50 -0500 (EST) Content-Disposition: inline; filename=writeback-nfs-should-commit.patch Sender: owner-linux-mm@kvack.org To: Andrew Morton Cc: Jan Kara , Wu Fengguang , Christoph Hellwig , Trond Myklebust , Dave Chinner , Theodore Ts'o , Chris Mason , Peter Zijlstra , Mel Gorman , Rik van Riel , KOSAKI Motohiro , Greg Thelen , Minchan Kim , linux-mm , linux-fsdevel@vger.kernel.org, LKML List-Id: linux-mm.kvack.org The heuristics introduced by commit 420e3646 ("NFS: Reduce the number of unnecessary COMMIT calls") do not work well for large inodes being actively written to. Refine the criterion to - it has gone quiet (all data transfered to server) - has accumulated >= 4MB data to commit (so it will be large IO) - too few active commits (hence active IO) in the server Signed-off-by: Wu Fengguang --- fs/nfs/write.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) --- linux-next.orig/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 +++ linux-next/fs/nfs/write.c 2010-12-13 21:46:21.000000000 +0800 @@ -1518,17 +1518,38 @@ out_mark_dirty: return res; } -static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_control *wbc) +static bool nfs_should_commit(struct inode *inode, + struct writeback_control *wbc) { + struct nfs_server *nfss = NFS_SERVER(inode); struct nfs_inode *nfsi = NFS_I(inode); + unsigned long npages = nfsi->npages; + unsigned long to_commit = nfsi->ncommit; + unsigned long in_commit = atomic_long_read(&nfss->in_commit); + + /* no more active writes */ + if (to_commit == npages) + return true; + + /* big enough */ + if (to_commit >= MIN_WRITEBACK_PAGES) + return true; + + /* active commits drop low: kick more IO for the server disk */ + if (to_commit > in_commit / 2) + return true; + + return false; +} + +static int nfs_commit_unstable_pages(struct inode *inode, + struct writeback_control *wbc) +{ int flags = FLUSH_SYNC; int ret = 0; if (wbc->sync_mode == WB_SYNC_NONE) { - /* Don't commit yet if this is a non-blocking flush and there - * are a lot of outstanding writes for this mapping. - */ - if (nfsi->ncommit <= (nfsi->npages >> 1)) + if (!nfs_should_commit(inode, wbc)) goto out_mark_dirty; /* don't wait for the COMMIT response */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org