6
6
*/
7
7
#include "internal.h"
8
8
#include <linux/prefetch.h>
9
+ #include <linux/sched/mm.h>
9
10
#include <linux/dax.h>
10
11
#include <trace/events/erofs.h>
11
12
@@ -35,14 +36,20 @@ void *erofs_bread(struct erofs_buf *buf, struct inode *inode,
35
36
erofs_off_t offset = blknr_to_addr (blkaddr );
36
37
pgoff_t index = offset >> PAGE_SHIFT ;
37
38
struct page * page = buf -> page ;
39
+ struct folio * folio ;
40
+ unsigned int nofs_flag ;
38
41
39
42
if (!page || page -> index != index ) {
40
43
erofs_put_metabuf (buf );
41
- page = read_cache_page_gfp (mapping , index ,
42
- mapping_gfp_constraint (mapping , ~__GFP_FS ));
43
- if (IS_ERR (page ))
44
- return page ;
44
+
45
+ nofs_flag = memalloc_nofs_save ();
46
+ folio = read_cache_folio (mapping , index , NULL , NULL );
47
+ memalloc_nofs_restore (nofs_flag );
48
+ if (IS_ERR (folio ))
49
+ return folio ;
50
+
45
51
/* should already be PageUptodate, no need to lock page */
52
+ page = folio_file_page (folio , index );
46
53
buf -> page = page ;
47
54
}
48
55
if (buf -> kmap_type == EROFS_NO_KMAP ) {
@@ -63,6 +70,10 @@ void *erofs_bread(struct erofs_buf *buf, struct inode *inode,
63
70
void * erofs_read_metabuf (struct erofs_buf * buf , struct super_block * sb ,
64
71
erofs_blk_t blkaddr , enum erofs_kmap_type type )
65
72
{
73
+ if (erofs_is_fscache_mode (sb ))
74
+ return erofs_bread (buf , EROFS_SB (sb )-> s_fscache -> inode ,
75
+ blkaddr , type );
76
+
66
77
return erofs_bread (buf , sb -> s_bdev -> bd_inode , blkaddr , type );
67
78
}
68
79
0 commit comments