[Ocfs2-tools-devel] [PATCH 05/11] fsck.ocfs2: Add progress in Passes 1 and 2
Sunil Mushran
sunil.mushran at oracle.com
Thu Sep 22 19:04:33 PDT 2011
Both inode scanning (pass 1) and directory scanning (pass 2) can take
a considerable amount of time. This patch adds progress to the two passes.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
fsck.ocfs2/Makefile | 6 ++++--
fsck.ocfs2/dirblocks.c | 2 ++
fsck.ocfs2/fsck.c | 9 ++++++++-
fsck.ocfs2/fsck.ocfs2.8.in | 4 ++++
fsck.ocfs2/include/fsck.h | 2 ++
fsck.ocfs2/pass1.c | 18 ++++++++++++++++++
fsck.ocfs2/pass2.c | 13 +++++++++++++
7 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/fsck.ocfs2/Makefile b/fsck.ocfs2/Makefile
index d5f5d7e..f806ba6 100644
--- a/fsck.ocfs2/Makefile
+++ b/fsck.ocfs2/Makefile
@@ -14,6 +14,8 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS)
LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a
LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a
+LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal
+LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a
ifndef OCFS2_DYNAMIC_FSCK
LDFLAGS += -static
@@ -69,8 +71,8 @@ DIST_RULES = dist-subdircreate
dist-subdircreate:
$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
-fsck.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
+fsck.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS) $(LIBTOOLS_INTERNAL_DEPS)
+ $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(LIBTOOLS_INTERNAL_LIBS) $(COM_ERR_LIBS)
$(OBJS): prompt-codes.h
diff --git a/fsck.ocfs2/dirblocks.c b/fsck.ocfs2/dirblocks.c
index 08726f2..67b0eb5 100644
--- a/fsck.ocfs2/dirblocks.c
+++ b/fsck.ocfs2/dirblocks.c
@@ -151,6 +151,8 @@ void o2fsck_dir_block_iterate(o2fsck_state *ost, dirblock_iterator func,
ret = func(dbe, priv_data);
if (ret & OCFS2_DIRENT_ABORT)
break;
+ if (ost->ost_prog)
+ tools_progress_step(ost->ost_prog, 1);
}
}
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 28eddf9..891a85f 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -133,6 +133,7 @@ static void print_usage(void)
" -b superblock Treat given block as the super block\n"
" -B blocksize Force the given block size\n"
" -G Ask to fix mismatched inode generations\n"
+ " -P Show progress\n"
" -t Show I/O statistics\n"
" -tt Show I/O statistics per pass\n"
" -u Access the device with buffering\n"
@@ -703,7 +704,9 @@ int main(int argc, char **argv)
setlinebuf(stderr);
setlinebuf(stdout);
- while((c = getopt(argc, argv, "b:B:DfFGnupavVytr:")) != EOF) {
+ tools_progress_disable();
+
+ while((c = getopt(argc, argv, "b:B:DfFGnupavVytPr:")) != EOF) {
switch (c) {
case 'b':
blkno = read_number(optarg);
@@ -764,6 +767,10 @@ int main(int argc, char **argv)
ost->ost_answer = 0;
break;
+ case 'P':
+ tools_progress_enable();
+ break;
+
case 'y':
ost->ost_ask = 0;
ost->ost_answer = 1;
diff --git a/fsck.ocfs2/fsck.ocfs2.8.in b/fsck.ocfs2/fsck.ocfs2.8.in
index 58fe261..9ad7c38 100644
--- a/fsck.ocfs2/fsck.ocfs2.8.in
+++ b/fsck.ocfs2/fsck.ocfs2.8.in
@@ -72,6 +72,10 @@ with the value 4 logically or'd into the exit code. (See the
boot scripts.
.TP
+\fB\-P\fR
+Show progress.
+
+.TP
\fB\-r\fR \fIbackup-number\fR
\fImkfs.ocfs2\fR makes upto 6 backup copies of the superblock at offsets
1G, 4G, 16G, 64G, 256G and 1T depending on the size of the volume.
diff --git a/fsck.ocfs2/include/fsck.h b/fsck.ocfs2/include/fsck.h
index 2822fe1..80aeba3 100644
--- a/fsck.ocfs2/include/fsck.h
+++ b/fsck.ocfs2/include/fsck.h
@@ -28,6 +28,7 @@
#include "icount.h"
#include "dirblocks.h"
+#include "tools-internal/progress.h"
struct refcount_file;
@@ -96,6 +97,7 @@ typedef struct _o2fsck_state {
errcode_t ost_err;
struct o2fsck_resource_track ost_rt;
+ struct tools_progress *ost_prog;
/* counters */
uint32_t ost_file_count;
diff --git a/fsck.ocfs2/pass1.c b/fsck.ocfs2/pass1.c
index ac79037..83507ce 100644
--- a/fsck.ocfs2/pass1.c
+++ b/fsck.ocfs2/pass1.c
@@ -1457,6 +1457,7 @@ errcode_t o2fsck_pass1(o2fsck_state *ost)
ocfs2_filesys *fs = ost->ost_fs;
int valid;
struct o2fsck_resource_track rt;
+ uint64_t numinodes;
printf("Pass 1: Checking inodes and blocks\n");
@@ -1476,6 +1477,16 @@ errcode_t o2fsck_pass1(o2fsck_state *ost)
goto out_free;
}
+ if (tools_progress_enabled()) {
+ numinodes = ocfs2_get_max_inode_count(scan);
+ if (numinodes)
+ ost->ost_prog =
+ tools_progress_start("Scanning inodes",
+ "inodes", numinodes);
+ if (ost->ost_prog)
+ setbuf(stdout, NULL);
+ }
+
for(;;) {
ret = ocfs2_get_next_inode(scan, &blkno, buf);
if (ret) {
@@ -1525,6 +1536,9 @@ errcode_t o2fsck_pass1(o2fsck_state *ost)
}
update_inode_alloc(ost, di, blkno, valid);
+
+ if (ost->ost_prog)
+ tools_progress_step(ost->ost_prog, 1);
}
mark_local_allocs(ost);
@@ -1548,5 +1562,9 @@ out_free:
o2fsck_add_resource_track(&ost->ost_rt, &rt);
out:
+ if (ost->ost_prog) {
+ tools_progress_stop(ost->ost_prog);
+ setlinebuf(stdout);
+ }
return ret;
}
diff --git a/fsck.ocfs2/pass2.c b/fsck.ocfs2/pass2.c
index 44ebd83..ff2abd2 100644
--- a/fsck.ocfs2/pass2.c
+++ b/fsck.ocfs2/pass2.c
@@ -955,6 +955,14 @@ errcode_t o2fsck_pass2(o2fsck_state *ost)
o2fsck_init_resource_track(&rt, fs->fs_io);
+ if (tools_progress_enabled() && ost->ost_dirblocks.db_numblocks) {
+ ost->ost_prog =
+ tools_progress_start("Scanning directories", "dirs",
+ ost->ost_dirblocks.db_numblocks);
+ if (ost->ost_prog)
+ setbuf(stdout, NULL);
+ }
+
o2fsck_strings_init(&dd.strings);
ret = ocfs2_malloc_block(ost->ost_fs->fs_io, &dd.dirblock_buf);
@@ -1002,6 +1010,11 @@ errcode_t o2fsck_pass2(o2fsck_state *ost)
o2fsck_print_resource_track("Pass 2", ost, &rt, fs->fs_io);
o2fsck_add_resource_track(&ost->ost_rt, &rt);
out:
+ if (ost->ost_prog) {
+ tools_progress_stop(ost->ost_prog);
+ setlinebuf(stdout);
+ }
+ tools_progress_disable();
if (dd.dirblock_buf)
ocfs2_free(&dd.dirblock_buf);
if (dd.inoblock_buf)
--
1.7.4.1
More information about the Ocfs2-tools-devel
mailing list