ext4_dir_idx: make qsort as a default dir idx sort algorithm
authorgkostka <kostka.grzegorz@gmail.com>
Sat, 20 May 2017 07:23:54 +0000 (09:23 +0200)
committergkostka <kostka.grzegorz@gmail.com>
Sat, 20 May 2017 08:12:47 +0000 (10:12 +0200)
include/ext4_config.h
src/ext4_dir_idx.c

index 8b8c6d8a52e67b3d7474bcbcd4d85cf3478adedc..56cabf2fb6609f1753eb10818e246e076ad24c30 100644 (file)
@@ -88,11 +88,6 @@ extern "C" {
 #define CONFIG_JOURNALING_ENABLE 1
 #endif
 
-/**@brief   Enable directory indexing comb sort*/
-#ifndef CONFIG_DIR_INDEX_COMB_SORT
-#define CONFIG_DIR_INDEX_COMB_SORT 1
-#endif
-
 /**@brief   Include error codes from ext4_errno or standard library.*/
 #ifndef CONFIG_HAVE_OWN_ERRNO
 #define CONFIG_HAVE_OWN_ERRNO 0
index e1efa28fe0c9fb0564ff5c86d634577b654b7c79..b56e9fe0f961b777e4d7fe6a509a1e6664ebbd05 100644 (file)
@@ -830,42 +830,6 @@ cleanup:
        return rc;
 }
 
-#if CONFIG_DIR_INDEX_COMB_SORT
-#define SWAP_ENTRY(se1, se2)                                                   \
-       do {                                                                   \
-               struct ext4_dx_sort_entry tmp = se1;                           \
-               se1 = se2;                                                     \
-               se2 = tmp;                                                     \
-       \
-} while (0)
-
-static void comb_sort(struct ext4_dx_sort_entry *se, uint32_t count)
-{
-       struct ext4_dx_sort_entry *p, *q, *top = se + count - 1;
-       bool more;
-       /* Combsort */
-       while (count > 2) {
-               count = (count * 10) / 13;
-               if (count - 9 < 2)
-                       count = 11;
-               for (p = top, q = p - count; q >= se; p--, q--)
-                       if (p->hash < q->hash)
-                               SWAP_ENTRY(*p, *q);
-       }
-       /* Bubblesort */
-       do {
-               more = 0;
-               q = top;
-               while (q-- > se) {
-                       if (q[1].hash >= q[0].hash)
-                               continue;
-                       SWAP_ENTRY(*(q + 1), *q);
-                       more = 1;
-               }
-       } while (more);
-}
-#else
-
 /**@brief  Compare function used to pass in quicksort implementation.
  *         It can compare two entries by hash value.
  * @param arg1  First entry
@@ -888,7 +852,6 @@ static int ext4_dir_dx_entry_comparator(const void *arg1, const void *arg2)
        else
                return 1;
 }
-#endif
 
 /**@brief  Insert new index entry to block.
  *         Note that space for new entry must be checked by caller.
@@ -996,13 +959,9 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref,
                de = (void *)((uint8_t *)de + elen);
        }
 
-/* Sort all entries */
-#if CONFIG_DIR_INDEX_COMB_SORT
-       comb_sort(sort, idx);
-#else
        qsort(sort, idx, sizeof(struct ext4_dx_sort_entry),
              ext4_dir_dx_entry_comparator);
-#endif
+
        /* Allocate new block for store the second part of entries */
        ext4_fsblk_t new_fblock;
        uint32_t new_iblock;