[lvc-project] [PATCH 19/19] gfs2: Remove unnecessary sd_jdesc NULL check in gfs2_log_flush

Fedor Pchelkin pchelkin at ispras.ru
Tue Apr 14 19:09:54 MSK 2026


[PATCH 19/19] означает, что это 19-ый по счёту патч в серии из 19 патчей.
Для одного патча нужно [PATCH].

Также сейчас патч убирает проверку не только в одной конкретной функции,
потому "in gfs2_log_flush" можно убрать из названия.

On Tue, 14. Apr 19:03, Nikolai Kuznetsov wrote:
> Commit 35264909e9d1 ("gfs2: Fix NULL pointer dereference in
> gfs2_log_flush") added an explicit NULL check for sd_jdesc
> to avoid a race with unmount.
> 
> Note that the explicit NULL check alone was insufficient, as other
> functions e.g. log_distance() still dereference sd_jdesc.
> 
> However, gfs2_log_flush() checks for SDF_JOURNAL_LIVE bit and bails
> out if it's not set. During unmount this bit is cleared in final
> shutdown flush which is called in gfs2_make_fs_ro().
> 
> Filesystem becomes RO firstly and only then sd_jdesc is assigned
> NULL in gfs2_jindex_free(), so the race is not possible. The
> explicit check is redundant, remove it.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 35264909e9d1 ("gfs2: Fix NULL pointer dereference in gfs2_log_flush")
> Fixes: 74b4dbb94606 ("gfs2: prevent NULL pointer dereference during unmount")
> Signed-off-by: Nikolai Kuznetsov <niku.csmsu at yandex.ru>
> ---

Ну, что ж, предлагаю пробовать отправлять в сообщество
https://portal.linuxtesting.ru/How-to-send-patches-to-kernel.html#Идентификация-адресатов

Дальше действуем по реакции с их стороны.

>  fs/gfs2/log.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
> index 78bba8cc10b8..0b91f3e0928a 100644
> --- a/fs/gfs2/log.c
> +++ b/fs/gfs2/log.c
> @@ -467,7 +467,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)
>  {
>  	atomic_add(blks, &sdp->sd_log_blks_free);
>  	trace_gfs2_log_blocks(sdp, blks);
> -	gfs2_assert_withdraw(sdp, !sdp->sd_jdesc ||
> +	gfs2_assert_withdraw(sdp,
>  			atomic_read(&sdp->sd_log_blks_free) <=
>  			sdp->sd_jdesc->jd_blocks);
>  	if (atomic_read(&sdp->sd_log_blks_needed))
> @@ -1137,8 +1137,9 @@ static void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
>  	lops_before_commit(sdp, tr);
>  	if (gfs2_withdrawn(sdp))
>  		goto out_withdraw;
> -	if (sdp->sd_jdesc)
> -		gfs2_log_submit_write(&sdp->sd_jdesc->jd_log_bio);
> +
> +	gfs2_log_submit_write(&sdp->sd_jdesc->jd_log_bio);
> +
>  	if (gfs2_withdrawn(sdp))
>  		goto out_withdraw;
>  
> -- 
> 2.43.0



More information about the lvc-project mailing list