All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes
@ 2021-12-18  0:16 Darrick J. Wong
  2021-12-18  0:19 ` [PATCH 1/3] libxcmd: use emacs mode for command history editing Darrick J. Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Darrick J. Wong @ 2021-12-18  0:16 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

Hi Eric,

Here's a rollup of a few random fixes that <cough> might be <cough>
needed to produce a working 5.14.3 package for <cough> reasons.

--D

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] libxcmd: use emacs mode for command history editing
  2021-12-18  0:16 [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes Darrick J. Wong
@ 2021-12-18  0:19 ` Darrick J. Wong
  2021-12-18  0:20 ` [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values Darrick J. Wong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2021-12-18  0:19 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Prior to xfsprogs 5.7.0, we built xfsprogs with libreadline support by
default.  In its default configuration, that library interpreted various
keystrokes in a direct manner (e.g. backspace deletes the character to
the left of the cursor), which seems consistent with how emacs behaves.

However, libeditline's default keybindings are consistent with vim,
which means that suddenly users are presented with not the same line
editing interface that they had before.  Since libeditline is
configurable (put "bind -v" in editrc if you really want vim mode),
let's put things back the way they were.  At least as much as we can.

Fixes: bbe12eb9 ("xfsprogs: remove libreadline support")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 db/input.c      |    1 +
 libxcmd/input.c |    1 +
 2 files changed, 2 insertions(+)

diff --git a/db/input.c b/db/input.c
index 448e84b0..d8113599 100644
--- a/db/input.c
+++ b/db/input.c
@@ -227,6 +227,7 @@ fetchline(void)
 		el_set(el, EL_SIGNAL, 1);
 		el_set(el, EL_PROMPT, el_get_prompt);
 		el_set(el, EL_HIST, history, (const char *)hist);
+		el_set(el, EL_EDITOR, "emacs");
 	}
 
 	if (inputstacksize == 1) {
diff --git a/libxcmd/input.c b/libxcmd/input.c
index e3fa626a..fa80e5ab 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -45,6 +45,7 @@ fetchline(void)
 		el_set(el, EL_SIGNAL, 1);
 		el_set(el, EL_PROMPT, el_get_prompt);
 		el_set(el, EL_HIST, history, (const char *)hist);
+		el_set(el, EL_EDITOR, "emacs");
 	}
 	cmd = el_gets(el, &count);
 	if (!cmd)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values
  2021-12-18  0:16 [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes Darrick J. Wong
  2021-12-18  0:19 ` [PATCH 1/3] libxcmd: use emacs mode for command history editing Darrick J. Wong
@ 2021-12-18  0:20 ` Darrick J. Wong
  2021-12-24  7:04   ` Christoph Hellwig
  2021-12-18  0:20 ` [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels Darrick J. Wong
  2021-12-18  0:23 ` [PATCH v2 4/3] mkfs: document sample configuration file location Darrick J. Wong
  3 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-12-18  0:20 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Eric and I were trying to play with mkfs.configuration files, when I
spotted this (with the libini package from Ubuntu 20.04):

# cat << EOF > /tmp/r
[data]
su=2097152
sw=1
EOF
# mkfs.xfs -f -c options=/tmp/r /dev/sda
Parameters parsed from config file /tmp/r successfully
-d su option requires a value

It turns out that libini's parser uses stack variables(!) to store the
value of a key=value pair that it parses, and passes this stack array to
the parse_cfgopt function.  If the particular option calls getstr(),
then we save the value of that pointer (not its contents) to the
cli_params.  Being a stack array, the contents will be overwritten by
other function calls, which means that our value of '2097152' has been
destroyed by the time we actually call getnum when we're validating the
new fs config.

We never noticed this until now because the only other caller was
getsubopt on the argv array, which gets chopped up but left intact in
memory.  The solution is to make a private copy of those strings if we
ever save them for later.  For now we'll be lazy and let the memory
leak, since mkfs is not a long-running process.

Fixes: 33c62516 ("mkfs: add initial ini format config file parsing support")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 mkfs/xfs_mkfs.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 3a41e17f..fcad6b55 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1438,12 +1438,21 @@ getstr(
 	struct opt_params	*opts,
 	int			index)
 {
+	char			*ret;
+
 	check_opt(opts, index, true);
 
 	/* empty strings for string options are not valid */
 	if (!str || *str == '\0')
 		reqval(opts->name, opts->subopts, index);
-	return (char *)str;
+
+	ret = strdup(str);
+	if (!ret) {
+		fprintf(stderr, _("Out of memory while saving suboptions.\n"));
+		exit(1);
+	}
+
+	return ret;
 }
 
 static int

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels
  2021-12-18  0:16 [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes Darrick J. Wong
  2021-12-18  0:19 ` [PATCH 1/3] libxcmd: use emacs mode for command history editing Darrick J. Wong
  2021-12-18  0:20 ` [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values Darrick J. Wong
@ 2021-12-18  0:20 ` Darrick J. Wong
  2021-12-24  7:04   ` Christoph Hellwig
  2021-12-18  0:23 ` [PATCH v2 4/3] mkfs: document sample configuration file location Darrick J. Wong
  3 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-12-18  0:20 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Add some sample mkfs configuration files that capture the mkfs feature
defaults at the time of the release of the last four upstream LTS
kernels.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
v3: make it easier to substitute the mkfs config dir with a single
variable
v2: add missing config file for 5.4 kernel
---
 include/builddefs.in |    2 ++
 mkfs/Makefile        |   10 +++++++++-
 mkfs/lts_4.19.conf   |   13 +++++++++++++
 mkfs/lts_5.10.conf   |   13 +++++++++++++
 mkfs/lts_5.15.conf   |   13 +++++++++++++
 mkfs/lts_5.4.conf    |   13 +++++++++++++
 mkfs/xfs_mkfs.c      |    4 ++++
 7 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 mkfs/lts_4.19.conf
 create mode 100644 mkfs/lts_5.10.conf
 create mode 100644 mkfs/lts_5.15.conf
 create mode 100644 mkfs/lts_5.4.conf

diff --git a/include/builddefs.in b/include/builddefs.in
index f10d1796..0d3a4d17 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -66,6 +66,8 @@ DK_INC_DIR	= @includedir@/disk
 PKG_MAN_DIR	= @mandir@
 PKG_DOC_DIR	= @datadir@/doc/@pkg_name@
 PKG_LOCALE_DIR	= @datadir@/locale
+PKG_DATA_DIR	= @datadir@/@pkg_name@
+MKFS_CFG_DIR	= @datadir@/@pkg_name@/mkfs
 
 CC		= @cc@
 BUILD_CC	= @BUILD_CC@
diff --git a/mkfs/Makefile b/mkfs/Makefile
index 811ba9db..009f6742 100644
--- a/mkfs/Makefile
+++ b/mkfs/Makefile
@@ -9,19 +9,27 @@ LTCOMMAND = mkfs.xfs
 
 HFILES =
 CFILES = proto.c xfs_mkfs.c
+CFGFILES = \
+	lts_4.19.conf \
+	lts_5.4.conf \
+	lts_5.10.conf \
+	lts_5.15.conf
 
 LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) \
 	$(LIBUUID) $(LIBINIH) $(LIBURCU)
 LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG)
 LLDFLAGS = -static-libtool-libs
 
-default: depend $(LTCOMMAND)
+default: depend $(LTCOMMAND) $(CFGFILES)
 
 include $(BUILDRULES)
 
 install: default
 	$(INSTALL) -m 755 -d $(PKG_ROOT_SBIN_DIR)
 	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_ROOT_SBIN_DIR)
+	$(INSTALL) -m 755 -d $(MKFS_CFG_DIR)
+	$(INSTALL) -m 644 $(CFGFILES) $(MKFS_CFG_DIR)
+
 install-dev:
 
 -include .dep
diff --git a/mkfs/lts_4.19.conf b/mkfs/lts_4.19.conf
new file mode 100644
index 00000000..d21fcb7e
--- /dev/null
+++ b/mkfs/lts_4.19.conf
@@ -0,0 +1,13 @@
+# V5 features that were the mkfs defaults when the upstream Linux 4.19 LTS
+# kernel was released at the end of 2018.
+
+[metadata]
+bigtime=0
+crc=1
+finobt=1
+inobtcount=0
+reflink=0
+rmapbt=0
+
+[inode]
+sparse=1
diff --git a/mkfs/lts_5.10.conf b/mkfs/lts_5.10.conf
new file mode 100644
index 00000000..ac00960e
--- /dev/null
+++ b/mkfs/lts_5.10.conf
@@ -0,0 +1,13 @@
+# V5 features that were the mkfs defaults when the upstream Linux 5.10 LTS
+# kernel was released at the end of 2020.
+
+[metadata]
+bigtime=0
+crc=1
+finobt=1
+inobtcount=0
+reflink=1
+rmapbt=0
+
+[inode]
+sparse=1
diff --git a/mkfs/lts_5.15.conf b/mkfs/lts_5.15.conf
new file mode 100644
index 00000000..32082958
--- /dev/null
+++ b/mkfs/lts_5.15.conf
@@ -0,0 +1,13 @@
+# V5 features that were the mkfs defaults when the upstream Linux 5.15 LTS
+# kernel was released at the end of 2021.
+
+[metadata]
+bigtime=1
+crc=1
+finobt=1
+inobtcount=1
+reflink=1
+rmapbt=0
+
+[inode]
+sparse=1
diff --git a/mkfs/lts_5.4.conf b/mkfs/lts_5.4.conf
new file mode 100644
index 00000000..dd60b9f1
--- /dev/null
+++ b/mkfs/lts_5.4.conf
@@ -0,0 +1,13 @@
+# V5 features that were the mkfs defaults when the upstream Linux 5.4 LTS
+# kernel was released at the end of 2019.
+
+[metadata]
+bigtime=0
+crc=1
+finobt=1
+inobtcount=0
+reflink=1
+rmapbt=0
+
+[inode]
+sparse=1
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index fcad6b55..af536a8a 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3875,6 +3875,10 @@ main(
 			.nodalign = false,
 			.nortalign = false,
 			.bigtime = false,
+			/*
+			 * When we decide to enable a new feature by default,
+			 * please remember to update the mkfs conf files.
+			 */
 		},
 	};
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/3] mkfs: document sample configuration file location
  2021-12-18  0:16 [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes Darrick J. Wong
                   ` (2 preceding siblings ...)
  2021-12-18  0:20 ` [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels Darrick J. Wong
@ 2021-12-18  0:23 ` Darrick J. Wong
  2021-12-24  7:05   ` Christoph Hellwig
  3 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-12-18  0:23 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Update the documentation to note where one can find sample configuration
files.  While we're at it, add -c to the topmost list of mkfs.xfs
options.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
v2: use the mkfs config file directory from the build system
---
 man/man8/Makefile      |    7 +++++++
 man/man8/mkfs.xfs.8.in |    4 ++++
 2 files changed, 11 insertions(+)
 rename man/man8/{mkfs.xfs.8 => mkfs.xfs.8.in} (99%)

diff --git a/man/man8/Makefile b/man/man8/Makefile
index e6a55729..272e45ae 100644
--- a/man/man8/Makefile
+++ b/man/man8/Makefile
@@ -12,8 +12,10 @@ ifneq ("$(ENABLE_SCRUB)","yes")
 else
   MAN_PAGES = $(shell echo *.$(MAN_SECTION))
 endif
+MAN_PAGES	+= mkfs.xfs.8
 MAN_DEST	= $(PKG_MAN_DIR)/man$(MAN_SECTION)
 LSRCFILES	= $(MAN_PAGES)
+DIRT		= mkfs.xfs.8
 
 default : $(MAN_PAGES)
 
@@ -22,4 +24,9 @@ include $(BUILDRULES)
 install : default
 	$(INSTALL) -m 755 -d $(MAN_DEST)
 	$(INSTALL_MAN)
+
+mkfs.xfs.8: mkfs.xfs.8.in
+	@echo "    [SED]    $@"
+	$(Q)$(SED) -e 's|@mkfs_cfg_dir@|$(MKFS_CFG_DIR)|g' < $^ > $@
+
 install-dev :
diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8.in
similarity index 99%
rename from man/man8/mkfs.xfs.8
rename to man/man8/mkfs.xfs.8.in
index 880e949b..a3526753 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8.in
@@ -7,6 +7,9 @@ mkfs.xfs \- construct an XFS filesystem
 .B \-b
 .I block_size_options
 ] [
+.B \-c
+.I config_file_options
+] [
 .B \-m
 .I global_metadata_options
 ] [
@@ -159,6 +162,7 @@ The configuration options will be sourced from the file specified by the
 option string.
 This option can be use either an absolute or relative path to the configuration
 file to be read.
+Sample configuration files can be found in @mkfs_cfg_dir@.
 .RE
 .PP
 .PD 0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values
  2021-12-18  0:20 ` [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values Darrick J. Wong
@ 2021-12-24  7:04   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-12-24  7:04 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, xfs

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels
  2021-12-18  0:20 ` [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels Darrick J. Wong
@ 2021-12-24  7:04   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-12-24  7:04 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, xfs

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/3] mkfs: document sample configuration file location
  2021-12-18  0:23 ` [PATCH v2 4/3] mkfs: document sample configuration file location Darrick J. Wong
@ 2021-12-24  7:05   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-12-24  7:05 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, xfs

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-24  7:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18  0:16 [PATCHSET 5.14.3 0/3] xfsprogs: packaging fixes Darrick J. Wong
2021-12-18  0:19 ` [PATCH 1/3] libxcmd: use emacs mode for command history editing Darrick J. Wong
2021-12-18  0:20 ` [PATCH 2/3] mkfs: prevent corruption of passed-in suboption string values Darrick J. Wong
2021-12-24  7:04   ` Christoph Hellwig
2021-12-18  0:20 ` [PATCH v3 3/3] mkfs: add configuration files for the last few LTS kernels Darrick J. Wong
2021-12-24  7:04   ` Christoph Hellwig
2021-12-18  0:23 ` [PATCH v2 4/3] mkfs: document sample configuration file location Darrick J. Wong
2021-12-24  7:05   ` Christoph Hellwig

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.