Re: [PATCH 1/2] ocfs2: cluster: use GFP_NOFS for heartbeat bio allocation
From: Andrew Morton
Date: Fri Jul 10 2026 - 20:26:54 EST
On Fri, 10 Jul 2026 15:17:55 +0800 Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx> wrote:
> o2hb_setup_one_bio() allocates the heartbeat bio with GFP_ATOMIC. The
> disk heartbeat runs in the o2hb kernel thread (o2hb_do_disk_heartbeat),
> which is process context and can sleep, so there is no atomicity
> requirement here.
>
> GFP_ATOMIC lacks __GFP_DIRECT_RECLAIM, so the allocation is not served
> from the fs_bio_set mempool reserve and can return NULL under memory
> pressure. A failed heartbeat allocation aborts the heartbeat and can
> lead to the local node being fenced, which is exactly what the old
> comment worried about.
>
> Use GFP_NOFS instead. It keeps __GFP_DIRECT_RECLAIM so the allocation is
> backed by the fs_bio_set mempool and cannot fail, while avoiding
> recursion back into the filesystem during heartbeat I/O. As the
> allocation can no longer fail, drop the dead ERR_PTR(-ENOMEM) path in
> o2hb_setup_one_bio() and the now-redundant IS_ERR() handling in its
> callers.
fyi, AI review asked a thing:
https://sashiko.dev/#/patchset/20260710071756.3586797-1-joseph.qi@xxxxxxxxxxxxxxxxx