From: tytso@mit.edu
To: Akira Fujita <a-fujita@rs.jp.nec.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 1/3] ext4: Fix insertion point of extent in mext_insert_across_blocks()
Date: Fri, 5 Mar 2010 11:10:08 -0500 [thread overview]
Message-ID: <20100305161008.GB6000@thunk.org> (raw)
In-Reply-To: <4B90BEA9.9020208@rs.jp.nec.com>
On Fri, Mar 05, 2010 at 05:19:53PM +0900, Akira Fujita wrote:
>
> Sounds interesting.
> It seems to be able to try easily except (2).
> I think that we can mark block bitmap as in use with debugfs (do_setb).
> Do you have another better idea for the tool you mentioned at (2)?
The libext2fs library is very powerful. :-)
Here's a quicky program I whipped up fairly quickly. The code that
actually messes with the block bitmap is in the for loop; the rest is
just generic setup. Feel free to reuse this program as a framework
for other times when you want to quickly create a program to do
something programmatic where debugfs isn't quite powerful enough for
your needs.
I have considered trying to integrate tcl into debugfs, so that you
could do this in thing more easily in debugfs directly, but it's so
easy to write throwaway C programs that I've never bothered.
Regards,
- Ted
/*
* fill-bitmap.c --- Program which writes marks roughly half of the
* blocks in the filesystem as being in use.
*
* Compile via: cc -o fill-bitmap fill-bitmap.c -lext2fs -lcom_err
*
* Copyright 2010 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
* License.
* %End-Header%
*/
#include <ext2fs/ext2_fs.h>
#include <ext2fs/ext2fs.h>
#include <et/com_err.h>
#include <stdlib.h>
char *program_name;
static void usage(void)
{
fprintf(stderr, "Usage: %s device\n", program_name);
exit (1);
}
int main (int argc, char ** argv)
{
errcode_t retval;
ext2_filsys fs;
char *device_name;
blk_t blk;
add_error_table(&et_ext2_error_table);
if (argc != 2)
usage();
program_name = argv[0];
device_name = argv[1];
retval = ext2fs_open (device_name, EXT2_FLAG_RW, 0, 0,
unix_io_manager, &fs);
if (retval) {
com_err(program_name, retval, "while trying to open %s",
device_name);
exit(1);
}
retval = ext2fs_read_bitmaps(fs);
if (retval) {
com_err(program_name, retval, "while reading bitmaps");
exit(1);
}
for (blk = fs->super->s_first_data_block;
blk < fs->super->s_blocks_count; blk++) {
if (ext2fs_test_block_bitmap(fs->block_map, blk))
continue;
if (random() & 1)
continue;
ext2fs_mark_block_bitmap(fs->block_map, blk);
ext2fs_block_alloc_stats(fs, blk, 1);
}
ext2fs_close(fs);
remove_error_table(&et_ext2_error_table);
exit (0);
}
next prev parent reply other threads:[~2010-03-05 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-03 6:49 [PATCH 1/3] ext4: Fix insertion point of extent in mext_insert_across_blocks() Akira Fujita
2010-03-04 1:25 ` tytso
2010-03-04 5:50 ` Greg Freemyer
2010-03-05 8:19 ` Akira Fujita
2010-03-05 16:10 ` tytso [this message]
2010-03-08 8:40 ` Akira Fujita
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=20100305161008.GB6000@thunk.org \
--to=tytso@mit.edu \
--cc=a-fujita@rs.jp.nec.com \
--cc=linux-ext4@vger.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;
as well as URLs for NNTP newsgroup(s).