Skip to content

Commit a436a0b

Browse files
committed
Merge tag 'ext4_for_linux-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: - Refactor code paths involved with partial block zero-out in prearation for converting ext4 to use iomap for buffered writes - Remove use of d_alloc() from ext4 in preparation for the deprecation of this interface - Replace some J_ASSERTS with a journal abort so we can avoid a kernel panic for a localized file system error - Simplify various code paths in mballoc, move_extent, and fast commit - Fix rare deadlock in jbd2_journal_cancel_revoke() that can be triggered by generic/013 when blocksize < pagesize - Fix memory leak when releasing an extended attribute when its value is stored in an ea_inode - Fix various potential kunit test bugs in fs/ext4/extents.c - Fix potential out-of-bounds access in check_xattr() with a corrupted file system - Make the jbd2_inode dirty range tracking safe for lockless reads - Avoid a WARN_ON when writeback files due to a corrupted file system; we already print an ext4 warning indicatign that data will be lost, so the WARN_ON is not necessary and doesn't add any new information * tag 'ext4_for_linux-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (37 commits) jbd2: fix deadlock in jbd2_journal_cancel_revoke() ext4: fix missing brelse() in ext4_xattr_inode_dec_ref_all() ext4: fix possible null-ptr-deref in mbt_kunit_exit() ext4: fix possible null-ptr-deref in extents_kunit_exit() ext4: fix the error handling process in extents_kunit_init). ext4: call deactivate_super() in extents_kunit_exit() ext4: fix miss unlock 'sb->s_umount' in extents_kunit_init() ext4: fix bounds check in check_xattrs() to prevent out-of-bounds access ext4: zero post-EOF partial block before appending write ext4: move pagecache_isize_extended() out of active handle ext4: remove ctime/mtime update from ext4_alloc_file_blocks() ext4: unify SYNC mode checks in fallocate paths ext4: ensure zeroed partial blocks are persisted in SYNC mode ext4: move zero partial block range functions out of active handle ext4: pass allocate range as loff_t to ext4_alloc_file_blocks() ext4: remove handle parameters from zero partial block functions ext4: move ordered data handling out of ext4_block_do_zero_range() ext4: rename ext4_block_zero_page_range() to ext4_block_zero_range() ext4: factor out journalled block zeroing range ext4: rename and extend ext4_block_truncate_page() ...
2 parents 30999ad + 981fcc5 commit a436a0b

19 files changed

Lines changed: 628 additions & 384 deletions

fs/ext4/ext4.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <linux/seqlock.h>
2929
#include <linux/mutex.h>
3030
#include <linux/timer.h>
31-
#include <linux/wait.h>
3231
#include <linux/sched/signal.h>
3332
#include <linux/blockgroup_lock.h>
3433
#include <linux/percpu_counter.h>
@@ -1082,9 +1081,6 @@ struct ext4_inode_info {
10821081

10831082
spinlock_t i_raw_lock; /* protects updates to the raw inode */
10841083

1085-
/* Fast commit wait queue for this inode */
1086-
wait_queue_head_t i_fc_wait;
1087-
10881084
/*
10891085
* Protect concurrent accesses on i_fc_lblk_start, i_fc_lblk_len
10901086
* and inode's EXT4_FC_STATE_COMMITTING state bit.
@@ -2976,7 +2972,8 @@ void __ext4_fc_track_unlink(handle_t *handle, struct inode *inode,
29762972
void __ext4_fc_track_link(handle_t *handle, struct inode *inode,
29772973
struct dentry *dentry);
29782974
void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry);
2979-
void ext4_fc_track_link(handle_t *handle, struct dentry *dentry);
2975+
void ext4_fc_track_link(handle_t *handle, struct inode *inode,
2976+
struct dentry *dentry);
29802977
void __ext4_fc_track_create(handle_t *handle, struct inode *inode,
29812978
struct dentry *dentry);
29822979
void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
@@ -3101,8 +3098,9 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
31013098
extern int ext4_chunk_trans_extent(struct inode *inode, int nrblocks);
31023099
extern int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
31033100
int pextents);
3104-
extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
3105-
loff_t lstart, loff_t lend);
3101+
extern int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end);
3102+
extern int ext4_zero_partial_blocks(struct inode *inode, loff_t lstart,
3103+
loff_t length, bool *did_zero);
31063104
extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf);
31073105
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
31083106
extern int ext4_get_projid(struct inode *inode, kprojid_t *projid);
@@ -3721,7 +3719,7 @@ extern int ext4_handle_dirty_dirblock(handle_t *handle, struct inode *inode,
37213719
extern int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
37223720
struct inode *inode, struct dentry *dentry);
37233721
extern int __ext4_link(struct inode *dir, struct inode *inode,
3724-
struct dentry *dentry);
3722+
const struct qstr *d_name, struct dentry *dentry);
37253723

37263724
#define S_SHIFT 12
37273725
static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = {

fs/ext4/extents-test.c

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@ static struct file_system_type ext_fs_type = {
142142

143143
static void extents_kunit_exit(struct kunit *test)
144144
{
145-
struct super_block *sb = k_ctx.k_ei->vfs_inode.i_sb;
146-
struct ext4_sb_info *sbi = sb->s_fs_info;
145+
struct ext4_sb_info *sbi;
147146

147+
if (!k_ctx.k_ei)
148+
return;
149+
150+
sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info;
148151
ext4_es_unregister_shrinker(sbi);
152+
deactivate_super(sbi->s_sb);
149153
kfree(sbi);
150154
kfree(k_ctx.k_ei);
151155
kfree(k_ctx.k_data);
@@ -224,34 +228,38 @@ static int extents_kunit_init(struct kunit *test)
224228
(struct kunit_ext_test_param *)(test->param_value);
225229
int err;
226230

227-
sb = sget(&ext_fs_type, NULL, ext_set, 0, NULL);
228-
if (IS_ERR(sb))
229-
return PTR_ERR(sb);
230-
231-
sb->s_blocksize = 4096;
232-
sb->s_blocksize_bits = 12;
233-
234231
sbi = kzalloc_obj(struct ext4_sb_info);
235232
if (sbi == NULL)
236233
return -ENOMEM;
237234

235+
sb = sget(&ext_fs_type, NULL, ext_set, 0, NULL);
236+
if (IS_ERR(sb)) {
237+
kfree(sbi);
238+
return PTR_ERR(sb);
239+
}
240+
238241
sbi->s_sb = sb;
239242
sb->s_fs_info = sbi;
240243

244+
sb->s_blocksize = 4096;
245+
sb->s_blocksize_bits = 12;
246+
241247
if (!param || !param->disable_zeroout)
242248
sbi->s_extent_max_zeroout_kb = 32;
243249

250+
err = ext4_es_register_shrinker(sbi);
251+
if (err)
252+
goto out_deactivate;
253+
244254
/* setup the mock inode */
245255
k_ctx.k_ei = kzalloc_obj(struct ext4_inode_info);
246-
if (k_ctx.k_ei == NULL)
247-
return -ENOMEM;
256+
if (k_ctx.k_ei == NULL) {
257+
err = -ENOMEM;
258+
goto out;
259+
}
248260
ei = k_ctx.k_ei;
249261
inode = &ei->vfs_inode;
250262

251-
err = ext4_es_register_shrinker(sbi);
252-
if (err)
253-
return err;
254-
255263
ext4_es_init_tree(&ei->i_es_tree);
256264
rwlock_init(&ei->i_es_lock);
257265
INIT_LIST_HEAD(&ei->i_es_list);
@@ -266,8 +274,10 @@ static int extents_kunit_init(struct kunit *test)
266274
inode->i_sb = sb;
267275

268276
k_ctx.k_data = kzalloc(EXT_DATA_LEN * 4096, GFP_KERNEL);
269-
if (k_ctx.k_data == NULL)
270-
return -ENOMEM;
277+
if (k_ctx.k_data == NULL) {
278+
err = -ENOMEM;
279+
goto out;
280+
}
271281

272282
/*
273283
* set the data area to a junk value
@@ -309,7 +319,23 @@ static int extents_kunit_init(struct kunit *test)
309319
kunit_activate_static_stub(test, ext4_ext_zeroout, ext4_ext_zeroout_stub);
310320
kunit_activate_static_stub(test, ext4_issue_zeroout,
311321
ext4_issue_zeroout_stub);
322+
up_write(&sb->s_umount);
323+
312324
return 0;
325+
326+
out:
327+
kfree(k_ctx.k_ei);
328+
k_ctx.k_ei = NULL;
329+
330+
kfree(k_ctx.k_data);
331+
k_ctx.k_data = NULL;
332+
333+
ext4_es_unregister_shrinker(sbi);
334+
out_deactivate:
335+
deactivate_locked_super(sb);
336+
kfree(sbi);
337+
338+
return err;
313339
}
314340

315341
/*

0 commit comments

Comments
 (0)