Re: [PATCH 1/2] ocfs2: cluster: use GFP_NOFS for heartbeat bio allocation
Joseph Qi <[email protected]> Sun, 12 Jul 2026 20:43:25 +0800
| Newsgroups | dev.linux.lists.ocfs2-devel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 7/11/26 8:26 AM, Andrew Morton wrote: > On Fri, 10 Jul 2026 15:17:55 +0800 Joseph Qi <[email protected]> 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/[email protected] GFP_NOFS won't reintroduce the fencing stall. mempool_alloc strips __GFP_DIRECT_RECLAIM on the first attempt (mempool_adjust_gfp) and checks the reserve before any reclaim, so the common path never blocks. Reclaim happens only if the reserve is fully drained — strictly better than GFP_ATOMIC failing outright. And the further improvement is what next patch exactly does. Thanks, Joseph