Skip to contentSkip to conversation

f2fs: adjust the way of calculating nat block

PATCH In review Fan Li 3 participants 5 messages Mar 8, 2017 – Mar 9, 2017 1 message not in the archive F2FS file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20170308054010epcas5p1873bf561bd7ceac17a63a6e6cebb8365@epcas5p1.samsung.com

Fan Li

author
#1 lore raw

PATCH 1/1 f2fs: adjust the way of calculating nat block

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

---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/node.h +1 -3
index 2f9603f..f9fb5b8 100644
@@ -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

maintainer
#2 lore raw
Quoted 13 lines · Fan Li

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

---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/node.h +0 -0
index 2f9603f..f9fb5b8 100644
@@ -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);

fs/f2fs/node.h static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) · line 207

Quoted 10 lines
fs/f2fs/node.h +1 -3
        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,

Quoted 5 lines
fs/f2fs/node.h +0 -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

author
#3 lore raw
Quoted 27 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Thursday, March 09, 2017 5:56 AM
To: Fan Li
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block

Quoted 17 lines · Fan Li

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

---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/node.h index 2f9603f..f9fb5b8 renamed from fs/f2fs/node.h +0 -0

100644

fs/f2fs/node.h +0 -1
@@ -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;
 
Quoted 8 lines

fs/f2fs/node.h static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) · line 207

Quoted 6 lines
fs/f2fs/node.h +1 -2
        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.

Quoted 8 lines

Thanks,

Quoted 5 lines
fs/f2fs/node.h +0 -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

#4 lore raw
Quoted 36 lines · Fan Li
Quoted 27 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Thursday, March 09, 2017 5:56 AM
To: Fan Li
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block

Quoted 17 lines · Fan Li

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

---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/node.h index 2f9603f..f9fb5b8 renamed from fs/f2fs/node.h +0 -0

100644

fs/f2fs/node.h +0 -1
@@ -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;
 
Quoted 8 lines

fs/f2fs/node.h static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) · line 207

Quoted 6 lines
fs/f2fs/node.h +1 -2
        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.

Quoted 4 lines

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,

Quoted 13 lines
Quoted 10 lines

Thanks,

Quoted 5 lines
fs/f2fs/node.h +0 -1
                (block_off & (sbi->blocks_per_seg - 1)));
 
        if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
--

2.7.4

Quoted 12 lines

------------------------------------------------------------------------------
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 [email protected]
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

maintainer
#5 lore raw
Quoted 42 lines · Chao Yu
Quoted 36 lines · Fan Li
Quoted 27 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Thursday, March 09, 2017 5:56 AM
To: Fan Li
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: adjust the way of calculating nat block

Quoted 17 lines · Fan Li

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

---
 fs/f2fs/node.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/f2fs/node.h index 2f9603f..f9fb5b8 renamed from fs/f2fs/node.h +0 -0

100644

fs/f2fs/node.h +0 -1
@@ -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;
 
Quoted 8 lines

fs/f2fs/node.h static inline pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) · line 207

Quoted 6 lines
fs/f2fs/node.h +1 -2
        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.

Quoted 4 lines

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.

Quoted 4 lines

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,

Quoted 33 lines

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,

Quoted 13 lines
Quoted 10 lines

Thanks,

Quoted 5 lines
fs/f2fs/node.h +0 -1
                (block_off & (sbi->blocks_per_seg - 1)));
 
        if (f2fs_test_bit(block_off, nm_i->nat_bitmap))
--

2.7.4

Quoted 12 lines

------------------------------------------------------------------------------
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 [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Quoted 10 lines

------------------------------------------------------------------------------
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 [email protected]
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