]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: remove the old bag implementation
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:19 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:42 +0000 (11:37 -0700)
Remove the old bag implementation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
repair/rmap.c
repair/slab.c
repair/slab.h

index 7cb3a315a5b3654e22ec342474a09b73b671fed9..553c7a6c3658a0a5e46ef1adf26e914f218a389a 100644 (file)
@@ -41,13 +41,6 @@ struct xfs_ag_rmap {
        int                     ar_flcount;
 };
 
-/* Only the parts of struct xfs_rmap_irec that we need to compute refcounts. */
-struct rmap_for_refcount {
-       xfs_agblock_t   rm_startblock;
-       xfs_extlen_t    rm_blockcount;
-       uint64_t        rm_owner;
-};
-
 static struct xfs_ag_rmap *ag_rmaps;
 bool rmapbt_suspect;
 static bool refcbt_suspect;
index 44ca0468eda2022c0a5005798d46603867c87c57..a0114ac23730f74f846ea9fa6c059417a003da61 100644 (file)
@@ -77,28 +77,6 @@ struct xfs_slab_cursor {
        struct xfs_slab_hdr_cursor      hcur[0];        /* per-slab cursors */
 };
 
-/*
- * Bags -- each bag is an array of record items; when a bag fills up, we resize
- * it and hope we don't run out of memory.
- */
-#define MIN_BAG_SIZE   4096
-struct xfs_bag {
-       uint64_t                bg_nr;          /* number of pointers */
-       uint64_t                bg_inuse;       /* number of slots in use */
-       char                    *bg_items;      /* pointer to block of items */
-       size_t                  bg_item_sz;     /* size of each item */
-};
-
-static inline void *bag_ptr(struct xfs_bag *bag, uint64_t idx)
-{
-       return &bag->bg_items[bag->bg_item_sz * idx];
-}
-
-static inline void *bag_end(struct xfs_bag *bag)
-{
-       return bag_ptr(bag, bag->bg_nr);
-}
-
 /*
  * Create a slab to hold some objects of a particular size.
  */
@@ -386,111 +364,3 @@ slab_count(
 {
        return slab->s_nr_items;
 }
-
-/*
- * Create a bag to point to some objects.
- */
-int
-init_bag(
-       struct xfs_bag  **bag,
-       size_t          item_sz)
-{
-       struct xfs_bag  *ptr;
-
-       ptr = calloc(1, sizeof(struct xfs_bag));
-       if (!ptr)
-               return -ENOMEM;
-       ptr->bg_item_sz = item_sz;
-       ptr->bg_items = calloc(MIN_BAG_SIZE, item_sz);
-       if (!ptr->bg_items) {
-               free(ptr);
-               return -ENOMEM;
-       }
-       ptr->bg_nr = MIN_BAG_SIZE;
-       *bag = ptr;
-       return 0;
-}
-
-/*
- * Free a bag of pointers.
- */
-void
-free_bag(
-       struct xfs_bag  **bag)
-{
-       struct xfs_bag  *ptr;
-
-       ptr = *bag;
-       if (!ptr)
-               return;
-       free(ptr->bg_items);
-       free(ptr);
-       *bag = NULL;
-}
-
-/*
- * Add an object to the pointer bag.
- */
-int
-bag_add(
-       struct xfs_bag  *bag,
-       void            *ptr)
-{
-       void            *p, *x;
-
-       p = bag_ptr(bag, bag->bg_inuse);
-       if (p == bag_end(bag)) {
-               /* No free space, alloc more pointers */
-               uint64_t        nr;
-
-               nr = bag->bg_nr * 2;
-               x = realloc(bag->bg_items, nr * bag->bg_item_sz);
-               if (!x)
-                       return -ENOMEM;
-               bag->bg_items = x;
-               memset(bag_end(bag), 0, bag->bg_nr * bag->bg_item_sz);
-               bag->bg_nr = nr;
-               p = bag_ptr(bag, bag->bg_inuse);
-       }
-       memcpy(p, ptr, bag->bg_item_sz);
-       bag->bg_inuse++;
-       return 0;
-}
-
-/*
- * Remove a pointer from a bag.
- */
-int
-bag_remove(
-       struct xfs_bag  *bag,
-       uint64_t        nr)
-{
-       ASSERT(nr < bag->bg_inuse);
-       memmove(bag_ptr(bag, nr), bag_ptr(bag, nr + 1),
-               (bag->bg_inuse - nr - 1) * bag->bg_item_sz);
-       bag->bg_inuse--;
-       return 0;
-}
-
-/*
- * Return the number of items in a bag.
- */
-uint64_t
-bag_count(
-       struct xfs_bag  *bag)
-{
-       return bag->bg_inuse;
-}
-
-/*
- * Return the nth item in a bag.
- */
-void *
-bag_item(
-       struct xfs_bag  *bag,
-       uint64_t        nr)
-{
-       if (nr >= bag->bg_inuse)
-               return NULL;
-       return bag_ptr(bag, nr);
-}
index 019b169024daaae04012aada4c1449014526ada7..77fb32163d5b1d223a0d337198b4f1b303b89899 100644 (file)
@@ -26,23 +26,4 @@ void *peek_slab_cursor(struct xfs_slab_cursor *cur);
 void advance_slab_cursor(struct xfs_slab_cursor *cur);
 void *pop_slab_cursor(struct xfs_slab_cursor *cur);
 
-struct xfs_bag;
-
-int init_bag(struct xfs_bag **bagp, size_t itemsz);
-void free_bag(struct xfs_bag **bagp);
-int bag_add(struct xfs_bag *bag, void *item);
-int bag_remove(struct xfs_bag *bag, uint64_t idx);
-uint64_t bag_count(struct xfs_bag *bag);
-void *bag_item(struct xfs_bag *bag, uint64_t idx);
-
-#define foreach_bag_ptr(bag, idx, ptr) \
-       for ((idx) = 0, (ptr) = bag_item((bag), (idx)); \
-            (idx) < bag_count(bag); \
-            (idx)++, (ptr) = bag_item((bag), (idx)))
-
-#define foreach_bag_ptr_reverse(bag, idx, ptr) \
-       for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \
-            (ptr) != NULL; \
-            (idx)--, (ptr) = bag_item((bag), (idx)))
-
 #endif /* SLAB_H_ */