Re: [PATCH] gfs2: restart rename when a signal interrupts the glock wait
From: Andreas Gruenbacher
Date: Thu Nov 26 2026 - 04:49:53 EST
On Thu, 26 Nov 2026 at 04:28, Hengyu Liang <hengyul@xxxxxxxxxx> wrote:
> Hi Andreas,
>
> On Wed, 25 Nov 2026 at 19:53, Andreas Gruenbacher <agruenba@xxxxxxxxxx> wrote:
> > Why not make gfs2_glock_async_wait() non-interruptible instead?
> > Something like the below should work.
>
> That is better, thanks.
>
> There is one problem in the sketch:
>
> > prepare_to_wait(waitq[i], wait + i, TASK_INTERRUPTIBLE);
> > if (!glocks_pending(num_gh, ghs))
> > break;
> > - if (signal_pending(current)) {
> > + ret = schedule_timeout_killable(ret);
>
> schedule_timeout_killable() sets the task state to TASK_KILLABLE again
> after glocks_pending() has been checked. If the last pending glock is
> granted between the check and that point, the wakeup sets the task to
> TASK_RUNNING and removes the wait entry, and then the state is
> overwritten. The task then sleeps until the timeout expires. It does
> not hang, but the rename waits for the rest of the timeout.
>
> I would pass TASK_KILLABLE to prepare_to_wait() and keep
> schedule_timeout():
>
> for (;;) {
> for (i = 0; i < num_gh; i++)
> prepare_to_wait(waitq[i], wait + i, TASK_KILLABLE);
> if (!glocks_pending(num_gh, ghs))
> break;
> if (fatal_signal_pending(current)) {
> ret = -EINTR;
> break;
> }
> ret = schedule_timeout(ret);
> if (!glocks_pending(num_gh, ghs))
> break;
> if (!ret) {
> ret = -ESTALE; /* request timed out. */
> break;
> }
> }
>
> The back-off sleep would be schedule_timeout_killable() followed by
> fatal_signal_pending(), as in your sketch.
>
> I tested this version on gfs2 for-next with lock_nolock, KASAN and
> lockdep. The mv reproducer from the patch moves all 12000 files, and no
> rename fails with EINTR under SA_RESTART handlers, handlers without
> SA_RESTART, or stop / continue. SIGKILL and SIGTERM still end a rename,
> and fsck.gfs2 is clean afterwards.
>
> If that is fine with you, I will send a v2 like this with your
> Suggested-by.
Yes, that sounds good.
Thanks,
Andreas