From patchwork Fri Oct 15 19:34:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 257511 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9FJda3n010936 for ; Fri, 15 Oct 2010 19:39:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932427Ab0JOTjg (ORCPT ); Fri, 15 Oct 2010 15:39:36 -0400 Received: from cdptpa-omtalb.mail.rr.com ([75.180.132.123]:52393 "EHLO cdptpa-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932088Ab0JOTjf (ORCPT ); Fri, 15 Oct 2010 15:39:35 -0400 X-Authority-Analysis: v=1.1 cv=NbXEDKLFVdSGLbv73FfL8HCBVY5OgrxhVC+VxVzi2k8= c=1 sm=0 a=IVQ9iBReTlYA:10 a=ld/erqUjW76FpBUqCqkKeA==:17 a=20KFwNOVAAAA:8 a=dN5Fi5L7OesYV_IFWmoA:9 a=BPxLED2rCz4NtJBSZi7L1a_dQB4A:4 a=jEp0ucaQiEUA:10 a=0kPLrQdw3YYA:10 a=ld/erqUjW76FpBUqCqkKeA==:117 X-Cloudmark-Score: 0 X-Originating-IP: 71.70.153.3 Received: from [71.70.153.3] ([71.70.153.3:49681] helo=mail.poochiereds.net) by cdptpa-oedge04.mail.rr.com (envelope-from ) (ecelerity 2.2.2.39 r()) with ESMTP id CD/31-25964-6FDA8BC4; Fri, 15 Oct 2010 19:39:34 +0000 Received: by mail.poochiereds.net (Postfix, from userid 4447) id D055D58189; Fri, 15 Oct 2010 15:34:09 -0400 (EDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH 12/13] cifs: wait for writeback to complete in cifs_flush Date: Fri, 15 Oct 2010 15:34:07 -0400 Message-Id: <1287171248-464-13-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1287171248-464-1-git-send-email-jlayton@redhat.com> References: <1287171248-464-1-git-send-email-jlayton@redhat.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Oct 2010 19:39:52 +0000 (UTC) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index baf4b50..128e07b 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1688,20 +1688,13 @@ int cifs_flush(struct file *file, fl_owner_t id) struct inode *inode = file->f_path.dentry->d_inode; int rc = 0; - /* Rather than do the steps manually: - lock the inode for writing - loop through pages looking for write behind data (dirty pages) - coalesce into contiguous 16K (or smaller) chunks to write to server - send to server (prefer in parallel) - deal with writebehind errors - unlock inode for writing - filemapfdatawrite appears easier for the time being */ - - rc = filemap_fdatawrite(inode->i_mapping); - /* reset wb rc if we were able to write out dirty pages */ - if (!rc) { - rc = CIFS_I(inode)->write_behind_rc; - CIFS_I(inode)->write_behind_rc = 0; + if (file->f_mode & FMODE_WRITE) { + rc = filemap_write_and_wait(inode->i_mapping); + /* reset wb rc if we were able to write out dirty pages */ + if (!rc) { + rc = CIFS_I(inode)->write_behind_rc; + CIFS_I(inode)->write_behind_rc = 0; + } } cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);