All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fan Li <fanofcode.li@samsung.com>
To: 'Chao Yu' <yuchao0@huawei.com>, jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH] f2fs: optimize __update_nat_bits
Date: Mon, 30 Oct 2017 15:19:48 +0800	[thread overview]
Message-ID: <000e01d3514f$a93addf0$fbb099d0$@samsung.com> (raw)
In-Reply-To: CGME20171030072058epcas2p153d0b5c921ea4d3f3da6c6fd9baa5124@epcas2p1.samsung.com

Make three modification for __update_nat_bits:
1. Take the codes of dealing the nat with nid 0 out of the loop
    Such nat only needs to be dealt with once at beginning.
2. Use " nat_index == 0" instead of " start_nid == 0" to decide if it's the first nat block
    It's better that we don't assume @start_nid is the first nid of the nat block it's in.
3. Use " if (nat_blk->entries[i].block_addr != NULL_ADDR)" to explicitly comfirm the value of block_addr
    use constant to make sure the codes is right, even if the value of NULL_ADDR changes.

Signed-off-by: Fan li <fanofcode.li@samsung.com>
---
 fs/f2fs/node.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index ac629d6..b97a031 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2407,15 +2407,17 @@ static void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid,
        unsigned int nat_index = start_nid / NAT_ENTRY_PER_BLOCK;
        struct f2fs_nat_block *nat_blk = page_address(page);
        int valid = 0;
-       int i;
+       int i = 0;

        if (!enabled_nat_bits(sbi, NULL))
                return;

-       for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) {
-               if (start_nid == 0 && i == 0)
-                       valid++;
-               if (nat_blk->entries[i].block_addr)
+       if (nat_index == 0) {
+               valid = 1;
+               i = 1;
+       }
+       for (; i < NAT_ENTRY_PER_BLOCK; i++) {
+               if (nat_blk->entries[i].block_addr != NULL_ADDR)
                        valid++;
        }
        if (valid == 0) {
--
2.7.4

       reply	other threads:[~2017-10-30  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171030072058epcas2p153d0b5c921ea4d3f3da6c6fd9baa5124@epcas2p1.samsung.com>
2017-10-30  7:19 ` Fan Li [this message]
2017-10-30  9:39   ` [PATCH] f2fs: optimize __update_nat_bits Chao Yu
2017-10-30  9:39     ` [f2fs-dev] " Chao Yu

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='000e01d3514f$a93addf0$fbb099d0$@samsung.com' \
    --to=fanofcode.li@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.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.