[PATCH] gfs2: restart rename when a signal interrupts the glock wait

From: Hengyu Liang

Date: Wed Nov 25 2026 - 12:50:20 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

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.

Fixes: 11d763f0b0af ("gfs2: Retries missing in gfs2_{rename,exchange}")
Cc: stable@xxxxxxxxxxxxxxx
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.

Since commit a098f26d3b80 ("gfs2: Get rid of sd_async_glock_wait"),
signals are only checked while a glock is still pending, so fewer
renames fail: 60 of the 12000 files on gfs2 for-next. The stable trees
that have commit 11d763f0b0af do not have that one, so the change is a
single line there.

Application impact (Ubuntu 26.04 user space): rsync 3.4.1 updates
12000 small files on gfs2 while its processes are stopped and
continued every 5 ms (kill -TSTP / -CONT). On v6.19, rsync exits with
0. On v7.0, it exits with 23 after 267 "rename ... Interrupted system
call" errors, and those files keep their old content.

Tested on gfs2 for-next (9aa0082cf969) with lock_nolock, KASAN and
lockdep: rename, RENAME_EXCHANGE and directory renames no longer fail
under a SA_RESTART handler or under stop / continue. A handler without
SA_RESTART still gets EINTR.

fs/gfs2/glock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index aa11168255e9..05e6b0f6ccc7 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1318,7 +1318,7 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
if (!glocks_pending(num_gh, ghs))
break;
if (signal_pending(current)) {
- ret = -EINTR;
+ ret = -ERESTARTSYS;
break;
}
ret = schedule_timeout(ret);
@@ -1329,7 +1329,7 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
break;
}
if (signal_pending(current)) {
- ret = -EINTR;
+ ret = -ERESTARTSYS;
break;
}
}
@@ -1363,7 +1363,7 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs,
return ret;

interrupted:
- ret = -EINTR;
+ ret = -ERESTARTSYS;
goto out;
}


base-commit: 9aa0082cf969a9973ec6554586753c53211ab799
--
2.53.0