diff mbox series

blk-mq: export blk_mq_submit_bio symbol

Message ID 20210909053653.144360-1-kumarpraveen@linux.microsoft.com (mailing list archive)
State New, archived
Headers show
Series blk-mq: export blk_mq_submit_bio symbol | expand

Commit Message

Praveen Kumar Sept. 9, 2021, 5:36 a.m. UTC
There are use-cases like replication where need to hook the blk I/O
operations for devices and perform specific operation and fallback to
its original I/O operations.
Prior to v5.9 there was make_request_fn and then blk_mq_submit_bio
exported apis, which provided infrastructure to drivers to develop these
features. However in v5.10-rc1 with below commit the API was removed
from the export list.

Previous commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.10-rc1&id=681cc5e8667e8579a2da8fa4090c48a2d73fc3bb

This patch exports the blk_mq_submit_bio symbol to provide flexibility
to the drivers.

Signed-off-by: Praveen Kumar <kumarpraveen@linux.microsoft.com>
---
 block/blk-mq.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Christoph Hellwig Sept. 9, 2021, 5:48 a.m. UTC | #1
On Thu, Sep 09, 2021 at 11:06:53AM +0530, Praveen Kumar wrote:
> There are use-cases like replication where need to hook the blk I/O
> operations for devices and perform specific operation and fallback to
> its original I/O operations.
> Prior to v5.9 there was make_request_fn and then blk_mq_submit_bio
> exported apis, which provided infrastructure to drivers to develop these
> features. However in v5.10-rc1 with below commit the API was removed
> from the export list.
> 
> Previous commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.10-rc1&id=681cc5e8667e8579a2da8fa4090c48a2d73fc3bb
> 
> This patch exports the blk_mq_submit_bio symbol to provide flexibility
> to the drivers.

Please send your users of this "feature" to this list for inclusion
and we'll help you to massage them into a non-broken version.

And yes, you should have gotten the memo by now that we don't export
anything for out of tree modules.
Chaitanya Kulkarni Sept. 9, 2021, 4:16 p.m. UTC | #2
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 65d3a63aecc6..40a9b085f029 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2283,6 +2283,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
>          blk_queue_exit(q);
>          return BLK_QC_T_NONE;
>   }
> +EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
>

Where is the code that used this API ?

>   static size_t order_to_size(unsigned int order)
>   {
> --
> 2.25.1
>
Praveen Kumar Sept. 10, 2021, 11:54 a.m. UTC | #3
On 09-09-2021 11:18, Christoph Hellwig wrote:
> On Thu, Sep 09, 2021 at 11:06:53AM +0530, Praveen Kumar wrote:
>> There are use-cases like replication where need to hook the blk I/O
>> operations for devices and perform specific operation and fallback to
>> its original I/O operations.
>> Prior to v5.9 there was make_request_fn and then blk_mq_submit_bio
>> exported apis, which provided infrastructure to drivers to develop these
>> features. However in v5.10-rc1 with below commit the API was removed
>> from the export list.
>>
>> Previous commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.10-rc1&id=681cc5e8667e8579a2da8fa4090c48a2d73fc3bb
>>
>> This patch exports the blk_mq_submit_bio symbol to provide flexibility
>> to the drivers.
> 
> Please send your users of this "feature" to this list for inclusion
> and we'll help you to massage them into a non-broken version.
> 

Thank you for the response and appreciate your help. Providing a bit of
details below.

The disk replication solution which I mentioned, hooks all the block i/o
operation using make_request_fn for specific device request queue and do
some massaging and then call the standard block operations.
The flow is something like below :

replication_func_init (struct block_device *bdev)
... orig_queue = bdev_get_queue(bdev)		// save the original state
... orig_request_fn = orig_queue->request_fn;
... orig_queue->make_request_fn = custom_function(say "replicate_request_func")


replicate_request_func(...) {
... does some driver specific massaging
... // calls original
    if (orig_queue->make_request_fn)
	orig_queue->make_request_fn(...)
    else
	blk_mq_make_request(...)
...

Now, the current implementation have make_request_fn moved to submit_bio, one
probable approach is to somehow, update the original submit_bio to custom
"replicate_submit_bio_func" and then handle the case likewise as done in
"replicate_request_func". But, "blk_mq_submit_bio" is not exported symbol..

Second, "submit_bio_noacct" is the next approach which we thought can be used
for submit the bio, but, for case where original submit_bio is NULL, we will
end calling recursively the new submit_bio, and panic. 

replicate_submit_bio_func
... does some driver specific massaging
... // calls exported symbol
   submit_bio_noacct
    __submit_bio_noacct(bio)
       __submit_bio
        disk->fops->submit_bio(bio) -> updated API
         replicate_submit_bio_func
           submit_bio_noacct

Hope, the provided information helps understanding the problem. If not, please
do let us know, we will try to provide more details accordingly.  Also, please
do provide your thoughts and suggestions how can we achieve the above kind of
functionality on latest kernel version.


Further, we were trying to understand the history over the removal of make_request_fn
in the queue within blk_mq_init_allocated_queue API, but didn't find much. Can you
please provide any information regarding the same. Also, is there a possibility of have
similar kind of implemenation for submit_bio ?

...
-	q->make_request_fn = blk_mq_make_request;
...
Patch : https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/block/blk-mq.c?h=v5.14&id=8cf7961dab42c9177a556b719c15f5b9449c24d1 

Regards,

~Praveen.
Praveen Kumar Sept. 13, 2021, 4:24 a.m. UTC | #4
On 09-09-2021 21:46, Chaitanya Kulkarni wrote:
> 
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index 65d3a63aecc6..40a9b085f029 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -2283,6 +2283,7 @@ blk_qc_t blk_mq_submit_bio(struct bio *bio)
>>          blk_queue_exit(q);
>>          return BLK_QC_T_NONE;
>>   }
>> +EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
>>
> 
> Where is the code that used this API ?
> 

Thanks Chaitanya for your response. Please check my response to Christoph.
That should give overall understanding of the use-case.

Regards,

~Praveen.
Christoph Hellwig Sept. 13, 2021, 6:09 a.m. UTC | #5
On Mon, Sep 13, 2021 at 09:54:54AM +0530, Praveen Kumar wrote:
> >> +EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
> >>
> > 
> > Where is the code that used this API ?
> > 
> 
> Thanks Chaitanya for your response. Please check my response to Christoph.
> That should give overall understanding of the use-case.

Which really doesn't matter, while you keep ingoring the relevant
question.  If you code is not upstream or at least actively being
submitted upstream your questions have no relevance whatsoever.
If you do not undertand that basic fact your are in the wrong place
here.
Praveen Kumar Sept. 13, 2021, 7:03 a.m. UTC | #6
On 13-09-2021 11:39, Christoph Hellwig wrote:
> On Mon, Sep 13, 2021 at 09:54:54AM +0530, Praveen Kumar wrote:
>>>> +EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
>>>>
>>>
>>> Where is the code that used this API ?
>>>
>>
>> Thanks Chaitanya for your response. Please check my response to Christoph.
>> That should give overall understanding of the use-case.
> 
> Which really doesn't matter, while you keep ingoring the relevant
> question.  If you code is not upstream or at least actively being
> submitted upstream your questions have no relevance whatsoever.
> If you do not undertand that basic fact your are in the wrong place
> here.
> 

Hi Christoph,

The upstream activity is being planned and will take sometime to reach to
that state as we have to make it ready for latest kernel.

To achieve the same, we were finding some solutions to handle latest changes.
If you have scanned my previous email where I have provided a detail what the driver
is doing, I did mention that we plan to use "blk_mq_submit_bio" but failed to do
so, as code is not exported. So, to the specific answer, this API is NOT being
used anywhere as of now.

However, as you mentioned, the API cannot be exported for any specific driver,
is there any solution or way if a custom driver wants to hook the existing bio path
and massage it and then fall back to original flow ?

Regards,

~Praveen.
Prasad Muppana Sept. 20, 2021, 5:30 a.m. UTC | #7
Hi Christoph,

We are in the process of opening the source code for the driver and stuck with this issue which is causing delay in the process. Currently, the Linux customers are impacted by this issue and mostly RHEL8.4 and Ubuntu customers are blocked. So we are looking for any solution that can mitigate this issue as short term goal and in the meantime, we will open the source which will have long term solution to handle this issue. Please help here in this case.

With Thanks,
Prasad 

-----Original Message-----
From: Praveen Kumar <kumarpraveen@linux.microsoft.com> 
Sent: Monday, September 13, 2021 12:34 PM
To: Christoph Hellwig <hch@infradead.org>
Cc: Chaitanya Kulkarni <chaitanyak@nvidia.com>; linux-block@vger.kernel.org; linux-kernel@vger.kernel.org; axboe@kernel.dk; schakrabarti@linux.microsoft.com; Prasad Muppana <Lalita.Muppana@microsoft.com>
Subject: Re: [PATCH] blk-mq: export blk_mq_submit_bio symbol

On 13-09-2021 11:39, Christoph Hellwig wrote:
> On Mon, Sep 13, 2021 at 09:54:54AM +0530, Praveen Kumar wrote:
>>>> +EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
>>>>
>>>
>>> Where is the code that used this API ?
>>>
>>
>> Thanks Chaitanya for your response. Please check my response to Christoph.
>> That should give overall understanding of the use-case.
> 
> Which really doesn't matter, while you keep ingoring the relevant 
> question.  If you code is not upstream or at least actively being 
> submitted upstream your questions have no relevance whatsoever.
> If you do not undertand that basic fact your are in the wrong place 
> here.
> 

Hi Christoph,

The upstream activity is being planned and will take sometime to reach to that state as we have to make it ready for latest kernel.

To achieve the same, we were finding some solutions to handle latest changes.
If you have scanned my previous email where I have provided a detail what the driver is doing, I did mention that we plan to use "blk_mq_submit_bio" but failed to do so, as code is not exported. So, to the specific answer, this API is NOT being used anywhere as of now.

However, as you mentioned, the API cannot be exported for any specific driver, is there any solution or way if a custom driver wants to hook the existing bio path and massage it and then fall back to original flow ?

Regards,

~Praveen.
Chaitanya Kulkarni Sept. 20, 2021, 8:25 p.m. UTC | #8
On 9/19/21 10:30 PM, Prasad Muppana wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Christoph,
> 
> We are in the process of opening the source code for the driver and stuck with this issue which is causing delay in the process. Currently, the Linux customers are impacted by this issue and mostly RHEL8.4 and Ubuntu customers are blocked. So we are looking for any solution that can mitigate this issue as short term goal and in the meantime, we will open the source which will have long term solution to handle this issue. Please help here in this case.
> 

The ideal way is to submit this with the code that is using this.
Prasad Muppana Sept. 22, 2021, 5:45 a.m. UTC | #9
Hi Chaitanya,

Thanks for the response.

Our driver code is not yet public and so Praveen has explained the flow of the code. Please let me know is there any other way to get some help here quickly.

With Thanks,
Prasad

-----Original Message-----
From: Chaitanya Kulkarni <chaitanyak@nvidia.com> 
Sent: Tuesday, September 21, 2021 1:55 AM
To: Prasad Muppana <Lalita.Muppana@microsoft.com>; Praveen Kumar <kumarpraveen@linux.microsoft.com>; Christoph Hellwig <hch@infradead.org>
Cc: linux-block@vger.kernel.org; linux-kernel@vger.kernel.org; axboe@kernel.dk; schakrabarti@linux.microsoft.com
Subject: [EXTERNAL] Re: [PATCH] blk-mq: export blk_mq_submit_bio symbol

On 9/19/21 10:30 PM, Prasad Muppana wrote:
> External email: Use caution opening links or attachments
> 
> 
> Hi Christoph,
> 
> We are in the process of opening the source code for the driver and stuck with this issue which is causing delay in the process. Currently, the Linux customers are impacted by this issue and mostly RHEL8.4 and Ubuntu customers are blocked. So we are looking for any solution that can mitigate this issue as short term goal and in the meantime, we will open the source which will have long term solution to handle this issue. Please help here in this case.
> 

The ideal way is to submit this with the code that is using this.
Jens Axboe Sept. 22, 2021, 2:29 p.m. UTC | #10
On 9/21/21 11:45 PM, Prasad Muppana wrote:
> Hi Chaitanya,
> 
> Thanks for the response.
> 
> Our driver code is not yet public and so Praveen has explained the
> flow of the code. Please let me know is there any other way to get
> some help here quickly.

The explanation, while appreciated, doesn't solve the problem here. We
_never_ add any exports for APIs that don't have any in-kernel users.
That's a hard rule that we've had forever. As such, there is not a path
for entry for this particular patch right now. It should be submitted
alongside the upstream submission request for the code using it, as a
preparatory patch.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 65d3a63aecc6..40a9b085f029 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2283,6 +2283,7 @@  blk_qc_t blk_mq_submit_bio(struct bio *bio)
 	blk_queue_exit(q);
 	return BLK_QC_T_NONE;
 }
+EXPORT_SYMBOL_GPL(blk_mq_submit_bio);
 
 static size_t order_to_size(unsigned int order)
 {