函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:mm\readahead.c Create Date:2022-07-27 15:35:58
首页 Copyright©Brick

530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
/**
 * page_cache_async_readahead - file readahead for marked pages
 * @mapping: address_space which holds the pagecache and I/O vectors
 * @ra: file_ra_state which holds the readahead state
 * @filp: passed on to ->readpage() and ->readpages()
 * @page: the page at @offset which has the PG_readahead flag set
 * @offset: start offset into @mapping, in pagecache page-sized units
 * @req_size: hint: total size of the read which the caller is performing in
 *            pagecache pages
 *
 * page_cache_async_readahead() should be called when a page is used which
 * has the PG_readahead flag; this is a marker to suggest that the application
 * has used up enough of the readahead window that we should start pulling in
 * more pages.
 */
void
page_cache_async_readahead(struct address_space *mapping,
               struct file_ra_state *ra, struct file *filp,
               struct page *page, pgoff_t offset,
               unsigned long req_size)
{
    /* no read-ahead */
    if (!ra->ra_pages)
        return;
 
    /*
     * Same bit is used for PG_readahead and PG_reclaim.
     */
    if (PageWriteback(page))
        return;
 
    ClearPageReadahead(page);
 
    /*
     * Defer asynchronous read-ahead on IO congestion.
     */
    if (inode_read_congested(mapping->host))
        return;
 
    if (blk_cgroup_congested())
        return;
 
    /* do read-ahead */
    ondemand_readahead(mapping, ra, filp, true, offset, req_size);
}