|
Kmods SIG |
8b815c |
From ef9297007e9904588682699e618c56401f61d1c2 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
8b815c |
From: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
8b815c |
Date: Thu, 2 Sep 2021 18:40:49 +0300
|
|
Kmods SIG |
8b815c |
Subject: [Backport ef9297007e99] src: Make binary search to search
|
|
Kmods SIG |
8b815c |
smaller chunks in beginning
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
We could try to optimize algorithm to first fill just small table and
|
|
Kmods SIG |
8b815c |
after that use bigger table all the way up to ARRAY_SIZE(offs). This
|
|
Kmods SIG |
8b815c |
way we can use bigger search array, but not lose benefits with entry
|
|
Kmods SIG |
8b815c |
count smaller < ARRAY_SIZE(offs).
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
|
|
Kmods SIG |
8b815c |
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
|
Kmods SIG |
8b815c |
---
|
|
Kmods SIG |
8b815c |
src/index.c | 7 +++++--
|
|
Kmods SIG |
8b815c |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
diff --git a/src/index.c b/src/index.c
|
|
Kmods SIG |
8b815c |
index a16256ab3e9ffd5bcc660c602194c9bd2de7cfc9..3ad1ee608e531ea7c7793e691fe706ee0a6c33a4 100644
|
|
Kmods SIG |
8b815c |
--- a/src/index.c
|
|
Kmods SIG |
8b815c |
+++ b/src/index.c
|
|
Kmods SIG |
8b815c |
@@ -8,6 +8,7 @@
|
|
Kmods SIG |
8b815c |
#include <linux/blkdev.h>
|
|
Kmods SIG |
8b815c |
#include <linux/buffer_head.h>
|
|
Kmods SIG |
8b815c |
#include <linux/fs.h>
|
|
Kmods SIG |
8b815c |
+#include <linux/kernel.h>
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
#include "debug.h"
|
|
Kmods SIG |
8b815c |
#include "ntfs.h"
|
|
Kmods SIG |
8b815c |
@@ -679,8 +680,9 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
|
|
Kmods SIG |
8b815c |
#ifdef NTFS3_INDEX_BINARY_SEARCH
|
|
Kmods SIG |
8b815c |
struct NTFS_DE *found = NULL;
|
|
Kmods SIG |
8b815c |
int min_idx = 0, mid_idx, max_idx = 0;
|
|
Kmods SIG |
8b815c |
+ int table_size = 8;
|
|
Kmods SIG |
8b815c |
int diff2;
|
|
Kmods SIG |
8b815c |
- u16 offs[64];
|
|
Kmods SIG |
8b815c |
+ u16 offs[128];
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
if (end > 0x10000)
|
|
Kmods SIG |
8b815c |
goto next;
|
|
Kmods SIG |
8b815c |
@@ -700,7 +702,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
|
|
Kmods SIG |
8b815c |
off += e_size;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
max_idx++;
|
|
Kmods SIG |
8b815c |
- if (max_idx < ARRAY_SIZE(offs))
|
|
Kmods SIG |
8b815c |
+ if (max_idx < table_size)
|
|
Kmods SIG |
8b815c |
goto fill_table;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
max_idx--;
|
|
Kmods SIG |
8b815c |
@@ -718,6 +720,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
|
|
Kmods SIG |
8b815c |
return NULL;
|
|
Kmods SIG |
8b815c |
|
|
Kmods SIG |
8b815c |
max_idx = 0;
|
|
Kmods SIG |
8b815c |
+ table_size = min(table_size * 2, 128);
|
|
Kmods SIG |
8b815c |
goto fill_table;
|
|
Kmods SIG |
8b815c |
}
|
|
Kmods SIG |
8b815c |
} else if (diff2 < 0) {
|
|
Kmods SIG |
8b815c |
--
|
|
Kmods SIG |
8b815c |
2.31.1
|
|
Kmods SIG |
8b815c |
|