All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 04/23] libxfs: remove the volname concept
Date: Mon, 11 Dec 2023 17:37:23 +0100	[thread overview]
Message-ID: <20231211163742.837427-5-hch@lst.de> (raw)
In-Reply-To: <20231211163742.837427-1-hch@lst.de>

IRIX has the concept of a volume that has data/log/rt subvolumes (that's
where the subvolume name in Linux comes from), but in the current
Linux-only xfsprogs version trying to pretend we do anything with that
it is just utterly confusing.  The volname is basically just a very
obsfucated second way to pass the data device name, so get rid of it
in the libxfs and progs internals.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 copy/xfs_copy.c   |  7 ++----
 db/info.c         |  2 +-
 db/init.c         | 13 +++-------
 db/init.h         |  1 -
 db/output.c       |  2 +-
 include/libxfs.h  |  1 -
 libxfs/init.c     | 24 ++++--------------
 libxfs/topology.c | 10 ++++----
 mkfs/xfs_mkfs.c   | 63 ++++++++++-------------------------------------
 repair/init.c     | 11 ++-------
 10 files changed, 33 insertions(+), 101 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 79f659467..66728f199 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -718,11 +718,8 @@ main(int argc, char **argv)
 	xargs.isdirect = LIBXFS_DIRECT;
 	xargs.isreadonly = LIBXFS_ISREADONLY;
 
-	if (source_is_file)  {
-		xargs.dname = source_name;
-		xargs.disfile = 1;
-	} else
-		xargs.volname = source_name;
+	xargs.dname = source_name;
+	xargs.disfile = source_is_file;
 
 	if (!libxfs_init(&xargs))  {
 		do_log(_("%s: couldn't initialize XFS library\n"
diff --git a/db/info.c b/db/info.c
index 0f6c29429..b30ada3aa 100644
--- a/db/info.c
+++ b/db/info.c
@@ -30,7 +30,7 @@ info_f(
 	struct xfs_fsop_geom	geo;
 
 	libxfs_fs_geometry(mp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER);
-	xfs_report_geom(&geo, fsdevice, x.logname, x.rtname);
+	xfs_report_geom(&geo, x.dname, x.logname, x.rtname);
 	return 0;
 }
 
diff --git a/db/init.c b/db/init.c
index 4599cc00d..18d9dfdd9 100644
--- a/db/init.c
+++ b/db/init.c
@@ -19,7 +19,6 @@
 
 static char		**cmdline;
 static int		ncmdline;
-char			*fsdevice;
 int			blkbb;
 int			exitcode;
 int			expert_mode;
@@ -91,11 +90,7 @@ init(
 	if (optind + 1 != argc)
 		usage();
 
-	fsdevice = argv[optind];
-	if (!x.disfile)
-		x.volname = fsdevice;
-	else
-		x.dname = fsdevice;
+	x.dname = argv[optind];
 	x.isdirect = LIBXFS_DIRECT;
 
 	x.bcache_flags = CACHE_MISCOMPARE_PURGE;
@@ -115,7 +110,7 @@ init(
 			1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, &bp, NULL);
 	if (error) {
 		fprintf(stderr, _("%s: %s is invalid (cannot read first 512 "
-			"bytes)\n"), progname, fsdevice);
+			"bytes)\n"), progname, x.dname);
 		exit(1);
 	}
 
@@ -126,7 +121,7 @@ init(
 	sbp = &xmount.m_sb;
 	if (sbp->sb_magicnum != XFS_SB_MAGIC) {
 		fprintf(stderr, _("%s: %s is not a valid XFS filesystem (unexpected SB magic number 0x%08x)\n"),
-			progname, fsdevice, sbp->sb_magicnum);
+			progname, x.dname, sbp->sb_magicnum);
 		if (!force) {
 			fprintf(stderr, _("Use -F to force a read attempt.\n"));
 			exit(EXIT_FAILURE);
@@ -139,7 +134,7 @@ init(
 	if (!mp) {
 		fprintf(stderr,
 			_("%s: device %s unusable (not an XFS filesystem?)\n"),
-			progname, fsdevice);
+			progname, x.dname);
 		exit(1);
 	}
 	mp->m_log = &xlog;
diff --git a/db/init.h b/db/init.h
index 16dc13f2b..05e75c100 100644
--- a/db/init.h
+++ b/db/init.h
@@ -4,7 +4,6 @@
  * All Rights Reserved.
  */
 
-extern char		*fsdevice;
 extern int		blkbb;
 extern int		exitcode;
 extern int		expert_mode;
diff --git a/db/output.c b/db/output.c
index 422148afa..30ae82ced 100644
--- a/db/output.c
+++ b/db/output.c
@@ -34,7 +34,7 @@ dbprintf(const char *fmt, ...)
 	blockint();
 	i = 0;
 	if (dbprefix)
-		i += printf("%s: ", fsdevice);
+		i += printf("%s: ", x.dname);
 	i += vprintf(fmt, ap);
 	unblockint();
 	va_end(ap);
diff --git a/include/libxfs.h b/include/libxfs.h
index 9b0294cb8..b35dc2184 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -94,7 +94,6 @@ struct iomap;
  */
 typedef struct libxfs_xinit {
 				/* input parameters */
-	char            *volname;       /* pathname of volume */
 	char            *dname;         /* pathname of data "subvolume" */
 	char            *logname;       /* pathname of log "subvolume" */
 	char            *rtname;        /* pathname of realtime "subvolume" */
diff --git a/libxfs/init.c b/libxfs/init.c
index 9cfd20e3f..894d84057 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -294,10 +294,8 @@ int
 libxfs_init(libxfs_init_t *a)
 {
 	char		*dname;
-	int		fd;
 	char		*logname;
 	char		*rtname;
-	int		rval = 0;
 	int		flags;
 
 	dname = a->dname;
@@ -308,20 +306,12 @@ libxfs_init(libxfs_init_t *a)
 	a->dsize = a->lbsize = a->rtbsize = 0;
 	a->dbsize = a->logBBsize = a->logBBstart = a->rtsize = 0;
 
-	fd = -1;
 	flags = (a->isreadonly | a->isdirect);
 
 	rcu_init();
 	rcu_register_thread();
 	radix_tree_init();
 
-	if (a->volname) {
-		if (!check_open(a->volname, flags))
-			goto done;
-		fd = open(a->volname, O_RDONLY);
-		dname = a->dname = a->volname;
-		a->volname = NULL;
-	}
 	if (dname) {
 		if (a->disfile) {
 			a->ddev= libxfs_device_open(dname, a->dcreat, flags,
@@ -398,16 +388,12 @@ libxfs_init(libxfs_init_t *a)
 	use_xfs_buf_lock = a->usebuflock;
 	xfs_dir_startup();
 	init_caches();
-	rval = 1;
-done:
-	if (fd >= 0)
-		close(fd);
-	if (!rval) {
-		libxfs_close_devices(a);
-		rcu_unregister_thread();
-	}
+	return 1;
 
-	return rval;
+done:
+	libxfs_close_devices(a);
+	rcu_unregister_thread();
+	return 0;
 }
 
 
diff --git a/libxfs/topology.c b/libxfs/topology.c
index a17c19691..25f47beda 100644
--- a/libxfs/topology.c
+++ b/libxfs/topology.c
@@ -292,7 +292,6 @@ void get_topology(
 	int			force_overwrite)
 {
 	struct stat statbuf;
-	char *dfile = xi->volname ? xi->volname : xi->dname;
 
 	/*
 	 * If our target is a regular file, use platform_findsizes
@@ -300,7 +299,7 @@ void get_topology(
 	 * for direct IO; we'll set our sector size to that if possible.
 	 */
 	if (xi->disfile ||
-	    (!stat(dfile, &statbuf) && S_ISREG(statbuf.st_mode))) {
+	    (!stat(xi->dname, &statbuf) && S_ISREG(statbuf.st_mode))) {
 		int fd;
 		int flags = O_RDONLY;
 		long long dummy;
@@ -309,15 +308,16 @@ void get_topology(
 		if (xi->disfile)
 			flags |= O_CREAT;
 
-		fd = open(dfile, flags, 0666);
+		fd = open(xi->dname, flags, 0666);
 		if (fd >= 0) {
-			platform_findsizes(dfile, fd, &dummy, &ft->lsectorsize);
+			platform_findsizes(xi->dname, fd, &dummy,
+					&ft->lsectorsize);
 			close(fd);
 			ft->psectorsize = ft->lsectorsize;
 		} else
 			ft->psectorsize = ft->lsectorsize = BBSIZE;
 	} else {
-		blkid_get_topology(dfile, &ft->dsunit, &ft->dswidth,
+		blkid_get_topology(xi->dname, &ft->dsunit, &ft->dswidth,
 				   &ft->lsectorsize, &ft->psectorsize,
 				   force_overwrite);
 	}
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index c522cb4df..19849ed21 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1959,7 +1959,6 @@ validate_sectorsize(
 	struct cli_params	*cli,
 	struct mkfs_default_params *dft,
 	struct fs_topology	*ft,
-	char			*dfile,
 	int			dry_run,
 	int			force_overwrite)
 {
@@ -1967,7 +1966,8 @@ validate_sectorsize(
 	 * Before anything else, verify that we are correctly operating on
 	 * files or block devices and set the control parameters correctly.
 	 */
-	check_device_type(dfile, &cli->xi->disfile, !cli->dsize, !dfile,
+	check_device_type(cli->xi->dname, &cli->xi->disfile,
+			  !cli->dsize, !cli->xi->dname,
 			  dry_run ? NULL : &cli->xi->dcreat, "d");
 	if (!cli->loginternal)
 		check_device_type(cli->xi->logname, &cli->xi->lisfile,
@@ -2929,36 +2929,17 @@ reported by the device (%u).\n"),
 	}
 }
 
-/*
- * This is more complex than it needs to be because we still support volume
- * based external logs. They are only discovered *after* the devices have been
- * opened, hence the crazy "is this really an internal log" checks here.
- */
 static void
 validate_logdev(
 	struct mkfs_params	*cfg,
-	struct cli_params	*cli,
-	char			**devname)
+	struct cli_params	*cli)
 {
 	struct libxfs_xinit	*xi = cli->xi;
 
-	*devname = NULL;
-
-	/* check for volume log first */
-	if (cli->loginternal && xi->volname && xi->logdev) {
-		*devname = _("volume log");
-		cfg->loginternal = false;
-	} else
-		cfg->loginternal = cli->loginternal;
+	cfg->loginternal = cli->loginternal;
 
 	/* now run device checks */
 	if (cfg->loginternal) {
-		if (xi->logdev) {
-			fprintf(stderr,
-_("can't have both external and internal logs\n"));
-			usage();
-		}
-
 		/*
 		 * if no sector size has been specified on the command line,
 		 * use what has been configured and validated for the data
@@ -2980,14 +2961,11 @@ _("log size %lld too large for internal log\n"),
 				(long long)cfg->logblocks);
 			usage();
 		}
-		*devname = _("internal log");
 		return;
 	}
 
 	/* External/log subvolume checks */
-	if (xi->logname)
-		*devname = xi->logname;
-	if (!*devname || !xi->logdev) {
+	if (!*xi->logname || !xi->logdev) {
 		fprintf(stderr, _("no log subvolume or external log.\n"));
 		usage();
 	}
@@ -3018,13 +2996,10 @@ reported by the device (%u).\n"),
 static void
 validate_rtdev(
 	struct mkfs_params	*cfg,
-	struct cli_params	*cli,
-	char			**devname)
+	struct cli_params	*cli)
 {
 	struct libxfs_xinit	*xi = cli->xi;
 
-	*devname = NULL;
-
 	if (!xi->rtdev) {
 		if (cli->rtsize) {
 			fprintf(stderr,
@@ -3032,7 +3007,6 @@ _("size specified for non-existent rt subvolume\n"));
 			usage();
 		}
 
-		*devname = _("none");
 		cfg->rtblocks = 0;
 		cfg->rtextents = 0;
 		cfg->rtbmblocks = 0;
@@ -3043,12 +3017,6 @@ _("size specified for non-existent rt subvolume\n"));
 		usage();
 	}
 
-	/* volume rtdev */
-	if (xi->volname)
-		*devname = _("volume rt");
-	else
-		*devname = xi->rtname;
-
 	if (cli->rtsize) {
 		if (cfg->rtblocks > DTOBT(xi->rtsize, cfg->blocklog)) {
 			fprintf(stderr,
@@ -4080,9 +4048,6 @@ main(
 	xfs_agnumber_t		agno;
 	struct xfs_buf		*buf;
 	int			c;
-	char			*dfile = NULL;
-	char			*logfile = NULL;
-	char			*rtfile = NULL;
 	int			dry_run = 0;
 	int			discard = 1;
 	int			force_overwrite = 0;
@@ -4222,9 +4187,8 @@ main(
 		fprintf(stderr, _("extra arguments\n"));
 		usage();
 	} else if (argc - optind == 1) {
-		dfile = xi.volname = getstr(argv[optind], &dopts, D_NAME);
-	} else
-		dfile = xi.dname;
+		xi.dname = getstr(argv[optind], &dopts, D_NAME);
+	}
 
 	/*
 	 * Now we have all the options parsed, we can read in the option file
@@ -4241,8 +4205,7 @@ main(
 	 * before opening the libxfs devices.
 	 */
 	validate_blocksize(&cfg, &cli, &dft);
-	validate_sectorsize(&cfg, &cli, &dft, &ft, dfile, dry_run,
-			    force_overwrite);
+	validate_sectorsize(&cfg, &cli, &dft, &ft, dry_run, force_overwrite);
 
 	/*
 	 * XXX: we still need to set block size and sector size global variables
@@ -4277,10 +4240,10 @@ main(
 	 * Open and validate the device configurations
 	 */
 	open_devices(&cfg, &xi);
-	validate_overwrite(dfile, force_overwrite);
+	validate_overwrite(xi.dname, force_overwrite);
 	validate_datadev(&cfg, &cli);
-	validate_logdev(&cfg, &cli, &logfile);
-	validate_rtdev(&cfg, &cli, &rtfile);
+	validate_logdev(&cfg, &cli);
+	validate_rtdev(&cfg, &cli);
 	calc_stripe_factors(&cfg, &cli, &ft);
 
 	/*
@@ -4321,7 +4284,7 @@ main(
 		struct xfs_fsop_geom	geo;
 
 		libxfs_fs_geometry(mp, &geo, XFS_FS_GEOM_MAX_STRUCT_VER);
-		xfs_report_geom(&geo, dfile, logfile, rtfile);
+		xfs_report_geom(&geo, xi.dname, xi.logname, xi.rtname);
 		if (dry_run)
 			exit(0);
 	}
diff --git a/repair/init.c b/repair/init.c
index 0d5bfabcf..6d019b393 100644
--- a/repair/init.c
+++ b/repair/init.c
@@ -54,15 +54,8 @@ xfs_init(libxfs_init_t *args)
 {
 	memset(args, 0, sizeof(libxfs_init_t));
 
-	if (isa_file)  {
-		args->disfile = 1;
-		args->dname = fs_name;
-		args->volname = NULL;
-	} else  {
-		args->disfile = 0;
-		args->volname = fs_name;
-		args->dname = NULL;
-	}
+	args->dname = fs_name;
+	args->disfile = isa_file;
 
 	if (log_spec)  {	/* External log specified */
 		args->logname = log_name;
-- 
2.39.2


  parent reply	other threads:[~2023-12-11 16:37 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 16:37 improve libxfs device handling Christoph Hellwig
2023-12-11 16:37 ` [PATCH 01/23] libxfs: remove the unused icache_flags member from struct libxfs_xinit Christoph Hellwig
2023-12-18  8:37   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 02/23] libxfs: remove the dead {d,log,rt}path variables in libxfs_init Christoph Hellwig
2023-12-18  8:38   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 03/23] libxfs/frog: remove latform_find{raw,block}path Christoph Hellwig
2023-12-18  8:41   ` Carlos Maiolino
2023-12-11 16:37 ` Christoph Hellwig [this message]
2023-12-18  8:47   ` [PATCH 04/23] libxfs: remove the volname concept Carlos Maiolino
2023-12-11 16:37 ` [PATCH 05/23] xfs_logprint: move all code to set up the fake xlog into logstat() Christoph Hellwig
2023-12-18  8:51   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 06/23] libxlog: remove the verbose argument to xlog_is_dirty Christoph Hellwig
2023-12-18  8:56   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 07/23] libxlog: add a helper to initialize a xlog without clobbering the x structure Christoph Hellwig
2023-12-18  9:00   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 08/23] libxlog: don't require a libxfs_xinit structure for xlog_init Christoph Hellwig
2023-12-18  9:06   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 09/23] libxlog: remove the global libxfs_xinit x structure Christoph Hellwig
2023-12-18  9:18   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 10/23] libxfs: rename struct libxfs_xinit to libxfs_init Christoph Hellwig
2023-12-18  9:20   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 11/23] libxfs: pass a struct libxfs_init to libxfs_mount Christoph Hellwig
2023-12-18  9:21   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 12/23] libxfs: pass a struct libxfs_init to libxfs_alloc_buftarg Christoph Hellwig
2023-12-18  9:21   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 13/23] libxfs: merge the file vs device cases in libxfs_init Christoph Hellwig
2023-12-18  9:23   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 14/23] libxfs: making passing flags to libxfs_init less confusing Christoph Hellwig
2023-12-18 12:30   ` Carlos Maiolino
2023-12-18 14:36     ` Christoph Hellwig
2023-12-11 16:37 ` [PATCH 15/23] libxfs: remove the setblksize == 1 case in libxfs_device_open Christoph Hellwig
2023-12-18 12:44   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 16/23] libfrog: make platform_set_blocksize exit on fatal failure Christoph Hellwig
2023-12-18 12:48   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 17/23] libxfs: remove dead size < 0 checks in libxfs_init Christoph Hellwig
2023-12-18 12:51   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 18/23] libxfs: mark libxfs_device_{open,close} static Christoph Hellwig
2023-12-18 12:52   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 19/23] libxfs: return the opened fd from libxfs_device_open Christoph Hellwig
2023-12-18 12:53   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 20/23] libxfs: pass the device fd to discard_blocks Christoph Hellwig
2023-12-18 12:53   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 21/23] xfs_repair: remove various libxfs_device_to_fd calls Christoph Hellwig
2023-12-18 12:55   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 22/23] libxfs: stash away the device fd in struct xfs_buftarg Christoph Hellwig
2023-12-18 12:58   ` Carlos Maiolino
2023-12-11 16:37 ` [PATCH 23/23] libxfs: split out a libxfs_dev structure from struct libxfs_init Christoph Hellwig
2023-12-18 13:01   ` Carlos Maiolino
2023-12-12  1:52 ` improve libxfs device handling Darrick J. Wong

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=20231211163742.837427-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=cem@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.