public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Utkal Singh <singhutkal015@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, hsiangkao@linux.alibaba.com,
	Utkal Singh <singhutkal015@gmail.com>
Subject: [PATCH] fsck: add --workers option to configure worker threads
Date: Sun, 22 Mar 2026 06:47:06 +0000	[thread overview]
Message-ID: <20260322064706.27001-1-singhutkal015@gmail.com> (raw)

Add a --workers=# command-line option to fsck.erofs to allow users
to configure the number of worker threads used during verification.

Parse the value using strtoul() and validate it against UINT_MAX
before storing it in fsckcfg.nr_workers. Return -EINVAL for invalid
inputs (non-numeric characters or out-of-range values).

Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
---
 fsck/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fsck/main.c b/fsck/main.c
index 16cc627..37e21f4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -4,6 +4,7 @@
  * Author: Daeho Jeong <daehojeong@google.com>
  */
 #include <stdlib.h>
+#include <limits.h>
 #include <getopt.h>
 #include <time.h>
 #include <utime.h>
@@ -42,6 +43,7 @@ struct erofsfsck_cfg {
 	erofs_nid_t nid;
 	const char *inode_path;
 	bool nosbcrc;
+	unsigned int nr_workers;
 };
 static struct erofsfsck_cfg fsckcfg;
 
@@ -64,6 +66,7 @@ static struct option long_options[] = {
 	{"nid", required_argument, 0, 15},
 	{"path", required_argument, 0, 16},
 	{"no-sbcrc", no_argument, 0, 512},
+	{"workers", required_argument, 0, 17},
 	{0, 0, 0, 0},
 };
 
@@ -117,6 +120,7 @@ static void usage(int argc, char **argv)
 		" --nid=#                check or extract from the target inode of nid #\n"
 		" --path=X               check or extract from the target inode of path X\n"
 		" --no-sbcrc             bypass the superblock checksum verification\n"
+		" --workers=#            number of worker threads\n"
 		" --[no-]xattrs          whether to dump extended attributes (default off)\n"
 		"\n"
 		" -a, -A, -y             no-op, for compatibility with fsck of other filesystems\n"
@@ -257,6 +261,15 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv)
 		case 16:
 			fsckcfg.inode_path = optarg;
 			break;
+		case 17: {
+			char *endptr;
+			unsigned long v = strtoul(optarg, &endptr, 0);
+
+			if (*endptr || v > UINT_MAX)
+				return -EINVAL;
+			fsckcfg.nr_workers = v;
+			break;
+		}
 		case 512:
 			fsckcfg.nosbcrc = true;
 			break;
-- 
2.43.0



             reply	other threads:[~2026-03-22  6:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-22  6:47 Utkal Singh [this message]
2026-03-22  8:36 ` [PATCH] fsck: add --workers option to configure worker threads Nithurshen
2026-03-22  8:57   ` Nithurshen
2026-03-22  9:31     ` Utkal Singh
2026-03-22  9:48       ` Gao Xiang
2026-03-22 16:23         ` Utkal Singh

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=20260322064706.27001-1-singhutkal015@gmail.com \
    --to=singhutkal015@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@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