Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757245Ab0FRDWY (ORCPT ); Thu, 17 Jun 2010 23:22:24 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:34013 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756229Ab0FRDWW (ORCPT ); Thu, 17 Jun 2010 23:22:22 -0400 Message-ID: <4C1AE641.1050103@oracle.com> Date: Fri, 18 Jun 2010 11:21:37 +0800 From: Tao Ma User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: linux-fsdevel@vger.kernel.org, Joel Becker , Christoph Hellwig , Nick Piggin , viro@zeniv.linux.org.uk CC: Tao Ma , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5] ocfs2: Let ocfs2_setattr use new truncate sequence. References: <1276240769-12491-1-git-send-email-tao.ma@oracle.com> In-Reply-To: <1276240769-12491-1-git-send-email-tao.ma@oracle.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Auth-Type: Internal IP X-Source-IP: acsinet15.oracle.com [141.146.126.227] X-CT-RefId: str=0001.0A090207.4C1AE662.0061:SCFMA922111,ss=1,fgs=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4301 Lines: 117 Hi Al and Christoph, can this patch be added to the vfs-2.6.git? Or I should ask Joel to include it in ocfs2.git? btw, I think both Nick and Joel have acked this patch? Regards, Tao On 06/11/2010 03:19 PM, Tao Ma wrote: > Let ocfs2 use the new truncate sequence. The changes include: > 1. Move inode_change_ok into cluster lock and remove inode_newsize_ok. > 2. Use truncate_setsize directly since we don't implement our > own ->truncate and what we need is "update i_size and > truncate_pagecache" which truncate_setsize now does. > 3. Change some i_size_read to inode->i_size in ocfs2_setattr > since we have i_muext held. > 4. For direct write, ocfs2 actually don't allow write to pass > i_size(see ocfs2_prepare_inode_for_write), so we don't have > a chance to increase i_size. So remove the bogus check. > > Cc: Joel Becker > Cc: Christoph Hellwig > Cc: Nick Piggin > Signed-off-by: Tao Ma > --- > fs/ocfs2/file.c | 47 +++++++++++------------------------------------ > 1 files changed, 11 insertions(+), 36 deletions(-) > > diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c > index 1fb0985..98b1f54 100644 > --- a/fs/ocfs2/file.c > +++ b/fs/ocfs2/file.c > @@ -960,13 +960,9 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) > return 0; > } > > - status = inode_change_ok(inode, attr); > - if (status) > - return status; > - > if (is_quota_modification(inode, attr)) > dquot_initialize(inode); > - size_change = S_ISREG(inode->i_mode)&& attr->ia_valid& ATTR_SIZE; > + size_change = attr->ia_valid& ATTR_SIZE; > if (size_change) { > status = ocfs2_rw_lock(inode, 1); > if (status< 0) { > @@ -982,12 +978,12 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) > goto bail_unlock_rw; > } > > - if (size_change&& attr->ia_size != i_size_read(inode)) { > - status = inode_newsize_ok(inode, attr->ia_size); > - if (status) > - goto bail_unlock; > + status = inode_change_ok(inode, attr); > + if (status) > + goto bail_unlock; > > - if (i_size_read(inode)> attr->ia_size) { > + if (size_change&& attr->ia_size != inode->i_size) { > + if (inode->i_size> attr->ia_size) { > if (ocfs2_should_order_data(inode)) { > status = ocfs2_begin_ordered_truncate(inode, > attr->ia_size); > @@ -1052,22 +1048,12 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) > } > > /* > - * This will intentionally not wind up calling truncate_setsize(), > - * since all the work for a size change has been done above. > - * Otherwise, we could get into problems with truncate as > - * ip_alloc_sem is used there to protect against i_size > - * changes. > - * > - * XXX: this means the conditional below can probably be removed. > + * Since all the work for a size change has been done above. > + * Call truncate_setsize directly to change size and truncate > + * pagecache. > */ > - if ((attr->ia_valid& ATTR_SIZE)&& > - attr->ia_size != i_size_read(inode)) { > - status = vmtruncate(inode, attr->ia_size); > - if (status) { > - mlog_errno(status); > - goto bail_commit; > - } > - } > + if ((attr->ia_valid& ATTR_SIZE)&& attr->ia_size != inode->i_size) > + truncate_setsize(inode, attr->ia_size); > > setattr_copy(inode, attr); > mark_inode_dirty(inode); > @@ -2122,17 +2108,6 @@ relock: > written = generic_file_direct_write(iocb, iov,&nr_segs, *ppos, > ppos, count, ocount); > if (written< 0) { > - /* > - * direct write may have instantiated a few > - * blocks outside i_size. Trim these off again. > - * Don't need i_size_read because we hold i_mutex. > - * > - * XXX(truncate): this looks buggy because ocfs2 did not > - * actually implement ->truncate. Take a look at > - * the new truncate sequence and update this accordingly > - */ > - if (*ppos + count> inode->i_size) > - truncate_setsize(inode, inode->i_size); > ret = written; > goto out_dio; > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/