From patchwork Sun Jul 18 21:51:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 112615 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6ILpUNJ022547 for ; Sun, 18 Jul 2010 21:51:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757409Ab0GRVvW (ORCPT ); Sun, 18 Jul 2010 17:51:22 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:40651 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757331Ab0GRVvW (ORCPT ); Sun, 18 Jul 2010 17:51:22 -0400 Received: from hch by bombadil.infradead.org with local (Exim 4.72 #1 (Red Hat Linux)) id 1OablZ-00056L-Cc; Sun, 18 Jul 2010 21:51:21 +0000 Date: Sun, 18 Jul 2010 17:51:21 -0400 From: Christoph Hellwig To: linux-cifs@vger.kernel.org Cc: viro@zeniv.linux.org.uk Subject: [PATCH] cifs: truncate fallout Message-ID: <20100718215121.GA19508@infradead.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html 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 (demeter.kernel.org [140.211.167.41]); Sun, 18 Jul 2010 21:51:30 +0000 (UTC) Index: linux-2.6/fs/cifs/inode.c =================================================================== --- linux-2.6.orig/fs/cifs/inode.c 2010-07-09 12:51:51.798649373 -0700 +++ linux-2.6/fs/cifs/inode.c 2010-07-09 12:55:00.594647100 -0700 @@ -1663,26 +1663,16 @@ static int cifs_truncate_page(struct add return rc; } -static int cifs_vmtruncate(struct inode *inode, loff_t offset) +static int cifs_setsize(struct inode *inode, loff_t offset) { loff_t oldsize; - int err; spin_lock(&inode->i_lock); - err = inode_newsize_ok(inode, offset); - if (err) { - spin_unlock(&inode->i_lock); - goto out; - } - oldsize = inode->i_size; i_size_write(inode, offset); spin_unlock(&inode->i_lock); + truncate_pagecache(inode, oldsize, offset); - if (inode->i_op->truncate) - inode->i_op->truncate(inode); -out: - return err; } static int @@ -1755,7 +1745,7 @@ cifs_set_file_size(struct inode *inode, if (rc == 0) { cifsInode->server_eof = attrs->ia_size; - rc = cifs_vmtruncate(inode, attrs->ia_size); + rc = cifs_setsize(inode, attrs->ia_size); cifs_truncate_page(inode->i_mapping, inode->i_size); } @@ -1876,7 +1866,7 @@ cifs_setattr_unix(struct dentry *direntr if ((attrs->ia_valid & ATTR_SIZE) && attrs->ia_size != i_size_read(inode)) { - rc = vmtruncate(inode, attrs->ia_size); + rc = truncate_setsize(inode, attrs->ia_size); if (rc) goto out; } @@ -2035,7 +2025,7 @@ cifs_setattr_nounix(struct dentry *diren if ((attrs->ia_valid & ATTR_SIZE) && attrs->ia_size != i_size_read(inode)) { - rc = vmtruncate(inode, attrs->ia_size); + rc = truncate_setsize(inode, attrs->ia_size); if (rc) goto cifs_setattr_exit; }