[PATCH v2] gfs2: make the glock wait in rename killable
From: Hengyu Liang
Date: Fri Nov 27 2026 - 04:44:52 EST
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.
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
Make the wait killable instead, so that only a fatal signal ends it.
With this change, mv moves all 12000 files again.
Fixes: 11d763f0b0af ("gfs2: Retries missing in gfs2_{rename,exchange}")
Cc: stable@xxxxxxxxxxxxxxx
Suggested-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
Signed-off-by: Hengyu Liang <hengyul@xxxxxxxxxx>
---
I found this while comparing the behavior of different kernel versions.
I used an LLM to analyze the problem and to draft the patch and this
message, and I analyzed the result myself.
v2: make the wait killable, as Andreas suggested, instead of returning
-ERESTARTSYS.
v1: https://lore.kernel.org/all/20261125175007.3659558-1-hengyul@xxxxxxxxxx/
Tested on gfs2 for-next with KASAN and lockdep: no rename fails under
signal handlers or stop / continue, SIGKILL still ends a waiting
rename, and fsck.gfs2 is clean.
fs/gfs2/glock.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 21b71fe286b7..5068b680606c 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1298,8 +1298,8 @@ 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))
+ schedule_timeout_killable(get_random_long() % (incr / 3));
+ if (fatal_signal_pending(current))
goto interrupted;
timeout += (incr / 3) + get_random_long() % (incr / 3);
}
@@ -1311,10 +1311,10 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
}
for (;;) {
for (i = 0; i < num_gh; i++)
- prepare_to_wait(waitq[i], wait + i, TASK_INTERRUPTIBLE);
+ prepare_to_wait(waitq[i], wait + i, TASK_KILLABLE);
if (!glocks_pending(num_gh, ghs))
break;
- if (signal_pending(current)) {
+ if (fatal_signal_pending(current)) {
ret = -EINTR;
break;
}
@@ -1325,10 +1325,6 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
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);
base-commit: a009501c151f7d19519312ccfa2070d30d62b249
--
2.53.0