Linux EXT4 FS development
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
	"Theodore Ts'o" <tytso@mit.edu>,
	linuxquota-devel@lists.sourceforge.net
Subject: [PATCH] quotasys: silence errors caused by vanishing mounts in the mount table
Date: Sat, 28 Nov 2026 14:22:45 -0500	[thread overview]
Message-ID: <20261128192248.148122-1-tytso@mit.edu> (raw)

Even when setquota is given a single explicit mountpoint (such as
/xt-vdc), it walks the entire mount table and opens mountpoints three
times (once each for user, group. and project quotas), before
filtering out the user-specified mountpoint.  Unfortunately (as is the
case with xfstests's generic/234), if setquota is racing with systemd
creating and removing the tmpfs mount /run/user/31415 when commands
are run under "su fsgqa", this can cause a spurious error messages
resulting in generic/234 failing intermittently.

Fix this by suppressing the error message while scanning the mount
table; since we take a snapshot of the mounts and then iterate over
them, it is quite normal that we might have some mounts that might
appear or disappear while we populate the in-memory mount information.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 quotasys.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/quotasys.c b/quotasys.c
index 7cbc864..6ee920a 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -440,7 +440,17 @@ int do_quotactl(int cmd, const char *dev, const char *mnt, int id, caddr_t addr)
 		int fd = open(mnt, O_DIRECTORY | O_PATH);
 
 		if (fd < 0) {
-			errstr(_("Unable to get a filedescriptor from mountpoint: %s\n"), mnt);
+			/*
+			 * The mount table we scan is only a snapshot; a
+			 * mount point which has been removed in the mean
+			 * time (e.g. /run/user/<uid>) is not worth a message.
+			 *
+			 * Besides, if quotactl_fd(2) is not available, the
+			 * fallback where we call quotactl(2) doesn't print
+			 * any error messages, but just returns -1 and sets errno.
+			 */
+			if (errno != ENOENT)
+				errstr(_("Unable to get a filedescriptor from mountpoint: %s: %s\n"), mnt, strerror(errno));
 			return fd;
 		}
 
@@ -1090,13 +1100,16 @@ alloc:
 		}
 			
 		if (!realpath(mnt->mnt_dir, mntpointbuf)) {
-			errstr(_("Cannot resolve mountpoint path %s: %s\n"), mnt->mnt_dir, strerror(errno));
+			/* Unmounted and removed since we read the mount table? */
+			if (errno != ENOENT)
+				errstr(_("Cannot resolve mountpoint path %s: %s\n"), mnt->mnt_dir, strerror(errno));
 			free((char *)devname);
 			continue;
 		}
 		
 		if (statfs(mntpointbuf, &fsstat) != 0) {
-			errstr(_("Cannot statfs() %s: %s\n"), mntpointbuf, strerror(errno));
+			if (errno != ENOENT)
+				errstr(_("Cannot statfs() %s: %s\n"), mntpointbuf, strerror(errno));
 			free((char *)devname);
 			continue;
 		}
-- 
2.56.1.839.g22a8290db9-goog


                 reply	other threads:[~2026-11-28 19:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261128192248.148122-1-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linuxquota-devel@lists.sourceforge.net \
    /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