diff mbox series

btrfs: User assert to document transaction requirement

Message ID 20191008132616.18183-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: User assert to document transaction requirement | expand

Commit Message

Nikolay Borisov Oct. 8, 2019, 1:26 p.m. UTC
Using an ASSERT in btrfs_pin_extent allows to more stringently observe
whether the function is called under a transaction or not.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Johannes Thumshirn Oct. 8, 2019, 1:31 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
David Sterba Oct. 10, 2019, 4:23 p.m. UTC | #2
On Tue, Oct 08, 2019 at 04:26:16PM +0300, Nikolay Borisov wrote:
> Using an ASSERT in btrfs_pin_extent allows to more stringently observe
> whether the function is called under a transaction or not.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5f4b0c4e22aa..59989ee64dbc 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2589,15 +2589,14 @@  static int pin_down_extent(struct btrfs_block_group_cache *cache,
 			 bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
 }
 
-/*
- * this function must be called within transaction
- */
 int btrfs_pin_extent(struct btrfs_fs_info *fs_info,
 		     u64 bytenr, u64 num_bytes, int reserved)
 {
 	struct btrfs_block_group_cache *cache;
 	int ret;
 
+	ASSERT(fs_info->running_transaction);
+
 	cache = btrfs_lookup_block_group(fs_info, bytenr);
 	BUG_ON(!cache); /* Logic error */