Commit cc3cb0a1 authored by David Howells's avatar David Howells

netfs: Allow the netfs to make the io (sub)request alloc larger

Allow the network filesystem to specify extra space to be allocated on the
end of the io (sub)request.  This allows cifs, for example, to use this
space rather than allocating its own cifs_readdata struct.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
parent 87b57a04
...@@ -22,7 +22,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, ...@@ -22,7 +22,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
struct netfs_io_request *rreq; struct netfs_io_request *rreq;
int ret; int ret;
rreq = kzalloc(sizeof(struct netfs_io_request), GFP_KERNEL); rreq = kzalloc(ctx->ops->io_request_size ?: sizeof(struct netfs_io_request),
GFP_KERNEL);
if (!rreq) if (!rreq)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -114,7 +115,9 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq ...@@ -114,7 +115,9 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq
{ {
struct netfs_io_subrequest *subreq; struct netfs_io_subrequest *subreq;
subreq = kzalloc(sizeof(struct netfs_io_subrequest), GFP_KERNEL); subreq = kzalloc(rreq->netfs_ops->io_subrequest_size ?:
sizeof(struct netfs_io_subrequest),
GFP_KERNEL);
if (subreq) { if (subreq) {
INIT_LIST_HEAD(&subreq->rreq_link); INIT_LIST_HEAD(&subreq->rreq_link);
refcount_set(&subreq->ref, 2); refcount_set(&subreq->ref, 2);
......
...@@ -210,6 +210,8 @@ struct netfs_io_request { ...@@ -210,6 +210,8 @@ struct netfs_io_request {
* Operations the network filesystem can/must provide to the helpers. * Operations the network filesystem can/must provide to the helpers.
*/ */
struct netfs_request_ops { struct netfs_request_ops {
unsigned int io_request_size; /* Alloc size for netfs_io_request struct */
unsigned int io_subrequest_size; /* Alloc size for netfs_io_subrequest struct */
int (*init_request)(struct netfs_io_request *rreq, struct file *file); int (*init_request)(struct netfs_io_request *rreq, struct file *file);
void (*free_request)(struct netfs_io_request *rreq); void (*free_request)(struct netfs_io_request *rreq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment