Re: [PATCH] gfs2: restart rename when a signal interrupts the glock wait
From: Andreas Gruenbacher
Date: Wed Nov 25 2026 - 13:53:52 EST
On Wed, 25 Nov 2026 at 18:50, Hengyu Liang <hengyul@xxxxxxxxxx> wrote:
> Commit 11d763f0b0af ("gfs2: Retries missing in gfs2_{rename,exchange}")
> made gfs2_glock_async_wait() interruptible. It returns -EINTR when a
> signal is pending.
>
> However, -EINTR goes back to user space as it is, and the system call
> is not restarted. As of now, rename() and renameat2() on gfs2 fail
> with EINTR when a signal arrives while they wait for a glock, also
> when the signal only stops and continues the process.
This is indeed undesirable.
> The issue can be reproduced with:
>
> mkfs.gfs2 -O -p lock_nolock -j 1 /dev/vda
> mount /dev/vda /mnt
> mkdir /mnt/a /mnt/b
> for i in $(seq 12000); do echo > /mnt/a/$i; done
> umount /mnt; mount /dev/vda /mnt
> mv /mnt/a/* /mnt/b/ &
> while kill -STOP $!; do kill -CONT $!; sleep 0.005; done
>
> Before commit 11d763f0b0af ("gfs2: Retries missing in
> gfs2_{rename,exchange}"), mv moves all 12000 files.
>
> After that commit, the result for 783 of the files is:
>
> mv: cannot move '/mnt/a/10' to '/mnt/b/10': Interrupted system call
>
> With this patch, mv moves all 12000 files again.
>
> This patch will return -ERESTARTSYS instead, as gfs2_statfs_slow()
> does for its glock wait, so that the system call is restarted.
Why not make gfs2_glock_async_wait() non-interruptible instead?
Something like the below should work.
Thanks,
Andreas
---
fs/gfs2/glock.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index d22a088c66cd..3a49699ba9cb 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1284,9 +1284,9 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
max_shift = BITS_PER_LONG - 2 - __fls(GL_GLOCK_HOLD_INCR);
incr = min(GL_GLOCK_HOLD_INCR << min(retries - 1, max_shift),
10 * HZ - GL_GLOCK_MIN_HOLD);
- schedule_timeout_interruptible(get_random_long() % (incr / 3));
- if (signal_pending(current))
- goto interrupted;
+ schedule_timeout_killable(get_random_long() % (incr / 3));
+ if (fatal_signal_pending(current))
+ return -EINTR;
timeout += (incr / 3) + get_random_long() % (incr / 3);
}
@@ -1300,21 +1300,17 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
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);
+ 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;
}
- if (signal_pending(current)) {
- ret = -EINTR;
- break;
- }
}
for (i = 0; i < num_gh; i++)
finish_wait(waitq[i], wait + i);
@@ -1344,10 +1340,6 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
}
}
return ret;
-
-interrupted:
- ret = -EINTR;
- goto out;
}
/**
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
--
2.56.1