]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - repair/incore_ino.c
libxfs: making passing flags to libxfs_init less confusing
[thirdparty/xfsprogs-dev.git] / repair / incore_ino.c
index fe41853b671e5c3cf7c9b10776e1d12a98a82f2b..0dd7a2f060fb40b274f5e2f4272278804f654448 100644 (file)
@@ -91,6 +91,7 @@ void add_inode_ref(struct ino_tree_node *irec, int ino_offset)
 {
        ASSERT(irec->ino_un.ex_data != NULL);
 
+       pthread_mutex_lock(&irec->lock);
        switch (irec->nlink_size) {
        case sizeof(uint8_t):
                if (irec->ino_un.ex_data->counted_nlinks.un8[ino_offset] < 0xff) {
@@ -112,6 +113,7 @@ void add_inode_ref(struct ino_tree_node *irec, int ino_offset)
        default:
                ASSERT(0);
        }
+       pthread_mutex_unlock(&irec->lock);
 }
 
 void drop_inode_ref(struct ino_tree_node *irec, int ino_offset)
@@ -120,6 +122,7 @@ void drop_inode_ref(struct ino_tree_node *irec, int ino_offset)
 
        ASSERT(irec->ino_un.ex_data != NULL);
 
+       pthread_mutex_lock(&irec->lock);
        switch (irec->nlink_size) {
        case sizeof(uint8_t):
                ASSERT(irec->ino_un.ex_data->counted_nlinks.un8[ino_offset] > 0);
@@ -139,6 +142,7 @@ void drop_inode_ref(struct ino_tree_node *irec, int ino_offset)
 
        if (refs == 0)
                irec->ino_un.ex_data->ino_reached &= ~IREC_MASK(ino_offset);
+       pthread_mutex_unlock(&irec->lock);
 }
 
 uint32_t num_inode_references(struct ino_tree_node *irec, int ino_offset)
@@ -161,6 +165,7 @@ uint32_t num_inode_references(struct ino_tree_node *irec, int ino_offset)
 void set_inode_disk_nlinks(struct ino_tree_node *irec, int ino_offset,
                uint32_t nlinks)
 {
+       pthread_mutex_lock(&irec->lock);
        switch (irec->nlink_size) {
        case sizeof(uint8_t):
                if (nlinks < 0xff) {
@@ -182,6 +187,7 @@ void set_inode_disk_nlinks(struct ino_tree_node *irec, int ino_offset,
        default:
                ASSERT(0);
        }
+       pthread_mutex_unlock(&irec->lock);
 }
 
 uint32_t get_inode_disk_nlinks(struct ino_tree_node *irec, int ino_offset)
@@ -205,7 +211,7 @@ alloc_ftypes_array(
 {
        uint8_t         *ptr;
 
-       if (!xfs_sb_version_hasftype(&mp->m_sb))
+       if (!xfs_has_ftype(mp))
                return NULL;
 
        ptr = calloc(XFS_INODES_PER_CHUNK, sizeof(*ptr));
@@ -253,6 +259,7 @@ alloc_ino_node(
        irec->nlink_size = sizeof(uint8_t);
        irec->disk_nlinks.un8 = alloc_nlink_array(irec->nlink_size);
        irec->ftypes = alloc_ftypes_array(mp);
+       pthread_mutex_init(&irec->lock, NULL);
        return irec;
 }
 
@@ -294,6 +301,7 @@ free_ino_tree_node(
        }
 
        free(irec->ftypes);
+       pthread_mutex_destroy(&irec->lock);
        free(irec);
 }
 
@@ -430,7 +438,7 @@ clear_uncertain_ino_cache(xfs_agnumber_t agno)
  * XFS_INODES_PER_CHUNK (64) inode chunk
  *
  * Each inode resides in a 64-inode chunk which can be part one or more chunks
- * (MAX(64, inodes-per-block).  The fs allocates in chunks (as opposed to 1
+ * (max(64, inodes-per-block).  The fs allocates in chunks (as opposed to 1
  * chunk) when a block can hold more than one chunk (inodes per block > 64).
  * Allocating in one chunk pieces causes us problems when it takes more than
  * one fs block to contain an inode chunk because the chunks can start on
@@ -535,7 +543,7 @@ set_inode_free_alloc(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agino_t ino)
        return(ino_rec);
 }
 
-void
+static void
 print_inode_list_int(xfs_agnumber_t agno, int uncertain)
 {
        ino_tree_node_t *ino_rec;
@@ -600,6 +608,7 @@ set_inode_parent(
        uint64_t                bitmask;
        parent_entry_t          *tmp;
 
+       pthread_mutex_lock(&irec->lock);
        if (full_ino_ex_data)
                ptbl = irec->ino_un.ex_data->parents;
        else
@@ -625,6 +634,7 @@ set_inode_parent(
 #endif
                ptbl->pentries[0] = parent;
 
+               pthread_mutex_unlock(&irec->lock);
                return;
        }
 
@@ -642,6 +652,7 @@ set_inode_parent(
 #endif
                ptbl->pentries[target] = parent;
 
+               pthread_mutex_unlock(&irec->lock);
                return;
        }
 
@@ -682,6 +693,7 @@ set_inode_parent(
 #endif
        ptbl->pentries[target] = parent;
        ptbl->pmask |= (1ULL << offset);
+       pthread_mutex_unlock(&irec->lock);
 }
 
 xfs_ino_t
@@ -692,6 +704,7 @@ get_inode_parent(ino_tree_node_t *irec, int offset)
        int             i;
        int             target;
 
+       pthread_mutex_lock(&irec->lock);
        if (full_ino_ex_data)
                ptbl = irec->ino_un.ex_data->parents;
        else
@@ -709,9 +722,11 @@ get_inode_parent(ino_tree_node_t *irec, int offset)
 #ifdef DEBUG
                ASSERT(target < ptbl->cnt);
 #endif
+               pthread_mutex_unlock(&irec->lock);
                return(ptbl->pentries[target]);
        }
 
+       pthread_mutex_unlock(&irec->lock);
        return(0LL);
 }
 
@@ -776,7 +791,7 @@ avl_ino_end(avlnode_t *node)
                XFS_INODES_PER_CHUNK));
 }
 
-avlops_t avl_ino_tree_ops = {
+static avlops_t avl_ino_tree_ops = {
        avl_ino_start,
        avl_ino_end
 };