From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: [PATCH 7/58] new helper: end_writeback() Date: Tue, 08 Jun 2010 23:16:02 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: linux-fsdevel@vger.kernel.org Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:38817 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932199Ab0FHWQD (ORCPT ); Tue, 8 Jun 2010 18:16:03 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.69 #1 (Red Hat Linux)) id 1OM75W-0004Y4-W4 for linux-fsdevel@vger.kernel.org; Tue, 08 Jun 2010 22:16:03 +0000 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Essentially, the minimal variant of ->evict_inode(). It's a trimmed-down clear_inode(), sans any fs callbacks. Once it returns we know that no async writeback will be happening; every ->evict_inode() instance should do that once and do that before doing anything ->write_inode() could interfere with (e.g. freeing the on-disk inode). Signed-off-by: Al Viro --- fs/hugetlbfs/inode.c | 2 +- fs/inode.c | 12 ++++++++++++ include/linux/fs.h | 1 + 3 files changed, 14 insertions(+), 1 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index bf1a2f4..6e5bd42 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -374,7 +374,7 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart) static void hugetlbfs_evict_inode(struct inode *inode) { truncate_hugepages(inode, 0); - clear_inode(inode); + end_writeback(inode); } static inline void diff --git a/fs/inode.c b/fs/inode.c index 139d475..3f45360 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -294,6 +294,18 @@ void __iget(struct inode *inode) inodes_stat.nr_unused--; } +void end_writeback(struct inode *inode) +{ + might_sleep(); + BUG_ON(inode->i_data.nrpages); + BUG_ON(!list_empty(&inode->i_data.private_list)); + BUG_ON(!(inode->i_state & I_FREEING)); + BUG_ON(inode->i_state & I_CLEAR); + inode_sync_wait(inode); + inode->i_state = I_FREEING | I_CLEAR; +} +EXPORT_SYMBOL(end_writeback); + /** * clear_inode - clear an inode * @inode: inode to clear diff --git a/include/linux/fs.h b/include/linux/fs.h index 788b003..cea7283 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2170,6 +2170,7 @@ extern void unlock_new_inode(struct inode *); extern void __iget(struct inode * inode); extern void iget_failed(struct inode *); extern void clear_inode(struct inode *); +extern void end_writeback(struct inode *); extern void destroy_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode(struct super_block *); -- 1.5.6.5