* [PATCH] btrfs: zoned: fix alloc offset calculation
@ 2021-08-09 4:13 Naohiro Aota
2021-08-10 13:54 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Naohiro Aota @ 2021-08-09 4:13 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba, Naohiro Aota
alloc_offset is offset from the start of a block group and @offset is
actually an address in logical space. Thus, we need to consider
block_group->start when calculating them.
Fixes: 011b41bffa3d ("btrfs: zoned: advance allocation pointer after tree log node")
Cc: stable@vger.kernel.org # 5.12+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
fs/btrfs/free-space-cache.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 8eeb65278ac0..e12f4d34e317 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2646,8 +2646,11 @@ int btrfs_remove_free_space(struct btrfs_block_group *block_group,
* btrfs_pin_extent_for_log_replay() when replaying the log.
* Advance the pointer not to overwrite the tree-log nodes.
*/
- if (block_group->alloc_offset < offset + bytes)
- block_group->alloc_offset = offset + bytes;
+ if (block_group->start + block_group->alloc_offset <
+ offset + bytes) {
+ block_group->alloc_offset =
+ offset + bytes - block_group->start;
+ }
return 0;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: zoned: fix alloc offset calculation
2021-08-09 4:13 [PATCH] btrfs: zoned: fix alloc offset calculation Naohiro Aota
@ 2021-08-10 13:54 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2021-08-10 13:54 UTC (permalink / raw)
To: Naohiro Aota; +Cc: linux-btrfs, David Sterba
On Mon, Aug 09, 2021 at 01:13:44PM +0900, Naohiro Aota wrote:
> alloc_offset is offset from the start of a block group and @offset is
> actually an address in logical space. Thus, we need to consider
> block_group->start when calculating them.
>
> Fixes: 011b41bffa3d ("btrfs: zoned: advance allocation pointer after tree log node")
> Cc: stable@vger.kernel.org # 5.12+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-10 13:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 4:13 [PATCH] btrfs: zoned: fix alloc offset calculation Naohiro Aota
2021-08-10 13:54 ` David Sterba
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).