mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lu Hongfei <luhongfei@vivo.com>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com, luhongfei@vivo.com
Subject: [PATCH] fs: btrfs: Optimize code execution process to save time
Date: Mon, 26 Jun 2023 18:07:16 +0800	[thread overview]
Message-ID: <20230626100716.18935-1-luhongfei@vivo.com> (raw)

Originally, the btrfs_check_data_free_space used round_down twice when
aligning the range, which to some extent increased the execution time of
the code.
After optimization, round_down only needs to be executed once, which can
improve code efficiency and increase code readability.

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
 fs/btrfs/delalloc-space.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
index 427abaf608b8..fd33b1cf1954 100644
--- a/fs/btrfs/delalloc-space.c
+++ b/fs/btrfs/delalloc-space.c
@@ -137,9 +137,8 @@ int btrfs_check_data_free_space(struct btrfs_inode *inode,
 	int ret;
 
 	/* align the range */
-	len = round_up(start + len, fs_info->sectorsize) -
-	      round_down(start, fs_info->sectorsize);
 	start = round_down(start, fs_info->sectorsize);
+	len = round_up(start + len, fs_info->sectorsize) - start;
 
 	if (noflush)
 		flush = BTRFS_RESERVE_NO_FLUSH;
-- 
2.39.0


             reply	other threads:[~2023-06-26 10:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 10:07 Lu Hongfei [this message]
2023-06-29 15:33 ` David Sterba
2023-07-10  1:35 ` kernel test robot

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=20230626100716.18935-1-luhongfei@vivo.com \
    --to=luhongfei@vivo.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=opensource.kernel@vivo.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

all inboxes | Powered by JetHome®