Skip to content

Commit deb9acc

Browse files
committed
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "A large number of cleanups and bug fixes, with many of the bug fixes found by Syzbot and fuzzing. (Many of the bug fixes involve less-used ext4 features such as fast_commit, inline_data and bigalloc) In addition, remove the writepage function for ext4, since the medium-term plan is to remove ->writepage() entirely. (The VM doesn't need or want writepage() for writeback, since it is fine with ->writepages() so long as ->migrate_folio() is implemented)" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (58 commits) ext4: fix reserved cluster accounting in __es_remove_extent() ext4: fix inode leak in ext4_xattr_inode_create() on an error path ext4: allocate extended attribute value in vmalloc area ext4: avoid unaccounted block allocation when expanding inode ext4: initialize quota before expanding inode in setproject ioctl ext4: stop providing .writepage hook mm: export buffer_migrate_folio_norefs() ext4: switch to using write_cache_pages() for data=journal writeout jbd2: switch jbd2_submit_inode_data() to use fs-provided hook for data writeout ext4: switch to using ext4_do_writepages() for ordered data writeout ext4: move percpu_rwsem protection into ext4_writepages() ext4: provide ext4_do_writepages() ext4: add support for writepages calls that cannot map blocks ext4: drop pointless IO submission from ext4_bio_write_page() ext4: remove nr_submitted from ext4_bio_write_page() ext4: move keep_towrite handling to ext4_bio_write_page() ext4: handle redirtying in ext4_bio_write_page() ext4: fix kernel BUG in 'ext4_write_inline_data_end()' ext4: make ext4_mb_initialize_context return void ext4: fix deadlock due to mbcache entry corruption ...
2 parents 9b93f50 + 1da18e3 commit deb9acc

32 files changed

+571
-367
lines changed

Documentation/filesystems/mount_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ process the parameters it is given.
803803
int fs_lookup_param(struct fs_context *fc,
804804
struct fs_parameter *value,
805805
bool want_bdev,
806+
unsigned int flags,
806807
struct path *_path);
807808
808809
This takes a parameter that carries a string or filename type and attempts

fs/ext4/ext4.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ enum {
558558
*
559559
* It's not paranoia if the Murphy's Law really *is* out to get you. :-)
560560
*/
561-
#define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG))
561+
#define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1U << EXT4_INODE_##FLAG))
562562
#define CHECK_FLAG_VALUE(FLAG) BUILD_BUG_ON(!TEST_FLAG_VALUE(FLAG))
563563

564564
static inline void ext4_check_flag_values(void)
@@ -2964,7 +2964,8 @@ int do_journal_get_write_access(handle_t *handle, struct inode *inode,
29642964
typedef enum {
29652965
EXT4_IGET_NORMAL = 0,
29662966
EXT4_IGET_SPECIAL = 0x0001, /* OK to iget a system inode */
2967-
EXT4_IGET_HANDLE = 0x0002 /* Inode # is from a handle */
2967+
EXT4_IGET_HANDLE = 0x0002, /* Inode # is from a handle */
2968+
EXT4_IGET_BAD = 0x0004 /* Allow to iget a bad inode */
29682969
} ext4_iget_flags;
29692970

29702971
extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
@@ -2999,6 +3000,7 @@ extern void ext4_set_inode_flags(struct inode *, bool init);
29993000
extern int ext4_alloc_da_blocks(struct inode *inode);
30003001
extern void ext4_set_aops(struct inode *inode);
30013002
extern int ext4_writepage_trans_blocks(struct inode *);
3003+
extern int ext4_normal_submit_inode_data_buffers(struct jbd2_inode *jinode);
30023004
extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
30033005
extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
30043006
loff_t lstart, loff_t lend);
@@ -3619,8 +3621,8 @@ extern void ext4_initialize_dirent_tail(struct buffer_head *bh,
36193621
unsigned int blocksize);
36203622
extern int ext4_handle_dirty_dirblock(handle_t *handle, struct inode *inode,
36213623
struct buffer_head *bh);
3622-
extern int __ext4_unlink(handle_t *handle, struct inode *dir, const struct qstr *d_name,
3623-
struct inode *inode);
3624+
extern int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
3625+
struct inode *inode, struct dentry *dentry);
36243626
extern int __ext4_link(struct inode *dir, struct inode *inode,
36253627
struct dentry *dentry);
36263628

@@ -3756,8 +3758,7 @@ extern void ext4_end_io_rsv_work(struct work_struct *work);
37563758
extern void ext4_io_submit(struct ext4_io_submit *io);
37573759
extern int ext4_bio_write_page(struct ext4_io_submit *io,
37583760
struct page *page,
3759-
int len,
3760-
bool keep_towrite);
3761+
int len);
37613762
extern struct ext4_io_end_vec *ext4_alloc_io_end_vec(ext4_io_end_t *io_end);
37623763
extern struct ext4_io_end_vec *ext4_last_io_end_vec(ext4_io_end_t *io_end);
37633764

fs/ext4/ext4_jbd2.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,21 @@ static int ext4_journal_check_start(struct super_block *sb)
8686
return 0;
8787
}
8888

89-
handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
89+
handle_t *__ext4_journal_start_sb(struct inode *inode,
90+
struct super_block *sb, unsigned int line,
9091
int type, int blocks, int rsv_blocks,
9192
int revoke_creds)
9293
{
9394
journal_t *journal;
9495
int err;
95-
96-
trace_ext4_journal_start(sb, blocks, rsv_blocks, revoke_creds,
97-
_RET_IP_);
96+
if (inode)
97+
trace_ext4_journal_start_inode(inode, blocks, rsv_blocks,
98+
revoke_creds, type,
99+
_RET_IP_);
100+
else
101+
trace_ext4_journal_start_sb(sb, blocks, rsv_blocks,
102+
revoke_creds, type,
103+
_RET_IP_);
98104
err = ext4_journal_check_start(sb);
99105
if (err < 0)
100106
return ERR_PTR(err);

fs/ext4/ext4_jbd2.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
261261
__ext4_handle_dirty_metadata(__func__, __LINE__, (handle), (inode), \
262262
(bh))
263263

264-
handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
265-
int type, int blocks, int rsv_blocks,
266-
int revoke_creds);
264+
handle_t *__ext4_journal_start_sb(struct inode *inode, struct super_block *sb,
265+
unsigned int line, int type, int blocks,
266+
int rsv_blocks, int revoke_creds);
267267
int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle);
268268

269269
#define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096)
@@ -303,7 +303,7 @@ static inline int ext4_trans_default_revoke_credits(struct super_block *sb)
303303
}
304304

305305
#define ext4_journal_start_sb(sb, type, nblocks) \
306-
__ext4_journal_start_sb((sb), __LINE__, (type), (nblocks), 0, \
306+
__ext4_journal_start_sb(NULL, (sb), __LINE__, (type), (nblocks), 0,\
307307
ext4_trans_default_revoke_credits(sb))
308308

309309
#define ext4_journal_start(inode, type, nblocks) \
@@ -323,7 +323,7 @@ static inline handle_t *__ext4_journal_start(struct inode *inode,
323323
int blocks, int rsv_blocks,
324324
int revoke_creds)
325325
{
326-
return __ext4_journal_start_sb(inode->i_sb, line, type, blocks,
326+
return __ext4_journal_start_sb(inode, inode->i_sb, line, type, blocks,
327327
rsv_blocks, revoke_creds);
328328
}
329329

fs/ext4/extents.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,9 +2635,8 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
26352635
unwritten, ex_ee_len);
26362636
path[depth].p_ext = ex;
26372637

2638-
a = ex_ee_block > start ? ex_ee_block : start;
2639-
b = ex_ee_block+ex_ee_len - 1 < end ?
2640-
ex_ee_block+ex_ee_len - 1 : end;
2638+
a = max(ex_ee_block, start);
2639+
b = min(ex_ee_block + ex_ee_len - 1, end);
26412640

26422641
ext_debug(inode, " border %u:%u\n", a, b);
26432642

@@ -5567,8 +5566,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
55675566
* ee_start_lblk to shift extents
55685567
*/
55695568
ret = ext4_ext_shift_extents(inode, handle,
5570-
ee_start_lblk > offset_lblk ? ee_start_lblk : offset_lblk,
5571-
len_lblk, SHIFT_RIGHT);
5569+
max(ee_start_lblk, offset_lblk), len_lblk, SHIFT_RIGHT);
55725570

55735571
up_write(&EXT4_I(inode)->i_data_sem);
55745572
if (IS_SYNC(inode))
@@ -5799,6 +5797,14 @@ int ext4_clu_mapped(struct inode *inode, ext4_lblk_t lclu)
57995797
struct ext4_extent *extent;
58005798
ext4_lblk_t first_lblk, first_lclu, last_lclu;
58015799

5800+
/*
5801+
* if data can be stored inline, the logical cluster isn't
5802+
* mapped - no physical clusters have been allocated, and the
5803+
* file has no extents
5804+
*/
5805+
if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))
5806+
return 0;
5807+
58025808
/* search for the extent closest to the first block in the cluster */
58035809
path = ext4_find_extent(inode, EXT4_C2B(sbi, lclu), NULL, 0);
58045810
if (IS_ERR(path)) {

fs/ext4/extents_status.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ static void __revise_pending(struct inode *inode, ext4_lblk_t lblk,
155155

156156
int __init ext4_init_es(void)
157157
{
158-
ext4_es_cachep = kmem_cache_create("ext4_extent_status",
159-
sizeof(struct extent_status),
160-
0, (SLAB_RECLAIM_ACCOUNT), NULL);
158+
ext4_es_cachep = KMEM_CACHE(extent_status, SLAB_RECLAIM_ACCOUNT);
161159
if (ext4_es_cachep == NULL)
162160
return -ENOMEM;
163161
return 0;
@@ -1371,7 +1369,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
13711369
if (count_reserved)
13721370
count_rsvd(inode, lblk, orig_es.es_len - len1 - len2,
13731371
&orig_es, &rc);
1374-
goto out;
1372+
goto out_get_reserved;
13751373
}
13761374

13771375
if (len1 > 0) {
@@ -1413,6 +1411,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
14131411
}
14141412
}
14151413

1414+
out_get_reserved:
14161415
if (count_reserved)
14171416
*reserved = get_rsvd(inode, end, es, &rc);
14181417
out:
@@ -1807,9 +1806,7 @@ static void ext4_print_pending_tree(struct inode *inode)
18071806

18081807
int __init ext4_init_pending(void)
18091808
{
1810-
ext4_pending_cachep = kmem_cache_create("ext4_pending_reservation",
1811-
sizeof(struct pending_reservation),
1812-
0, (SLAB_RECLAIM_ACCOUNT), NULL);
1809+
ext4_pending_cachep = KMEM_CACHE(pending_reservation, SLAB_RECLAIM_ACCOUNT);
18131810
if (ext4_pending_cachep == NULL)
18141811
return -ENOMEM;
18151812
return 0;

0 commit comments

Comments
 (0)