Skip to contentSkip to conversation

xfs_growfs: support shrinking unused space

PATCH In review Gao Xiang 2 participants 2 messages Mar 26, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Gao Xiang

author
#1 lore raw

PATCH v2 1/1 xfs_growfs: support shrinking unused space

From: Gao Xiang <[email protected]>

This allows shrinking operation can pass into kernel. Currently, only shrinking unused space in the tail AG functionality works.

---
v1: https://lore.kernel.org/r/[email protected]
change since v1:
- update manpage description (Darrick);

 growfs/xfs_growfs.c   | 9 ++++-----
 man/man8/xfs_growfs.8 | 8 +++++---
 2 files changed, 9 insertions(+), 8 deletions(-)
growfs/xfs_growfs.c +4 -5
index a68b515de40d..d45ba703cc6f 100644
@@ -246,12 +246,11 @@ main(int argc, char **argv)
 			error = 1;
 		}
 
-		if (!error && dsize < geo.datablocks) {
-			fprintf(stderr, _("data size %lld too small,"
-				" old size is %lld\n"),
+		if (!error && dsize < geo.datablocks)
+			fprintf(stderr,
+_("[EXPERIMENTAL] try to shrink unused space %lld, old size is %lld\n"),
 				(long long)dsize, (long long)geo.datablocks);
-			error = 1;
-		} else if (!error &&
+		if (!error &&
 			   dsize == geo.datablocks && maxpct == geo.imaxpct) {
 			if (dflag)
 				fprintf(stderr, _(
man/man8/xfs_growfs.8 +5 -3
index 60a88189dd88..a01269270580 100644
@@ -60,14 +60,16 @@ becomes available for additional file storage.
 .SH OPTIONS
 .TP
 .BI "\-d | \-D " size
-Specifies that the data section of the filesystem should be grown. If the
+Specifies that the data section of the filesystem should be resized. If the
 .B \-D
 .I size
-option is given, the data section is grown to that
+option is given, the data section is changed to that
 .IR size ,
 otherwise the data section is grown to the largest size possible with the
 .B \-d
-option. The size is expressed in filesystem blocks.
+option. The size is expressed in filesystem blocks. A filesystem with only
+1 AG cannot be shrunk further, and a filesystem cannot be shrunk to the point
+where it would only have 1 AG.
 .TP
 .B \-e
 Allows the real-time extent size to be specified. In
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#2 lore raw
Quoted 6 lines · Gao Xiang

From: Gao Xiang <[email protected]>

This allows shrinking operation can pass into kernel. Currently, only shrinking unused space in the tail AG functionality works.

Looks like a reasonable start,

--D

Quoted 57 lines

---
v1: https://lore.kernel.org/r/[email protected]
change since v1:
- update manpage description (Darrick);

 growfs/xfs_growfs.c   | 9 ++++-----
 man/man8/xfs_growfs.8 | 8 +++++---
 2 files changed, 9 insertions(+), 8 deletions(-)
growfs/xfs_growfs.c +4 -5
index a68b515de40d..d45ba703cc6f 100644
@@ -246,12 +246,11 @@ main(int argc, char **argv)
 			error = 1;
 		}
 
-		if (!error && dsize < geo.datablocks) {
-			fprintf(stderr, _("data size %lld too small,"
-				" old size is %lld\n"),
+		if (!error && dsize < geo.datablocks)
+			fprintf(stderr,
+_("[EXPERIMENTAL] try to shrink unused space %lld, old size is %lld\n"),
 				(long long)dsize, (long long)geo.datablocks);
-			error = 1;
-		} else if (!error &&
+		if (!error &&
 			   dsize == geo.datablocks && maxpct == geo.imaxpct) {
 			if (dflag)
 				fprintf(stderr, _(
man/man8/xfs_growfs.8 +5 -3
index 60a88189dd88..a01269270580 100644
@@ -60,14 +60,16 @@ becomes available for additional file storage.
 .SH OPTIONS
 .TP
 .BI "\-d | \-D " size
-Specifies that the data section of the filesystem should be grown. If the
+Specifies that the data section of the filesystem should be resized. If the
 .B \-D
 .I size
-option is given, the data section is grown to that
+option is given, the data section is changed to that
 .IR size ,
 otherwise the data section is grown to the largest size possible with the
 .B \-d
-option. The size is expressed in filesystem blocks.
+option. The size is expressed in filesystem blocks. A filesystem with only
+1 AG cannot be shrunk further, and a filesystem cannot be shrunk to the point
+where it would only have 1 AG.
 .TP
 .B \-e
 Allows the real-time extent size to be specified. In
Signature · 1 line
2.20.1