mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: btrfs: Optimize code execution process to save time
@ 2023-06-26 10:07 Lu Hongfei
  2023-06-29 15:33 ` David Sterba
  2023-07-10  1:35 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Lu Hongfei @ 2023-06-26 10:07 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-kernel
  Cc: opensource.kernel, luhongfei

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


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

end of thread, other threads:[~2023-07-10  1:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 10:07 [PATCH] fs: btrfs: Optimize code execution process to save time Lu Hongfei
2023-06-29 15:33 ` David Sterba
2023-07-10  1:35 ` kernel test robot

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®