linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mingming Cao <cmm@us.ibm.com>
To: Yongqiang Yang <xiaoqiangnk@gmail.com>
Cc: linux-ext4@vger.kernel.org, achender@linux.vnet.ibm.com
Subject: Re: [PATCH RFC 1/3] ext4:Add a function merging extent right and left.
Date: Fri, 15 Apr 2011 09:39:33 -0700	[thread overview]
Message-ID: <1302885573.2901.13.camel@mingming-laptop> (raw)
In-Reply-To: <BANLkTindru2SnxLLFwb7bMxnkuhwP9MH2g@mail.gmail.com>

On Fri, 2011-04-15 at 09:12 +0800, Yongqiang Yang wrote:
> On Fri, Apr 15, 2011 at 3:03 AM, Mingming Cao <cmm@us.ibm.com> wrote:
> > On Wed, 2011-04-13 at 22:40 -0700, Yongqiang Yang wrote:
> >> 1] Rename ext4_ext_try_to_merge() to ext4_ext_try_to_merge_right().
> >>
> >> 2] Add a new function ext4_ext_try_to_merge() which tries to merge
> >>    an extent both left and right.
> >>
> >> 3] Use the new function in ext4_ext_convert_unwritten_endio() and
> >>    ext4_ext_insert_extent().
> >>
> >> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
> >> ---
> >>  fs/ext4/extents.c |   65 ++++++++++++++++++++++++++++------------------------
> >>  1 files changed, 35 insertions(+), 30 deletions(-)
> >>
> >> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> >> index dd2cb50..11f30d2 100644
> >> --- a/fs/ext4/extents.c
> >> +++ b/fs/ext4/extents.c
> >> @@ -1563,7 +1563,7 @@ ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
> >>   * Returns 0 if the extents (ex and ex+1) were _not_ merged and returns
> >>   * 1 if they got merged.
> >>   */
> >> -static int ext4_ext_try_to_merge(struct inode *inode,
> >> +static int ext4_ext_try_to_merge_right(struct inode *inode,
> >>                                struct ext4_ext_path *path,
> >>                                struct ext4_extent *ex)
> >>  {
> >> @@ -1603,6 +1603,31 @@ static int ext4_ext_try_to_merge(struct inode *inode,
> >>  }
> >>
> >>  /*
> >> + * This function tries to merge the @ex extent to neighbours in the tree.
> >> + * return 1 if merge left else 0.
> >> + */
> >> +static int ext4_ext_try_to_merge(struct inode *inode,
> >> +                               struct ext4_ext_path *path,
> >> +                               struct ext4_extent *ex) {
> >> +     struct ext4_extent_header *eh;
> >> +     unsigned int depth;
> >> +     int merge_done = 0;
> >> +     int ret = 0;
> >> +
> >> +     depth = ext_depth(inode);
> >> +     BUG_ON(path[depth].p_hdr == NULL);
> >> +     eh = path[depth].p_hdr;
> >> +
> >> +     if (ex > EXT_FIRST_EXTENT(eh))
> >> +             merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1);
> >> +
> >> +     if (!merge_done)
> >> +             ret = ext4_ext_try_to_merge_right(inode, path, ex);
> >> +
> >
> > Is there any reason not to merge right after merge left? The old code
> > does both, I think.
> What does merge left do?  Actually it does as merge right, it merge
> ex-1 to right until no more merges can be done.  So if merge to right
> happens then, ex,ex+1 has been tried to merge also.
> 

Yep, you are right, the merge is always merge toward right. 

> >
> >> +     return ret;
> >> +}
> >> +
> >> +/*
> >>   * check if a portion of the "newext" extent overlaps with an
> >>   * existing extent.
> >>   *
> >> @@ -3039,6 +3064,7 @@ fix_extent_len:
> >>       ext4_ext_dirty(handle, inode, path + depth);
> >>       return err;
> >>  }
> >> +
> >>  static int ext4_convert_unwritten_extents_endio(handle_t *handle,
> >>                                             struct inode *inode,
> >>                                             struct ext4_ext_path *path)
> >> @@ -3047,46 +3073,25 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
> >>       struct ext4_extent_header *eh;
> >>       int depth;
> >>       int err = 0;
> >> -     int ret = 0;
> >>
> >>       depth = ext_depth(inode);
> >>       eh = path[depth].p_hdr;
> >>       ex = path[depth].p_ext;
> >>
> >> +     ext_debug("ext4_convert_unwritten_extents_endio: inode %lu, logical"
> >> +             "block %llu, max_blocks %u\n", inode->i_ino,
> >> +             (unsigned long long)le32_to_cpu(ex->ee_block),
> >> +             ext4_ext_get_actual_len(ex));
> >> +
> >>       err = ext4_ext_get_access(handle, inode, path + depth);
> >>       if (err)
> >>               goto out;
> >>       /* first mark the extent as initialized */
> >>       ext4_ext_mark_initialized(ex);
> >>
> >> -     /*
> >> -      * We have to see if it can be merged with the extent
> >> -      * on the left.
> >> -      */
> >> -     if (ex > EXT_FIRST_EXTENT(eh)) {
> >> -             /*
> >> -              * To merge left, pass "ex - 1" to try_to_merge(),
> >> -              * since it merges towards right _only_.
> >> -              */
> >> -             ret = ext4_ext_try_to_merge(inode, path, ex - 1);
> >> -             if (ret) {
> >> -                     err = ext4_ext_correct_indexes(handle, inode, path);
> >> -                     if (err)
> >> -                             goto out;
> >> -                     depth = ext_depth(inode);
> >> -                     ex--;
> >> -             }
> >> -     }
> >> -     /*
> >> -      * Try to Merge towards right.
> >> -      */
> >> -     ret = ext4_ext_try_to_merge(inode, path, ex);
> >> -     if (ret) {
> >> -             err = ext4_ext_correct_indexes(handle, inode, path);
> >> -             if (err)
> >> -                     goto out;
> >> -             depth = ext_depth(inode);
> >> -     }
> >> +     /* correct indexes is nt needed becasue borders are not changed */
> >> +     ext4_ext_try_to_merge(inode, path, ex);
> >> +
> >
> > Ah, so you discovered an issue -- currently ext4 can't merge across the
> > index block borders. that's a pity. This might need to fix up,
> Yes, currently borders are changed only in one case that storing an
> extent to an empty leaf.
> 
> I think the patch which enable merging across index block should be
> independent on these patches.
> 

Sure.

> 
> > especially with split is going to be heavily used in punch hole,
> > snapshots, direct IO handling holes.
> What does direct IO here refer to?  It seems I am missing something.
> 
> These patches involves ext4_ext_convrt_to_initialized() in buffer
> write case, and split_unwritten_extents() and
> convert_to_initialized_endio() in direct IO case.
> 

The plit_unwritten_extents() and convert_to_initialized_endio() were
added to support direct IO on holes/fallocated space. That's what I am
referring to above.

> >
> >
> >>       /* Mark modified extent as dirty */
> >>       err = ext4_ext_dirty(handle, inode, path + depth);
> >>  out:
> >
> >
> >
> 
> 
> 



  reply	other threads:[~2011-04-15 16:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-14  5:40 [PATCH REC 0/3] ext4:Factor common code from convert and split unwritten Yongqiang Yang
2011-04-14  5:40 ` [PATCH RFC 1/3] ext4:Add a function merging extent right and left Yongqiang Yang
2011-04-14 19:03   ` Mingming Cao
2011-04-15  1:12     ` Yongqiang Yang
2011-04-15 16:39       ` Mingming Cao [this message]
2011-04-14  5:40 ` [PATCH RFC 2/3] ext4:Add two functions splitting an extent Yongqiang Yang
2011-04-20 17:21   ` Allison Henderson
2011-04-20 18:13     ` Andreas Dilger
2011-04-20 20:52       ` Allison Henderson
2011-04-21  1:18     ` Yongqiang Yang
2011-04-14  5:40 ` [PATCH RFC 3/3] ext4:Reimplement convert and split_unwritten Yongqiang Yang
2011-04-21  1:21   ` Yongqiang Yang
2011-04-21  8:28   ` Allison Henderson
2011-04-21  9:10     ` Yongqiang Yang
2011-04-21 21:13       ` Allison Henderson
2011-04-14 14:14 ` [PATCH REC 0/3] ext4:Factor common code from convert and split unwritten Ted Ts'o
2011-04-14 14:34   ` Yongqiang Yang
2011-04-14 18:45     ` Mingming Cao
2011-04-14 14:36   ` Amir Goldstein

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=1302885573.2901.13.camel@mingming-laptop \
    --to=cmm@us.ibm.com \
    --cc=achender@linux.vnet.ibm.com \
    --cc=linux-ext4@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).