Skip to content

Commit 24c90a7

Browse files
dhowellsbrauner
authored andcommitted
netfs: Set the request work function upon allocation
Set the work function in the netfs_io_request work_struct when we allocate the request rather than doing this later. This reduces the number of places we need to set it in future code. Signed-off-by: David Howells <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ # v2 Signed-off-by: Christian Brauner <[email protected]>
1 parent c57de2a commit 24c90a7

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

fs/netfs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
2929
/*
3030
* io.c
3131
*/
32+
void netfs_rreq_work(struct work_struct *work);
3233
int netfs_begin_read(struct netfs_io_request *rreq, bool sync);
3334

3435
/*

fs/netfs/io.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static void netfs_rreq_assess(struct netfs_io_request *rreq, bool was_async)
426426
netfs_rreq_completed(rreq, was_async);
427427
}
428428

429-
static void netfs_rreq_work(struct work_struct *work)
429+
void netfs_rreq_work(struct work_struct *work)
430430
{
431431
struct netfs_io_request *rreq =
432432
container_of(work, struct netfs_io_request, work);
@@ -739,8 +739,6 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync)
739739
// TODO: Use bounce buffer if requested
740740
rreq->io_iter = rreq->iter;
741741

742-
INIT_WORK(&rreq->work, netfs_rreq_work);
743-
744742
/* Chop the read into slices according to what the cache and the netfs
745743
* want and submit each one.
746744
*/

fs/netfs/objects.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
4848
INIT_LIST_HEAD(&rreq->io_streams[0].subrequests);
4949
INIT_LIST_HEAD(&rreq->io_streams[1].subrequests);
5050
INIT_LIST_HEAD(&rreq->subrequests);
51-
INIT_WORK(&rreq->work, NULL);
5251
refcount_set(&rreq->ref, 1);
5352

53+
if (origin == NETFS_READAHEAD ||
54+
origin == NETFS_READPAGE ||
55+
origin == NETFS_READ_FOR_WRITE ||
56+
origin == NETFS_DIO_READ)
57+
INIT_WORK(&rreq->work, netfs_rreq_work);
58+
else
59+
INIT_WORK(&rreq->work, netfs_write_collection_worker);
60+
5461
__set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
5562
if (file && file->f_flags & O_NONBLOCK)
5663
__set_bit(NETFS_RREQ_NONBLOCK, &rreq->flags);

fs/netfs/write_issue.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping,
109109

110110
wreq->contiguity = wreq->start;
111111
wreq->cleaned_to = wreq->start;
112-
INIT_WORK(&wreq->work, netfs_write_collection_worker);
113112

114113
wreq->io_streams[0].stream_nr = 0;
115114
wreq->io_streams[0].source = NETFS_UPLOAD_TO_SERVER;

0 commit comments

Comments
 (0)