From: Artem Blagodarenko <artem.blagodarenko@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: adilger.kernel@dilger.ca, Vladimir Saveliev <c17830@cray.com>
Subject: [REF] LUS-6746 debugfs: fake_fill_fs to fragment filesystem
Date: Thu, 21 Nov 2019 15:03:15 +0300 [thread overview]
Message-ID: <20191121120315.14481-1-c17828@cray.com> (raw)
From: Vladimir Saveliev <c17830@cray.com>
New command is added to debugfs: fake_fill_fs <filling in %>
This command finds free blocks on a filesystem and mark as in use
specified fraction of those.
Example: debugfs -w -R 'fake_fill_fs 50' <device>
This can be to used in order to quickly fragment a filesystem which
may useful for block allocation improvement estimation.
Use it carefully, there is no way to recover free space but using
e2fsck.
Change-Id: Ib7ce7794eefac2726fef334810a5832d52a90398
Signed-off-by: Vladimir Saveliev <c17830@cray.com>
Signed-off-by: Artem Blagodarenko <c17828@cray.com>
Cray-bug-id: LUS-6746
---
debugfs/debug_cmds.ct | 2 ++
debugfs/debugfs.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/debugfs/debug_cmds.ct b/debugfs/debug_cmds.ct
index 1ff6c9dc..12557888 100644
--- a/debugfs/debug_cmds.ct
+++ b/debugfs/debug_cmds.ct
@@ -229,5 +229,7 @@ request do_journal_write, "Write a transaction to the journal",
request do_journal_run, "Recover the journal",
journal_run, jr;
+request do_fake_fill_fs, "Make the filesystem to look as if it was full",
+ fake_fill_fs;
end;
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 9b701455..25731883 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -2209,6 +2209,36 @@ err:
ext2fs_free_mem(&buf);
}
+void do_fake_fill_fs(int argc, char *argv[])
+{
+ __u64 block_count, i;
+ unsigned long v;
+ char *tmp;
+ int f;
+
+ if (common_args_process(argc, argv, 2, 2, argv[0],
+ "filling(%)", CHECK_FS_BITMAPS))
+ return;
+ if (check_fs_read_write(argv[0]))
+ return;
+ v = strtoul(argv[1], &tmp, 0);
+ if (v < 1 || v > 100) {
+ com_err("argv[0]", 0, "filling [1-100]");
+ }
+
+ block_count = ext2fs_blocks_count(current_fs->super);
+ for (i = 1, f = 0; i < block_count; i++) {
+ if (!ext2fs_test_block_bitmap2(current_fs->block_map, i)) {
+ f %= 100;
+ if (f < v)
+ ext2fs_block_alloc_stats2(current_fs, i, +1);
+ f ++;
+ }
+ }
+
+ ext2fs_mark_bb_dirty(current_fs);
+}
+
#ifndef READ_ONLY
void do_set_current_time(int argc, char *argv[],
int sci_idx EXT2FS_ATTR((unused)),
--
2.14.3 (Apple Git-98)
reply other threads:[~2019-11-21 12:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20191121120315.14481-1-c17828@cray.com \
--to=artem.blagodarenko@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=c17830@cray.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).