From patchwork Fri Apr 24 21:59:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Schwenke X-Patchwork-Id: 19874 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3OLxjV6017067 for ; Fri, 24 Apr 2009 21:59:46 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id A3B7F163CD2 for ; Fri, 24 Apr 2009 21:59:23 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=AWL, BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mailout2.pacific.net.au (mailout2-14.pacific.net.au [125.255.80.141]) by lists.samba.org (Postfix) with ESMTP id 905D8163B99 for ; Fri, 24 Apr 2009 21:59:08 +0000 (GMT) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout2.pacific.net.au (Postfix) with ESMTP id CAA9C130ACB for ; Sat, 25 Apr 2009 07:59:29 +1000 (EST) Received: from fender.bluetoad.com.au (unknown [203.143.225.228]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id A38D88C19 for ; Sat, 25 Apr 2009 07:59:27 +1000 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by fender.bluetoad.com.au (Postfix) with ESMTP id 143F43C00B57 for ; Sat, 25 Apr 2009 07:59:26 +1000 (EST) Received: from fender.bluetoad.com.au ([127.0.0.1]) by localhost (fender [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01435-04 for ; Sat, 25 Apr 2009 07:59:26 +1000 (EST) Received: from kay (fender.bluetoad.com.au [10.80.201.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by fender.bluetoad.com.au (Postfix) with ESMTP id 758E93C00B46 for ; Sat, 25 Apr 2009 07:59:26 +1000 (EST) Date: Sat, 25 Apr 2009 07:59:24 +1000 From: Peter Schwenke To: linux-cifs-client@lists.samba.org Message-ID: <20090424215924.GA25549@kay> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at bluetoad.com.au Subject: [linux-cifs-client] [PATCH] cifs: Detect errors in cifs_writepages when called during background write-back X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org The return code isn't checked in the case of cifs_writepages being invoked as a result of pdflush and potentially other background write-back. This results in data integrity problems when errors such as a network break occur when CIFSSMBWrite2 is called. The resulting error isn't acted on. This patch hangs on to the write-behind error so that it is available for detection later on. Signed-off-by: Peter Schwenke --- fs/cifs/file.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 042b122..f1a5b1e 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1200,6 +1200,7 @@ static int cifs_writepages(struct address_space *mapping, unsigned int bytes_to_write; unsigned int bytes_written; struct cifs_sb_info *cifs_sb; + struct cifsInodeInfo *cifs_inode = CIFS_I(mapping->host); int done = 0; pgoff_t end; pgoff_t index; @@ -1354,7 +1355,7 @@ retry: * CIFSSMBWrite2. We can't rely on the last handle * we used to still be valid */ - open_file = find_writable_file(CIFS_I(mapping->host)); + open_file = find_writable_file(cifs_inode); if (!open_file) { cERROR(1, ("No writable handles for inode")); rc = -EBADF; @@ -1374,6 +1375,18 @@ retry: set_bit(AS_ENOSPC, &mapping->flags); else set_bit(AS_EIO, &mapping->flags); + /* + * The return code isn't checked in the + * case of cifs_writepages being + * invoked from background write outs + * i.e. generic_sync_sb_inodes() + */ + if (wbc->sync_mode == WB_SYNC_NONE) { + if (rc == -ENOSPC) + cifs_inode->write_behind_rc = rc; + else + cifs_inode->write_behind_rc = -EIO; + } } else { cifs_stats_bytes_written(cifs_sb->tcon, bytes_written);