From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 1/5] Add unlocked version of inode_add_bytes() function Date: Mon, 14 Dec 2009 18:21:56 +0100 Message-ID: <20091214172155.GC4731@quack.suse.cz> References: <1260793276-8511-1-git-send-email-dmonakhov@openvz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Kara , linux-fsdevel@vger.kernel.org To: Dmitry Monakhov Return-path: Received: from cantor.suse.de ([195.135.220.2]:52411 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932317AbZLNRzu (ORCPT ); Mon, 14 Dec 2009 12:55:50 -0500 Content-Disposition: inline In-Reply-To: <1260793276-8511-1-git-send-email-dmonakhov@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon 14-12-09 15:21:12, Dmitry Monakhov wrote: > Quota code requires unlocked version of this function. Off course > we can just copy-paste the code, but copy-pasting is always an evil. Looks good. Merged into my tree. Honza > Signed-off-by: Dmitry Monakhov > --- > fs/stat.c | 10 ++++++++-- > include/linux/fs.h | 1 + > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/fs/stat.c b/fs/stat.c > index 075694e..c4ecd52 100644 > --- a/fs/stat.c > +++ b/fs/stat.c > @@ -401,9 +401,9 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename, > } > #endif /* __ARCH_WANT_STAT64 */ > > -void inode_add_bytes(struct inode *inode, loff_t bytes) > +/* Caller is here responsible for sufficient locking (ie. inode->i_lock) */ > +void __inode_add_bytes(struct inode *inode, loff_t bytes) > { > - spin_lock(&inode->i_lock); > inode->i_blocks += bytes >> 9; > bytes &= 511; > inode->i_bytes += bytes; > @@ -411,6 +411,12 @@ void inode_add_bytes(struct inode *inode, loff_t bytes) > inode->i_blocks++; > inode->i_bytes -= 512; > } > +} > + > +void inode_add_bytes(struct inode *inode, loff_t bytes) > +{ > + spin_lock(&inode->i_lock); > + __inode_add_bytes(inode, bytes); > spin_unlock(&inode->i_lock); > } > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 2620a8c..98ea200 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -2314,6 +2314,7 @@ extern const struct inode_operations page_symlink_inode_operations; > extern int generic_readlink(struct dentry *, char __user *, int); > extern void generic_fillattr(struct inode *, struct kstat *); > extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *); > +void __inode_add_bytes(struct inode *inode, loff_t bytes); > void inode_add_bytes(struct inode *inode, loff_t bytes); > void inode_sub_bytes(struct inode *inode, loff_t bytes); > loff_t inode_get_bytes(struct inode *inode); > -- > 1.6.0.4 > -- Jan Kara SUSE Labs, CR