All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: adjust the way of calculating nat block
       [not found] <CGME20170308054010epcas5p1873bf561bd7ceac17a63a6e6cebb8365@epcas5p1.samsung.com>
@ 2017-03-08  5:39 ` Fan Li
  2017-03-08 21:56   ` Jaegeuk Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Fan Li @ 2017-03-08  5:39 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

use a slightly simpler expression to calculate nat block with nid.

Signed-off-by: Fan Li <fanofcode.li@samsung.com>
---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 2f9603f..f9fb5b8 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -200,13 +200,11 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        pgoff_t block_off;
        pgoff_t block_addr;
-       int seg_off;

        block_off = NAT_BLOCK_OFFSET(start);
-       seg_off = block_off >> sbi->log_blocks_per_seg;

        block_addr = (pgoff_t)(nm_i->nat_blkaddr +
-               (seg_off << sbi->log_blocks_per_seg << 1) +
+               (block_off << 1) -
                (block_off & (sbi->blocks_per_seg - 1)));

        if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
--
2.7.4


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] f2fs: adjust the way of calculating nat block
  2017-03-08  5:39 ` [PATCH] f2fs: adjust the way of calculating nat block Fan Li
@ 2017-03-08 21:56   ` Jaegeuk Kim
  2017-03-09  5:37     ` Fan Li
  0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2017-03-08 21:56 UTC (permalink / raw)
  To: Fan Li; +Cc: linux-f2fs-devel

On 03/08, Fan Li wrote:
> use a slightly simpler expression to calculate nat block with nid.
> 
> Signed-off-by: Fan Li <fanofcode.li@samsung.com>
> ---
>  fs/f2fs/node.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
> index 2f9603f..f9fb5b8 100644
> --- a/fs/f2fs/node.h
> +++ b/fs/f2fs/node.h
> @@ -200,13 +200,11 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
>         struct f2fs_nm_info *nm_i = NM_I(sbi);
>         pgoff_t block_off;
>         pgoff_t block_addr;
> -       int seg_off;
> 
>         block_off = NAT_BLOCK_OFFSET(start);
> -       seg_off = block_off >> sbi->log_blocks_per_seg;
> 
>         block_addr = (pgoff_t)(nm_i->nat_blkaddr +
> -               (seg_off << sbi->log_blocks_per_seg << 1) +
> +               (block_off << 1) -

NAK. This breaks the behavior.

Thanks,

>                 (block_off & (sbi->blocks_per_seg - 1)));
> 
>         if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
> --
> 2.7.4

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] f2fs: adjust the way of calculating nat block
  2017-03-08 21:56   ` Jaegeuk Kim
@ 2017-03-09  5:37     ` Fan Li
  2017-03-09 11:20       ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Fan Li @ 2017-03-09  5:37 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-f2fs-devel



> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Thursday, March 09, 2017 5:56 AM
> To: Fan Li
> Cc: linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block
> 
> On 03/08, Fan Li wrote:
> > use a slightly simpler expression to calculate nat block with nid.
> >
> > Signed-off-by: Fan Li <fanofcode.li@samsung.com>
> > ---
> >  fs/f2fs/node.h | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index 2f9603f..f9fb5b8
> > 100644
> > --- a/fs/f2fs/node.h
> > +++ b/fs/f2fs/node.h
> > @@ -200,13 +200,11 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
> >         struct f2fs_nm_info *nm_i = NM_I(sbi);
> >         pgoff_t block_off;
> >         pgoff_t block_addr;
> > -       int seg_off;
> >
> >         block_off = NAT_BLOCK_OFFSET(start);
> > -       seg_off = block_off >> sbi->log_blocks_per_seg;
> >
> >         block_addr = (pgoff_t)(nm_i->nat_blkaddr +
> > -               (seg_off << sbi->log_blocks_per_seg << 1) +
> > +               (block_off << 1) -
> 
> NAK. This breaks the behavior.

OK, I'm guessing by "breaks the behavior", you mean make the code hard to understand?
I was concerned the same thing, but with the context, I think most people will be able to
 see right through it, and it saves some calculation, makes code as simple as possible, I
just think maybe it's worthy.


> 
> Thanks,
> 
> >                 (block_off & (sbi->blocks_per_seg - 1)));
> >
> >         if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
> > --
> > 2.7.4



------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] f2fs: adjust the way of calculating nat block
  2017-03-09  5:37     ` Fan Li
@ 2017-03-09 11:20       ` Chao Yu
  2017-03-09 23:58         ` Jaegeuk Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2017-03-09 11:20 UTC (permalink / raw)
  To: Fan Li, 'Jaegeuk Kim'; +Cc: linux-f2fs-devel

On 2017/3/9 13:37, Fan Li wrote:
> 
> 
>> -----Original Message-----
>> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
>> Sent: Thursday, March 09, 2017 5:56 AM
>> To: Fan Li
>> Cc: linux-f2fs-devel@lists.sourceforge.net
>> Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block
>>
>> On 03/08, Fan Li wrote:
>>> use a slightly simpler expression to calculate nat block with nid.
>>>
>>> Signed-off-by: Fan Li <fanofcode.li@samsung.com>
>>> ---
>>>  fs/f2fs/node.h | 4 +---
>>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index 2f9603f..f9fb5b8
>>> 100644
>>> --- a/fs/f2fs/node.h
>>> +++ b/fs/f2fs/node.h
>>> @@ -200,13 +200,11 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
>>>         struct f2fs_nm_info *nm_i = NM_I(sbi);
>>>         pgoff_t block_off;
>>>         pgoff_t block_addr;
>>> -       int seg_off;
>>>
>>>         block_off = NAT_BLOCK_OFFSET(start);
>>> -       seg_off = block_off >> sbi->log_blocks_per_seg;
>>>
>>>         block_addr = (pgoff_t)(nm_i->nat_blkaddr +
>>> -               (seg_off << sbi->log_blocks_per_seg << 1) +
>>> +               (block_off << 1) -
>>
>> NAK. This breaks the behavior.
> 
> OK, I'm guessing by "breaks the behavior", you mean make the code hard to understand?
> I was concerned the same thing, but with the context, I think most people will be able to
>  see right through it, and it saves some calculation, makes code as simple as possible, I
> just think maybe it's worthy.

I know both calculation are right, assume:
block_off = segment_off * 512 + off_in_segment
a) origin: (segment_off * 512) * 2 + off_in_segment
b) yours: 2 * (segment_off * 512 + off_in_segment) - off_in_segment

Seem calculation of yours is more simple, but from my side, readability is also
important, it's a bit hard to understand your calculation approach without comments.

Thanks,

> 
> 
>>
>> Thanks,
>>
>>>                 (block_off & (sbi->blocks_per_seg - 1)));
>>>
>>>         if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
>>> --
>>> 2.7.4
> 
> 
> 
> ------------------------------------------------------------------------------
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 
> 


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] f2fs: adjust the way of calculating nat block
  2017-03-09 11:20       ` Chao Yu
@ 2017-03-09 23:58         ` Jaegeuk Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2017-03-09 23:58 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

On 03/09, Chao Yu wrote:
> On 2017/3/9 13:37, Fan Li wrote:
> > 
> > 
> >> -----Original Message-----
> >> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> >> Sent: Thursday, March 09, 2017 5:56 AM
> >> To: Fan Li
> >> Cc: linux-f2fs-devel@lists.sourceforge.net
> >> Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block
> >>
> >> On 03/08, Fan Li wrote:
> >>> use a slightly simpler expression to calculate nat block with nid.
> >>>
> >>> Signed-off-by: Fan Li <fanofcode.li@samsung.com>
> >>> ---
> >>>  fs/f2fs/node.h | 4 +---
> >>>  1 file changed, 1 insertion(+), 3 deletions(-)
> >>>
> >>> diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index 2f9603f..f9fb5b8
> >>> 100644
> >>> --- a/fs/f2fs/node.h
> >>> +++ b/fs/f2fs/node.h
> >>> @@ -200,13 +200,11 @@ static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start)
> >>>         struct f2fs_nm_info *nm_i = NM_I(sbi);
> >>>         pgoff_t block_off;
> >>>         pgoff_t block_addr;
> >>> -       int seg_off;
> >>>
> >>>         block_off = NAT_BLOCK_OFFSET(start);
> >>> -       seg_off = block_off >> sbi->log_blocks_per_seg;
> >>>
> >>>         block_addr = (pgoff_t)(nm_i->nat_blkaddr +
> >>> -               (seg_off << sbi->log_blocks_per_seg << 1) +
> >>> +               (block_off << 1) -
> >>
> >> NAK. This breaks the behavior.
> > 
> > OK, I'm guessing by "breaks the behavior", you mean make the code hard to understand?
> > I was concerned the same thing, but with the context, I think most people will be able to
> >  see right through it, and it saves some calculation, makes code as simple as possible, I
> > just think maybe it's worthy.
> 
> I know both calculation are right, assume:
> block_off = segment_off * 512 + off_in_segment
> a) origin: (segment_off * 512) * 2 + off_in_segment
> b) yours: 2 * (segment_off * 512 + off_in_segment) - off_in_segment

Oh, I missed '-' in the end of the line.
Let me add Chao's explanation in the patch. :)

Thanks,

> 
> Seem calculation of yours is more simple, but from my side, readability is also
> important, it's a bit hard to understand your calculation approach without comments.
> 
> Thanks,
> 
> > 
> > 
> >>
> >> Thanks,
> >>
> >>>                 (block_off & (sbi->blocks_per_seg - 1)));
> >>>
> >>>         if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
> >>> --
> >>> 2.7.4
> > 
> > 
> > 
> > ------------------------------------------------------------------------------
> > Announcing the Oxford Dictionaries API! The API offers world-renowned
> > dictionary content that is easy and intuitive to access. Sign up for an
> > account today to start using our lexical data to power your apps and
> > projects. Get started today and enter our developer competition.
> > http://sdm.link/oxford
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> > 
> > 
> 
> 
> ------------------------------------------------------------------------------
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-09 23:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170308054010epcas5p1873bf561bd7ceac17a63a6e6cebb8365@epcas5p1.samsung.com>
2017-03-08  5:39 ` [PATCH] f2fs: adjust the way of calculating nat block Fan Li
2017-03-08 21:56   ` Jaegeuk Kim
2017-03-09  5:37     ` Fan Li
2017-03-09 11:20       ` Chao Yu
2017-03-09 23:58         ` Jaegeuk Kim

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.