public inbox for [email protected]
 help / color / mirror / Atom feed
From: Mark Harmstone <[email protected]>
To: Jens Axboe <[email protected]>,
	"[email protected]" <[email protected]>,
	"[email protected]" <[email protected]>
Subject: Re: [PATCH] btrfs: add io_uring interface for encoded writes
Date: Wed, 20 Nov 2024 15:50:40 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 12/11/24 21:11, Jens Axboe wrote:
> > 
> On 11/12/24 2:01 PM, Jens Axboe wrote:
>> This is why io_kiocb->async_data exists. uring_cmd is already using that
>> for the sqe, I think you'd want to add a 2nd "void *op_data" or
>> something in there, and have the uring_cmd alloc cache get clear that to
>> NULL and have uring_cmd alloc cache put kfree() it if it's non-NULL.
>>
>> We'd also need to move the uring_cache struct into
>> include/linux/io_uring_types.h so that btrfs can get to it (and probably
>> rename it to something saner, uring_cmd_async_data for example).
> 
> Here are two patches that implement that basic thing on the io_uring
> uring_cmd side. With that, you can then do:
> 
>> static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issue_flags)
>> {
>> 	struct io_kiocb *req = cmd_to_io_kiocb(cmd);
>> 	struct uring_cmd_async_data *data = req->async_data;
>> 	struct btrfs_ioctl_encoded_io_args *args;
>>
>> 	if (!data->op_data) {
>> 		data->op_data = kmalloc(sizeof(*args), GFP_NOIO);
>> 		if (!data->op_data)
>> 			return -ENOMEM;
>> 		if (copy_from_user(data->op_data, sqe_addr, sizeof(*args))
>> 			return -EFAULT;
>> 	}
>> 	...
>> }
> 
> and have it be both stable, and not need to worry about freeing it
> either. Hope that helps. Totally untested...
> 

This works, but I get a KASAN crash because 
io_issue_defs[IORING_OP_URING_CMD].async_size is now the wrong size. 
I'll send a patch for this.

Mark

  reply	other threads:[~2024-11-20 15:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 16:29 [PATCH] btrfs: add io_uring interface for encoded writes Mark Harmstone
2024-11-12 21:01 ` Jens Axboe
2024-11-12 21:11   ` Jens Axboe
2024-11-20 15:50     ` Mark Harmstone [this message]
2024-11-12 21:19   ` Jens Axboe
2024-11-15 17:29   ` Mark Harmstone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox