From: Tao Ma <tm@tao.ma>
To: linux-ext4@vger.kernel.org
Subject: [PATCH] ext4: Only call update_backups if necessary in online resize.
Date: Mon, 24 Sep 2012 23:00:17 +0800 [thread overview]
Message-ID: <1348498817-3598-1-git-send-email-tm@tao.ma> (raw)
From: Tao Ma <boyu.mt@taobao.com>
Now in online resize, we will add a bunch of groups at one time in
ext4_flex_group_add, so in most cases a lot of group descriptors
will be in the same group block. But in the end of this function,
update_backups will be called for every group descriptor and the
same block will be copied and journalled again and again.
It is really a waste.
So add a old_gdb to store the group block we have already done
the backup and skip the backup until we meet with a new group block.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
fs/ext4/resize.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 019d528..ae2f5fc 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1348,6 +1348,7 @@ exit_journal:
if (!err) {
int i;
+ sector_t old_gdb = 0;
update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
sizeof(struct ext4_super_block));
for (i = 0; i < flex_gd->count; i++, group++) {
@@ -1355,8 +1356,16 @@ exit_journal:
int gdb_num;
gdb_num = group / EXT4_BLOCKS_PER_GROUP(sb);
gdb_bh = sbi->s_group_desc[gdb_num];
- update_backups(sb, gdb_bh->b_blocknr, gdb_bh->b_data,
- gdb_bh->b_size);
+ /*
+ * only backup the group descriptor block
+ * which hasn't been updated before.
+ */
+ if (old_gdb != gdb_bh->b_blocknr) {
+ update_backups(sb, gdb_bh->b_blocknr,
+ gdb_bh->b_data,
+ gdb_bh->b_size);
+ old_gdb = gdb_bh->b_blocknr;
+ }
}
}
exit:
--
1.7.1
next reply other threads:[~2012-09-24 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 15:00 Tao Ma [this message]
2012-09-26 3:39 ` [PATCH] ext4: Only call update_backups if necessary in online resize Theodore Ts'o
2012-09-26 3:51 ` Tao Ma
2012-09-26 4:03 ` Theodore Ts'o
2012-09-26 5:26 ` Kevin Liao
2012-09-26 13:57 ` Theodore Ts'o
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=1348498817-3598-1-git-send-email-tm@tao.ma \
--to=tm@tao.ma \
--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).