Message ID | 71b8f94034f04da6f69f1ea0720825aabc852a54.1604065695.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: zoned block device support | expand |
On 10/30/20 9:51 AM, Naohiro Aota wrote: > This is a preparation for the next patch. This commit split > alloc_log_tree() to allocating tree structure part (remains in > alloc_log_tree()) and allocating tree node part (moved in > btrfs_alloc_log_tree_node()). The latter part is also exported to be used > in the next patch. > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > --- > fs/btrfs/disk-io.c | 31 +++++++++++++++++++++++++------ > fs/btrfs/disk-io.h | 2 ++ > 2 files changed, 27 insertions(+), 6 deletions(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 2b30ef8a7034..70885f3d3321 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -1211,7 +1211,6 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > struct btrfs_fs_info *fs_info) > { > struct btrfs_root *root; > - struct extent_buffer *leaf; > > root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); > if (!root) > @@ -1221,6 +1220,14 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > root->root_key.type = BTRFS_ROOT_ITEM_KEY; > root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; > > + return root; > +} > + > +int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans, > + struct btrfs_root *root) > +{ > + struct extent_buffer *leaf; > + > /* > * DON'T set SHAREABLE bit for log trees. > * > @@ -1233,26 +1240,31 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > > leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, > NULL, 0, 0, 0, BTRFS_NESTING_NORMAL); > - if (IS_ERR(leaf)) { > - btrfs_put_root(root); > - return ERR_CAST(leaf); > - } > + if (IS_ERR(leaf)) > + return PTR_ERR(leaf); > > root->node = leaf; > > btrfs_mark_buffer_dirty(root->node); > btrfs_tree_unlock(root->node); > - return root; > + > + return 0; > } > > int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, > struct btrfs_fs_info *fs_info) > { > struct btrfs_root *log_root; > + int ret; > > log_root = alloc_log_tree(trans, fs_info); > if (IS_ERR(log_root)) newline. > return PTR_ERR(log_root); > + ret = btrfs_alloc_log_tree_node(trans, log_root); > + if (ret) { > + kfree(log_root); btrfs_put_root(log_root); > + return ret; > + } newline. Thanks, Josef
On Tue, Nov 3, 2020 at 2:06 PM Josef Bacik <josef@toxicpanda.com> wrote: > > On 10/30/20 9:51 AM, Naohiro Aota wrote: > > This is a preparation for the next patch. This commit split > > alloc_log_tree() to allocating tree structure part (remains in > > alloc_log_tree()) and allocating tree node part (moved in > > btrfs_alloc_log_tree_node()). The latter part is also exported to be used > > in the next patch. > > > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > > --- > > fs/btrfs/disk-io.c | 31 +++++++++++++++++++++++++------ > > fs/btrfs/disk-io.h | 2 ++ > > 2 files changed, 27 insertions(+), 6 deletions(-) > > > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > > index 2b30ef8a7034..70885f3d3321 100644 > > --- a/fs/btrfs/disk-io.c > > +++ b/fs/btrfs/disk-io.c > > @@ -1211,7 +1211,6 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > > struct btrfs_fs_info *fs_info) > > { > > struct btrfs_root *root; > > - struct extent_buffer *leaf; > > > > root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); > > if (!root) > > @@ -1221,6 +1220,14 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > > root->root_key.type = BTRFS_ROOT_ITEM_KEY; > > root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; > > > > + return root; > > +} > > + > > +int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans, > > + struct btrfs_root *root) > > +{ > > + struct extent_buffer *leaf; > > + > > /* > > * DON'T set SHAREABLE bit for log trees. > > * > > @@ -1233,26 +1240,31 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, > > > > leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, > > NULL, 0, 0, 0, BTRFS_NESTING_NORMAL); > > - if (IS_ERR(leaf)) { > > - btrfs_put_root(root); > > - return ERR_CAST(leaf); > > - } > > + if (IS_ERR(leaf)) > > + return PTR_ERR(leaf); > > > > root->node = leaf; > > > > btrfs_mark_buffer_dirty(root->node); > > btrfs_tree_unlock(root->node); > > - return root; > > + > > + return 0; > > } > > > > int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, > > struct btrfs_fs_info *fs_info) > > { > > struct btrfs_root *log_root; > > + int ret; > > > > log_root = alloc_log_tree(trans, fs_info); > > if (IS_ERR(log_root)) > > newline. > > > return PTR_ERR(log_root); > > + ret = btrfs_alloc_log_tree_node(trans, log_root); > > + if (ret) { > > + kfree(log_root); > > btrfs_put_root(log_root); > > > + return ret; > > + } > > newline. Thanks, > > Josef These should've shown up on the patch formatter... was it simply not run, or did the patch formatter not catch it? Best regards, Amy Parker (they/them)
On Tue, Nov 03, 2020 at 02:10:47PM -0800, Amy Parker wrote: >On Tue, Nov 3, 2020 at 2:06 PM Josef Bacik <josef@toxicpanda.com> wrote: >> >> On 10/30/20 9:51 AM, Naohiro Aota wrote: >> > This is a preparation for the next patch. This commit split >> > alloc_log_tree() to allocating tree structure part (remains in >> > alloc_log_tree()) and allocating tree node part (moved in >> > btrfs_alloc_log_tree_node()). The latter part is also exported to be used >> > in the next patch. >> > >> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> >> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> >> > --- >> > fs/btrfs/disk-io.c | 31 +++++++++++++++++++++++++------ >> > fs/btrfs/disk-io.h | 2 ++ >> > 2 files changed, 27 insertions(+), 6 deletions(-) >> > >> > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >> > index 2b30ef8a7034..70885f3d3321 100644 >> > --- a/fs/btrfs/disk-io.c >> > +++ b/fs/btrfs/disk-io.c >> > @@ -1211,7 +1211,6 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, >> > struct btrfs_fs_info *fs_info) >> > { >> > struct btrfs_root *root; >> > - struct extent_buffer *leaf; >> > >> > root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); >> > if (!root) >> > @@ -1221,6 +1220,14 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, >> > root->root_key.type = BTRFS_ROOT_ITEM_KEY; >> > root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; >> > >> > + return root; >> > +} >> > + >> > +int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans, >> > + struct btrfs_root *root) >> > +{ >> > + struct extent_buffer *leaf; >> > + >> > /* >> > * DON'T set SHAREABLE bit for log trees. >> > * >> > @@ -1233,26 +1240,31 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, >> > >> > leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, >> > NULL, 0, 0, 0, BTRFS_NESTING_NORMAL); >> > - if (IS_ERR(leaf)) { >> > - btrfs_put_root(root); >> > - return ERR_CAST(leaf); >> > - } >> > + if (IS_ERR(leaf)) >> > + return PTR_ERR(leaf); >> > >> > root->node = leaf; >> > >> > btrfs_mark_buffer_dirty(root->node); >> > btrfs_tree_unlock(root->node); >> > - return root; >> > + >> > + return 0; >> > } >> > >> > int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, >> > struct btrfs_fs_info *fs_info) >> > { >> > struct btrfs_root *log_root; >> > + int ret; >> > >> > log_root = alloc_log_tree(trans, fs_info); >> > if (IS_ERR(log_root)) >> >> newline. >> >> > return PTR_ERR(log_root); >> > + ret = btrfs_alloc_log_tree_node(trans, log_root); >> > + if (ret) { >> > + kfree(log_root); >> >> btrfs_put_root(log_root); >> >> > + return ret; >> > + } >> >> newline. Thanks, >> >> Josef > >These should've shown up on the patch formatter... was it simply not run, >or did the patch formatter not catch it? Unfotunately, it was not caught by checkpatch.pl... > >Best regards, >Amy Parker >(they/them)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 2b30ef8a7034..70885f3d3321 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1211,7 +1211,6 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info) { struct btrfs_root *root; - struct extent_buffer *leaf; root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); if (!root) @@ -1221,6 +1220,14 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, root->root_key.type = BTRFS_ROOT_ITEM_KEY; root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; + return root; +} + +int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans, + struct btrfs_root *root) +{ + struct extent_buffer *leaf; + /* * DON'T set SHAREABLE bit for log trees. * @@ -1233,26 +1240,31 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, NULL, 0, 0, 0, BTRFS_NESTING_NORMAL); - if (IS_ERR(leaf)) { - btrfs_put_root(root); - return ERR_CAST(leaf); - } + if (IS_ERR(leaf)) + return PTR_ERR(leaf); root->node = leaf; btrfs_mark_buffer_dirty(root->node); btrfs_tree_unlock(root->node); - return root; + + return 0; } int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info) { struct btrfs_root *log_root; + int ret; log_root = alloc_log_tree(trans, fs_info); if (IS_ERR(log_root)) return PTR_ERR(log_root); + ret = btrfs_alloc_log_tree_node(trans, log_root); + if (ret) { + kfree(log_root); + return ret; + } WARN_ON(fs_info->log_root_tree); fs_info->log_root_tree = log_root; return 0; @@ -1264,11 +1276,18 @@ int btrfs_add_log_tree(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_root *log_root; struct btrfs_inode_item *inode_item; + int ret; log_root = alloc_log_tree(trans, fs_info); if (IS_ERR(log_root)) return PTR_ERR(log_root); + ret = btrfs_alloc_log_tree_node(trans, log_root); + if (ret) { + btrfs_put_root(log_root); + return ret; + } + log_root->last_trans = trans->transid; log_root->root_key.offset = root->root_key.objectid; diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index fee69ced58b4..b82ae3711c42 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -115,6 +115,8 @@ blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, extent_submit_bio_start_t *submit_bio_start); blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, int mirror_num); +int btrfs_alloc_log_tree_node(struct btrfs_trans_handle *trans, + struct btrfs_root *root); int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info); int btrfs_add_log_tree(struct btrfs_trans_handle *trans,