linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: David Sterba <dsterba@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	"kernel-team@fb.com" <kernel-team@fb.com>
Subject: Re: [PATCH 6/8] btrfs: extract out zone cache usage into it's own helper
Date: Wed, 21 Dec 2022 16:47:45 +0000	[thread overview]
Message-ID: <20221221164744.tzgzjviq6ykrwjyh@naota-xeon> (raw)
In-Reply-To: <20221220192456.GR10499@twin.jikos.cz>

On Tue, Dec 20, 2022 at 08:24:56PM +0100, David Sterba wrote:
> On Mon, Dec 19, 2022 at 07:05:15AM +0000, Naohiro Aota wrote:
> > On Fri, Dec 16, 2022 at 03:15:56PM -0500, Josef Bacik wrote:
> > > There's a special case for loading the device zone info if we have the
> > > zone cache which is a fair bit of code.  Extract this out into it's own
> > > helper to clean up the code a little bit, and as a side effect it fixes
> > > an uninitialized error we get with -Wmaybe-uninitialized where it
> > > thought zno may have been uninitialized.
> > > 
> > > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > 
> > I'm going to rewrite the code around here with the following WIP branch, to
> > improve the zone caching.
> > 
> > https://github.com/naota/linux/commits/feature/zone-cache
> > 
> > Specifically, this commit removes the for-loop and the "if (i ==
> > *nr_zones)" block you moved in this patch. So, the resulting code will be
> > small enough to keep it there.
> > 
> > https://github.com/naota/linux/commit/8d592ac744111bb2f51595a1608beecadb2c5d03
> > 
> > Could you wait for a while for me to clean-up and send the series? I'll
> > also check the series with -Wmaybe-uninitialized.
> 
> I'd like to have the warnigs fixes first but if there is a shorter fix
> that would not move the code then it can go in now and you wouldn't have
> to redo your changes.

Sure, how about this then?

From 50bc2858dc58301ca1b7d61bb72ca2566e59032c Mon Sep 17 00:00:00 2001
From: Naohiro Aota <naohiro.aota@wdc.com>
Date: Thu, 22 Dec 2022 01:17:59 +0900
Subject: [PATCH] btrfs: zoned: fix uninit warning in btrfs_get_dev_zones

Fix an uninitialized error we get with -Wmaybe-uninitialized where it
thought zno may have been uninitialized.

Since there will be a rewrite of the code, avoid moving the code around and
do the small enough fix.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/linux-btrfs/af6c527cbd8bdc782e50bd33996ee83acc3a16fb.1671221596.git.josef@toxicpanda.com/
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/zoned.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index a759668477bb..ab63f8443e0a 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -220,7 +220,6 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
 			       struct blk_zone *zones, unsigned int *nr_zones)
 {
 	struct btrfs_zoned_device_info *zinfo = device->zone_info;
-	u32 zno;
 	int ret;
 
 	if (!*nr_zones)
@@ -235,6 +234,7 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
 	/* Check cache */
 	if (zinfo->zone_cache) {
 		unsigned int i;
+		u32 zno;
 
 		ASSERT(IS_ALIGNED(pos, zinfo->zone_size));
 		zno = pos >> zinfo->zone_size_shift;
@@ -274,9 +274,12 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
 		return -EIO;
 
 	/* Populate cache */
-	if (zinfo->zone_cache)
+	if (zinfo->zone_cache) {
+		u32 zno = pos >> zinfo->zone_size_shift;
+
 		memcpy(zinfo->zone_cache + zno, zones,
 		       sizeof(*zinfo->zone_cache) * *nr_zones);
+	}
 
 	return 0;
 }
-- 
2.39.0

  reply	other threads:[~2022-12-21 16:47 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 20:15 [PATCH 0/8] Fixup uninitialized warnings and enable extra checks Josef Bacik
2022-12-16 20:15 ` [PATCH 1/8] btrfs: fix uninit warning in run_one_async_start Josef Bacik
2022-12-17  0:15   ` Qu Wenruo
2022-12-19  7:51   ` Johannes Thumshirn
2022-12-20 19:03     ` David Sterba
2022-12-21 18:26     ` David Sterba
2022-12-16 20:15 ` [PATCH 2/8] btrfs: fix uninit warning in btrfs_cleanup_ordered_extents Josef Bacik
2022-12-17  0:16   ` Qu Wenruo
2022-12-19  7:53   ` Johannes Thumshirn
2022-12-16 20:15 ` [PATCH 3/8] btrfs: fix uninit warning from get_inode_gen usage Josef Bacik
2022-12-17  0:16   ` Qu Wenruo
2022-12-19  7:55   ` Johannes Thumshirn
2022-12-20 19:16   ` David Sterba
2022-12-16 20:15 ` [PATCH 4/8] btrfs: fix uninit warning in btrfs_update_block_group Josef Bacik
2022-12-17  0:16   ` Qu Wenruo
2022-12-19  7:56   ` Johannes Thumshirn
2022-12-16 20:15 ` [PATCH 5/8] btrfs: fix uninit warning in __set_extent_bit and convert_extent_bit Josef Bacik
2022-12-17  0:17   ` Qu Wenruo
2022-12-16 20:15 ` [PATCH 6/8] btrfs: extract out zone cache usage into it's own helper Josef Bacik
2022-12-19  7:05   ` Naohiro Aota
2022-12-20 19:24     ` David Sterba
2022-12-21 16:47       ` Naohiro Aota [this message]
2022-12-21 18:08         ` David Sterba
2022-12-16 20:15 ` [PATCH 7/8] btrfs: fix uninit warning in btrfs_sb_log_location Josef Bacik
2022-12-19  6:23   ` Naohiro Aota
2022-12-19  7:59   ` Johannes Thumshirn
2022-12-16 20:15 ` [PATCH 8/8] btrfs: turn on -Wmaybe-uninitialized Josef Bacik
2022-12-17  0:18   ` Qu Wenruo
2022-12-26  4:17   ` Nathan Chancellor
2022-12-26 14:04     ` Naresh Kamboju
2023-01-02 12:42       ` David Sterba
2023-02-22  2:59   ` Guenter Roeck
2023-02-22 16:38     ` David Sterba
2023-02-22 17:18       ` Guenter Roeck
2023-03-12 13:06         ` Linux regression tracking (Thorsten Leemhuis)
2023-03-12 14:37           ` Guenter Roeck
2023-03-12 14:57             ` Linux regression tracking (Thorsten Leemhuis)
2023-03-26 18:03             ` Linux regression tracking #update (Thorsten Leemhuis)
2023-03-14 21:59           ` David Sterba
2023-02-24 17:22     ` Guenter Roeck
2022-12-16 23:55 ` [PATCH 0/8] Fixup uninitialized warnings and enable extra checks Qu Wenruo
2022-12-17  0:07   ` Qu Wenruo
2022-12-20 19:37 ` David Sterba
2022-12-21 18:36   ` 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=20221221164744.tzgzjviq6ykrwjyh@naota-xeon \
    --to=naohiro.aota@wdc.com \
    --cc=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.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;
as well as URLs for NNTP newsgroup(s).