All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Ma <tao.ma@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 1/1] Ocfs2: Optimize punching-hole codes v4.
Date: Fri, 09 Apr 2010 12:28:00 +0800	[thread overview]
Message-ID: <4BBEACD0.9030103@oracle.com> (raw)
In-Reply-To: <4BBEAA9C.5040408@oracle.com>



tristan wrote:
> Tao Ma wrote:
>> Hi Tristan,
>>
>> tristan wrote:
>>> Tao,
>>>
>>> Thanks a lot for your quick review;)
>>>
>>> Tao Ma wrote:
>>>> Hi Tristan,
>>>> Tristan Ye wrote:
>>>>> Changes from v3 to v4:
>>>>>
>>>>> 1. Fix a bug when crossing extent blocks.
>>>>>
>>>>> 2. Fix a bug when hole exists in the beginning of an extent block.
>>>>>
>>>>> 3. Apply tao's comments.
>>>>>
>>>>>
>>>>> Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
>>>>> ---
>>>>>  fs/ocfs2/file.c |  233 
>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++-------
>>>>>  1 files changed, 206 insertions(+), 27 deletions(-)
>>>>>
>>>>> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
>>>>> index db2e0c9..75e087f 100644
>>>>> --- a/fs/ocfs2/file.c
>>>>> +++ b/fs/ocfs2/file.c
>>>>> @@ -1423,18 +1423,154 @@ out:
>>>>>      return ret;
>>>>>  }
>>>>>  
>>>>> +static void ocfs2_find_rec(struct ocfs2_extent_list *el,
>>>>> +               struct ocfs2_extent_rec **rec_found,
>>>>> +               u32 *pos)
>>>>> +{
>>>>> +    int i, found = 0;
>>>>> +    struct ocfs2_extent_rec *rec = NULL;
>>>>> +
>>>>> +    for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
>>>>> +
>>>>> +        rec = &el->l_recs[i];
>>>>> +
>>>>> +        if (le32_to_cpu(rec->e_cpos) <= *pos) {
>>>>> +            found = 1;
>>>>> +            break;
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    if (!found)
>>>>> +        *rec_found = NULL;
>>>>> +    else
>>>>> +        *rec_found = &el->l_recs[i];
>>>>> +}
>>>>>   
>>>> This function never returns pos now. So why you want to pass a *pos?
>>>> another issue is that now it seems that you only want to returns a rec?
>>>> then why not change this function to
>>>> static int ocfs2_find_rec(struct ocfs2_extent_list *el, u32 pos)
>>>
>>> Yes, it's confusing to use *pos, thanks for pointing this out.
>>>
>>>> and after the loop, just return i. So if i>=0, you find it, if i < 
>>>> 0, no rec is found. Looks more natural?
>>>
>>> I think returning  a meaty record would be more straightforward.
>> why? actually as I have said below, these 2 functions ocfs2_find_rec 
>> and ocfs2_find_rec_with_holes can be integrated into one function 
>> named ocfs2_find_rec or whatever. You are too nervous about holes 
>> actually.
> 
> Hole still needs to be handled, while I may over-treat this  a little bit.
> 
> I'll try to merge the 2 funcs into one.
>> So
>> static int ocfs2_find_rec(struct ocfs2_extent_list *el, u32 pos)
>> {
>>     int i;
>>     struct ocfs2_extent_rec *rec = NULL;
>>
>>     for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
>>         rec = &el->l_recs[i];
>>
>>         if (le32_to_cpu(rec->e_cpos) < pos)
>>             break;
>>     }
>>
>>     return i;
>> }
> 
> Not enough,
> 
> cases about 'we didn't find a rec' and 'we find rec[0]' both return i=0;
what do you mean? If we can't find a rec, i will be set to -1, so we 
will return '-1'. It is the rule of 'for'.

Regards,
Tao

  reply	other threads:[~2010-04-09  4:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-08 11:02 [Ocfs2-devel] [PATCH 1/1] Ocfs2: Optimize punching-hole codes v4 Tristan Ye
2010-04-08 14:56 ` Tao Ma
2010-04-09  1:56   ` tristan
2010-04-09  2:31     ` Tao Ma
2010-04-09  4:18       ` tristan
2010-04-09  4:28         ` Tao Ma [this message]
2010-04-09  2:08   ` tristan

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=4BBEACD0.9030103@oracle.com \
    --to=tao.ma@oracle.com \
    --cc=ocfs2-devel@oss.oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.