mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hengyu Liang <hengyul@cs.unc.edu>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] gfs2: restart rename when a signal interrupts the glock wait
Date: Wed, 25 Nov 2026 12:50:07 -0500	[thread overview]
Message-ID: <20261125175007.3659558-1-hengyul@cs.unc.edu> (raw)

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@vger.kernel.org
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
---
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


             reply	other threads:[~2026-11-25 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:50 Hengyu Liang [this message]
2026-11-25 18:53 ` Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125175007.3659558-1-hengyul@cs.unc.edu \
    --to=hengyul@cs.unc.edu \
    --cc=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®