Message ID | 1351000527-24952-4-git-send-email-list.btrfs@jan-o-sch.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 10/23/2012 09:55 PM, Jan Schmidt wrote: > Tree mod log treated old root buffers as always empty buffers when starting > the rewind operations. However, the old root may still be part of the > current tree at a lower level, with still some valid entries. > Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Tested-by: Liu Bo <bo.li.liu@oracle.com> thanks, liubo > Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> > --- > fs/btrfs/ctree.c | 16 ++++++++++++++-- > 1 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c > index e6b75cc..1b60c56 100644 > --- a/fs/btrfs/ctree.c > +++ b/fs/btrfs/ctree.c > @@ -1239,6 +1239,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) > struct tree_mod_root *old_root = NULL; > u64 old_generation = 0; > u64 logical; > + u32 blocksize; > > eb = btrfs_read_lock_root_node(root); > tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq); > @@ -1254,10 +1255,21 @@ get_old_root(struct btrfs_root *root, u64 time_seq) > } > > tm = tree_mod_log_search(root->fs_info, logical, time_seq); > - if (old_root) > + if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { > + blocksize = btrfs_level_size(root, old_root->level); > + eb = read_tree_block(root, logical, blocksize, 0); > + if (!eb) { > + pr_warn("btrfs: failed to read tree block %llu from get_old_root\n", > + logical); > + WARN_ON(1); > + } else { > + eb = btrfs_clone_extent_buffer(eb); > + } > + } else if (old_root) { > eb = alloc_dummy_extent_buffer(logical, root->nodesize); > - else > + } else { > eb = btrfs_clone_extent_buffer(root->node); > + } > btrfs_tree_read_unlock(root->node); > free_extent_buffer(root->node); > if (!eb) > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/23/2012 09:55 PM, Jan Schmidt wrote: > Tree mod log treated old root buffers as always empty buffers when starting > the rewind operations. However, the old root may still be part of the > current tree at a lower level, with still some valid entries. > > Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> > --- > fs/btrfs/ctree.c | 16 ++++++++++++++-- > 1 files changed, 14 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c > index e6b75cc..1b60c56 100644 > --- a/fs/btrfs/ctree.c > +++ b/fs/btrfs/ctree.c > @@ -1239,6 +1239,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) > struct tree_mod_root *old_root = NULL; > u64 old_generation = 0; > u64 logical; > + u32 blocksize; > > eb = btrfs_read_lock_root_node(root); > tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq); > @@ -1254,10 +1255,21 @@ get_old_root(struct btrfs_root *root, u64 time_seq) > } > > tm = tree_mod_log_search(root->fs_info, logical, time_seq); > - if (old_root) > + if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { > + blocksize = btrfs_level_size(root, old_root->level); > + eb = read_tree_block(root, logical, blocksize, 0); I found that read_tree_block() may use GFP_NOFS if we need to create an eb, and this may block read_lock(). It's not always blocked but it did block, so we'd better give an atomic version of this. thanks, liubo > + if (!eb) { > + pr_warn("btrfs: failed to read tree block %llu from get_old_root\n", > + logical); > + WARN_ON(1); > + } else { > + eb = btrfs_clone_extent_buffer(eb); > + } > + } else if (old_root) { > eb = alloc_dummy_extent_buffer(logical, root->nodesize); > - else > + } else { > eb = btrfs_clone_extent_buffer(root->node); > + } > btrfs_tree_read_unlock(root->node); > free_extent_buffer(root->node); > if (!eb) > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index e6b75cc..1b60c56 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1239,6 +1239,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) struct tree_mod_root *old_root = NULL; u64 old_generation = 0; u64 logical; + u32 blocksize; eb = btrfs_read_lock_root_node(root); tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq); @@ -1254,10 +1255,21 @@ get_old_root(struct btrfs_root *root, u64 time_seq) } tm = tree_mod_log_search(root->fs_info, logical, time_seq); - if (old_root) + if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { + blocksize = btrfs_level_size(root, old_root->level); + eb = read_tree_block(root, logical, blocksize, 0); + if (!eb) { + pr_warn("btrfs: failed to read tree block %llu from get_old_root\n", + logical); + WARN_ON(1); + } else { + eb = btrfs_clone_extent_buffer(eb); + } + } else if (old_root) { eb = alloc_dummy_extent_buffer(logical, root->nodesize); - else + } else { eb = btrfs_clone_extent_buffer(root->node); + } btrfs_tree_read_unlock(root->node); free_extent_buffer(root->node); if (!eb)
Tree mod log treated old root buffers as always empty buffers when starting the rewind operations. However, the old root may still be part of the current tree at a lower level, with still some valid entries. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> --- fs/btrfs/ctree.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)