Message ID | 492da9326ecb5f888e76117983603bb502b7b589.1612434091.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: zoned block device support | expand |
On Thu, Feb 4, 2021 at 10:23 AM Naohiro Aota <naohiro.aota@wdc.com> wrote: > > This is the 3/3 patch to enable tree-log on zoned filesystems. > > The allocation order of nodes of "fs_info->log_root_tree" and nodes of > "root->log_root" is not the same as the writing order of them. So, the > writing causes unaligned write errors. > > Reorder the allocation of them by delaying allocation of the root node of > "fs_info->log_root_tree," so that the node buffers can go out sequentially > to devices. > > Cc: Filipe Manana <fdmanana@gmail.com> > Reviewed-by: Josef Bacik <josef@toxicpanda.com> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > --- > fs/btrfs/disk-io.c | 12 +++++++----- > fs/btrfs/tree-log.c | 27 +++++++++++++++++++++------ > 2 files changed, 28 insertions(+), 11 deletions(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 84c6650d5ef7..c2576c5fe62e 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -1298,16 +1298,18 @@ 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) { > - btrfs_put_root(log_root); > - return ret; > + if (!btrfs_is_zoned(fs_info)) { > + int ret = btrfs_alloc_log_tree_node(trans, log_root); > + > + if (ret) { > + btrfs_put_root(log_root); > + return ret; > + } > } > > WARN_ON(fs_info->log_root_tree); > diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c > index 8be3164d4c5d..7ba044bfa9b1 100644 > --- a/fs/btrfs/tree-log.c > +++ b/fs/btrfs/tree-log.c > @@ -3159,6 +3159,19 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, > list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); > root_log_ctx.log_transid = log_root_tree->log_transid; > > + if (btrfs_is_zoned(fs_info)) { > + mutex_lock(&fs_info->tree_log_mutex); > + if (!log_root_tree->node) { As commented in v14, the log root tree is not protected by fs_info->tree_log_mutex anymore. It is fs_info->tree_root->log_mutex as of 5.10. Everything else was addressed and looks good. Thanks. > + ret = btrfs_alloc_log_tree_node(trans, log_root_tree); > + if (ret) { > + mutex_unlock(&fs_info->tree_log_mutex); > + mutex_unlock(&log_root_tree->log_mutex); > + goto out; > + } > + } > + mutex_unlock(&fs_info->tree_log_mutex); > + } > + > /* > * Now we are safe to update the log_root_tree because we're under the > * log_mutex, and we're a current writer so we're holding the commit > @@ -3317,12 +3330,14 @@ static void free_log_tree(struct btrfs_trans_handle *trans, > .process_func = process_one_buffer > }; > > - ret = walk_log_tree(trans, log, &wc); > - if (ret) { > - if (trans) > - btrfs_abort_transaction(trans, ret); > - else > - btrfs_handle_fs_error(log->fs_info, ret, NULL); > + if (log->node) { > + ret = walk_log_tree(trans, log, &wc); > + if (ret) { > + if (trans) > + btrfs_abort_transaction(trans, ret); > + else > + btrfs_handle_fs_error(log->fs_info, ret, NULL); > + } > } > > clear_extent_bits(&log->dirty_log_pages, 0, (u64)-1, > -- > 2.30.0 >
On 04/02/2021 12:57, Filipe Manana wrote: > On Thu, Feb 4, 2021 at 10:23 AM Naohiro Aota <naohiro.aota@wdc.com> wrote: >> >> This is the 3/3 patch to enable tree-log on zoned filesystems. >> >> The allocation order of nodes of "fs_info->log_root_tree" and nodes of >> "root->log_root" is not the same as the writing order of them. So, the >> writing causes unaligned write errors. >> >> Reorder the allocation of them by delaying allocation of the root node of >> "fs_info->log_root_tree," so that the node buffers can go out sequentially >> to devices. >> >> Cc: Filipe Manana <fdmanana@gmail.com> >> Reviewed-by: Josef Bacik <josef@toxicpanda.com> >> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> >> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> >> --- >> fs/btrfs/disk-io.c | 12 +++++++----- >> fs/btrfs/tree-log.c | 27 +++++++++++++++++++++------ >> 2 files changed, 28 insertions(+), 11 deletions(-) >> >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >> index 84c6650d5ef7..c2576c5fe62e 100644 >> --- a/fs/btrfs/disk-io.c >> +++ b/fs/btrfs/disk-io.c >> @@ -1298,16 +1298,18 @@ 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) { >> - btrfs_put_root(log_root); >> - return ret; >> + if (!btrfs_is_zoned(fs_info)) { >> + int ret = btrfs_alloc_log_tree_node(trans, log_root); >> + >> + if (ret) { >> + btrfs_put_root(log_root); >> + return ret; >> + } >> } >> >> WARN_ON(fs_info->log_root_tree); >> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c >> index 8be3164d4c5d..7ba044bfa9b1 100644 >> --- a/fs/btrfs/tree-log.c >> +++ b/fs/btrfs/tree-log.c >> @@ -3159,6 +3159,19 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, >> list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); >> root_log_ctx.log_transid = log_root_tree->log_transid; >> >> + if (btrfs_is_zoned(fs_info)) { >> + mutex_lock(&fs_info->tree_log_mutex); >> + if (!log_root_tree->node) { > > As commented in v14, the log root tree is not protected by > fs_info->tree_log_mutex anymore. > It is fs_info->tree_root->log_mutex as of 5.10. > > Everything else was addressed and looks good. > Thanks. David, can you add this or should we send an incremental patch? This survived fstests -g quick run with lockdep enabled. diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 7ba044bfa9b1..36c4a60d20dc 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3160,7 +3160,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, root_log_ctx.log_transid = log_root_tree->log_transid; if (btrfs_is_zoned(fs_info)) { - mutex_lock(&fs_info->tree_log_mutex); + mutex_lock(&fs_info->tree_root->log_mutex); if (!log_root_tree->node) { ret = btrfs_alloc_log_tree_node(trans, log_root_tree); if (ret) { @@ -3169,7 +3169,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, goto out; } } - mutex_unlock(&fs_info->tree_log_mutex); + mutex_unlock(&fs_info->tree_root->log_mutex); } /*
On Thu, Feb 04, 2021 at 02:54:25PM +0000, Johannes Thumshirn wrote: > On 04/02/2021 12:57, Filipe Manana wrote: > > On Thu, Feb 4, 2021 at 10:23 AM Naohiro Aota <naohiro.aota@wdc.com> wrote: > >> --- a/fs/btrfs/tree-log.c > >> +++ b/fs/btrfs/tree-log.c > >> @@ -3159,6 +3159,19 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, > >> list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); > >> root_log_ctx.log_transid = log_root_tree->log_transid; > >> > >> + if (btrfs_is_zoned(fs_info)) { > >> + mutex_lock(&fs_info->tree_log_mutex); > >> + if (!log_root_tree->node) { > > > > As commented in v14, the log root tree is not protected by > > fs_info->tree_log_mutex anymore. > > It is fs_info->tree_root->log_mutex as of 5.10. > > > > Everything else was addressed and looks good. > > Thanks. > > David, can you add this or should we send an incremental patch? > This survived fstests -g quick run with lockdep enabled. > > diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c > index 7ba044bfa9b1..36c4a60d20dc 100644 > --- a/fs/btrfs/tree-log.c > +++ b/fs/btrfs/tree-log.c > @@ -3160,7 +3160,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, > root_log_ctx.log_transid = log_root_tree->log_transid; > if (btrfs_is_zoned(fs_info)) { > - mutex_lock(&fs_info->tree_log_mutex); > + mutex_lock(&fs_info->tree_root->log_mutex); > if (!log_root_tree->node) { > ret = btrfs_alloc_log_tree_node(trans, log_root_tree); > if (ret) { > @@ -3169,7 +3169,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, > goto out; > } > } > - mutex_unlock(&fs_info->tree_log_mutex); > + mutex_unlock(&fs_info->tree_root->log_mutex); Folded to the patch, thanks.
On 04/02/2021 16:50, David Sterba wrote: > On Thu, Feb 04, 2021 at 02:54:25PM +0000, Johannes Thumshirn wrote: >> On 04/02/2021 12:57, Filipe Manana wrote: >>> On Thu, Feb 4, 2021 at 10:23 AM Naohiro Aota <naohiro.aota@wdc.com> wrote: >>>> --- a/fs/btrfs/tree-log.c >>>> +++ b/fs/btrfs/tree-log.c >>>> @@ -3159,6 +3159,19 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, >>>> list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); >>>> root_log_ctx.log_transid = log_root_tree->log_transid; >>>> >>>> + if (btrfs_is_zoned(fs_info)) { >>>> + mutex_lock(&fs_info->tree_log_mutex); >>>> + if (!log_root_tree->node) { >>> >>> As commented in v14, the log root tree is not protected by >>> fs_info->tree_log_mutex anymore. >>> It is fs_info->tree_root->log_mutex as of 5.10. >>> >>> Everything else was addressed and looks good. >>> Thanks. >> >> David, can you add this or should we send an incremental patch? >> This survived fstests -g quick run with lockdep enabled. >> >> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c >> index 7ba044bfa9b1..36c4a60d20dc 100644 >> --- a/fs/btrfs/tree-log.c >> +++ b/fs/btrfs/tree-log.c >> @@ -3160,7 +3160,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, >> root_log_ctx.log_transid = log_root_tree->log_transid; >> if (btrfs_is_zoned(fs_info)) { >> - mutex_lock(&fs_info->tree_log_mutex); >> + mutex_lock(&fs_info->tree_root->log_mutex); >> if (!log_root_tree->node) { >> ret = btrfs_alloc_log_tree_node(trans, log_root_tree); >> if (ret) { >> @@ -3169,7 +3169,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, >> goto out; >> } >> } >> - mutex_unlock(&fs_info->tree_log_mutex); >> + mutex_unlock(&fs_info->tree_root->log_mutex); > > Folded to the patch, thanks. > Thanks a lot
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 84c6650d5ef7..c2576c5fe62e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1298,16 +1298,18 @@ 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) { - btrfs_put_root(log_root); - return ret; + if (!btrfs_is_zoned(fs_info)) { + int ret = btrfs_alloc_log_tree_node(trans, log_root); + + if (ret) { + btrfs_put_root(log_root); + return ret; + } } WARN_ON(fs_info->log_root_tree); diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 8be3164d4c5d..7ba044bfa9b1 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3159,6 +3159,19 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, list_add_tail(&root_log_ctx.list, &log_root_tree->log_ctxs[index2]); root_log_ctx.log_transid = log_root_tree->log_transid; + if (btrfs_is_zoned(fs_info)) { + mutex_lock(&fs_info->tree_log_mutex); + if (!log_root_tree->node) { + ret = btrfs_alloc_log_tree_node(trans, log_root_tree); + if (ret) { + mutex_unlock(&fs_info->tree_log_mutex); + mutex_unlock(&log_root_tree->log_mutex); + goto out; + } + } + mutex_unlock(&fs_info->tree_log_mutex); + } + /* * Now we are safe to update the log_root_tree because we're under the * log_mutex, and we're a current writer so we're holding the commit @@ -3317,12 +3330,14 @@ static void free_log_tree(struct btrfs_trans_handle *trans, .process_func = process_one_buffer }; - ret = walk_log_tree(trans, log, &wc); - if (ret) { - if (trans) - btrfs_abort_transaction(trans, ret); - else - btrfs_handle_fs_error(log->fs_info, ret, NULL); + if (log->node) { + ret = walk_log_tree(trans, log, &wc); + if (ret) { + if (trans) + btrfs_abort_transaction(trans, ret); + else + btrfs_handle_fs_error(log->fs_info, ret, NULL); + } } clear_extent_bits(&log->dirty_log_pages, 0, (u64)-1,