Skip to content

Commit 7991c92

Browse files
committed
Merge tag 'ext4_for_linus-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: - more folio conversion patches - add support for FS_IOC_GETFSSYSFSPATH - mballoc cleaups and add more kunit tests - sysfs cleanups and bug fixes - miscellaneous bug fixes and cleanups * tag 'ext4_for_linus-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (40 commits) ext4: fix error pointer dereference in ext4_mb_load_buddy_gfp() jbd2: add prefix 'jbd2' for 'shrink_type' jbd2: use shrink_type type instead of bool type for __jbd2_journal_clean_checkpoint_list() ext4: fix uninitialized ratelimit_state->lock access in __ext4_fill_super() ext4: remove calls to to set/clear the folio error flag ext4: propagate errors from ext4_sb_bread() in ext4_xattr_block_cache_find() ext4: fix mb_cache_entry's e_refcnt leak in ext4_xattr_block_cache_find() jbd2: remove redundant assignement to variable err ext4: remove the redundant folio_wait_stable() ext4: fix potential unnitialized variable ext4: convert ac_buddy_page to ac_buddy_folio ext4: convert ac_bitmap_page to ac_bitmap_folio ext4: convert ext4_mb_init_cache() to take a folio ext4: convert bd_buddy_page to bd_buddy_folio ext4: convert bd_bitmap_page to bd_bitmap_folio ext4: open coding repeated check in next_linear_group ext4: use correct criteria name instead stale integer number in comment ext4: call ext4_mb_mark_free_simple to free continuous bits in found chunk ext4: add test_mb_mark_used_cost to estimate cost of mb_mark_used ext4: keep "prefetch_grp" and "nr" consistent ...
2 parents 61ea647 + c6a6c96 commit 7991c92

File tree

19 files changed

+481
-363
lines changed

19 files changed

+481
-363
lines changed

fs/ext4/acl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ 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-
7671
return 0;
7772
}
7873
#endif /* CONFIG_EXT4_FS_POSIX_ACL */

fs/ext4/ext4.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ enum criteria {
213213
#define EXT4_MB_USE_RESERVED 0x2000
214214
/* Do strict check for free blocks while retrying block allocation */
215215
#define EXT4_MB_STRICT_CHECK 0x4000
216-
/* Large fragment size list lookup succeeded at least once for cr = 0 */
216+
/* Large fragment size list lookup succeeded at least once for
217+
* CR_POWER2_ALIGNED */
217218
#define EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED 0x8000
218-
/* Avg fragment size rb tree lookup succeeded at least once for cr = 1 */
219+
/* Avg fragment size rb tree lookup succeeded at least once for
220+
* CR_GOAL_LEN_FAST */
219221
#define EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED 0x00010000
220-
/* Avg fragment size rb tree lookup succeeded at least once for cr = 1.5 */
222+
/* Avg fragment size rb tree lookup succeeded at least once for
223+
* CR_BEST_AVAIL_LEN */
221224
#define EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED 0x00020000
222225

223226
struct ext4_allocation_request {

fs/ext4/extents.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3402,9 +3402,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
34023402
struct ext4_extent *ex, *abut_ex;
34033403
ext4_lblk_t ee_block, eof_block;
34043404
unsigned int ee_len, depth, map_len = map->m_len;
3405-
int allocated = 0, max_zeroout = 0;
34063405
int err = 0;
34073406
int split_flag = EXT4_EXT_DATA_VALID2;
3407+
int allocated = 0;
3408+
unsigned int max_zeroout = 0;
34083409

34093410
ext_debug(inode, "logical block %llu, max_blocks %u\n",
34103411
(unsigned long long)map->m_lblk, map_len);

fs/ext4/file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,7 @@ static int ext4_sample_last_mounted(struct super_block *sb,
844844
if (err)
845845
goto out_journal;
846846
lock_buffer(sbi->s_sbh);
847-
strncpy(sbi->s_es->s_last_mounted, cp,
848-
sizeof(sbi->s_es->s_last_mounted));
847+
strtomem_pad(sbi->s_es->s_last_mounted, cp, 0);
849848
ext4_superblock_csum_set(sb);
850849
unlock_buffer(sbi->s_sbh);
851850
ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
@@ -885,7 +884,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
885884
return ret;
886885
}
887886

888-
filp->f_mode |= FMODE_NOWAIT;
887+
filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
889888
return dquot_file_open(inode, filp);
890889
}
891890

fs/ext4/inode.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ static int mpage_submit_folio(struct mpage_da_data *mpd, struct folio *folio)
18651865
len = folio_size(folio);
18661866
if (folio_pos(folio) + len > size &&
18671867
!ext4_verity_in_progress(mpd->inode))
1868-
len = size & ~PAGE_MASK;
1868+
len = size & (len - 1);
18691869
err = ext4_bio_write_folio(&mpd->io_submit, folio, len);
18701870
if (!err)
18711871
mpd->wbc->nr_to_write--;
@@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle,
23342334

23352335
if (folio_pos(folio) + len > size &&
23362336
!ext4_verity_in_progress(inode))
2337-
len = size - folio_pos(folio);
2337+
len = size & (len - 1);
23382338

23392339
return ext4_journal_folio_buffers(handle, folio, len);
23402340
}
@@ -2887,9 +2887,6 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
28872887
if (IS_ERR(folio))
28882888
return PTR_ERR(folio);
28892889

2890-
/* In case writeback began while the folio was unlocked */
2891-
folio_wait_stable(folio);
2892-
28932890
#ifdef CONFIG_FS_ENCRYPTION
28942891
ret = ext4_block_write_begin(folio, pos, len, ext4_da_get_block_prep);
28952892
#else
@@ -3530,7 +3527,6 @@ static const struct address_space_operations ext4_aops = {
35303527
.bmap = ext4_bmap,
35313528
.invalidate_folio = ext4_invalidate_folio,
35323529
.release_folio = ext4_release_folio,
3533-
.direct_IO = noop_direct_IO,
35343530
.migrate_folio = buffer_migrate_folio,
35353531
.is_partially_uptodate = block_is_partially_uptodate,
35363532
.error_remove_folio = generic_error_remove_folio,
@@ -3547,7 +3543,6 @@ static const struct address_space_operations ext4_journalled_aops = {
35473543
.bmap = ext4_bmap,
35483544
.invalidate_folio = ext4_journalled_invalidate_folio,
35493545
.release_folio = ext4_release_folio,
3550-
.direct_IO = noop_direct_IO,
35513546
.migrate_folio = buffer_migrate_folio_norefs,
35523547
.is_partially_uptodate = block_is_partially_uptodate,
35533548
.error_remove_folio = generic_error_remove_folio,
@@ -3564,7 +3559,6 @@ static const struct address_space_operations ext4_da_aops = {
35643559
.bmap = ext4_bmap,
35653560
.invalidate_folio = ext4_invalidate_folio,
35663561
.release_folio = ext4_release_folio,
3567-
.direct_IO = noop_direct_IO,
35683562
.migrate_folio = buffer_migrate_folio,
35693563
.is_partially_uptodate = block_is_partially_uptodate,
35703564
.error_remove_folio = generic_error_remove_folio,
@@ -3573,7 +3567,6 @@ static const struct address_space_operations ext4_da_aops = {
35733567

35743568
static const struct address_space_operations ext4_dax_aops = {
35753569
.writepages = ext4_dax_writepages,
3576-
.direct_IO = noop_direct_IO,
35773570
.dirty_folio = noop_dirty_folio,
35783571
.bmap = ext4_bmap,
35793572
.swap_activate = ext4_iomap_swap_activate,

fs/ext4/ioctl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,8 @@ static int ext4_ioctl_getlabel(struct ext4_sb_info *sbi, char __user *user_label
11501150
*/
11511151
BUILD_BUG_ON(EXT4_LABEL_MAX >= FSLABEL_MAX);
11521152

1153-
memset(label, 0, sizeof(label));
11541153
lock_buffer(sbi->s_sbh);
1155-
strncpy(label, sbi->s_es->s_volume_name, EXT4_LABEL_MAX);
1154+
strscpy_pad(label, sbi->s_es->s_volume_name);
11561155
unlock_buffer(sbi->s_sbh);
11571156

11581157
if (copy_to_user(user_label, label, sizeof(label)))

fs/ext4/mballoc-test.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,31 @@ struct mbt_ext4_super_block {
3030
#define MBT_CTX(_sb) (&MBT_SB(_sb)->mbt_ctx)
3131
#define MBT_GRP_CTX(_sb, _group) (&MBT_CTX(_sb)->grp_ctx[_group])
3232

33+
static struct inode *mbt_alloc_inode(struct super_block *sb)
34+
{
35+
struct ext4_inode_info *ei;
36+
37+
ei = kmalloc(sizeof(struct ext4_inode_info), GFP_KERNEL);
38+
if (!ei)
39+
return NULL;
40+
41+
INIT_LIST_HEAD(&ei->i_orphan);
42+
init_rwsem(&ei->xattr_sem);
43+
init_rwsem(&ei->i_data_sem);
44+
inode_init_once(&ei->vfs_inode);
45+
ext4_fc_init_inode(&ei->vfs_inode);
46+
47+
return &ei->vfs_inode;
48+
}
49+
50+
static void mbt_free_inode(struct inode *inode)
51+
{
52+
kfree(EXT4_I(inode));
53+
}
54+
3355
static const struct super_operations mbt_sops = {
56+
.alloc_inode = mbt_alloc_inode,
57+
.free_inode = mbt_free_inode,
3458
};
3559

3660
static void mbt_kill_sb(struct super_block *sb)
@@ -859,6 +883,56 @@ static void test_mb_free_blocks(struct kunit *test)
859883
ext4_mb_unload_buddy(&e4b);
860884
}
861885

886+
#define COUNT_FOR_ESTIMATE 100000
887+
static void test_mb_mark_used_cost(struct kunit *test)
888+
{
889+
struct ext4_buddy e4b;
890+
struct super_block *sb = (struct super_block *)test->priv;
891+
struct ext4_free_extent ex;
892+
int ret;
893+
struct test_range ranges[TEST_RANGE_COUNT];
894+
int i, j;
895+
unsigned long start, end, all = 0;
896+
897+
/* buddy cache assumes that each page contains at least one block */
898+
if (sb->s_blocksize > PAGE_SIZE)
899+
kunit_skip(test, "blocksize exceeds pagesize");
900+
901+
ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);
902+
KUNIT_ASSERT_EQ(test, ret, 0);
903+
904+
ex.fe_group = TEST_GOAL_GROUP;
905+
for (j = 0; j < COUNT_FOR_ESTIMATE; j++) {
906+
mbt_generate_test_ranges(sb, ranges, TEST_RANGE_COUNT);
907+
start = jiffies;
908+
for (i = 0; i < TEST_RANGE_COUNT; i++) {
909+
if (ranges[i].len == 0)
910+
continue;
911+
912+
ex.fe_start = ranges[i].start;
913+
ex.fe_len = ranges[i].len;
914+
ext4_lock_group(sb, TEST_GOAL_GROUP);
915+
mb_mark_used(&e4b, &ex);
916+
ext4_unlock_group(sb, TEST_GOAL_GROUP);
917+
}
918+
end = jiffies;
919+
all += (end - start);
920+
921+
for (i = 0; i < TEST_RANGE_COUNT; i++) {
922+
if (ranges[i].len == 0)
923+
continue;
924+
925+
ext4_lock_group(sb, TEST_GOAL_GROUP);
926+
mb_free_blocks(NULL, &e4b, ranges[i].start,
927+
ranges[i].len);
928+
ext4_unlock_group(sb, TEST_GOAL_GROUP);
929+
}
930+
}
931+
932+
kunit_info(test, "costed jiffies %lu\n", all);
933+
ext4_mb_unload_buddy(&e4b);
934+
}
935+
862936
static const struct mbt_ext4_block_layout mbt_test_layouts[] = {
863937
{
864938
.blocksize_bits = 10,
@@ -901,6 +975,8 @@ static struct kunit_case mbt_test_cases[] = {
901975
KUNIT_CASE_PARAM(test_mb_mark_used, mbt_layouts_gen_params),
902976
KUNIT_CASE_PARAM(test_mb_free_blocks, mbt_layouts_gen_params),
903977
KUNIT_CASE_PARAM(test_mark_diskspace_used, mbt_layouts_gen_params),
978+
KUNIT_CASE_PARAM_ATTR(test_mb_mark_used_cost, mbt_layouts_gen_params,
979+
{ .speed = KUNIT_SPEED_SLOW }),
904980
{}
905981
};
906982

0 commit comments

Comments
 (0)