linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: xiaoqiangnk@gmail.com, "Theodore Ts'o" <tytso@mit.edu>,
	stable@vger.kernel.org
Subject: [PATCH 2/5] ext4: avoid duplicate writes of the backup bg descriptor blocks
Date: Sun,  2 Sep 2012 00:51:22 -0400	[thread overview]
Message-ID: <1346561485-6413-3-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1346561485-6413-1-git-send-email-tytso@mit.edu>

From: Yongqiang Yang <xiaoqiangnk@gmail.com>

The resize code was needlessly writing the backup block group
descriptor blocks multiple times (once per block group) during an
online resize.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
---
 fs/ext4/resize.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 724e250..e3f5f53 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1353,13 +1353,15 @@ exit_journal:
 		err = err2;
 
 	if (!err) {
-		int i;
+		int gdb_num = group / EXT4_DESC_PER_BLOCK(sb);
+		int gdb_num_end = ((group + flex_gd->count - 1) /
+				   EXT4_DESC_PER_BLOCK(sb));
+
 		update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
 			       sizeof(struct ext4_super_block));
-		for (i = 0; i < flex_gd->count; i++, group++) {
+		for (; gdb_num <= gdb_num_end; gdb_num++) {
 			struct buffer_head *gdb_bh;
-			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);
-- 
1.7.12.rc0.22.gcdd159b


  parent reply	other threads:[~2012-09-02  5:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02  4:51 [PATCH 0/5] meta_bg online resize patches Theodore Ts'o
2012-09-02  4:51 ` [PATCH 1/5] ext4: when resizing, do not copy gdt blocks for groups that do not have them Theodore Ts'o
2012-09-02  4:51 ` Theodore Ts'o [this message]
2012-09-02  4:51 ` [PATCH 3/5] ext4: grow the s_flex_groups array as needed when resizing Theodore Ts'o
2012-09-02  4:51 ` [PATCH 4/5] ext4: grow the s_group_info array as needed Theodore Ts'o
2012-09-02  4:51 ` [PATCH 5/5] ext4: add online resizing support for meta_bg and bit64 Theodore Ts'o
2012-09-03 16:33   ` [PATCH 5/5 -v2] ext4: add online resizing support for meta_bg and 64-bit file systems 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=1346561485-6413-3-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xiaoqiangnk@gmail.com \
    /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).