Avoid orphan inodes cleanup during replaying log
PATCH 6/8 Avoid orphan inodes cleanup during replaying log
We do log replay in a single transaction, so it's not good to do unbound operations during replaying log. This patch makes orphan inodes cleanup executed after replaying log. It also avoid doing other unbound operations such as truncating a file during replaying log. These unbound operations are postponed to the orphan inode cleanup stage.
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/disk-io.c +3 -0
@@ -1971,6 +1971,9 @@ struct btrfs_root *open_ctree(struct supif (sb->s_flags &MS_RDONLY ) { ret =btrfs_commit_super (tree_root);BUG_ON (ret); + }else { + ret =btrfs_cleanup_fs_roots (fs_info); +BUG_ON (ret); } }
fs/btrfs/inode.c +8 -1
@@ -2054,6 +2054,9 @@ void btrfs_orphan_cleanup(struct btrfs_rstruct inode *inode;int ret =0 , nr_unlink =0 , nr_truncate =0 ; +if (root->fs_info->log_root_recovering) +return ; + path =btrfs_alloc_path ();if (!path)return ;
@@ -2063,7 +2066,6 @@ void btrfs_orphan_cleanup(struct btrfs_rbtrfs_set_key_type (&key,BTRFS_ORPHAN_ITEM_KEY ); key.offset = (u64)-1 ; -while (1 ) { ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 ) {
@@ -3236,6 +3238,11 @@ void btrfs_delete_inode(struct inode *in }btrfs_wait_ordered_range (inode,0 , (u64)-1 ); +if (root->fs_info->log_root_recovering) { +BUG_ON (!list_empty (&BTRFS_I (inode)->i_orphan)); + goto no_delete; + } +if (inode->i_nlink >0 ) {BUG_ON (btrfs_root_refs (&root->root_item) !=0 ); goto no_delete;
fs/btrfs/tree-log.c +24 -25
77 lines not on this page · raw message