aboutsummaryrefslogtreecommitdiffstats
path: root/e2fsck
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2023-01-27 12:42:47 -0500
committerTheodore Ts'o <tytso@mit.edu>2023-01-27 12:42:47 -0500
commit8f4f9f0ec5bd53973043bced10e57b471db32632 (patch)
tree77b0d63c1ef23c9730c2c67a685534e5bc8cc2a1 /e2fsck
parentd37a9f1818fa04fc91a497b3541ed205804720af (diff)
parent9fd9c75204c5c1c021fa9911b787e62e9657802e (diff)
downloade2fsprogs-8f4f9f0ec5bd53973043bced10e57b471db32632.tar.gz
Merge branch 'maint' into next
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/dirinfo.c2
-rw-r--r--e2fsck/dx_dirinfo.c2
-rw-r--r--e2fsck/e2fsck.h2
-rw-r--r--e2fsck/jfs_user.h62
-rw-r--r--e2fsck/journal.c5
-rw-r--r--e2fsck/pass1.c2
-rw-r--r--e2fsck/pass1b.c73
-rw-r--r--e2fsck/pass2.c2
-rw-r--r--e2fsck/rehash.c10
9 files changed, 68 insertions, 92 deletions
diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c
index 49d624c57..9873e3854 100644
--- a/e2fsck/dirinfo.c
+++ b/e2fsck/dirinfo.c
@@ -376,7 +376,7 @@ void e2fsck_dir_info_iter_end(e2fsck_t ctx EXT2FS_ATTR((unused)),
}
/*
- * A simple interator function
+ * A simple iterator function
*/
struct dir_info *e2fsck_dir_info_iter(e2fsck_t ctx, struct dir_info_iter *iter)
{
diff --git a/e2fsck/dx_dirinfo.c b/e2fsck/dx_dirinfo.c
index caca3e307..4b764b0f6 100644
--- a/e2fsck/dx_dirinfo.c
+++ b/e2fsck/dx_dirinfo.c
@@ -143,7 +143,7 @@ ext2_ino_t e2fsck_get_num_dx_dirinfo(e2fsck_t ctx)
}
/*
- * A simple interator function
+ * A simple iterator function
*/
struct dx_dir_info *e2fsck_dx_dir_info_iter(e2fsck_t ctx, ext2_ino_t *control)
{
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 252a17db2..3f2dc3084 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -236,7 +236,7 @@ typedef struct e2fsck_struct *e2fsck_t;
#define MAX_EXTENT_DEPTH_COUNT 8
/*
- * This strucutre is used to manage the list of extents in a file. Placing
+ * This structure is used to manage the list of extents in a file. Placing
* it here since this is used by fast_commit.h.
*/
struct extent_list {
diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h
index 969cd1b92..1167c80d3 100644
--- a/e2fsck/jfs_user.h
+++ b/e2fsck/jfs_user.h
@@ -82,16 +82,9 @@ struct kdev_s {
#define buffer_req(bh) 1
#define do_readahead(journal, start) do {} while (0)
-typedef struct kmem_cache {
- int object_length;
-} kmem_cache_t;
-
-#define kmem_cache_alloc(cache, flags) malloc((cache)->object_length)
-#define kmem_cache_free(cache, obj) free(obj)
-#define kmem_cache_create(name, len, a, b, c) do_cache_create(len)
-#define kmem_cache_destroy(cache) do_cache_destroy(cache)
-#define kmalloc(len, flags) malloc(len)
-#define kfree(p) free(p)
+struct kmem_cache {
+ unsigned int object_size;
+};
#define cond_resched() do { } while (0)
@@ -107,8 +100,16 @@ typedef struct kmem_cache {
* functions.
*/
#ifdef NO_INLINE_FUNCS
-extern kmem_cache_t *do_cache_create(int len);
-extern void do_cache_destroy(kmem_cache_t *cache);
+extern struct kmem_cache *kmem_cache_create(const char *name,
+ unsigned int size,
+ unsigned int align,
+ unsigned int flags,
+ void (*ctor)(void *));
+extern void kmem_cache_destroy(struct kmem_cache *s);
+extern void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags);
+extern void kmem_cache_free(struct kmem_cache *s, void *objp);
+extern void *kmalloc(size_t size, gfp_t flags);
+extern void kfree(const void *objp);
extern size_t journal_tag_bytes(journal_t *journal);
extern __u32 __hash_32(__u32 val);
extern __u32 hash_32(__u32 val, unsigned int bits);
@@ -139,19 +140,46 @@ extern void jbd2_descriptor_block_csum_set(journal_t *j,
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
-_INLINE_ kmem_cache_t *do_cache_create(int len)
+_INLINE_ struct kmem_cache *
+kmem_cache_create(const char *name EXT2FS_ATTR((unused)),
+ unsigned int size,
+ unsigned int align EXT2FS_ATTR((unused)),
+ unsigned int flags EXT2FS_ATTR((unused)),
+ void (*ctor)(void *) EXT2FS_ATTR((unused)))
{
- kmem_cache_t *new_cache;
+ struct kmem_cache *new_cache;
new_cache = malloc(sizeof(*new_cache));
if (new_cache)
- new_cache->object_length = len;
+ new_cache->object_size = size;
return new_cache;
}
-_INLINE_ void do_cache_destroy(kmem_cache_t *cache)
+_INLINE_ void kmem_cache_destroy(struct kmem_cache *s)
+{
+ free(s);
+}
+
+_INLINE_ void *kmem_cache_alloc(struct kmem_cache *cachep,
+ gfp_t flags EXT2FS_ATTR((unused)))
+{
+ return malloc(cachep->object_size);
+}
+
+_INLINE_ void kmem_cache_free(struct kmem_cache *s EXT2FS_ATTR((unused)),
+ void *objp)
+{
+ free(objp);
+}
+
+_INLINE_ void *kmalloc(size_t size, gfp_t flags EXT2FS_ATTR((unused)))
+{
+ return malloc(size);
+}
+
+_INLINE_ void kfree(const void *objp)
{
- free(cache);
+ free((void *)objp);
}
/* generic hashing taken from the Linux kernel */
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index d802c5e9f..c7868d894 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -888,7 +888,7 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
/*
* Mark the file system to indicate it contains errors. That's
* because the updates performed by fast commit replay code are
- * not atomic and may result in incosistent file system if it
+ * not atomic and may result in inconsistent file system if it
* crashes before the replay is complete.
*/
ctx->fs->super->s_state |= EXT2_ERROR_FS;
@@ -1039,7 +1039,8 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
tried_backup_jnl++;
}
if (!j_inode->i_ext2.i_links_count ||
- !LINUX_S_ISREG(j_inode->i_ext2.i_mode)) {
+ !LINUX_S_ISREG(j_inode->i_ext2.i_mode) ||
+ (j_inode->i_ext2.i_flags & EXT4_ENCRYPT_FL)) {
retval = EXT2_ET_NO_JOURNAL;
goto try_backup_journal;
}
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 73909c391..591acad53 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1331,7 +1331,7 @@ void e2fsck_pass1(e2fsck_t ctx)
goto endit;
}
block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 3,
- "block interate buffer");
+ "block iterate buffer");
if (EXT2_INODE_SIZE(fs->super) == EXT2_GOOD_OLD_INODE_SIZE)
e2fsck_use_inode_shortcuts(ctx, 1);
e2fsck_intercept_block_allocations(ctx);
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 92c746c1d..950af5be0 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -90,7 +90,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
struct dup_inode *dp, char *block_buf);
static errcode_t clone_file(e2fsck_t ctx, ext2_ino_t ino,
struct dup_inode *dp, char* block_buf);
-static int check_if_fs_block(e2fsck_t ctx, blk64_t test_block);
+static int check_if_fs_block(e2fsck_t ctx, blk64_t block);
static int check_if_fs_cluster(e2fsck_t ctx, blk64_t cluster);
static void pass1b(e2fsck_t ctx, char *block_buf);
@@ -815,8 +815,6 @@ static int clone_file_block(ext2_filsys fs,
should_write = 0;
c = EXT2FS_B2C(fs, blockcnt);
- if (check_if_fs_cluster(ctx, EXT2FS_B2C(fs, *block_nr)))
- is_meta = 1;
if (c == cs->dup_cluster && cs->alloc_block) {
new_block = cs->alloc_block;
@@ -894,6 +892,8 @@ cluster_alloc_ok:
return BLOCK_ABORT;
}
}
+ if (check_if_fs_cluster(ctx, EXT2FS_B2C(fs, *block_nr)))
+ is_meta = 1;
cs->save_dup_cluster = (is_meta ? NULL : p);
cs->save_blocknr = *block_nr;
*block_nr = new_block;
@@ -1021,37 +1021,9 @@ errout:
* This routine returns 1 if a block overlaps with one of the superblocks,
* group descriptors, inode bitmaps, or block bitmaps.
*/
-static int check_if_fs_block(e2fsck_t ctx, blk64_t test_block)
+static int check_if_fs_block(e2fsck_t ctx, blk64_t block)
{
- ext2_filsys fs = ctx->fs;
- blk64_t first_block;
- dgrp_t i;
-
- first_block = fs->super->s_first_data_block;
- for (i = 0; i < fs->group_desc_count; i++) {
-
- /* Check superblocks/block group descriptors */
- if (ext2fs_bg_has_super(fs, i)) {
- if (test_block >= first_block &&
- (test_block <= first_block + fs->desc_blocks))
- return 1;
- }
-
- /* Check the inode table */
- if ((ext2fs_inode_table_loc(fs, i)) &&
- (test_block >= ext2fs_inode_table_loc(fs, i)) &&
- (test_block < (ext2fs_inode_table_loc(fs, i) +
- fs->inode_blocks_per_group)))
- return 1;
-
- /* Check the bitmap blocks */
- if ((test_block == ext2fs_block_bitmap_loc(fs, i)) ||
- (test_block == ext2fs_inode_bitmap_loc(fs, i)))
- return 1;
-
- first_block += fs->super->s_blocks_per_group;
- }
- return 0;
+ return ext2fs_test_block_bitmap2(ctx->block_metadata_map, block);
}
/*
@@ -1061,37 +1033,14 @@ static int check_if_fs_block(e2fsck_t ctx, blk64_t test_block)
static int check_if_fs_cluster(e2fsck_t ctx, blk64_t cluster)
{
ext2_filsys fs = ctx->fs;
- blk64_t first_block;
- dgrp_t i;
-
- first_block = fs->super->s_first_data_block;
- for (i = 0; i < fs->group_desc_count; i++) {
-
- /* Check superblocks/block group descriptors */
- if (ext2fs_bg_has_super(fs, i)) {
- if (cluster >= EXT2FS_B2C(fs, first_block) &&
- (cluster <= EXT2FS_B2C(fs, first_block +
- fs->desc_blocks)))
- return 1;
- }
+ blk64_t block = EXT2FS_C2B(fs, cluster);
+ int i;
- /* Check the inode table */
- if ((ext2fs_inode_table_loc(fs, i)) &&
- (cluster >= EXT2FS_B2C(fs,
- ext2fs_inode_table_loc(fs, i))) &&
- (cluster <= EXT2FS_B2C(fs,
- ext2fs_inode_table_loc(fs, i) +
- fs->inode_blocks_per_group - 1)))
+ for (i = 0; i < EXT2FS_CLUSTER_RATIO(fs); i++) {
+ if (ext2fs_test_block_bitmap2(ctx->block_metadata_map,
+ block + i))
return 1;
-
- /* Check the bitmap blocks */
- if ((cluster == EXT2FS_B2C(fs,
- ext2fs_block_bitmap_loc(fs, i))) ||
- (cluster == EXT2FS_B2C(fs,
- ext2fs_inode_bitmap_loc(fs, i))))
- return 1;
-
- first_block += fs->super->s_blocks_per_group;
}
+
return 0;
}
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index bc6ffa182..410edd116 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1812,7 +1812,7 @@ struct del_block {
};
/*
- * This function is called to deallocate a block, and is an interator
+ * This function is called to deallocate a block, and is an iterator
* functioned called by deallocate inode via ext2fs_iterate_block().
*/
static int deallocate_inode_block(ext2_filsys fs,
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index f7b19f62f..c1da7d527 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -1053,13 +1053,11 @@ retry_nohash:
/* Sort the list */
resort:
if (fd.compress && fd.num_array > 1)
- sort_r_simple(fd.harray+2, fd.num_array-2,
- sizeof(struct hash_entry),
- hash_cmp, &name_cmp_ctx);
+ sort_r(fd.harray+2, fd.num_array-2, sizeof(struct hash_entry),
+ hash_cmp, &name_cmp_ctx);
else
- sort_r_simple(fd.harray, fd.num_array,
- sizeof(struct hash_entry),
- hash_cmp, &name_cmp_ctx);
+ sort_r(fd.harray, fd.num_array, sizeof(struct hash_entry),
+ hash_cmp, &name_cmp_ctx);
/*
* Look for duplicates