Skip to content

Commit 9c94b39

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: - Replace ext4's bmap and iopoll implementations to use iomap. - Clean up extent tree handling. - Other cleanups and miscellaneous bug fixes * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (31 commits) ext4: save all error info in save_error_info() and drop ext4_set_errno() ext4: fix incorrect group count in ext4_fill_super error message ext4: fix incorrect inodes per group in error message ext4: don't set dioread_nolock by default for blocksize < pagesize ext4: disable dioread_nolock whenever delayed allocation is disabled ext4: do not commit super on read-only bdev ext4: avoid ENOSPC when avoiding to reuse recently deleted inodes ext4: unregister sysfs path before destroying jbd2 journal ext4: check for non-zero journal inum in ext4_calculate_overhead ext4: remove map_from_cluster from ext4_ext_map_blocks ext4: clean up ext4_ext_insert_extent() call in ext4_ext_map_blocks() ext4: mark block bitmap corrupted when found instead of BUGON ext4: use flexible-array member for xattr structs ext4: use flexible-array member in struct fname Documentation: correct the description of FIEMAP_EXTENT_LAST ext4: move ext4_fiemap to use iomap framework ext4: make ext4_ind_map_blocks work with fiemap ext4: move ext4 bmap to use iomap infrastructure ext4: optimize ext4_ext_precache for 0 depth ext4: add IOMAP_F_MERGED for non-extent based mapping ...
2 parents 3476195 + 54d3adb commit 9c94b39

File tree

22 files changed

+392
-675
lines changed

22 files changed

+392
-675
lines changed

Documentation/filesystems/fiemap.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ data. Note that the opposite is not true - it would be valid for
115115
FIEMAP_EXTENT_NOT_ALIGNED to appear alone.
116116

117117
* FIEMAP_EXTENT_LAST
118-
This is the last extent in the file. A mapping attempt past this
119-
extent will return nothing.
118+
This is generally the last extent in the file. A mapping attempt past
119+
this extent may return nothing. Some implementations set this flag to
120+
indicate this extent is the last one in the range queried by the user
121+
(via fiemap->fm_length).
120122

121123
* FIEMAP_EXTENT_UNKNOWN
122124
The location of this extent is currently unknown. This may indicate

fs/ext4/balloc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,9 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
516516
wait_on_buffer(bh);
517517
ext4_simulate_fail_bh(sb, bh, EXT4_SIM_BBITMAP_EIO);
518518
if (!buffer_uptodate(bh)) {
519-
ext4_set_errno(sb, EIO);
520-
ext4_error(sb, "Cannot read block bitmap - "
521-
"block_group = %u, block_bitmap = %llu",
522-
block_group, (unsigned long long) bh->b_blocknr);
519+
ext4_error_err(sb, EIO, "Cannot read block bitmap - "
520+
"block_group = %u, block_bitmap = %llu",
521+
block_group, (unsigned long long) bh->b_blocknr);
523522
ext4_mark_group_bitmap_corrupted(sb, block_group,
524523
EXT4_GROUP_INFO_BBITMAP_CORRUPT);
525524
return -EIO;

fs/ext4/block_validity.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,8 @@ static int ext4_data_block_valid_rcu(struct ext4_sb_info *sbi,
166166

167167
if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
168168
(start_blk + count < start_blk) ||
169-
(start_blk + count > ext4_blocks_count(sbi->s_es))) {
170-
sbi->s_es->s_last_error_block = cpu_to_le64(start_blk);
169+
(start_blk + count > ext4_blocks_count(sbi->s_es)))
171170
return 0;
172-
}
173171

174172
if (system_blks == NULL)
175173
return 1;
@@ -181,10 +179,8 @@ static int ext4_data_block_valid_rcu(struct ext4_sb_info *sbi,
181179
n = n->rb_left;
182180
else if (start_blk >= (entry->start_blk + entry->count))
183181
n = n->rb_right;
184-
else {
185-
sbi->s_es->s_last_error_block = cpu_to_le64(start_blk);
182+
else
186183
return 0;
187-
}
188184
}
189185
return 1;
190186
}
@@ -220,10 +216,12 @@ static int ext4_protect_reserved_inode(struct super_block *sb,
220216
} else {
221217
if (!ext4_data_block_valid_rcu(sbi, system_blks,
222218
map.m_pblk, n)) {
223-
ext4_error(sb, "blocks %llu-%llu from inode %u "
224-
"overlap system zone", map.m_pblk,
225-
map.m_pblk + map.m_len - 1, ino);
226219
err = -EFSCORRUPTED;
220+
__ext4_error(sb, __func__, __LINE__, -err,
221+
map.m_pblk, "blocks %llu-%llu "
222+
"from inode %u overlap system zone",
223+
map.m_pblk,
224+
map.m_pblk + map.m_len - 1, ino);
227225
break;
228226
}
229227
err = add_system_zone(system_blks, map.m_pblk, n);
@@ -365,7 +363,6 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
365363
int ext4_check_blockref(const char *function, unsigned int line,
366364
struct inode *inode, __le32 *p, unsigned int max)
367365
{
368-
struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
369366
__le32 *bref = p;
370367
unsigned int blk;
371368

@@ -379,7 +376,6 @@ int ext4_check_blockref(const char *function, unsigned int line,
379376
if (blk &&
380377
unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
381378
blk, 1))) {
382-
es->s_last_error_block = cpu_to_le64(blk);
383379
ext4_error_inode(inode, function, line, blk,
384380
"invalid block");
385381
return -EFSCORRUPTED;

fs/ext4/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ struct fname {
392392
__u32 inode;
393393
__u8 name_len;
394394
__u8 file_type;
395-
char name[0];
395+
char name[];
396396
};
397397

398398
/*

fs/ext4/ext4.h

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ struct flex_groups {
414414
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
415415
#define EXT4_VERITY_FL 0x00100000 /* Verity protected inode */
416416
#define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
417-
#define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
417+
/* 0x00400000 was formerly EXT4_EOFBLOCKS_FL */
418418
#define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
419419
#define EXT4_PROJINHERIT_FL 0x20000000 /* Create with parents projid */
420420
#define EXT4_CASEFOLD_FL 0x40000000 /* Casefolded file */
@@ -487,7 +487,7 @@ enum {
487487
EXT4_INODE_EXTENTS = 19, /* Inode uses extents */
488488
EXT4_INODE_VERITY = 20, /* Verity protected inode */
489489
EXT4_INODE_EA_INODE = 21, /* Inode used for large EA */
490-
EXT4_INODE_EOFBLOCKS = 22, /* Blocks allocated beyond EOF */
490+
/* 22 was formerly EXT4_INODE_EOFBLOCKS */
491491
EXT4_INODE_INLINE_DATA = 28, /* Data in inode. */
492492
EXT4_INODE_PROJINHERIT = 29, /* Create with parents projid */
493493
EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */
@@ -533,7 +533,6 @@ static inline void ext4_check_flag_values(void)
533533
CHECK_FLAG_VALUE(EXTENTS);
534534
CHECK_FLAG_VALUE(VERITY);
535535
CHECK_FLAG_VALUE(EA_INODE);
536-
CHECK_FLAG_VALUE(EOFBLOCKS);
537536
CHECK_FLAG_VALUE(INLINE_DATA);
538537
CHECK_FLAG_VALUE(PROJINHERIT);
539538
CHECK_FLAG_VALUE(RESERVED);
@@ -2771,21 +2770,20 @@ extern const char *ext4_decode_error(struct super_block *sb, int errno,
27712770
extern void ext4_mark_group_bitmap_corrupted(struct super_block *sb,
27722771
ext4_group_t block_group,
27732772
unsigned int flags);
2774-
extern void ext4_set_errno(struct super_block *sb, int err);
27752773

2776-
extern __printf(4, 5)
2777-
void __ext4_error(struct super_block *, const char *, unsigned int,
2774+
extern __printf(6, 7)
2775+
void __ext4_error(struct super_block *, const char *, unsigned int, int, __u64,
27782776
const char *, ...);
2779-
extern __printf(5, 6)
2780-
void __ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t,
2781-
const char *, ...);
2777+
extern __printf(6, 7)
2778+
void __ext4_error_inode(struct inode *, const char *, unsigned int,
2779+
ext4_fsblk_t, int, const char *, ...);
27822780
extern __printf(5, 6)
27832781
void __ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t,
27842782
const char *, ...);
27852783
extern void __ext4_std_error(struct super_block *, const char *,
27862784
unsigned int, int);
2787-
extern __printf(4, 5)
2788-
void __ext4_abort(struct super_block *, const char *, unsigned int,
2785+
extern __printf(5, 6)
2786+
void __ext4_abort(struct super_block *, const char *, unsigned int, int,
27892787
const char *, ...);
27902788
extern __printf(4, 5)
27912789
void __ext4_warning(struct super_block *, const char *, unsigned int,
@@ -2806,22 +2804,31 @@ void __ext4_grp_locked_error(const char *, unsigned int,
28062804
#define EXT4_ERROR_INODE(inode, fmt, a...) \
28072805
ext4_error_inode((inode), __func__, __LINE__, 0, (fmt), ## a)
28082806

2809-
#define EXT4_ERROR_INODE_BLOCK(inode, block, fmt, a...) \
2810-
ext4_error_inode((inode), __func__, __LINE__, (block), (fmt), ## a)
2807+
#define EXT4_ERROR_INODE_ERR(inode, err, fmt, a...) \
2808+
__ext4_error_inode((inode), __func__, __LINE__, 0, (err), (fmt), ## a)
2809+
2810+
#define ext4_error_inode_block(inode, block, err, fmt, a...) \
2811+
__ext4_error_inode((inode), __func__, __LINE__, (block), (err), \
2812+
(fmt), ## a)
28112813

28122814
#define EXT4_ERROR_FILE(file, block, fmt, a...) \
28132815
ext4_error_file((file), __func__, __LINE__, (block), (fmt), ## a)
28142816

28152817
#ifdef CONFIG_PRINTK
28162818

28172819
#define ext4_error_inode(inode, func, line, block, fmt, ...) \
2818-
__ext4_error_inode(inode, func, line, block, fmt, ##__VA_ARGS__)
2820+
__ext4_error_inode(inode, func, line, block, 0, fmt, ##__VA_ARGS__)
2821+
#define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \
2822+
__ext4_error_inode((inode), (func), (line), (block), \
2823+
(err), (fmt), ##__VA_ARGS__)
28192824
#define ext4_error_file(file, func, line, block, fmt, ...) \
28202825
__ext4_error_file(file, func, line, block, fmt, ##__VA_ARGS__)
28212826
#define ext4_error(sb, fmt, ...) \
2822-
__ext4_error(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
2823-
#define ext4_abort(sb, fmt, ...) \
2824-
__ext4_abort(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
2827+
__ext4_error((sb), __func__, __LINE__, 0, 0, (fmt), ##__VA_ARGS__)
2828+
#define ext4_error_err(sb, err, fmt, ...) \
2829+
__ext4_error((sb), __func__, __LINE__, (err), 0, (fmt), ##__VA_ARGS__)
2830+
#define ext4_abort(sb, err, fmt, ...) \
2831+
__ext4_abort((sb), __func__, __LINE__, (err), (fmt), ##__VA_ARGS__)
28252832
#define ext4_warning(sb, fmt, ...) \
28262833
__ext4_warning(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
28272834
#define ext4_warning_inode(inode, fmt, ...) \
@@ -2839,7 +2846,12 @@ void __ext4_grp_locked_error(const char *, unsigned int,
28392846
#define ext4_error_inode(inode, func, line, block, fmt, ...) \
28402847
do { \
28412848
no_printk(fmt, ##__VA_ARGS__); \
2842-
__ext4_error_inode(inode, "", 0, block, " "); \
2849+
__ext4_error_inode(inode, "", 0, block, 0, " "); \
2850+
} while (0)
2851+
#define ext4_error_inode_err(inode, func, line, block, err, fmt, ...) \
2852+
do { \
2853+
no_printk(fmt, ##__VA_ARGS__); \
2854+
__ext4_error_inode(inode, "", 0, block, err, " "); \
28432855
} while (0)
28442856
#define ext4_error_file(file, func, line, block, fmt, ...) \
28452857
do { \
@@ -2849,12 +2861,17 @@ do { \
28492861
#define ext4_error(sb, fmt, ...) \
28502862
do { \
28512863
no_printk(fmt, ##__VA_ARGS__); \
2852-
__ext4_error(sb, "", 0, " "); \
2864+
__ext4_error(sb, "", 0, 0, 0, " "); \
2865+
} while (0)
2866+
#define ext4_error_err(sb, err, fmt, ...) \
2867+
do { \
2868+
no_printk(fmt, ##__VA_ARGS__); \
2869+
__ext4_error(sb, "", 0, err, 0, " "); \
28532870
} while (0)
2854-
#define ext4_abort(sb, fmt, ...) \
2871+
#define ext4_abort(sb, err, fmt, ...) \
28552872
do { \
28562873
no_printk(fmt, ##__VA_ARGS__); \
2857-
__ext4_abort(sb, "", 0, " "); \
2874+
__ext4_abort(sb, "", 0, err, " "); \
28582875
} while (0)
28592876
#define ext4_warning(sb, fmt, ...) \
28602877
do { \

fs/ext4/ext4_jbd2.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ static int ext4_journal_check_start(struct super_block *sb)
8080
* take the FS itself readonly cleanly.
8181
*/
8282
if (journal && is_journal_aborted(journal)) {
83-
ext4_set_errno(sb, -journal->j_errno);
84-
ext4_abort(sb, "Detected aborted journal");
83+
ext4_abort(sb, -journal->j_errno, "Detected aborted journal");
8584
return -EROFS;
8685
}
8786
return 0;
@@ -272,8 +271,7 @@ int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
272271
if (err) {
273272
ext4_journal_abort_handle(where, line, __func__,
274273
bh, handle, err);
275-
ext4_set_errno(inode->i_sb, -err);
276-
__ext4_abort(inode->i_sb, where, line,
274+
__ext4_abort(inode->i_sb, where, line, -err,
277275
"error %d when attempting revoke", err);
278276
}
279277
BUFFER_TRACE(bh, "exit");
@@ -332,6 +330,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
332330
err);
333331
}
334332
} else {
333+
set_buffer_uptodate(bh);
335334
if (inode)
336335
mark_buffer_dirty_inode(bh, inode);
337336
else
@@ -342,11 +341,8 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
342341
struct ext4_super_block *es;
343342

344343
es = EXT4_SB(inode->i_sb)->s_es;
345-
es->s_last_error_block =
346-
cpu_to_le64(bh->b_blocknr);
347-
ext4_set_errno(inode->i_sb, EIO);
348-
ext4_error_inode(inode, where, line,
349-
bh->b_blocknr,
344+
ext4_error_inode_err(inode, where, line,
345+
bh->b_blocknr, EIO,
350346
"IO error syncing itable block");
351347
err = -EIO;
352348
}

fs/ext4/ext4_jbd2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
512512
return 0;
513513
if (ext4_should_journal_data(inode))
514514
return 0;
515+
/* temporary fix to prevent generic/422 test failures */
516+
if (!test_opt(inode->i_sb, DELALLOC))
517+
return 0;
515518
return 1;
516519
}
517520

0 commit comments

Comments
 (0)