From patchwork Mon Dec 13 15:00:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 406462 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 oBDF1Ocn017890 for ; Mon, 13 Dec 2010 15:01:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752853Ab0LMPBZ (ORCPT ); Mon, 13 Dec 2010 10:01:25 -0500 Received: from mail-ew0-f45.google.com ([209.85.215.45]:37976 "EHLO mail-ew0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969Ab0LMPBZ (ORCPT ); Mon, 13 Dec 2010 10:01:25 -0500 Received: by mail-ew0-f45.google.com with SMTP id 10so3926985ewy.4 for ; Mon, 13 Dec 2010 07:01:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=1v4onaeCkcuPFDDDHYcpEGuOJ+8K+kSDzI7QC0oYK/k=; b=K58nX6N6MQQeyNsW+Rvx7WyyYigG18qitoBJtDwHdpqdSyoj3O2GTXo6YeFiMmD3sz IN56VjZWMFzjeBg+tAmadFVAa4SH/DoQV3v3B1R27qs9nFg/6L0LRza3ZnJRjBpT09Ml SoAgmisEkrqqQsQ32lwiSKcvbJ/q6w+KpHy0M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=x0cxHwWKvmaKZYcy7KAZs82F5JogOhVyVfm9gRZoW7MlDNYTtAiKkKBrkV/uU5F7vQ z0VcTFC4nGrPXealOFj4PHevVDYyFHMdTR6NN/eUkBnKQttcme2A3w8PskVIK7MvNInp JDE+qS5nUrWWzRHlzD0e9cTfmRwJSkcICMhZQ= Received: by 10.213.27.209 with SMTP id j17mr4063865ebc.56.1292252483663; Mon, 13 Dec 2010 07:01:23 -0800 (PST) Received: from localhost.localdomain (PPPoE-78-29-112-8.san.ru [78.29.112.8]) by mx.google.com with ESMTPS id w20sm148969eeh.0.2010.12.13.07.01.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 13 Dec 2010 07:01:22 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 3/7] CIFS: Implement cifs_strict_fsync Date: Mon, 13 Dec 2010 18:00:51 +0300 Message-Id: <1292252455-4025-3-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1292252455-4025-1-git-send-email-piastryyy@gmail.com> References: <1292252455-4025-1-git-send-email-piastryyy@gmail.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]); Mon, 13 Dec 2010 15:01:26 +0000 (UTC) diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index e47c00d..657738f 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h @@ -61,6 +61,7 @@ extern int cifs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); extern int cifs_revalidate_file(struct file *filp); extern int cifs_revalidate_dentry(struct dentry *); +extern void cifs_invalidate_mapping(struct inode *inode); extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int cifs_setattr(struct dentry *, struct iattr *); diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 626cfa3..938f26a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1588,8 +1588,26 @@ static int cifs_write_end(struct file *file, struct address_space *mapping, int cifs_strict_fsync(struct file *file, int datasync) { + int xid; int rc = 0; - /* BB */ + struct cifsTconInfo *tcon; + struct cifsFileInfo *smbfile = file->private_data; + struct inode *inode = file->f_path.dentry->d_inode; + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + + xid = GetXid(); + + cFYI(1, "Sync file - name: %s datasync: 0x%x", + file->f_path.dentry->d_name.name, datasync); + + if (!CIFS_I(inode)->clientCanCacheRead) + cifs_invalidate_mapping(inode); + + tcon = tlink_tcon(smbfile->tlink); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) + rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); + + FreeXid(xid); return rc; } @@ -1599,21 +1617,16 @@ int cifs_fsync(struct file *file, int datasync) int rc = 0; struct cifsTconInfo *tcon; struct cifsFileInfo *smbfile = file->private_data; - struct inode *inode = file->f_path.dentry->d_inode; + struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); xid = GetXid(); cFYI(1, "Sync file - name: %s datasync: 0x%x", file->f_path.dentry->d_name.name, datasync); - rc = filemap_write_and_wait(inode->i_mapping); - if (rc == 0) { - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); - - tcon = tlink_tcon(smbfile->tlink); - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) - rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); - } + tcon = tlink_tcon(smbfile->tlink); + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) + rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); FreeXid(xid); return rc; diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index b245cf0..a8f7cf3 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1683,7 +1683,7 @@ cifs_inode_needs_reval(struct inode *inode) /* * Zap the cache. Called when invalid_mapping flag is set. */ -static void +void cifs_invalidate_mapping(struct inode *inode) { int rc;