Skip to content

Commit 47188d3

Browse files
committed
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 bugfixes from Ted Ts'o: "Various regression and bug fixes for ext4" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: don't allow ext4_free_blocks() to fail due to ENOMEM ext4: fix spelling errors and a comment in extent_status tree ext4: rate limit printk in buffer_io_error() ext4: don't show usrquota/grpquota twice in /proc/mounts ext4: fix warning in ext4_evict_inode() ext4: fix ext4_get_group_number() ext4: silence warning in ext4_writepages()
2 parents ad81f05 + e7676a7 commit 47188d3

File tree

6 files changed

+51
-47
lines changed

6 files changed

+51
-47
lines changed

fs/ext4/balloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ ext4_group_t ext4_get_group_number(struct super_block *sb,
3838
ext4_group_t group;
3939

4040
if (test_opt2(sb, STD_GROUP_SIZE))
41-
group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) +
42-
block) >>
41+
group = (block -
42+
le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) >>
4343
(EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3);
4444
else
4545
ext4_get_group_no_and_offset(sb, block, &group, NULL);

fs/ext4/extents_status.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
439439
*/
440440
if (!ext4_es_is_written(es) && !ext4_es_is_unwritten(es)) {
441441
if (in_range(es->es_lblk, ee_block, ee_len)) {
442-
pr_warn("ES insert assertation failed for "
442+
pr_warn("ES insert assertion failed for "
443443
"inode: %lu we can find an extent "
444444
"at block [%d/%d/%llu/%c], but we "
445445
"want to add an delayed/hole extent "
@@ -458,7 +458,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
458458
*/
459459
if (es->es_lblk < ee_block ||
460460
ext4_es_pblock(es) != ee_start + es->es_lblk - ee_block) {
461-
pr_warn("ES insert assertation failed for inode: %lu "
461+
pr_warn("ES insert assertion failed for inode: %lu "
462462
"ex_status [%d/%d/%llu/%c] != "
463463
"es_status [%d/%d/%llu/%c]\n", inode->i_ino,
464464
ee_block, ee_len, ee_start,
@@ -468,7 +468,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
468468
}
469469

470470
if (ee_status ^ es_status) {
471-
pr_warn("ES insert assertation failed for inode: %lu "
471+
pr_warn("ES insert assertion failed for inode: %lu "
472472
"ex_status [%d/%d/%llu/%c] != "
473473
"es_status [%d/%d/%llu/%c]\n", inode->i_ino,
474474
ee_block, ee_len, ee_start,
@@ -481,7 +481,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
481481
* that we don't want to add an written/unwritten extent.
482482
*/
483483
if (!ext4_es_is_delayed(es) && !ext4_es_is_hole(es)) {
484-
pr_warn("ES insert assertation failed for inode: %lu "
484+
pr_warn("ES insert assertion failed for inode: %lu "
485485
"can't find an extent at block %d but we want "
486486
"to add an written/unwritten extent "
487487
"[%d/%d/%llu/%llx]\n", inode->i_ino,
@@ -519,21 +519,21 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
519519
* We want to add a delayed/hole extent but this
520520
* block has been allocated.
521521
*/
522-
pr_warn("ES insert assertation failed for inode: %lu "
522+
pr_warn("ES insert assertion failed for inode: %lu "
523523
"We can find blocks but we want to add a "
524524
"delayed/hole extent [%d/%d/%llu/%llx]\n",
525525
inode->i_ino, es->es_lblk, es->es_len,
526526
ext4_es_pblock(es), ext4_es_status(es));
527527
return;
528528
} else if (ext4_es_is_written(es)) {
529529
if (retval != es->es_len) {
530-
pr_warn("ES insert assertation failed for "
530+
pr_warn("ES insert assertion failed for "
531531
"inode: %lu retval %d != es_len %d\n",
532532
inode->i_ino, retval, es->es_len);
533533
return;
534534
}
535535
if (map.m_pblk != ext4_es_pblock(es)) {
536-
pr_warn("ES insert assertation failed for "
536+
pr_warn("ES insert assertion failed for "
537537
"inode: %lu m_pblk %llu != "
538538
"es_pblk %llu\n",
539539
inode->i_ino, map.m_pblk,
@@ -549,7 +549,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
549549
}
550550
} else if (retval == 0) {
551551
if (ext4_es_is_written(es)) {
552-
pr_warn("ES insert assertation failed for inode: %lu "
552+
pr_warn("ES insert assertion failed for inode: %lu "
553553
"We can't find the block but we want to add "
554554
"an written extent [%d/%d/%llu/%llx]\n",
555555
inode->i_ino, es->es_lblk, es->es_len,
@@ -632,10 +632,8 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
632632
}
633633

634634
/*
635-
* ext4_es_insert_extent() adds a space to a extent status tree.
636-
*
637-
* ext4_es_insert_extent is called by ext4_da_write_begin and
638-
* ext4_es_remove_extent.
635+
* ext4_es_insert_extent() adds information to an inode's extent
636+
* status tree.
639637
*
640638
* Return 0 on success, error code on failure.
641639
*/

fs/ext4/inode.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle,
465465
if (es_map->m_lblk != map->m_lblk ||
466466
es_map->m_flags != map->m_flags ||
467467
es_map->m_pblk != map->m_pblk) {
468-
printk("ES cache assertation failed for inode: %lu "
468+
printk("ES cache assertion failed for inode: %lu "
469469
"es_cached ex [%d/%d/%llu/%x] != "
470470
"found ex [%d/%d/%llu/%x] retval %d flags %x\n",
471471
inode->i_ino, es_map->m_lblk, es_map->m_len,
@@ -558,7 +558,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
558558

559559
#ifdef ES_AGGRESSIVE_TEST
560560
if (retval != map->m_len) {
561-
printk("ES len assertation failed for inode: %lu "
561+
printk("ES len assertion failed for inode: %lu "
562562
"retval %d != map->m_len %d "
563563
"in %s (lookup)\n", inode->i_ino, retval,
564564
map->m_len, __func__);
@@ -659,7 +659,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
659659

660660
#ifdef ES_AGGRESSIVE_TEST
661661
if (retval != map->m_len) {
662-
printk("ES len assertation failed for inode: %lu "
662+
printk("ES len assertion failed for inode: %lu "
663663
"retval %d != map->m_len %d "
664664
"in %s (allocation)\n", inode->i_ino, retval,
665665
map->m_len, __func__);
@@ -1642,7 +1642,7 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
16421642

16431643
#ifdef ES_AGGRESSIVE_TEST
16441644
if (retval != map->m_len) {
1645-
printk("ES len assertation failed for inode: %lu "
1645+
printk("ES len assertion failed for inode: %lu "
16461646
"retval %d != map->m_len %d "
16471647
"in %s (lookup)\n", inode->i_ino, retval,
16481648
map->m_len, __func__);
@@ -2163,7 +2163,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
21632163

21642164
mpd->io_submit.io_end->offset =
21652165
((loff_t)map->m_lblk) << inode->i_blkbits;
2166-
while (map->m_len) {
2166+
do {
21672167
err = mpage_map_one_extent(handle, mpd);
21682168
if (err < 0) {
21692169
struct super_block *sb = inode->i_sb;
@@ -2201,7 +2201,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
22012201
err = mpage_map_and_submit_buffers(mpd);
22022202
if (err < 0)
22032203
return err;
2204-
}
2204+
} while (map->m_len);
22052205

22062206
/* Update on-disk size after IO is submitted */
22072207
disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT;

fs/ext4/mballoc.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,11 +4740,16 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
47404740
* blocks being freed are metadata. these blocks shouldn't
47414741
* be used until this transaction is committed
47424742
*/
4743+
retry:
47434744
new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS);
47444745
if (!new_entry) {
4745-
ext4_mb_unload_buddy(&e4b);
4746-
err = -ENOMEM;
4747-
goto error_return;
4746+
/*
4747+
* We use a retry loop because
4748+
* ext4_free_blocks() is not allowed to fail.
4749+
*/
4750+
cond_resched();
4751+
congestion_wait(BLK_RW_ASYNC, HZ/50);
4752+
goto retry;
47484753
}
47494754
new_entry->efd_start_cluster = bit;
47504755
new_entry->efd_group = block_group;

fs/ext4/page-io.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/kernel.h>
2626
#include <linux/slab.h>
2727
#include <linux/mm.h>
28+
#include <linux/ratelimit.h>
2829

2930
#include "ext4_jbd2.h"
3031
#include "xattr.h"
@@ -55,7 +56,7 @@ void ext4_exit_pageio(void)
5556
static void buffer_io_error(struct buffer_head *bh)
5657
{
5758
char b[BDEVNAME_SIZE];
58-
printk(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
59+
printk_ratelimited(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
5960
bdevname(bh->b_bdev, b),
6061
(unsigned long long)bh->b_blocknr);
6162
}
@@ -308,6 +309,7 @@ ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end)
308309
return io_end;
309310
}
310311

312+
/* BIO completion function for page writeback */
311313
static void ext4_end_bio(struct bio *bio, int error)
312314
{
313315
ext4_io_end_t *io_end = bio->bi_private;
@@ -318,18 +320,6 @@ static void ext4_end_bio(struct bio *bio, int error)
318320
if (test_bit(BIO_UPTODATE, &bio->bi_flags))
319321
error = 0;
320322

321-
if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
322-
/*
323-
* Link bio into list hanging from io_end. We have to do it
324-
* atomically as bio completions can be racing against each
325-
* other.
326-
*/
327-
bio->bi_private = xchg(&io_end->bio, bio);
328-
} else {
329-
ext4_finish_bio(bio);
330-
bio_put(bio);
331-
}
332-
333323
if (error) {
334324
struct inode *inode = io_end->inode;
335325

@@ -341,7 +331,24 @@ static void ext4_end_bio(struct bio *bio, int error)
341331
(unsigned long long)
342332
bi_sector >> (inode->i_blkbits - 9));
343333
}
344-
ext4_put_io_end_defer(io_end);
334+
335+
if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
336+
/*
337+
* Link bio into list hanging from io_end. We have to do it
338+
* atomically as bio completions can be racing against each
339+
* other.
340+
*/
341+
bio->bi_private = xchg(&io_end->bio, bio);
342+
ext4_put_io_end_defer(io_end);
343+
} else {
344+
/*
345+
* Drop io_end reference early. Inode can get freed once
346+
* we finish the bio.
347+
*/
348+
ext4_put_io_end_defer(io_end);
349+
ext4_finish_bio(bio);
350+
bio_put(bio);
351+
}
345352
}
346353

347354
void ext4_io_submit(struct ext4_io_submit *io)

fs/ext4/super.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,12 +1702,6 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
17021702

17031703
if (sbi->s_qf_names[GRPQUOTA])
17041704
seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
1705-
1706-
if (test_opt(sb, USRQUOTA))
1707-
seq_puts(seq, ",usrquota");
1708-
1709-
if (test_opt(sb, GRPQUOTA))
1710-
seq_puts(seq, ",grpquota");
17111705
#endif
17121706
}
17131707

@@ -3624,10 +3618,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
36243618
sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
36253619
sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
36263620

3627-
/* Do we have standard group size of blocksize * 8 blocks ? */
3628-
if (sbi->s_blocks_per_group == blocksize << 3)
3629-
set_opt2(sb, STD_GROUP_SIZE);
3630-
36313621
for (i = 0; i < 4; i++)
36323622
sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
36333623
sbi->s_def_hash_version = es->s_def_hash_version;
@@ -3697,6 +3687,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
36973687
goto failed_mount;
36983688
}
36993689

3690+
/* Do we have standard group size of clustersize * 8 blocks ? */
3691+
if (sbi->s_blocks_per_group == clustersize << 3)
3692+
set_opt2(sb, STD_GROUP_SIZE);
3693+
37003694
/*
37013695
* Test whether we have more sectors than will fit in sector_t,
37023696
* and whether the max offset is addressable by the page cache.

0 commit comments

Comments
 (0)