[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230626100716.18935-1-luhongfei@vivo.com>
Date: Mon, 26 Jun 2023 18:07:16 +0800
From: Lu Hongfei <luhongfei@...o.com>
To: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com, luhongfei@...o.com
Subject: [PATCH] fs: btrfs: Optimize code execution process to save time
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@...o.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
Powered by blists - more mailing lists