linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH 3/3] ext4: optimize block allocation on grow indepth
Date: Wed, 1 Oct 2014 22:52:55 -0400	[thread overview]
Message-ID: <20141002025255.GF16766@thunk.org> (raw)
In-Reply-To: <1411455752-2332-3-git-send-email-dmonakhov@openvz.org>

On Tue, Sep 23, 2014 at 11:02:32AM +0400, Dmitry Monakhov wrote:
> It is reasonable to prepent newly created index to older one.
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>

Thanks, applied with a minor change.

				- Ted

commit c69c690d41e6438ef8e3e9b09d9eb4f2fe669be2
Author: Dmitry Monakhov <dmonakhov@openvz.org>
Date:   Wed Oct 1 22:52:39 2014 -0400

    ext4: optimize block allocation on grow indepth
    
    It is reasonable to prepent newld created index to older one.
    
    [ Dropped no longer used function parameter newext. -tytso ]
    
    Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 8170b32..c3ed9af2 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1263,16 +1263,24 @@ cleanup:
  *   just created block
  */
 static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
-				 unsigned int flags,
-				 struct ext4_extent *newext)
+				 unsigned int flags)
 {
 	struct ext4_extent_header *neh;
 	struct buffer_head *bh;
-	ext4_fsblk_t newblock;
+	ext4_fsblk_t newblock, goal = 0;
+	struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
 	int err = 0;
 
-	newblock = ext4_ext_new_meta_block(handle, inode, NULL,
-		newext, &err, flags);
+	/* Try to prepend new index to old one */
+	if (ext_depth(inode))
+		goal = ext4_idx_pblock(EXT_FIRST_INDEX(ext_inode_hdr(inode)));
+	if (goal > le32_to_cpu(es->s_first_data_block)) {
+		flags |= EXT4_MB_HINT_TRY_GOAL;
+		goal--;
+	} else
+		goal = ext4_inode_to_goal_block(inode);
+	newblock = ext4_new_meta_blocks(handle, inode, goal, flags,
+					NULL, &err);
 	if (newblock == 0)
 		return err;
 
@@ -1373,7 +1381,7 @@ repeat:
 			err = PTR_ERR(path);
 	} else {
 		/* tree is full, time to grow in depth */
-		err = ext4_ext_grow_indepth(handle, inode, mb_flags, newext);
+		err = ext4_ext_grow_indepth(handle, inode, mb_flags);
 		if (err)
 			goto out;
 

  parent reply	other threads:[~2014-10-02  2:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23  7:02 [PATCH 1/3] ext4: fix over-defensive complain after journal abort Dmitry Monakhov
2014-09-23  7:02 ` [PATCH 2/3] ext4: get rid of code duplication Dmitry Monakhov
2014-09-23  9:54   ` Jan Kara
2014-10-02  2:27     ` Theodore Ts'o
2014-09-23  7:02 ` [PATCH 3/3] ext4: optimize block allocation on grow indepth Dmitry Monakhov
2014-09-23 10:00   ` Jan Kara
2014-09-23 10:26     ` Dmitry Monakhov
2014-10-02  2:52   ` Theodore Ts'o [this message]
2014-10-02  2:24 ` [PATCH 1/3] ext4: fix over-defensive complain after journal abort 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=20141002025255.GF16766@thunk.org \
    --to=tytso@mit.edu \
    --cc=dmonakhov@openvz.org \
    --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).