All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map
@ 2021-08-09  0:29 Naohiro Aota
  2021-08-10 11:23 ` Johannes Thumshirn
  2021-08-10 14:04 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Naohiro Aota @ 2021-08-09  0:29 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Naohiro Aota, Johannes Thumshirn, Filipe Manana

We call split_zoned_em() on an extent_map on submitting a bio for it. Thus,
we can assume the extent_map is PINNED, not LOGGING, and in the modified
list. Add ASSERT()s to ensure the  extent_maps after the split also has the
proper flags set and are in the modified list.

Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Suggested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/inode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0c40dfaf6c0d..7d3882e9ef10 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2303,7 +2303,6 @@ static int split_zoned_em(struct btrfs_inode *inode, u64 start, u64 len,
 	struct extent_map *split_mid = NULL;
 	struct extent_map *split_post = NULL;
 	int ret = 0;
-	int modified;
 	unsigned long flags;
 
 	/* Sanity check */
@@ -2333,11 +2332,12 @@ static int split_zoned_em(struct btrfs_inode *inode, u64 start, u64 len,
 	ASSERT(em->len == len);
 	ASSERT(!test_bit(EXTENT_FLAG_COMPRESSED, &em->flags));
 	ASSERT(em->block_start < EXTENT_MAP_LAST_BYTE);
+	ASSERT(test_bit(EXTENT_FLAG_PINNED, &em->flags));
+	ASSERT(!test_bit(EXTENT_FLAG_LOGGING, &em->flags));
+	ASSERT(!list_empty(&em->list));
 
 	flags = em->flags;
 	clear_bit(EXTENT_FLAG_PINNED, &em->flags);
-	clear_bit(EXTENT_FLAG_LOGGING, &flags);
-	modified = !list_empty(&em->list);
 
 	/* First, replace the em with a new extent_map starting from * em->start */
 	split_pre->start = em->start;
@@ -2351,7 +2351,7 @@ static int split_zoned_em(struct btrfs_inode *inode, u64 start, u64 len,
 	split_pre->compress_type = em->compress_type;
 	split_pre->generation = em->generation;
 
-	replace_extent_mapping(em_tree, em, split_pre, modified);
+	replace_extent_mapping(em_tree, em, split_pre, 1);
 
 	/*
 	 * Now we only have an extent_map at:
@@ -2371,7 +2371,7 @@ static int split_zoned_em(struct btrfs_inode *inode, u64 start, u64 len,
 		split_mid->flags = flags;
 		split_mid->compress_type = em->compress_type;
 		split_mid->generation = em->generation;
-		add_extent_mapping(em_tree, split_mid, modified);
+		add_extent_mapping(em_tree, split_mid, 1);
 	}
 
 	if (post) {
@@ -2385,7 +2385,7 @@ static int split_zoned_em(struct btrfs_inode *inode, u64 start, u64 len,
 		split_post->flags = flags;
 		split_post->compress_type = em->compress_type;
 		split_post->generation = em->generation;
-		add_extent_mapping(em_tree, split_post, modified);
+		add_extent_mapping(em_tree, split_post, 1);
 	}
 
 	/* Once for us */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map
  2021-08-09  0:29 [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map Naohiro Aota
@ 2021-08-10 11:23 ` Johannes Thumshirn
  2021-08-10 14:04 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2021-08-10 11:23 UTC (permalink / raw)
  To: Naohiro Aota, linux-btrfs; +Cc: David Sterba, Filipe Manana

Looks good to me,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map
  2021-08-09  0:29 [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map Naohiro Aota
  2021-08-10 11:23 ` Johannes Thumshirn
@ 2021-08-10 14:04 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-08-10 14:04 UTC (permalink / raw)
  To: Naohiro Aota; +Cc: linux-btrfs, David Sterba, Johannes Thumshirn, Filipe Manana

On Mon, Aug 09, 2021 at 09:29:18AM +0900, Naohiro Aota wrote:
> We call split_zoned_em() on an extent_map on submitting a bio for it. Thus,
> we can assume the extent_map is PINNED, not LOGGING, and in the modified
> list. Add ASSERT()s to ensure the  extent_maps after the split also has the
> proper flags set and are in the modified list.
> 
> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Suggested-by: Filipe Manana <fdmanana@suse.com>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-10 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  0:29 [PATCH] btrfs: zoned: add ASSERTs on splitting extent_map Naohiro Aota
2021-08-10 11:23 ` Johannes Thumshirn
2021-08-10 14:04 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.