* [PATCH] libext2fs: speed up the max extent depth api call
@ 2014-12-15 6:37 Darrick J. Wong
2014-12-15 17:29 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2014-12-15 6:37 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: linux-ext4
The maximum extent tree depth really only depends on the filesystem
block size, so cache the last result if possible.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
lib/ext2fs/extent.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index b1130f6..19f38fd 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -1725,9 +1725,16 @@ size_t ext2fs_max_extent_depth(ext2_extent_handle_t handle)
size_t extents_per_block = (handle->fs->blocksize -
sizeof(struct ext3_extent_header)) /
sizeof(struct ext3_extent);
+ static unsigned int last_blocksize = 0;
+ static size_t last_result = 0;
- return 1 + ((ul_log2(EXT_MAX_EXTENT_LBLK) - ul_log2(iblock_extents)) /
+ if (last_blocksize && last_blocksize == handle->fs->blocksize)
+ return last_result;
+
+ last_result = 1 + ((ul_log2(EXT_MAX_EXTENT_LBLK) - ul_log2(iblock_extents)) /
ul_log2(extents_per_block));
+ last_blocksize = handle->fs->blocksize;
+ return last_result;
}
#ifdef DEBUG
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libext2fs: speed up the max extent depth api call
2014-12-15 6:37 [PATCH] libext2fs: speed up the max extent depth api call Darrick J. Wong
@ 2014-12-15 17:29 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2014-12-15 17:29 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-ext4
On Sun, Dec 14, 2014 at 10:37:45PM -0800, Darrick J. Wong wrote:
> The maximum extent tree depth really only depends on the filesystem
> block size, so cache the last result if possible.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-15 17:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-15 6:37 [PATCH] libext2fs: speed up the max extent depth api call Darrick J. Wong
2014-12-15 17:29 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).