pageout

 

/*

 * pageout is called by shrink_page_list() foreach dirty page.

 * Calls ->writepage().

 */

staticpageout_t pageout(struct page *page, struct address_space *mapping,

                      struct scan_control *sc)

{

 

       if (!is_page_cache_freeable(page))

              return PAGE_KEEP;

 

       if (!mapping) {

              if (page_has_private(page)) {

                     if(try_to_free_buffers(page)) {

                            ClearPageDirty(page);

                            pr_info("%s:orphaned page\n", __func__);

                            return PAGE_CLEAN;

                     }

              }

              return PAGE_KEEP;

       }

       if (mapping->a_ops->writepage ==NULL)

              return PAGE_ACTIVATE;

       if (!may_write_to_inode(mapping->host,sc))

              return PAGE_KEEP;

 

       if(clear_page_dirty_for_io(page)) {

              int res;

              struct writeback_control wbc = {

                     .sync_mode = WB_SYNC_NONE,

                     .nr_to_write =SWAP_CLUSTER_MAX,

                     .range_start = 0,

                     .range_end = LLONG_MAX,

                     .for_reclaim = 1,

              };

 

              SetPageReclaim(page);

              res = mapping->a_ops->writepage(page, &wbc);

              if (res < 0)

                     handle_write_error(mapping,page, res);

              if (res == AOP_WRITEPAGE_ACTIVATE){

                     ClearPageReclaim(page);

                     return PAGE_ACTIVATE;

              }

 

              if (!PageWriteback(page)) {

                     ClearPageReclaim(page);

              }

              trace_mm_vmscan_writepage(page);

              inc_zone_page_state(page, NR_VMSCAN_WRITE);

              return PAGE_SUCCESS;

       }

 

       return PAGE_CLEAN;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值