fscache.c (3c265d7dcefab21a58ca5454c0f778412bde0870) | fscache.c (ec00b5e29ce3a2493616a03b56593690574a8c86) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (C) 2022, Alibaba Cloud 4 */ 5#include <linux/fscache.h> 6#include "internal.h" 7 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (C) 2022, Alibaba Cloud 4 */ 5#include <linux/fscache.h> 6#include "internal.h" 7 |
8/* 9 * Read data from fscache and fill the read data into page cache described by 10 * @start/len, which shall be both aligned with PAGE_SIZE. @pstart describes 11 * the start physical address in the cache file. 12 */ 13static int erofs_fscache_read_folios(struct fscache_cookie *cookie, 14 struct address_space *mapping, 15 loff_t start, size_t len, 16 loff_t pstart) 17{ 18 enum netfs_io_source source; 19 struct netfs_io_request rreq = {}; 20 struct netfs_io_subrequest subreq = { .rreq = &rreq, }; 21 struct netfs_cache_resources *cres = &rreq.cache_resources; 22 struct super_block *sb = mapping->host->i_sb; 23 struct iov_iter iter; 24 size_t done = 0; 25 int ret; 26 27 ret = fscache_begin_read_operation(cres, cookie); 28 if (ret) 29 return ret; 30 31 while (done < len) { 32 subreq.start = pstart + done; 33 subreq.len = len - done; 34 subreq.flags = 1 << NETFS_SREQ_ONDEMAND; 35 36 source = cres->ops->prepare_read(&subreq, LLONG_MAX); 37 if (WARN_ON(subreq.len == 0)) 38 source = NETFS_INVALID_READ; 39 if (source != NETFS_READ_FROM_CACHE) { 40 erofs_err(sb, "failed to fscache prepare_read (source %d)", 41 source); 42 ret = -EIO; 43 goto out; 44 } 45 46 iov_iter_xarray(&iter, READ, &mapping->i_pages, 47 start + done, subreq.len); 48 ret = fscache_read(cres, subreq.start, &iter, 49 NETFS_READ_HOLE_FAIL, NULL, NULL); 50 if (ret) { 51 erofs_err(sb, "failed to fscache_read (ret %d)", ret); 52 goto out; 53 } 54 55 done += subreq.len; 56 } 57out: 58 fscache_end_operation(cres); 59 return ret; 60} 61 |
|
8static const struct address_space_operations erofs_fscache_meta_aops = { 9}; 10 11int erofs_fscache_register_cookie(struct super_block *sb, 12 struct erofs_fscache **fscache, 13 char *name, bool need_inode) 14{ 15 struct fscache_volume *volume = EROFS_SB(sb)->volume; --- 96 unchanged lines hidden --- | 62static const struct address_space_operations erofs_fscache_meta_aops = { 63}; 64 65int erofs_fscache_register_cookie(struct super_block *sb, 66 struct erofs_fscache **fscache, 67 char *name, bool need_inode) 68{ 69 struct fscache_volume *volume = EROFS_SB(sb)->volume; --- 96 unchanged lines hidden --- |