Skip to content

Commit 57aff99

Browse files
committed
Merge tag 'ext4_for_linus-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "Cleanup ext4's multi-block allocator, including adding some unit tests, as well as cleaning how we update the backup superblock after online resizes or updating the label or uuid. Optimize handling of released data blocks in ext4's commit machinery to avoid a potential lock contention on s_md_lock spinlock. Fix a number of ext4 bugs: - fix race between writepages and remount - fix racy may inline data check in dio write - add missed brelse in an error path in update_backups - fix umask handling when ACL support is disabled - fix lost EIO error when a journal commit races with a fsync of the blockdev - fix potential improper i_size when there is a crash right after an O_SYNC direct write. - check extent node for validity before potentially using what might be an invalid pointer - fix potential stale data exposure when writing to an unwritten extent and the file system is nearly out of space - fix potential accounting error around block reservations when writing partial delayed allocation writes to a bigalloc cluster - avoid memory allocation failure when tracking partial delayed allocation writes to a bigalloc cluster - fix various debugging print messages" * tag 'ext4_for_linus-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (41 commits) ext4: properly sync file size update after O_SYNC direct IO ext4: fix racy may inline data check in dio write ext4: run mballoc test with different layouts setting ext4: add first unit test for ext4_mb_new_blocks_simple in mballoc ext4: add some kunit stub for mballoc kunit test ext4: call ext4_mb_mark_context in ext4_group_add_blocks() ext4: Separate block bitmap and buddy bitmap freeing in ext4_group_add_blocks() ext4: call ext4_mb_mark_context in ext4_mb_clear_bb ext4: Separate block bitmap and buddy bitmap freeing in ext4_mb_clear_bb() ext4: call ext4_mb_mark_context in ext4_mb_mark_diskspace_used ext4: extend ext4_mb_mark_context to support allocation under journal ext4: call ext4_mb_mark_context in ext4_free_blocks_simple ext4: factor out codes to update block bitmap and group descriptor on disk from ext4_mb_mark_bb ext4: make state in ext4_mb_mark_bb to be bool jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev ext4: apply umask if ACL support is disabled ext4: mark buffer new if it is unwritten to avoid stale data exposure ext4: move 'ix' sanity check to corrent position jbd2: fix printk format type for 'io_block' in do_one_pass() jbd2: print io_block if check data block checksum failed when do recovery ...
2 parents 91a683c + 9156289 commit 57aff99

File tree

14 files changed

+823
-585
lines changed

14 files changed

+823
-585
lines changed

fs/ext4/acl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
6868
static inline int
6969
ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
7070
{
71+
/* usually, the umask is applied by posix_acl_create(), but if
72+
ext4 ACL support is disabled at compile time, we need to do
73+
it here, because posix_acl_create() will never be called */
74+
inode->i_mode &= ~current_umask();
75+
7176
return 0;
7277
}
7378
#endif /* CONFIG_EXT4_FS_POSIX_ACL */

fs/ext4/balloc.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mballoc.h"
2323

2424
#include <trace/events/ext4.h>
25+
#include <kunit/static_stub.h>
2526

2627
static unsigned ext4_num_base_meta_clusters(struct super_block *sb,
2728
ext4_group_t block_group);
@@ -111,10 +112,8 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
111112
itbl_blk_start = ext4_inode_table(sb, gdp);
112113
itbl_blk_end = itbl_blk_start + sbi->s_itb_per_group - 1;
113114
if (itbl_blk_start <= end && itbl_blk_end >= start) {
114-
itbl_blk_start = itbl_blk_start >= start ?
115-
itbl_blk_start : start;
116-
itbl_blk_end = itbl_blk_end <= end ?
117-
itbl_blk_end : end;
115+
itbl_blk_start = max(itbl_blk_start, start);
116+
itbl_blk_end = min(itbl_blk_end, end);
118117

119118
itbl_cluster_start = EXT4_B2C(sbi, itbl_blk_start - start);
120119
itbl_cluster_end = EXT4_B2C(sbi, itbl_blk_end - start);
@@ -274,6 +273,9 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
274273
struct ext4_sb_info *sbi = EXT4_SB(sb);
275274
struct buffer_head *bh_p;
276275

276+
KUNIT_STATIC_STUB_REDIRECT(ext4_get_group_desc,
277+
sb, block_group, bh);
278+
277279
if (block_group >= ngroups) {
278280
ext4_error(sb, "block_group >= groups_count - block_group = %u,"
279281
" groups_count = %u", block_group, ngroups);
@@ -468,6 +470,9 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group,
468470
ext4_fsblk_t bitmap_blk;
469471
int err;
470472

473+
KUNIT_STATIC_STUB_REDIRECT(ext4_read_block_bitmap_nowait,
474+
sb, block_group, ignore_locked);
475+
471476
desc = ext4_get_group_desc(sb, block_group, NULL);
472477
if (!desc)
473478
return ERR_PTR(-EFSCORRUPTED);
@@ -563,6 +568,9 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
563568
{
564569
struct ext4_group_desc *desc;
565570

571+
KUNIT_STATIC_STUB_REDIRECT(ext4_wait_block_bitmap,
572+
sb, block_group, bh);
573+
566574
if (!buffer_new(bh))
567575
return 0;
568576
desc = ext4_get_group_desc(sb, block_group, NULL);

fs/ext4/ext4.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ struct ext4_sb_info {
15041504
loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
15051505
struct buffer_head * s_sbh; /* Buffer containing the super block */
15061506
struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */
1507+
/* Array of bh's for the block group descriptors */
15071508
struct buffer_head * __rcu *s_group_desc;
15081509
unsigned int s_mount_opt;
15091510
unsigned int s_mount_opt2;
@@ -1574,7 +1575,7 @@ struct ext4_sb_info {
15741575
unsigned int *s_mb_maxs;
15751576
unsigned int s_group_info_size;
15761577
unsigned int s_mb_free_pending;
1577-
struct list_head s_freed_data_list; /* List of blocks to be freed
1578+
struct list_head s_freed_data_list[2]; /* List of blocks to be freed
15781579
after commit completed */
15791580
struct list_head s_discard_list;
15801581
struct work_struct s_discard_work;
@@ -1686,7 +1687,8 @@ struct ext4_sb_info {
16861687

16871688
/*
16881689
* Barrier between writepages ops and changing any inode's JOURNAL_DATA
1689-
* or EXTENTS flag.
1690+
* or EXTENTS flag or between writepages ops and changing DELALLOC or
1691+
* DIOREAD_NOLOCK mount options on remount.
16901692
*/
16911693
struct percpu_rw_semaphore s_writepages_rwsem;
16921694
struct dax_device *s_daxdev;
@@ -2934,7 +2936,7 @@ extern int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
29342936
extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
29352937
extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid);
29362938
extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,
2937-
int len, int state);
2939+
int len, bool state);
29382940
static inline bool ext4_mb_cr_expensive(enum criteria cr)
29392941
{
29402942
return cr >= CR_GOAL_LEN_SLOW;

fs/ext4/extents.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,11 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
10101010
ix = curp->p_idx;
10111011
}
10121012

1013+
if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) {
1014+
EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!");
1015+
return -EFSCORRUPTED;
1016+
}
1017+
10131018
len = EXT_LAST_INDEX(curp->p_hdr) - ix + 1;
10141019
BUG_ON(len < 0);
10151020
if (len > 0) {
@@ -1019,11 +1024,6 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
10191024
memmove(ix + 1, ix, len * sizeof(struct ext4_extent_idx));
10201025
}
10211026

1022-
if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) {
1023-
EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!");
1024-
return -EFSCORRUPTED;
1025-
}
1026-
10271027
ix->ei_block = cpu_to_le32(logical);
10281028
ext4_idx_store_pblock(ix, ptr);
10291029
le16_add_cpu(&curp->p_hdr->eh_entries, 1);
@@ -6081,13 +6081,13 @@ int ext4_ext_clear_bb(struct inode *inode)
60816081
for (j = 0; j < path->p_depth; j++) {
60826082

60836083
ext4_mb_mark_bb(inode->i_sb,
6084-
path[j].p_block, 1, 0);
6084+
path[j].p_block, 1, false);
60856085
ext4_fc_record_regions(inode->i_sb, inode->i_ino,
60866086
0, path[j].p_block, 1, 1);
60876087
}
60886088
ext4_free_ext_path(path);
60896089
}
6090-
ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0);
6090+
ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, false);
60916091
ext4_fc_record_regions(inode->i_sb, inode->i_ino,
60926092
map.m_lblk, map.m_pblk, map.m_len, 1);
60936093
}

0 commit comments

Comments
 (0)