]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: clarify do_chunk_alloc()'s return value
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 29 Jul 2016 18:09:50 +0000 (11:09 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 1 Jun 2017 06:07:19 +0000 (23:07 -0700)
commitef1ab072aa5aa8c937704c3bb6eaad18c125cbb1
tree36432e66e82e63f64c1eea53793fd5466b419a89
parentdb313c94fac21de05d136542758d71d1a0f9f02a
Btrfs: clarify do_chunk_alloc()'s return value

Orabug: 25975316

Function start_transaction() can return ERR_PTR(1) when flush is
BTRFS_RESERVE_FLUSH_LIMIT, so the call graph is

start_transaction (return ERR_PTR(1))
  -> btrfs_block_rsv_add (return 1)
     -> reserve_metadata_bytes (return 1)
        -> flush_space (return 1)
           -> do_chunk_alloc  (return 1)

With BTRFS_RESERVE_FLUSH_LIMIT, if flush_space is already on the
flush_state of ALLOC_CHUNK and it successfully allocates a new
chunk, then instead of trying to reserve space again,
reserve_metadata_bytes returns 1 immediately.

Eventually the callers who call start_transaction() usually just
do the IS_ERR() check which ERR_PTR(1) can pass, then it'll get
a panic when dereferencing a pointer which is ERR_PTR(1).

The following patch fixes the above problem.
"btrfs: flush_space: treat return value of do_chunk_alloc properly"
https://patchwork.kernel.org/patch/7778651/

This add comments to clarify do_chunk_alloc()'s return value.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 28b737f6ede3661fe610937706c4a6f50e9ab769)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/extent-tree.c