@@ -394,28 +394,29 @@ void ext4_io_submit_init(struct ext4_io_submit *io,
394
394
io -> io_end = NULL ;
395
395
}
396
396
397
- static int io_submit_init_bio (struct ext4_io_submit * io ,
398
- struct buffer_head * bh )
397
+ static void io_submit_init_bio (struct ext4_io_submit * io ,
398
+ struct buffer_head * bh )
399
399
{
400
400
struct bio * bio ;
401
401
402
+ /*
403
+ * bio_alloc will _always_ be able to allocate a bio if
404
+ * __GFP_DIRECT_RECLAIM is set, see comments for bio_alloc_bioset().
405
+ */
402
406
bio = bio_alloc (GFP_NOIO , BIO_MAX_PAGES );
403
- if (!bio )
404
- return - ENOMEM ;
405
407
bio -> bi_iter .bi_sector = bh -> b_blocknr * (bh -> b_size >> 9 );
406
408
bio_set_dev (bio , bh -> b_bdev );
407
409
bio -> bi_end_io = ext4_end_bio ;
408
410
bio -> bi_private = ext4_get_io_end (io -> io_end );
409
411
io -> io_bio = bio ;
410
412
io -> io_next_block = bh -> b_blocknr ;
411
413
wbc_init_bio (io -> io_wbc , bio );
412
- return 0 ;
413
414
}
414
415
415
- static int io_submit_add_bh (struct ext4_io_submit * io ,
416
- struct inode * inode ,
417
- struct page * page ,
418
- struct buffer_head * bh )
416
+ static void io_submit_add_bh (struct ext4_io_submit * io ,
417
+ struct inode * inode ,
418
+ struct page * page ,
419
+ struct buffer_head * bh )
419
420
{
420
421
int ret ;
421
422
@@ -424,17 +425,14 @@ static int io_submit_add_bh(struct ext4_io_submit *io,
424
425
ext4_io_submit (io );
425
426
}
426
427
if (io -> io_bio == NULL ) {
427
- ret = io_submit_init_bio (io , bh );
428
- if (ret )
429
- return ret ;
428
+ io_submit_init_bio (io , bh );
430
429
io -> io_bio -> bi_write_hint = inode -> i_write_hint ;
431
430
}
432
431
ret = bio_add_page (io -> io_bio , page , bh -> b_size , bh_offset (bh ));
433
432
if (ret != bh -> b_size )
434
433
goto submit_and_retry ;
435
434
wbc_account_cgroup_owner (io -> io_wbc , page , bh -> b_size );
436
435
io -> io_next_block ++ ;
437
- return 0 ;
438
436
}
439
437
440
438
int ext4_bio_write_page (struct ext4_io_submit * io ,
@@ -527,39 +525,28 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
527
525
gfp_flags |= __GFP_NOFAIL ;
528
526
goto retry_encrypt ;
529
527
}
530
- bounce_page = NULL ;
531
- goto out ;
528
+
529
+ printk_ratelimited (KERN_ERR "%s: ret = %d\n" , __func__ , ret );
530
+ redirty_page_for_writepage (wbc , page );
531
+ do {
532
+ clear_buffer_async_write (bh );
533
+ bh = bh -> b_this_page ;
534
+ } while (bh != head );
535
+ goto unlock ;
532
536
}
533
537
}
534
538
535
539
/* Now submit buffers to write */
536
540
do {
537
541
if (!buffer_async_write (bh ))
538
542
continue ;
539
- ret = io_submit_add_bh (io , inode , bounce_page ?: page , bh );
540
- if (ret ) {
541
- /*
542
- * We only get here on ENOMEM. Not much else
543
- * we can do but mark the page as dirty, and
544
- * better luck next time.
545
- */
546
- break ;
547
- }
543
+ io_submit_add_bh (io , inode ,
544
+ bounce_page ? bounce_page : page , bh );
548
545
nr_submitted ++ ;
549
546
clear_buffer_dirty (bh );
550
547
} while ((bh = bh -> b_this_page ) != head );
551
548
552
- /* Error stopped previous loop? Clean up buffers... */
553
- if (ret ) {
554
- out :
555
- fscrypt_free_bounce_page (bounce_page );
556
- printk_ratelimited (KERN_ERR "%s: ret = %d\n" , __func__ , ret );
557
- redirty_page_for_writepage (wbc , page );
558
- do {
559
- clear_buffer_async_write (bh );
560
- bh = bh -> b_this_page ;
561
- } while (bh != head );
562
- }
549
+ unlock :
563
550
unlock_page (page );
564
551
/* Nothing submitted - we have to end page writeback */
565
552
if (!nr_submitted )
0 commit comments