From patchwork Mon Apr 20 07:42:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Schwenke X-Patchwork-Id: 18981 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 n3K7gZ37026388 for ; Mon, 20 Apr 2009 07:42:35 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 1B97C163C36 for ; Mon, 20 Apr 2009 07:42:14 +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=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 mailout1.pacific.net.au (mailout1-12.pacific.net.au [125.255.80.131]) by lists.samba.org (Postfix) with ESMTP id 8FD9A163B88 for ; Mon, 20 Apr 2009 07:42:09 +0000 (GMT) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id 658814C048C for ; Mon, 20 Apr 2009 17:42:25 +1000 (EST) Received: from fender.bluetoad.com.au (unknown [203.143.225.228]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id 1DCB78C04 for ; Mon, 20 Apr 2009 17:42:25 +1000 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by fender.bluetoad.com.au (Postfix) with ESMTP id AF50C3C00B59 for ; Mon, 20 Apr 2009 17:42:24 +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 15885-03 for ; Mon, 20 Apr 2009 17:42:24 +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 1D5573C00B57 for ; Mon, 20 Apr 2009 17:42:23 +1000 (EST) Date: Mon, 20 Apr 2009 17:42:21 +1000 From: Peter Schwenke To: linux-cifs-client@lists.samba.org Message-ID: <20090420074221.GA13131@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 from pdflush (V2) 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. This results in data integrity problems when errors such as a network break occur when CIFSSMBWrite2 is called. The resulting EAGAIN isn't acted 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..c00a674 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 as a result of pdflush. + * See generic_sync_sb_inodes() + */ + if (current_is_pdflush()) { + 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);