[PATCH v3 20/22] erofs: implement fscache-based data readahead for non-inline layout

Jeffle Xu jefflexu at linux.alibaba.com
Wed Feb 9 17:01:06 AEDT 2022


Signed-off-by: Jeffle Xu <jefflexu at linux.alibaba.com>
---
 fs/erofs/fscache.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index c8a0851230e5..ef5eef33e3d5 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -197,6 +197,7 @@ static int erofs_fscache_readpage(struct file *file, struct page *page)
 
 enum erofs_fscache_readahead_type {
 	EROFS_FSCACHE_READAHEAD_TYPE_HOLE,
+	EROFS_FSCACHE_READAHEAD_TYPE_NOINLINE,
 };
 
 static int erofs_fscache_do_readahead(struct readahead_control *rac,
@@ -205,10 +206,14 @@ static int erofs_fscache_do_readahead(struct readahead_control *rac,
 {
 	size_t offset, length, done;
 	struct page *page;
+	int ret = 0;
 
 	/*
-	 * 1) For CHUNK_BASED (HOLE), the output map.m_la is rounded down to
-	 *    the nearest chunk boundary, and thus offset will be non-zero.
+	 * 1) For CHUNK_BASED (HOLE/NOINLINE), the output map.m_la is rounded
+	 *    down to the nearest chunk boundary, and thus offset will be
+	 *    non-zero.
+	 * 2) For the other cases, the output map.m_la shall be equal to o_la,
+	 *    and thus offset will be zero.
 	 */
 	offset = fsmap->o_la - fsmap->m_la;
 	length = fsmap->m_llen - offset;
@@ -222,11 +227,18 @@ static int erofs_fscache_do_readahead(struct readahead_control *rac,
 		case EROFS_FSCACHE_READAHEAD_TYPE_HOLE:
 			zero_user(page, 0, PAGE_SIZE);
 			break;
+		case EROFS_FSCACHE_READAHEAD_TYPE_NOINLINE:
+			ret = erofs_fscache_readpage_noinline(page, fsmap);
+			fsmap->m_pa += EROFS_BLKSIZ;
+			break;
 		default:
 			DBG_BUGON(1);
 			return -EINVAL;
 		}
 
+		if (ret)
+			return ret;
+
 		SetPageUptodate(page);
 		unlock_page(page);
 	}
@@ -263,7 +275,16 @@ static void erofs_fscache_readahead(struct readahead_control *rac)
 			ret = erofs_fscache_do_readahead(rac, &fsmap,
 					EROFS_FSCACHE_READAHEAD_TYPE_HOLE);
 		} else {
+			ret = erofs_fscache_get_map(&fsmap, &map, sb);
+			if (ret)
+				return;
+
 			switch (vi->datalayout) {
+			case EROFS_INODE_FLAT_PLAIN:
+			case EROFS_INODE_CHUNK_BASED:
+				ret = erofs_fscache_do_readahead(rac, &fsmap,
+					EROFS_FSCACHE_READAHEAD_TYPE_NOINLINE);
+				break;
 			default:
 				DBG_BUGON(1);
 				return;
-- 
2.27.0



More information about the Linux-erofs mailing list