+2007-04-06 Theodore Tso <tytso@mit.edu>
+
+ * e2fsck.h, pass1.c, pass2.c: If e2fsck.conf configures a
+ scratch_files directory which is available, and the number
+ of directories exceeds scratch_files.numdirs_threshold,
+ then try to use the tdb library to store the inode count
+ abstraction. This allows us to check very large
+ filesystems without needing as much physical memory.
+
2007-04-04 Theodore Tso <tytso@mit.edu>
* dirinfo.c, pass2.c, pass3.c, rehash.c, e2fsck.h: Change the
extern int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx);
/* pass1.c */
+extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
+ ext2_icount_t *ret);
extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool);
extern int e2fsck_pass1_check_device_inode(ext2_filsys fs,
struct ext2_inode *inode);
}
}
+extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
+ ext2_icount_t *ret)
+{
+ ext2_ino_t num_dirs;
+ errcode_t retval;
+ char *tdb_dir, uuid[40];
+ int fd, threshold, enable;
+
+ *ret = 0;
+
+ profile_get_string(ctx->profile, "scratch_files", "directory", 0, 0,
+ &tdb_dir);
+ profile_get_integer(ctx->profile, "scratch_files",
+ "numdirs_threshold", 0, 0, &threshold);
+ profile_get_boolean(ctx->profile, "scratch_files",
+ "icount", 0, 1, &enable);
+
+ retval = ext2fs_get_num_dirs(ctx->fs, &num_dirs);
+ if (retval)
+ num_dirs = 1024; /* Guess */
+
+ if (!enable || !tdb_dir || access(tdb_dir, W_OK) ||
+ (threshold && num_dirs <= threshold))
+ return;
+
+ retval = ext2fs_create_icount_tdb(ctx->fs, tdb_dir, flags, ret);
+ if (retval)
+ *ret = 0;
+}
+
void e2fsck_pass1(e2fsck_t ctx)
{
int i;
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
- &ctx->inode_link_info);
+ e2fsck_setup_tdb_icount(ctx, 0, &ctx->inode_link_info);
+ if (!ctx->inode_link_info)
+ pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
+ &ctx->inode_link_info);
if (pctx.errcode) {
fix_problem(ctx, PR_1_ALLOCATE_ICOUNT, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
if (!(ctx->options & E2F_OPT_PREEN))
fix_problem(ctx, PR_2_PASS_HEADER, &cd.pctx);
- cd.pctx.errcode = ext2fs_create_icount2(fs, EXT2_ICOUNT_OPT_INCREMENT,
+ e2fsck_setup_tdb_icount(ctx, EXT2_ICOUNT_OPT_INCREMENT,
+ &ctx->inode_count);
+ if (ctx->inode_count)
+ cd.pctx.errcode = 0;
+ else
+ cd.pctx.errcode = ext2fs_create_icount2(fs,
+ EXT2_ICOUNT_OPT_INCREMENT,
0, ctx->inode_link_info,
&ctx->inode_count);
if (cd.pctx.errcode) {