From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: [PATCH 45/58][v2] convert btrfs to ->evict_inode() Date: Wed, 9 Jun 2010 02:46:25 +0100 Message-ID: <20100609014625.GT31073@ZenIV.linux.org.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: linux-fsdevel@vger.kernel.org Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:56727 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885Ab0FIBq0 (ORCPT ); Tue, 8 Jun 2010 21:46:26 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.69 #1 (Red Hat Linux)) id 1OMAN7-0007Dd-WB for linux-fsdevel@vger.kernel.org; Wed, 09 Jun 2010 01:46:26 +0000 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: [original variant of patch changed behaviour; fixed] NB: do we want btrfs_wait_ordered_range() on eviction of inodes with positive i_nlink on subvolume with zero root_refs? If not, btrfs_evict_inode() can be simplified by unconditionally bailing out in case of i_nlink > 0 in the very beginning... Signed-off-by: Al Viro diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 29c2009..394d542 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2389,7 +2389,7 @@ unsigned long btrfs_force_ra(struct address_space *mapping, pgoff_t offset, pgoff_t last_index); int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); int btrfs_readpage(struct file *file, struct page *page); -void btrfs_delete_inode(struct inode *inode); +void btrfs_evict_inode(struct inode *inode); void btrfs_put_inode(struct inode *inode); int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); void btrfs_dirty_inode(struct inode *inode); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15fa2fe..21ea393 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3668,7 +3668,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) return err; } -void btrfs_delete_inode(struct inode *inode) +void btrfs_evict_inode(struct inode *inode) { struct btrfs_trans_handle *trans; struct btrfs_root *root = BTRFS_I(inode)->root; @@ -3676,10 +3676,14 @@ void btrfs_delete_inode(struct inode *inode) int ret; truncate_inode_pages(&inode->i_data, 0); + if (inode->i_nlink && btrfs_root_refs(&root->root_item) != 0) + goto no_delete; + if (is_bad_inode(inode)) { btrfs_orphan_del(NULL, inode); goto no_delete; } + /* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */ btrfs_wait_ordered_range(inode, 0, (u64)-1); if (root->fs_info->log_root_recovering) { @@ -3729,7 +3733,7 @@ void btrfs_delete_inode(struct inode *inode) btrfs_end_transaction(trans, root); btrfs_btree_balance_dirty(root, nr); no_delete: - clear_inode(inode); + end_writeback(inode); return; } diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d34b2df..edf9faa 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -795,7 +795,7 @@ static int btrfs_unfreeze(struct super_block *sb) static const struct super_operations btrfs_super_ops = { .drop_inode = btrfs_drop_inode, - .delete_inode = btrfs_delete_inode, + .evict_inode = btrfs_evict_inode, .put_super = btrfs_put_super, .sync_fs = btrfs_sync_fs, .show_options = btrfs_show_options,