* [PATCH v2] gfs2_grow: Optionally allow not issuing discard requests
@ 2025-02-19 15:36 Mark Syms
2025-02-19 16:15 ` Andrew Price
0 siblings, 1 reply; 2+ messages in thread
From: Mark Syms @ 2025-02-19 15:36 UTC (permalink / raw)
To: gfs2; +Cc: Mark Syms
mkfs.gfs2 supports a -K option which disables issuing discard requests
for unused blocks on the LUN. gfs2_grow does not have an equivalent
option so even if the filesystem was originally created with the -K
option a subsequent grow operation will incur the, potentially high,
cost of performing the discard.
Signed-off-by: Mark Syms <mark.syms@cloud.com>
---
v2:
* Fix indentation of break statement
---
gfs2/mkfs/main_grow.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index e378a668..2d74c3fa 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -31,6 +31,7 @@
static uint64_t override_device_size = 0;
static int test = 0;
static uint64_t fssize = 0, fsgrowth;
+static int skip_discard = 0;
int print_level = MSG_NOTICE;
extern int create_new_inode(struct lgfs2_sbd *sdp);
@@ -72,6 +73,7 @@ static void usage(void)
"-T", NULL, _("Do everything except update file system"),
"-V", NULL, _("Display version information"),
"-v", NULL, _("Increase verbosity"),
+ "-K", NULL, _("Don't try to discard unused blocks"),
NULL, NULL, NULL /* Must be kept at the end */
};
@@ -92,7 +94,7 @@ static void decode_arguments(int argc, char *argv[], struct lgfs2_sbd *sdp)
{
int opt;
- while ((opt = getopt(argc, argv, "VD:hqTv?")) != EOF) {
+ while ((opt = getopt(argc, argv, "VD:hqTv?K")) != EOF) {
switch (opt) {
case 'D': /* This option is for testing only */
override_device_size = atoi(optarg);
@@ -116,6 +118,9 @@ static void decode_arguments(int argc, char *argv[], struct lgfs2_sbd *sdp)
case 'v':
increase_verbosity();
break;
+ case 'K':
+ skip_discard = 1;
+ break;
case ':':
case '?':
/* Unknown flag */
@@ -207,7 +212,9 @@ static unsigned initialize_new_portion(struct lgfs2_sbd *sdp, lgfs2_rgrps_t rgs)
unsigned rgcount = 0;
uint64_t rgaddr = fssize;
- discard_blocks(sdp->device_fd, rgaddr * sdp->sd_bsize, fsgrowth * sdp->sd_bsize);
+ if (skip_discard == 0)
+ discard_blocks(sdp->device_fd, rgaddr * sdp->sd_bsize, fsgrowth * sdp->sd_bsize);
+
/* Build the remaining resource groups */
while (1) {
int err = 0;
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] gfs2_grow: Optionally allow not issuing discard requests
2025-02-19 15:36 [PATCH v2] gfs2_grow: Optionally allow not issuing discard requests Mark Syms
@ 2025-02-19 16:15 ` Andrew Price
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Price @ 2025-02-19 16:15 UTC (permalink / raw)
To: Mark Syms; +Cc: gfs2
On 19/02/2025 15:36, Mark Syms wrote:
> mkfs.gfs2 supports a -K option which disables issuing discard requests
> for unused blocks on the LUN. gfs2_grow does not have an equivalent
> option so even if the filesystem was originally created with the -K
> option a subsequent grow operation will incur the, potentially high,
> cost of performing the discard.
Looks good to me. Could you add an entry for the new -K option to the
man page (gfs2/man/gfs2_grow.8)? A follow-up patch would be fine.
Thanks,
Andy
>
> Signed-off-by: Mark Syms <mark.syms@cloud.com>
>
> ---
> v2:
> * Fix indentation of break statement
> ---
> gfs2/mkfs/main_grow.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
> index e378a668..2d74c3fa 100644
> --- a/gfs2/mkfs/main_grow.c
> +++ b/gfs2/mkfs/main_grow.c
> @@ -31,6 +31,7 @@
> static uint64_t override_device_size = 0;
> static int test = 0;
> static uint64_t fssize = 0, fsgrowth;
> +static int skip_discard = 0;
> int print_level = MSG_NOTICE;
>
> extern int create_new_inode(struct lgfs2_sbd *sdp);
> @@ -72,6 +73,7 @@ static void usage(void)
> "-T", NULL, _("Do everything except update file system"),
> "-V", NULL, _("Display version information"),
> "-v", NULL, _("Increase verbosity"),
> + "-K", NULL, _("Don't try to discard unused blocks"),
> NULL, NULL, NULL /* Must be kept at the end */
> };
>
> @@ -92,7 +94,7 @@ static void decode_arguments(int argc, char *argv[], struct lgfs2_sbd *sdp)
> {
> int opt;
>
> - while ((opt = getopt(argc, argv, "VD:hqTv?")) != EOF) {
> + while ((opt = getopt(argc, argv, "VD:hqTv?K")) != EOF) {
> switch (opt) {
> case 'D': /* This option is for testing only */
> override_device_size = atoi(optarg);
> @@ -116,6 +118,9 @@ static void decode_arguments(int argc, char *argv[], struct lgfs2_sbd *sdp)
> case 'v':
> increase_verbosity();
> break;
> + case 'K':
> + skip_discard = 1;
> + break;
> case ':':
> case '?':
> /* Unknown flag */
> @@ -207,7 +212,9 @@ static unsigned initialize_new_portion(struct lgfs2_sbd *sdp, lgfs2_rgrps_t rgs)
> unsigned rgcount = 0;
> uint64_t rgaddr = fssize;
>
> - discard_blocks(sdp->device_fd, rgaddr * sdp->sd_bsize, fsgrowth * sdp->sd_bsize);
> + if (skip_discard == 0)
> + discard_blocks(sdp->device_fd, rgaddr * sdp->sd_bsize, fsgrowth * sdp->sd_bsize);
> +
> /* Build the remaining resource groups */
> while (1) {
> int err = 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-19 16:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 15:36 [PATCH v2] gfs2_grow: Optionally allow not issuing discard requests Mark Syms
2025-02-19 16:15 ` Andrew Price
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox