summaryrefslogtreecommitdiffstats
path: root/fs/netfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/netfs')
-rw-r--r--fs/netfs/internal.h7
-rw-r--r--fs/netfs/objects.c13
-rw-r--r--fs/netfs/read_helper.c23
3 files changed, 26 insertions, 17 deletions
diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h
index a0b7d1bf9f3d..89837e904fa7 100644
--- a/fs/netfs/internal.h
+++ b/fs/netfs/internal.h
@@ -17,9 +17,12 @@
/*
* objects.c
*/
-struct netfs_io_request *netfs_alloc_request(const struct netfs_request_ops *ops,
+struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
+ struct file *file,
+ const struct netfs_request_ops *ops,
void *netfs_priv,
- struct file *file);
+ loff_t start, size_t len,
+ enum netfs_io_origin origin);
void netfs_get_request(struct netfs_io_request *rreq, enum netfs_rreq_ref_trace what);
void netfs_clear_subrequests(struct netfs_io_request *rreq, bool was_async);
void netfs_put_request(struct netfs_io_request *rreq, bool was_async,
diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c
index 39097893e847..986d7a9d25dd 100644
--- a/fs/netfs/objects.c
+++ b/fs/netfs/objects.c
@@ -11,17 +11,24 @@
/*
* Allocate an I/O request and initialise it.
*/
-struct netfs_io_request *netfs_alloc_request(
- const struct netfs_request_ops *ops, void *netfs_priv,
- struct file *file)
+struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
+ struct file *file,
+ const struct netfs_request_ops *ops,
+ void *netfs_priv,
+ loff_t start, size_t len,
+ enum netfs_io_origin origin)
{
static atomic_t debug_ids;
struct netfs_io_request *rreq;
rreq = kzalloc(sizeof(struct netfs_io_request), GFP_KERNEL);
if (rreq) {
+ rreq->start = start;
+ rreq->len = len;
+ rreq->origin = origin;
rreq->netfs_ops = ops;
rreq->netfs_priv = netfs_priv;
+ rreq->mapping = mapping;
rreq->inode = file_inode(file);
rreq->i_size = i_size_read(rreq->inode);
rreq->debug_id = atomic_inc_return(&debug_ids);
diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index 8f277da487b6..dea085715286 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -763,12 +763,13 @@ void netfs_readahead(struct readahead_control *ractl,
if (readahead_count(ractl) == 0)
goto cleanup;
- rreq = netfs_alloc_request(ops, netfs_priv, ractl->file);
+ rreq = netfs_alloc_request(ractl->mapping, ractl->file,
+ ops, netfs_priv,
+ readahead_pos(ractl),
+ readahead_length(ractl),
+ NETFS_READAHEAD);
if (!rreq)
goto cleanup;
- rreq->mapping = ractl->mapping;
- rreq->start = readahead_pos(ractl);
- rreq->len = readahead_length(ractl);
if (ops->begin_cache_operation) {
ret = ops->begin_cache_operation(rreq);
@@ -838,16 +839,15 @@ int netfs_readpage(struct file *file,
_enter("%lx", folio_index(folio));
- rreq = netfs_alloc_request(ops, netfs_priv, file);
+ rreq = netfs_alloc_request(folio->mapping, file, ops, netfs_priv,
+ folio_file_pos(folio), folio_size(folio),
+ NETFS_READPAGE);
if (!rreq) {
if (netfs_priv)
ops->cleanup(folio_file_mapping(folio), netfs_priv);
folio_unlock(folio);
return -ENOMEM;
}
- rreq->mapping = folio_file_mapping(folio);
- rreq->start = folio_file_pos(folio);
- rreq->len = folio_size(folio);
if (ops->begin_cache_operation) {
ret = ops->begin_cache_operation(rreq);
@@ -1008,12 +1008,11 @@ retry:
}
ret = -ENOMEM;
- rreq = netfs_alloc_request(ops, netfs_priv, file);
+ rreq = netfs_alloc_request(mapping, file, ops, netfs_priv,
+ folio_file_pos(folio), folio_size(folio),
+ NETFS_READ_FOR_WRITE);
if (!rreq)
goto error;
- rreq->mapping = folio_file_mapping(folio);
- rreq->start = folio_file_pos(folio);
- rreq->len = folio_size(folio);
rreq->no_unlock_folio = folio_index(folio);
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
netfs_priv = NULL;