hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/mpage.c
....@@ -39,8 +39,6 @@
3939 EXPORT_TRACEPOINT_SYMBOL(android_fs_datawrite_end);
4040 EXPORT_TRACEPOINT_SYMBOL(android_fs_dataread_start);
4141 EXPORT_TRACEPOINT_SYMBOL(android_fs_dataread_end);
42
-EXPORT_TRACEPOINT_SYMBOL(android_fs_fsync_start);
43
-EXPORT_TRACEPOINT_SYMBOL(android_fs_fsync_end);
4442
4543 /*
4644 * I/O completion handler for multipage BIOs.
....@@ -57,7 +55,7 @@
5755 static void mpage_end_io(struct bio *bio)
5856 {
5957 struct bio_vec *bv;
60
- int i;
58
+ struct bvec_iter_all iter_all;
6159
6260 if (trace_android_fs_dataread_end_enabled() &&
6361 (bio_data_dir(bio) == READ)) {
....@@ -69,7 +67,7 @@
6967 bio->bi_iter.bi_size);
7068 }
7169
72
- bio_for_each_segment_all(bv, bio, i) {
70
+ bio_for_each_segment_all(bv, bio, iter_all) {
7371 struct page *page = bv->bv_page;
7472 page_endio(page, bio_op(bio),
7573 blk_status_to_errno(bio->bi_status));
....@@ -100,7 +98,7 @@
10098 }
10199 bio->bi_end_io = mpage_end_io;
102100 bio_set_op_attrs(bio, op, op_flags);
103
- guard_bio_eod(op, bio);
101
+ guard_bio_eod(bio);
104102 submit_bio(bio);
105103 return NULL;
106104 }
....@@ -129,7 +127,7 @@
129127 }
130128
131129 /*
132
- * support function for mpage_readpages. The fs supplied get_block might
130
+ * support function for mpage_readahead. The fs supplied get_block might
133131 * return an up to date buffer. This is used to map that buffer into
134132 * the page, which allows readpage to avoid triggering a duplicate call
135133 * to get_block.
....@@ -376,13 +374,8 @@
376374 }
377375
378376 /**
379
- * mpage_readpages - populate an address space with some pages & start reads against them
380
- * @mapping: the address_space
381
- * @pages: The address of a list_head which contains the target pages. These
382
- * pages have their ->index populated and are otherwise uninitialised.
383
- * The page at @pages->prev has the lowest file offset, and reads should be
384
- * issued in @pages->prev to @pages->next order.
385
- * @nr_pages: The number of pages at *@pages
377
+ * mpage_readahead - start reads against pages
378
+ * @rac: Describes which pages to read.
386379 * @get_block: The filesystem's block mapper function.
387380 *
388381 * This function walks the pages and the blocks within each page, building and
....@@ -419,36 +412,25 @@
419412 *
420413 * This all causes the disk requests to be issued in the correct order.
421414 */
422
-int
423
-mpage_readpages(struct address_space *mapping, struct list_head *pages,
424
- unsigned nr_pages, get_block_t get_block)
415
+void mpage_readahead(struct readahead_control *rac, get_block_t get_block)
425416 {
417
+ struct page *page;
426418 struct mpage_readpage_args args = {
427419 .get_block = get_block,
428420 .is_readahead = true,
429421 };
430
- unsigned page_idx;
431422
432
- for (page_idx = 0; page_idx < nr_pages; page_idx++) {
433
- struct page *page = lru_to_page(pages);
434
-
423
+ while ((page = readahead_page(rac))) {
435424 prefetchw(&page->flags);
436
- list_del(&page->lru);
437
- if (!add_to_page_cache_lru(page, mapping,
438
- page->index,
439
- readahead_gfp_mask(mapping))) {
440
- args.page = page;
441
- args.nr_pages = nr_pages - page_idx;
442
- args.bio = do_mpage_readpage(&args);
443
- }
425
+ args.page = page;
426
+ args.nr_pages = readahead_count(rac);
427
+ args.bio = do_mpage_readpage(&args);
444428 put_page(page);
445429 }
446
- BUG_ON(!list_empty(pages));
447430 if (args.bio)
448431 mpage_bio_submit(REQ_OP_READ, REQ_RAHEAD, args.bio);
449
- return 0;
450432 }
451
-EXPORT_SYMBOL(mpage_readpages);
433
+EXPORT_SYMBOL_NS(mpage_readahead, ANDROID_GKI_VFS_EXPORT_ONLY);
452434
453435 /*
454436 * This isn't called much at all
....@@ -466,7 +448,7 @@
466448 mpage_bio_submit(REQ_OP_READ, 0, args.bio);
467449 return 0;
468450 }
469
-EXPORT_SYMBOL(mpage_readpage);
451
+EXPORT_SYMBOL_NS(mpage_readpage, ANDROID_GKI_VFS_EXPORT_ONLY);
470452
471453 /*
472454 * Writing is not so simple.
....@@ -601,7 +583,7 @@
601583 * Page has buffers, but they are all unmapped. The page was
602584 * created by pagein or read over a hole which was handled by
603585 * block_read_full_page(). If this address_space is also
604
- * using mpage_readpages then this can rarely happen.
586
+ * using mpage_readahead then this can rarely happen.
605587 */
606588 goto confused;
607589 }
....@@ -685,7 +667,7 @@
685667 * the confused fail path above (OOM) will be very confused when
686668 * it finds all bh marked clean (i.e. it will not write anything)
687669 */
688
- wbc_account_io(wbc, page, PAGE_SIZE);
670
+ wbc_account_cgroup_owner(wbc, page, PAGE_SIZE);
689671 length = first_unmapped << blkbits;
690672 if (bio_add_page(bio, page, length, 0) < length) {
691673 bio = mpage_bio_submit(REQ_OP_WRITE, op_flags, bio);