Add --enable-test-io-debug configure option which causes e2fsck and

tune2fs to use the test I/O manager.

The test I/O manager has been changed to not do anything extra by 
default, unless the TEST_IO_FLAGS and/or TEST_IO_BLOCK environment
variables are set, which controls what I/O operations are logged and
a block number to watch, respectively.  The log messages are sent to
stderr by default, unless a filename is specified via the 
TEST_IO_LOGFILE environment variable.
bitmap-optimize
Theodore Ts'o 2003-05-05 12:08:47 -04:00
parent becf36f6ac
commit 2a29f1354f
9 changed files with 365 additions and 231 deletions

View File

@ -1,5 +1,7 @@
2003-05-05 Theodore Ts'o <tytso@mit.edu>
* configure.in, configure: Add --enable-testio-debug configure option.
* configure.in, configure, Makefile.in: Add --with-diet-libc
convenience option. Add --disable-evms option.

441
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -382,6 +382,21 @@ fi
echo "Disabling blkid debugging by default"
)
dnl
dnl handle --enable-testio-debug
dnl
AC_ARG_ENABLE([testio-debug],
[ --enable-testio-debug enable the use of the test I/O manager for debugging],
if test "$enableval" = "no"
then
echo "Disabling testio debugging"
else
AC_DEFINE(CONFIG_TESTIO_DEBUG)
echo "Enabling testio debugging"
fi
,
echo "Disabling testio debugging by default"
)
dnl
dnl handle --enable-swapfs
dnl
AC_ARG_ENABLE([swapfs],

View File

@ -1,3 +1,8 @@
2003-05-05 Theodore Ts'o <tytso@mit.edu>
* unix.c (main): If --enable-testio-debug is set, then use the
test_io manager so we can watch what e2fsck is doing.
2003-05-03 Theodore Ts'o <tytso@mit.edu>
* unix.c (show_stats): Remove uneeded use of _() around string

View File

@ -824,11 +824,11 @@ int main (int argc, char *argv[])
}
ctx->superblock = ctx->use_superblock;
restart:
#if 1
io_ptr = unix_io_manager;
#else
#ifdef CONFIG_TESTIO_DEBUG
io_ptr = test_io_manager;
test_io_backing_manager = unix_io_manager;
#else
io_ptr = unix_io_manager;
#endif
flags = 0;
if ((ctx->options & E2F_OPT_READONLY) == 0)

View File

@ -1,3 +1,10 @@
2003-05-05 Theodore Ts'o <tytso@mit.edu>
* test_io.c: Pay attention to the environment variables
TEST_IO_LOGFILE, TEST_IO_FLAGS, and TEST_IO_BLOCK to
determine whether or not we should log io activity, and to
where.
2003-05-03 Theodore Ts'o <tytso@mit.edu>
* tst_badblocks.c (file_test): Use tmpfile() instead of mktemp().

View File

@ -36,6 +36,9 @@
struct test_private_data {
int magic;
io_channel real;
int flags;
FILE *outfile;
unsigned long block;
void (*read_blk)(unsigned long block, int count, errcode_t err);
void (*write_blk)(unsigned long block, int count, errcode_t err);
void (*set_blksize)(int blksize, errcode_t err);
@ -82,6 +85,34 @@ void (*test_io_cb_set_blksize)
void (*test_io_cb_write_byte)
(unsigned long block, int count, errcode_t err) = 0;
/*
* Test flags
*/
#define TEST_FLAG_READ 0x01
#define TEST_FLAG_WRITE 0x02
#define TEST_FLAG_SET_BLKSIZE 0x04
#define TEST_FLAG_FLUSH 0x08
static void test_dump_block(io_channel channel,
struct test_private_data *data,
unsigned long block, void *buf)
{
const unsigned char *cp;
FILE *f = data->outfile;
int i;
unsigned long cksum = 0;
for (i=0, cp = buf; i < channel->block_size; i++, cp++) {
cksum += *cp;
}
fprintf(f, "Contents of block %d, checksum %08x: \n", block, cksum);
for (i=0, cp = buf; i < channel->block_size; i++, cp++) {
if ((i % 16) == 0)
fprintf(f, "%04x: ", i);
fprintf(f, "%02x%c", *cp, ((i % 16) == 15) ? '\n' : ' ');
}
}
static errcode_t test_open(const char *name, int flags, io_channel *channel)
{
io_channel io = NULL;
@ -127,6 +158,20 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
data->write_blk = test_io_cb_write_blk;
data->set_blksize = test_io_cb_set_blksize;
data->write_byte = test_io_cb_write_byte;
data->outfile = NULL;
if (getenv("TEST_IO_LOGFILE"))
data->outfile = fopen(getenv("TEST_IO_LOGFILE"), "w");
if (!data->outfile)
data->outfile = stderr;
data->flags = 0;
if (getenv("TEST_IO_FLAGS"))
data->flags = strtoul(getenv("TEST_IO_FLAGS"), NULL, 0);
data->block = 0;
if (getenv("TEST_IO_BLOCK"))
data->block = strtoul(getenv("TEST_IO_BLOCK"), NULL, 0);
*channel = io;
return 0;
@ -153,6 +198,9 @@ static errcode_t test_close(io_channel channel)
if (data->real)
retval = io_channel_close(data->real);
if (data->outfile)
fclose(data->outfile);
ext2fs_free_mem((void **) &channel->private_data);
if (channel->name)
@ -174,9 +222,11 @@ static errcode_t test_set_blksize(io_channel channel, int blksize)
retval = io_channel_set_blksize(data->real, blksize);
if (data->set_blksize)
data->set_blksize(blksize, retval);
else
printf("Test_io: set_blksize(%d) returned %s\n",
blksize, retval ? error_message(retval) : "OK");
if (data->flags & TEST_FLAG_SET_BLKSIZE)
fprintf(data->outfile,
"Test_io: set_blksize(%d) returned %s\n",
blksize, retval ? error_message(retval) : "OK");
channel->block_size = blksize;
return retval;
}
@ -195,9 +245,12 @@ static errcode_t test_read_blk(io_channel channel, unsigned long block,
retval = io_channel_read_blk(data->real, block, count, buf);
if (data->read_blk)
data->read_blk(block, count, retval);
else
printf("Test_io: read_blk(%lu, %d) returned %s\n",
block, count, retval ? error_message(retval) : "OK");
if (data->flags & TEST_FLAG_READ)
fprintf(data->outfile,
"Test_io: read_blk(%lu, %d) returned %s\n",
block, count, retval ? error_message(retval) : "OK");
if (data->block && data->block == block)
test_dump_block(channel, data, block, buf);
return retval;
}
@ -215,9 +268,12 @@ static errcode_t test_write_blk(io_channel channel, unsigned long block,
retval = io_channel_write_blk(data->real, block, count, buf);
if (data->write_blk)
data->write_blk(block, count, retval);
else
printf("Test_io: write_blk(%lu, %d) returned %s\n",
block, count, retval ? error_message(retval) : "OK");
if (data->flags & TEST_FLAG_WRITE)
fprintf(data->outfile,
"Test_io: write_blk(%lu, %d) returned %s\n",
block, count, retval ? error_message(retval) : "OK");
if (data->block && data->block == block)
test_dump_block(channel, data, block, buf);
return retval;
}
@ -235,9 +291,10 @@ static errcode_t test_write_byte(io_channel channel, unsigned long offset,
retval = io_channel_write_byte(data->real, offset, count, buf);
if (data->write_byte)
data->write_byte(offset, count, retval);
else
printf("Test_io: write_byte(%lu, %d) returned %s\n",
offset, count, retval ? error_message(retval) : "OK");
if (data->flags & TEST_FLAG_WRITE)
fprintf(data->outfile,
"Test_io: write_byte(%lu, %d) returned %s\n",
offset, count, retval ? error_message(retval) : "OK");
return retval;
}
@ -256,8 +313,9 @@ static errcode_t test_flush(io_channel channel)
if (data->real)
retval = io_channel_flush(data->real);
printf("Test_io: flush() returned %s\n",
retval ? error_message(retval) : "OK");
if (data->flags & TEST_FLAG_FLUSH)
fprintf(data->outfile, "Test_io: flush() returned %s\n",
retval ? error_message(retval) : "OK");
return retval;
}

View File

@ -1,3 +1,9 @@
2003-05-05 Theodore Ts'o <tytso@mit.edu>
* tune2fs.c (main, add_journal_device, remove_journal_device): If
--enable-testio-debug is set, then use the test_io manager
so we can watch what tune2fs is doing.
2003-05-03 Theodore Ts'o <tytso@mit.edu>
* uuidgen.c (main): Add setup functions for NLS support.

View File

@ -109,6 +109,7 @@ static void remove_journal_device(ext2_filsys fs)
int i, nr_users;
errcode_t retval;
int commit_remove_journal = 0;
io_manager io_ptr;
if (f_flag)
commit_remove_journal = 1; /* force removal even if error */
@ -123,9 +124,15 @@ static void remove_journal_device(ext2_filsys fs)
return;
}
#ifdef CONFIG_TESTIO_DEBUG
io_ptr = test_io_manager;
test_io_backing_manager = unix_io_manager;
#else
io_ptr = unix_io_manager;
#endif
retval = ext2fs_open(journal_path, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
fs->blocksize, unix_io_manager, &jfs);
fs->blocksize, io_ptr, &jfs);
if (retval) {
com_err(program_name, retval,
_("while trying to open external journal"));
@ -358,6 +365,7 @@ static void add_journal(ext2_filsys fs)
unsigned long journal_blocks;
errcode_t retval;
ext2_filsys jfs;
io_manager io_ptr;
if (fs->super->s_feature_compat &
EXT3_FEATURE_COMPAT_HAS_JOURNAL) {
@ -367,9 +375,15 @@ static void add_journal(ext2_filsys fs)
if (journal_device) {
check_plausibility(journal_device);
check_mount(journal_device, 0, _("journal"));
#ifdef CONFIG_TESTIO_DEBUG
io_ptr = test_io_manager;
test_io_backing_manager = unix_io_manager;
#else
io_ptr = unix_io_manager;
#endif
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
EXT2_FLAG_JOURNAL_DEV_OK, 0,
fs->blocksize, unix_io_manager, &jfs);
fs->blocksize, io_ptr, &jfs);
if (retval) {
com_err(program_name, retval,
_("\n\twhile trying to open journal on %s\n"),
@ -704,6 +718,7 @@ int main (int argc, char ** argv)
errcode_t retval;
ext2_filsys fs;
struct ext2_super_block *sb;
io_manager io_ptr;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
@ -722,8 +737,13 @@ int main (int argc, char ** argv)
else
parse_tune2fs_options(argc, argv);
retval = ext2fs_open (device_name, open_flag, 0, 0,
unix_io_manager, &fs);
#ifdef CONFIG_TESTIO_DEBUG
io_ptr = test_io_manager;
test_io_backing_manager = unix_io_manager;
#else
io_ptr = unix_io_manager;
#endif
retval = ext2fs_open (device_name, open_flag, 0, 0, io_ptr, &fs);
if (retval) {
com_err (program_name, retval, _("while trying to open %s"),
device_name);