mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
xfs: don't let memory failures leak blocks and kill repairs
LOLLM complains that a memory allocation failure in
xrep_newbt_add_blocks results in online repair leaking blocks that were
previously allocated to write a new btree, but the problem is worse than
that -- a limitation of the codebase is that the callers cannot undo the
transaction /and/ return the error -- either you undo all changes and
commit the transaction, or you error out and the filesystem goes down.
However, the new btree space reservation object isn't that big (~48
bytes). Let's just do a NOFAIL allocation and the problem goes away.
Cc: stable@vger.kernel.org # v6.8
Fixes: be40841763 ("xfs: implement block reservation accounting for btrees we're staging")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
d7b92cbe56
commit
ab1c416d23
|
|
@ -193,9 +193,11 @@ xrep_newbt_add_blocks(
|
|||
struct xrep_newbt_resv *resv;
|
||||
int error;
|
||||
|
||||
resv = kmalloc_obj(struct xrep_newbt_resv, XCHK_GFP_FLAGS);
|
||||
if (!resv)
|
||||
return -ENOMEM;
|
||||
/*
|
||||
* We have no way to clean up the allocated space *and* return an
|
||||
* ENOMEM if we fail to allocate this control structure.
|
||||
*/
|
||||
resv = kmalloc_obj(struct xrep_newbt_resv, GFP_KERNEL | __GFP_NOFAIL);
|
||||
|
||||
INIT_LIST_HEAD(&resv->list);
|
||||
resv->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user