From: Saranya Muruganandam <saranyamohan@google.com>
To: linux-ext4@vger.kernel.org, tytso@mit.edu
Cc: adilger.kernel@dilger.ca, Andreas Dilger <adilger@whamcloud.com>,
Saranya Muruganandam <saranyamohan@google.com>
Subject: [RFC PATCH v3 58/61] e2fsck: misc cleanups for pfsck
Date: Wed, 18 Nov 2020 07:39:44 -0800 [thread overview]
Message-ID: <20201118153947.3394530-59-saranyamohan@google.com> (raw)
In-Reply-To: <20201118153947.3394530-1-saranyamohan@google.com>
From: Andreas Dilger <adilger@whamcloud.com>
Add -m option description to e2fsck.8 man page.
Rename e2fsck_struct fs_num_threads to pfs_num_threads to avoid
confusion with the ext2_filsys fs_num_threads field, and move
thread_info to be together with the other CONFIG_PFSCK fields.
Move ext2_filsys fs_num_threads to fit into the __u16 "pad" field
to avoid consuming one of the few remaining __u32 reserved fields.
Fix a few print format warnings.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Saranya Muruganandam <saranyamohan@google.com>
---
e2fsck/e2fsck.8.in | 8 +++++++-
e2fsck/e2fsck.h | 13 +++++--------
e2fsck/pass1.c | 29 +++++++++++++++--------------
e2fsck/unix.c | 4 ++--
lib/ext2fs/ext2fs.h | 5 ++---
5 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/e2fsck/e2fsck.8.in b/e2fsck/e2fsck.8.in
index 4e3890b2..404d07fe 100644
--- a/e2fsck/e2fsck.8.in
+++ b/e2fsck/e2fsck.8.in
@@ -8,7 +8,7 @@ e2fsck \- check a Linux ext2/ext3/ext4 file system
.SH SYNOPSIS
.B e2fsck
[
-.B \-pacnyrdfkvtDFV
+.B \-pacnyrdfkmvtDFV
]
[
.B \-b
@@ -329,6 +329,12 @@ Set the bad blocks list to be the list of blocks specified by
option, except the bad blocks list is cleared before the blocks listed
in the file are added to the bad blocks list.)
.TP
+.B \-m " threads"
+Run e2fsck with up to the specified number of
+.IR threads .
+The actual number of threads may be lower, if the filesystem does not
+have enough block groups to effectively parallelize the workload.
+.TP
.B \-n
Open the filesystem read-only, and assume an answer of `no' to all
questions. Allows
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 1469c3e1..362e128c 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -243,8 +243,8 @@ struct e2fsck_thread {
dgrp_t et_group_next;
/* Scanned inode number */
ext2_ino_t et_inode_number;
- char et_log_buf[2048];
char et_log_length;
+ char et_log_buf[2048];
};
#endif
@@ -333,11 +333,6 @@ struct e2fsck_struct {
ext2_ino_t stashed_ino;
struct ext2_inode *stashed_inode;
- /* if @global_ctx is null, this field is unused */
-#ifdef CONFIG_PFSCK
- struct e2fsck_thread thread_info;
-#endif
-
/*
* Location of the lost and found directory
*/
@@ -450,7 +445,9 @@ struct e2fsck_struct {
/* Undo file */
char *undo_file;
#ifdef CONFIG_PFSCK
- __u32 fs_num_threads;
+ /* if @global_ctx is null, this field is unused */
+ struct e2fsck_thread thread_info;
+ __u32 pfs_num_threads;
__u32 mmp_update_thread;
int fs_need_locking;
/* serialize fix operation for multiple threads */
@@ -689,7 +686,7 @@ int check_backup_super_block(e2fsck_t ctx);
void check_resize_inode(e2fsck_t ctx);
/* util.c */
-#define E2FSCK_MAX_THREADS (65536)
+#define E2FSCK_MAX_THREADS (65535)
extern void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned long size,
const char *description);
extern int ask(e2fsck_t ctx, const char * string, int def);
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 7768119b..8d4e2675 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1260,7 +1260,7 @@ static void e2fsck_pass1_set_thread_num(e2fsck_t ctx)
{
unsigned flexbg_size = 1;
ext2_filsys fs = ctx->fs;
- int num_threads = ctx->fs_num_threads;
+ int num_threads = ctx->pfs_num_threads;
int max_threads;
if (num_threads < 1) {
@@ -1280,6 +1280,8 @@ static void e2fsck_pass1_set_thread_num(e2fsck_t ctx)
max_threads = fs->group_desc_count / flexbg_size;
if (max_threads == 0)
max_threads = 1;
+ if (max_threads > E2FSCK_MAX_THREADS)
+ max_threads = E2FSCK_MAX_THREADS;
if (num_threads > max_threads) {
fprintf(stderr, "Use max possible thread num: %d instead\n",
@@ -1287,7 +1289,7 @@ static void e2fsck_pass1_set_thread_num(e2fsck_t ctx)
num_threads = max_threads;
}
out:
- ctx->fs_num_threads = num_threads;
+ ctx->pfs_num_threads = num_threads;
ctx->fs->fs_num_threads = num_threads;
}
#endif
@@ -1315,7 +1317,7 @@ static errcode_t e2fsck_pass1_prepare(e2fsck_t ctx)
#ifdef CONFIG_PFSCK
/* don't use more than 1/10 of memory for threads checking */
- readahead_kb = get_memory_size() / (10 * ctx->fs_num_threads);
+ readahead_kb = get_memory_size() / (10 * ctx->pfs_num_threads);
/* maybe better disable RA if this is too small? */
if (ctx->readahead_kb > readahead_kb)
ctx->readahead_kb = readahead_kb;
@@ -1373,7 +1375,7 @@ static errcode_t e2fsck_pass1_prepare(e2fsck_t ctx)
#ifdef CONFIG_PFSCK
pthread_rwlock_init(&ctx->fs_fix_rwlock, NULL);
pthread_rwlock_init(&ctx->fs_block_map_rwlock, NULL);
- if (ctx->fs_num_threads > 1)
+ if (ctx->pfs_num_threads > 1)
ctx->fs_need_locking = 1;
#endif
@@ -1633,7 +1635,7 @@ void e2fsck_pass1_run(e2fsck_t ctx)
if (ctx->global_ctx) {
if (ctx->options & E2F_OPT_DEBUG &&
ctx->options & E2F_OPT_MULTITHREAD)
- fprintf(stderr, "thread %d jumping to group %d\n",
+ fprintf(stderr, "thread %d jumping to group %u\n",
ctx->thread_info.et_thread_index,
ctx->thread_info.et_group_start);
pctx.errcode = ext2fs_inode_scan_goto_blockgroup(scan,
@@ -3129,11 +3131,11 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx)
static int e2fsck_pass1_threads_join(struct e2fsck_thread_info *infos,
e2fsck_t global_ctx)
{
- errcode_t rc;
- errcode_t ret = 0;
- int i;
- struct e2fsck_thread_info *pinfo;
- int num_threads = global_ctx->fs_num_threads;
+ errcode_t rc;
+ errcode_t ret = 0;
+ struct e2fsck_thread_info *pinfo;
+ int num_threads = global_ctx->pfs_num_threads;
+ int i;
/* merge invalid bitmaps will recalculate it */
global_ctx->invalid_bitmaps = 0;
@@ -3199,7 +3201,7 @@ static void *e2fsck_pass1_thread(void *arg)
out:
if (thread_ctx->options & E2F_OPT_MULTITHREAD)
log_out(thread_ctx,
- _("Scanned group range [%lu, %lu), inodes %lu\n"),
+ _("Scanned group range [%u, %u), inodes %u\n"),
thread_ctx->thread_info.et_group_start,
thread_ctx->thread_info.et_group_end,
thread_ctx->thread_info.et_inode_number);
@@ -3225,7 +3227,7 @@ static int e2fsck_pass1_threads_start(struct e2fsck_thread_info **pinfo,
int i;
e2fsck_t thread_ctx;
dgrp_t average_group;
- int num_threads = global_ctx->fs_num_threads;
+ int num_threads = global_ctx->pfs_num_threads;
#ifdef DEBUG_THREADS
struct e2fsck_thread_debug thread_debug =
{PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0};
@@ -3329,8 +3331,7 @@ void e2fsck_pass1(e2fsck_t ctx)
if (retval)
return;
#ifdef CONFIG_PFSCK
- if (ctx->fs_num_threads > 1 ||
- ctx->options & E2F_OPT_MULTITHREAD) {
+ if (ctx->pfs_num_threads > 1 || ctx->options & E2F_OPT_MULTITHREAD) {
need_single = 0;
e2fsck_pass1_multithread(ctx);
}
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index cd31bcd5..bebc19ed 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -908,12 +908,12 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
_("Invalid multiple thread num.\n"));
if (thread_num > E2FSCK_MAX_THREADS) {
fprintf(stderr,
- _("threads %lu too large (max %lu)\n"),
+ _("threads %lu too large (max %u)\n"),
thread_num, E2FSCK_MAX_THREADS);
fatal_error(ctx, 0);
}
ctx->options |= E2F_OPT_MULTITHREAD;
- ctx->fs_num_threads = thread_num;
+ ctx->pfs_num_threads = thread_num;
break;
#endif
case 'n':
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 616c9412..f74303f4 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -254,12 +254,11 @@ struct struct_ext2_filsys {
time_t now;
int cluster_ratio_bits;
__u16 default_bitmap_type;
- __u16 pad;
- __u32 fs_num_threads;
+ __u16 fs_num_threads;
/*
* Reserved for future expansion
*/
- __u32 reserved[4];
+ __u32 reserved[5];
/*
* Reserved for the use of the calling application.
--
2.29.2.299.gdc1121823c-goog
next prev parent reply other threads:[~2020-11-18 15:42 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 15:38 [RFC PATCH v3 00/61] Introduce parallel fsck to e2fsck pass1 Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 01/61] e2fsck: add -m option for multithread Saranya Muruganandam
2020-11-23 19:53 ` harshad shirwadkar
2020-11-23 21:28 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 02/61] e2fsck: copy context when using multi-thread fsck Saranya Muruganandam
2020-11-23 19:55 ` harshad shirwadkar
2020-11-23 21:38 ` Theodore Y. Ts'o
2020-12-17 23:56 ` Darrick J. Wong
2020-12-18 1:13 ` Wang Shilong
2020-12-18 1:27 ` Darrick J. Wong
2020-11-18 15:38 ` [RFC PATCH v3 03/61] e2fsck: copy fs " Saranya Muruganandam
2020-11-23 22:12 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 04/61] e2fsck: clear icache " Saranya Muruganandam
2020-11-23 22:27 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 05/61] e2fsck: add assert when copying context Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 06/61] e2fsck: copy bitmaps " Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 07/61] e2fsck: copy badblocks when copying fs Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 08/61] e2fsck: open io-channel " Saranya Muruganandam
2020-11-23 22:38 ` Theodore Y. Ts'o
2020-11-24 14:17 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 09/61] e2fsck: create logs for mult-threads Saranya Muruganandam
2020-11-23 23:05 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 10/61] e2fsck: optionally configure one pfsck thread Saranya Muruganandam
2020-11-23 23:16 ` Theodore Y. Ts'o
2020-11-18 15:38 ` [RFC PATCH v3 11/61] e2fsck: add start/end group for thread Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 12/61] e2fsck: split groups to different threads Saranya Muruganandam
2020-11-18 15:38 ` [RFC PATCH v3 13/61] e2fsck: print thread log properly Saranya Muruganandam
2020-11-23 23:40 ` Theodore Y. Ts'o
2020-11-18 15:39 ` [RFC PATCH v3 14/61] e2fsck: merge bitmaps after thread completes Saranya Muruganandam
2020-11-24 2:00 ` Theodore Y. Ts'o
2020-11-18 15:39 ` [RFC PATCH v3 15/61] e2fsck: do not change global variables Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 16/61] e2fsck: optimize the inserting of dir_info_db Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 17/61] e2fsck: merge dir_info after thread finishes Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 18/61] e2fsck: rbtree bitmap for dir Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 19/61] e2fsck: merge badblocks after thread finishes Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 20/61] e2fsck: merge icounts " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 21/61] e2fsck: merge dblist " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 22/61] e2fsck: add debug codes for multiple threads Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 23/61] e2fsck: merge counts after threads finish Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 24/61] e2fsck: merge fs flags when " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 25/61] e2fsck: merge dx_dir_info after " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 26/61] e2fsck: merge dirs_to_hash when " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 27/61] e2fsck: merge context flags properly Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 28/61] e2fsck: merge quota context after threads finish Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 29/61] e2fsck: serialize fix operations Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 30/61] e2fsck: move some fixes out of parallel pthreads Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 31/61] e2fsck: split and merge invalid bitmaps Saranya Muruganandam
2020-12-18 0:05 ` Darrick J. Wong
2020-12-18 1:19 ` Wang Shilong
2020-11-18 15:39 ` [RFC PATCH v3 32/61] e2fsck: merge EA blocks properly Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 33/61] e2fsck: kickoff mutex lock for block found map Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 34/61] e2fsck: allow admin specify number of threads Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 35/61] e2fsck: adjust " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 36/61] e2fsck: fix readahead for pfsck of pass1 Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 37/61] e2fsck: merge options after threads finish Saranya Muruganandam
2020-12-17 23:30 ` Darrick J. Wong
2020-11-18 15:39 ` [RFC PATCH v3 38/61] e2fsck: reset lost_and_found " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 39/61] e2fsck: merge extent depth count " Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 40/61] e2fsck: simplify e2fsck context merging codes Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 41/61] e2fsck: set E2F_FLAG_ALLOC_OK after threads Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 42/61] e2fsck: wait fix thread finish before checking Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 43/61] e2fsck: cleanup e2fsck_pass1_thread_join() Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 44/61] e2fsck: avoid too much memory allocation for pfsck Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 45/61] e2fsck: make default smallest RA size to 1M Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 46/61] ext2fs: parallel bitmap loading Saranya Muruganandam
2020-11-24 2:44 ` Theodore Y. Ts'o
2020-11-18 15:39 ` [RFC PATCH v3 47/61] e2fsck: update mmp block in one thread Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 48/61] e2fsck: reset @inodes_to_rebuild if restart Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 49/61] e2fsck: fix build for make rpm Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 50/61] e2fsck: move ext2fs_get_avg_group to rw_bitmaps.c Saranya Muruganandam
2020-11-24 2:12 ` Theodore Y. Ts'o
2020-11-18 15:39 ` [RFC PATCH v3 51/61] configure: enable pfsck by default Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 53/61] e2fsck: fix f_multithread_ok test Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 54/61] e2fsck: fix race in ext2fs_read_bitmaps() Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 55/61] e2fsck: fix readahead for pass1 without pfsck Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 56/61] e2fsck: fix memory leaks with pfsck enabled Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 57/61] ext2fs: fix to set tail flags " Saranya Muruganandam
2020-11-18 15:39 ` Saranya Muruganandam [this message]
2020-11-18 15:39 ` [RFC PATCH v3 59/61] e2fsck: update mmp block race Saranya Muruganandam
2020-11-18 15:39 ` [RFC PATCH v3 60/61] e2fsck: propagate number of threads Saranya Muruganandam
2020-11-24 3:56 ` Theodore Y. Ts'o
2020-11-18 15:39 ` [RFC PATCH v3 61/61] e2fsck: Annotating fields in e2fsck_struct Saranya Muruganandam
2020-11-19 15:58 ` [RFC PATCH v3 00/61] Introduce parallel fsck to e2fsck pass1 Theodore Y. Ts'o
2020-11-23 21:25 ` Theodore Y. Ts'o
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=20201118153947.3394530-59-saranyamohan@google.com \
--to=saranyamohan@google.com \
--cc=adilger.kernel@dilger.ca \
--cc=adilger@whamcloud.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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.