mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
fuse-uring: refactor setting up copy state for payload copying
Add a new helper function setup_fuse_copy_state() to contain the logic for setting up the copy state for payload copying. Reviewed-by: Bernd Schubert <bschubert@ddn.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Baokun Li <libaokun@linux.alibaba.com> Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
b2bbd7dcd2
commit
c0f9203732
|
|
@ -642,6 +642,27 @@ static int copy_header_from_ring(struct fuse_ring_ent *ent,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int setup_fuse_copy_state(struct fuse_copy_state *cs,
|
||||
struct fuse_ring *ring, struct fuse_req *req,
|
||||
struct fuse_ring_ent *ent, int dir,
|
||||
struct iov_iter *iter)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = import_ubuf(dir, ent->payload, ring->max_payload_sz, iter);
|
||||
if (err) {
|
||||
pr_info_ratelimited("fuse: Import of user buffer failed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
fuse_copy_init(cs, dir == ITER_DEST, iter);
|
||||
|
||||
cs->is_uring = true;
|
||||
cs->req = req;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fuse_uring_copy_from_ring(struct fuse_ring *ring,
|
||||
struct fuse_req *req,
|
||||
struct fuse_ring_ent *ent)
|
||||
|
|
@ -657,15 +678,10 @@ static int fuse_uring_copy_from_ring(struct fuse_ring *ring,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
err = import_ubuf(ITER_SOURCE, ent->payload, ring->max_payload_sz,
|
||||
&iter);
|
||||
err = setup_fuse_copy_state(&cs, ring, req, ent, ITER_SOURCE, &iter);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
fuse_copy_init(&cs, false, &iter);
|
||||
cs.is_uring = true;
|
||||
cs.req = req;
|
||||
|
||||
err = fuse_copy_out_args(&cs, args, ring_in_out.payload_sz);
|
||||
fuse_copy_finish(&cs);
|
||||
return err;
|
||||
|
|
@ -688,15 +704,9 @@ static int fuse_uring_args_to_ring(struct fuse_ring *ring, struct fuse_req *req,
|
|||
.commit_id = req->in.h.unique,
|
||||
};
|
||||
|
||||
err = import_ubuf(ITER_DEST, ent->payload, ring->max_payload_sz, &iter);
|
||||
if (err) {
|
||||
pr_info_ratelimited("fuse: Import of user buffer failed\n");
|
||||
err = setup_fuse_copy_state(&cs, ring, req, ent, ITER_DEST, &iter);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
fuse_copy_init(&cs, true, &iter);
|
||||
cs.is_uring = true;
|
||||
cs.req = req;
|
||||
|
||||
if (num_args > 0) {
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user