]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: fix comment in alloc_bitmap() and drop stale TODO
authorRajeev Tapadia <rtapadia730@gmail.com>
Fri, 3 Oct 2025 13:30:02 +0000 (19:00 +0530)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 20:37:37 +0000 (21:37 +0100)
All callers of alloc_bitmap() hold a transaction handle, so GFP_NOFS is
needed to avoid deadlocks on recursion. Update the comment and drop the
stale TODO.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Rajeev Tapadia <rtapadia730@gmail.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c

index 9ed36bbe9d351bcd2cc8f21432f5ee2e9952a32c..26eae347739fbabef781d6dcf0d769efe15b40ad 100644 (file)
@@ -165,11 +165,9 @@ static unsigned long *alloc_bitmap(u32 bitmap_size)
 
        /*
         * GFP_NOFS doesn't work with kvmalloc(), but we really can't recurse
-        * into the filesystem as the free space bitmap can be modified in the
-        * critical section of a transaction commit.
-        *
-        * TODO: push the memalloc_nofs_{save,restore}() to the caller where we
-        * know that recursion is unsafe.
+        * into the filesystem here. All callers hold a transaction handle
+        * open, so if a GFP_KERNEL allocation recurses into the filesystem
+        * and triggers a transaction commit, we would deadlock.
         */
        nofs_flag = memalloc_nofs_save();
        ret = kvzalloc(bitmap_rounded_size, GFP_KERNEL);