Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Andrey Albershteyn <aalbersh@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/7] libfrog: try to pass struct fs_path objects to quotactl wrapper
Date: Tue, 15 Sep 2026 09:15:33 -0700	[thread overview]
Message-ID: <20260915161533.GD2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <aqk5gM82hhqq-Upd@infradead.org>

On Tue, Sep 15, 2026 at 05:26:40AM -0700, Christoph Hellwig wrote:
> On Tue, Sep 15, 2026 at 12:34:33PM +0200, Andrey Albershteyn wrote:
> > > +	const struct fs_path	*mount,
> > > +	enum xfs_quota_cmd	xcommand,
> > > +	uint			xtype,
> > > +	uint			id,
> > > +	void			*addr)
> > > +{
> > > +	return xfsquotactl(xcommand, mount->fs_name, xtype, id, addr);
> > 
> > The xfsquotactl() can be unfolded here and calls may be replaced
> > with xfrog_quotactl(), no?
> 
> Yeah, looks like we should be able to kill it.  But maybe do that
> as a follow on cleanup?

Hrm.  There are two xfsquotactl() callers remaining after this patch.
One of them is set_limits() in quota/edit.c.  One of the callers of
set_limits is limit_f, which could very well pass through the fs_path
like everywhere else:

	set_limits(id, type, mask, fs_path->mnt_fd, fs_path->fs_name,
		   &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard);

Obviously a good candidate for passing the fs_path instead of the raw
pieces.

The other set_limits caller is restore_file:

static void
restore_file(
	FILE		*fp,
	uint		type)
{
	char		buffer[512];
	char		dev[512];
	uint		mask;
	int		cnt;
	uint32_t	id;
	uint64_t	bsoft, bhard, isoft, ihard, rtbsoft, rtbhard;

	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
		if (strncmp("fs = ", buffer, 5) == 0) {
			/*
			 * Copy the device name to dev, strip off the trailing
			 * newline, and move on to the next line.
			 */
			strncpy(dev, buffer + 5, sizeof(dev) - 1);
			dev[strlen(dev) - 1] = '\0';
			continue;
		}
		rtbsoft = rtbhard = 0;
		cnt = sscanf(buffer, "%u %llu %llu %llu %llu %llu %llu\n",
				&id,
				(unsigned long long *)&bsoft,
				(unsigned long long *)&bhard,
				(unsigned long long *)&isoft,
				(unsigned long long *)&ihard,
				(unsigned long long *)&rtbsoft,
				(unsigned long long *)&rtbhard);
		if (cnt == 5 || cnt == 7) {
			mask = FS_DQ_ISOFT|FS_DQ_IHARD|FS_DQ_BSOFT|FS_DQ_BHARD;
			if (cnt == 7)
				mask |= FS_DQ_RTBSOFT|FS_DQ_RTBHARD;
			set_limits(id, type, mask, -1, dev, &bsoft, &bhard,
					&isoft, &ihard, &rtbsoft, &rtbhard);
		}
	}
}

Here, we have a device string, but no open fd to it.  I could construct
a fake fs_path object to use the xfrog_quotactl() interface, but that's
kinda nasty so I'd rather just leave it as an xfsquotactl() site.

The second caller is makecfg_f -> get_qflags, which is added in a couple
of patches.  That one I could just pass it through

	mount = fs_table_lookup_mount(file->name);
	if (!mount) {
		fprintf(stderr, _("%s: Not a XFS mount point.\n"), file->name);
		return 1;
	}

	mount->mnt_fd = file->xfd.fd;
	ret = get_qflags(mount, &qflags);
	mount->mnt_fd = -1;

Regrettably, struct fileio in spaceman/ is private to xfs_spaceman so
there's no general way to pass that to a libfrog function, which is why
we have to play switcheroo games with mount->mnt_fd here.

--D

  reply	other threads:[~2026-09-15 16:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  5:48 [PATCHSET 2/2] xfsprogs: use quotactl_fd when possible Darrick J. Wong
2026-09-14  5:49 ` [PATCH 1/7] libfrog: hoist xfsquotactl out of xfs_quota Darrick J. Wong
2026-09-15 12:24   ` Christoph Hellwig
2026-09-14  5:50 ` [PATCH 2/7] libfrog: clean up xfsquotactl a little bit Darrick J. Wong
2026-09-15 12:25   ` Christoph Hellwig
2026-09-14  5:50 ` [PATCH 3/7] libfrog: enhance struct fs_path to store optional mount fd Darrick J. Wong
2026-09-15 12:25   ` Christoph Hellwig
2026-09-14  5:50 ` [PATCH 4/7] libfrog: try to pass struct fs_path objects to quotactl wrapper Darrick J. Wong
2026-09-15 10:34   ` Andrey Albershteyn
2026-09-15 12:26     ` Christoph Hellwig
2026-09-15 16:15       ` Darrick J. Wong [this message]
2026-09-16  8:33         ` Andrey Albershteyn
2026-09-14  5:50 ` [PATCH 5/7] libfrog: add quotactl_fd support to xfsquotactl Darrick J. Wong
2026-09-15 12:27   ` Christoph Hellwig
2026-09-14  5:51 ` [PATCH 6/7] xfs_quota: open the filesystem mountpoint for quota operations Darrick J. Wong
2026-09-15 12:27   ` Christoph Hellwig
2026-09-14  5:51 ` [PATCH 7/7] xfs_spaceman: port makecfg to use xfsquotactl Darrick J. Wong
2026-09-15 12:28   ` Christoph Hellwig

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=20260915161533.GD2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-xfs@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