rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Qingsong Chen" <changxian.cqs@antgroup.com>
To: Benno Lossin <benno.lossin@proton.me>
Cc: linux-kernel@vger.kernel.org, 田洪亮 <tate.thl@antgroup.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH 2/8] rust: kernel: add `request` related TargetOperations
Date: Mon, 17 Jul 2023 11:42:34 +0800	[thread overview]
Message-ID: <081f7e9b-a769-b4cf-4df4-b0bb5c9a1594@antgroup.com> (raw)
In-Reply-To: <-IRG_a-qIx3Io5P-2p2t7mTbhsaV-Jizcvu0frlx6Pfj5mrnYL92vL5ZGfhY5lXdfAP-g3B02SpBAKWgPwpfxVpWBjMMWmTnhF9DLdU9808=@proton.me>

On 7/14/23 11:49 PM, Benno Lossin wrote:
>> @@ -31,6 +31,39 @@ pub trait TargetOperations: Sized {
>>      /// Map block IOs. Return [`MapState`] to indicate how to handle the `bio`
>>      /// later (end or resubmit).
>>      fn map(t: &mut Target<Self>, bio: Pin<&mut Bio>) -> MapState;
>> +
>> +    /// Map `request`. Return [`MapState`] and the optional cloned `request`.
>> +    #[allow(unused)]
>> +    fn clone_and_map_rq<'a>(
>> +        t: &mut Target<Self>,
>> +        rq: Pin<&mut Request>,
>> +        map_ctx: &mut MapInfo,
>> +    ) -> (MapState, Option<Pin<&'a mut Request>>) {
>> +        unimplemented!()
> 
> Note that these should be implemented when you submit this as an actual
> patch. (Not sure what you would do in this case, but throwing a panic is
> not a good idea.) This also applies to all subsequent patches.
> I think you might have done this, because you want the C side to choose
> the default implementation. But it should also be possible to call these
> from the Rust side.

In fact, we don't want users to call these callbacks manually. The 
normal call-chain would be like this: `map_request`(c) ->
`dm_clone_and_map_rq_fn`(unsafe rust) -> `clone_and_map_rq`(rust).
If users don't implement `clone_and_map_rq`, we would check the
corresponding field of `TargetType`, using the `check_target_operations`
macro. So it won't call the default implementation generally.

Regards,
Qingsong

  reply	other threads:[~2023-07-17  3:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25 12:16 [RFC PATCH 0/8] Rust device mapper abstractions Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 1/8] rust: kernel: add basic abstractions for device-mapper Qingsong Chen
2023-06-25 12:25   ` Greg KH
2023-06-26  3:26     ` Qingsong Chen
2023-06-26 16:39       ` Boqun Feng
2023-07-14 15:48   ` Benno Lossin
2023-07-17  3:04     ` Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 2/8] rust: kernel: add `request` related TargetOperations Qingsong Chen
2023-07-14 15:49   ` Benno Lossin
2023-07-17  3:42     ` Qingsong Chen [this message]
2023-06-25 12:16 ` [RFC PATCH 3/8] rust: kernel: add some hook TargetOperations Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 4/8] rust: kernel: add some info handler TargetOperations Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 5/8] rust: kernel: add underlying device related TargetOperations Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 6/8] rust: kernel: add DAX " Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 7/8] rust: kernel: prepare to implement dm target in Rust Qingsong Chen
2023-06-25 12:16 ` [RFC PATCH 8/8] samples: rust: add a device mapper linear target Qingsong Chen

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 \
    --in-reply-to=081f7e9b-a769-b4cf-4df4-b0bb5c9a1594@antgroup.com \
    --to=changxian.cqs@antgroup.com \
    --cc=alex.gaynor@gmail.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tate.thl@antgroup.com \
    --cc=wedsonaf@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).