public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] btrfs: remove the zoned/zone_size union in struct btrfs_fs_info
Date: Thu, 24 Mar 2022 17:52:09 +0100	[thread overview]
Message-ID: <20220324165210.1586851-2-hch@lst.de> (raw)
In-Reply-To: <20220324165210.1586851-1-hch@lst.de>

Reading a value from a different member of a union is not just a great
way to obsfucate code, but also creates an aliasing violation.  Switch
btrfs_is_zoned to look at ->zone_size and remove the union.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/ctree.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b7631b88426e3..0edcce6d2db64 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1045,10 +1045,7 @@ struct btrfs_fs_info {
 	 * Zone size > 0 when in ZONED mode, otherwise it's used for a check
 	 * if the mode is enabled
 	 */
-	union {
-		u64 zone_size;
-		u64 zoned;
-	};
+	u64 zone_size;
 
 	struct mutex zoned_meta_io_lock;
 	spinlock_t treelog_bg_lock;
@@ -3928,7 +3925,7 @@ static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
 
 static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
 {
-	return fs_info->zoned != 0;
+	return fs_info->zone_size > 0;
 }
 
 static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root)
-- 
2.30.2


  reply	other threads:[~2022-03-24 16:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 16:52 btrfs zoned fixlets Christoph Hellwig
2022-03-24 16:52 ` Christoph Hellwig [this message]
2022-03-25  7:33   ` [PATCH 1/2] btrfs: remove the zoned/zone_size union in struct btrfs_fs_info Johannes Thumshirn
2022-03-28 14:37     ` David Sterba
2022-03-28 12:46   ` Naohiro Aota
2022-03-28 19:01   ` David Sterba
2022-03-24 16:52 ` [PATCH 2/2] btrfs: fix and document the zoned device choice in alloc_new_bio Christoph Hellwig
2022-03-25  9:09   ` Johannes Thumshirn
2022-03-28 19:12     ` David Sterba
2022-03-28 23:04       ` Naohiro Aota
2022-03-30 15:10         ` David Sterba
2022-03-28 13:31   ` Naohiro Aota
2022-03-25  7:35 ` btrfs zoned fixlets Johannes Thumshirn
2022-03-25  7:50   ` Christoph Hellwig
2022-04-08 16:41 ` Christoph Hellwig
2022-04-08 16:50   ` David Sterba
2022-04-11 16:39 ` 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=20220324165210.1586851-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /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