From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH v2 1/4] btrfs: zoned: encapsulate inode locking for zoned relocation
Date: Tue, 7 Dec 2021 20:08:12 +0100 [thread overview]
Message-ID: <20211207190812.GC28560@twin.jikos.cz> (raw)
In-Reply-To: <b1d1bab106ddc4456224c0bf1c1bfcfaea4844b7.1638886948.git.johannes.thumshirn@wdc.com>
On Tue, Dec 07, 2021 at 06:28:34AM -0800, Johannes Thumshirn wrote:
> Encapsulate the inode lock needed for serializing the data relocation
> writes on a zoned filesystem into a helper.
>
> This streamlines the code reading flow and hides special casing for
> zoned filesystems.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Reviewed-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/extent_io.c | 8 ++------
> fs/btrfs/zoned.h | 17 +++++++++++++++++
> 2 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 1a67f4b3986b..cc27e6e6d6ce 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -5184,8 +5184,6 @@ int extent_writepages(struct address_space *mapping,
> struct writeback_control *wbc)
> {
> struct inode *inode = mapping->host;
> - const bool data_reloc = btrfs_is_data_reloc_root(BTRFS_I(inode)->root);
> - const bool zoned = btrfs_is_zoned(BTRFS_I(inode)->root->fs_info);
> int ret = 0;
> struct extent_page_data epd = {
> .bio_ctrl = { 0 },
> @@ -5197,11 +5195,9 @@ int extent_writepages(struct address_space *mapping,
> * Allow only a single thread to do the reloc work in zoned mode to
> * protect the write pointer updates.
> */
> - if (data_reloc && zoned)
> - btrfs_inode_lock(inode, 0);
> + btrfs_zoned_data_reloc_lock(inode);
> ret = extent_write_cache_pages(mapping, wbc, &epd);
> - if (data_reloc && zoned)
> - btrfs_inode_unlock(inode, 0);
> + btrfs_zoned_data_reloc_unlock(inode);
> ASSERT(ret <= 0);
> if (ret < 0) {
> end_write_bio(&epd, ret);
> diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
> index 4344f4818389..e3eaf03a3422 100644
> --- a/fs/btrfs/zoned.h
> +++ b/fs/btrfs/zoned.h
> @@ -8,6 +8,7 @@
> #include "volumes.h"
> #include "disk-io.h"
> #include "block-group.h"
> +#include "btrfs_inode.h"
>
> /*
> * Block groups with more than this value (percents) of unusable space will be
> @@ -354,4 +355,20 @@ static inline void btrfs_clear_treelog_bg(struct btrfs_block_group *bg)
> spin_unlock(&fs_info->treelog_bg_lock);
> }
>
> +static inline void btrfs_zoned_data_reloc_lock(struct inode *inode)
All internal API should use struct btrfs_inode, applied with the
following diff:
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5195,9 +5195,9 @@ int extent_writepages(struct address_space *mapping,
* Allow only a single thread to do the reloc work in zoned mode to
* protect the write pointer updates.
*/
- btrfs_zoned_data_reloc_lock(inode);
+ btrfs_zoned_data_reloc_lock(BTRFS_I(inode));
ret = extent_write_cache_pages(mapping, wbc, &epd);
- btrfs_zoned_data_reloc_unlock(inode);
+ btrfs_zoned_data_reloc_unlock(BTRFS_I(inode));
ASSERT(ret <= 0);
if (ret < 0) {
end_write_bio(&epd, ret);
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index e3eaf03a3422..a7b4cd6dd9f4 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -355,20 +355,20 @@ static inline void btrfs_clear_treelog_bg(struct btrfs_block_group *bg)
spin_unlock(&fs_info->treelog_bg_lock);
}
-static inline void btrfs_zoned_data_reloc_lock(struct inode *inode)
+static inline void btrfs_zoned_data_reloc_lock(struct btrfs_inode *inode)
{
- struct btrfs_root *root = BTRFS_I(inode)->root;
+ struct btrfs_root *root = inode->root;
if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info))
- btrfs_inode_lock(inode, 0);
+ btrfs_inode_lock(&inode->vfs_inode, 0);
}
-static inline void btrfs_zoned_data_reloc_unlock(struct inode *inode)
+static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode)
{
- struct btrfs_root *root = BTRFS_I(inode)->root;
+ struct btrfs_root *root = inode->root;
if (btrfs_is_data_reloc_root(root) && btrfs_is_zoned(root->fs_info))
- btrfs_inode_unlock(inode, 0);
+ btrfs_inode_unlock(&inode->vfs_inode, 0);
}
#endif
next prev parent reply other threads:[~2021-12-07 19:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 14:28 [PATCH v2 0/4] btrfs: first batch of zoned cleanups Johannes Thumshirn
2021-12-07 14:28 ` [PATCH v2 1/4] btrfs: zoned: encapsulate inode locking for zoned relocation Johannes Thumshirn
2021-12-07 19:08 ` David Sterba [this message]
2021-12-08 9:06 ` Johannes Thumshirn
2021-12-08 12:05 ` David Sterba
2021-12-07 14:28 ` [PATCH v2 2/4] btrfs: zoned: simplify btrfs_check_meta_write_pointer Johannes Thumshirn
2021-12-07 14:28 ` [PATCH v2 3/4] btrfs: zoned: sink zone check into btrfs_repair_one_zone Johannes Thumshirn
2021-12-07 14:28 ` [PATCH v2 4/4] btrfs: zoned: it's pointless to check for REQ_OP_ZONE_APPEND and btrfs_is_zoned Johannes Thumshirn
2021-12-07 19:12 ` [PATCH v2 0/4] btrfs: first batch of zoned cleanups David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211207190812.GC28560@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox