diff mbox series

[resend,v2] lib: scatterlist: Fix to support no mapped sg

Message ID 1563940463-95597-1-git-send-email-wangzhou1@hisilicon.com
State Accepted
Commit 79e178f4383a3a645f76bc2dd44c477b361c6a98
Headers show
Series [resend,v2] lib: scatterlist: Fix to support no mapped sg | expand

Commit Message

Zhou Wang July 24, 2019, 3:54 a.m. UTC
In function sg_split, the second sg_calculate_split will return -EINVAL
when in_mapped_nents is 0.

Indeed there is no need to do second sg_calculate_split and sg_split_mapped
when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in
original sgl.

Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>

Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

---
v2: Just add Acked-by from Robert.

 lib/sg_split.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

-- 
2.8.1

Comments

Zhou Wang July 29, 2019, 1:44 a.m. UTC | #1
On 2019/7/24 11:54, Zhou Wang wrote:
> In function sg_split, the second sg_calculate_split will return -EINVAL

> when in_mapped_nents is 0.

> 

> Indeed there is no need to do second sg_calculate_split and sg_split_mapped

> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in

> original sgl.

> 

> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>

> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

> ---

> v2: Just add Acked-by from Robert.

> 

>  lib/sg_split.c | 12 +++++++-----

>  1 file changed, 7 insertions(+), 5 deletions(-)

> 

> diff --git a/lib/sg_split.c b/lib/sg_split.c

> index 9982c63..60a0bab 100644

> --- a/lib/sg_split.c

> +++ b/lib/sg_split.c

> @@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,

>  	 * The order of these 3 calls is important and should be kept.

>  	 */

>  	sg_split_phys(splitters, nb_splits);

> -	ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

> -				 split_sizes, splitters, true);

> -	if (ret < 0)

> -		goto err;

> -	sg_split_mapped(splitters, nb_splits);

> +	if (in_mapped_nents) {

> +		ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

> +					 split_sizes, splitters, true);

> +		if (ret < 0)

> +			goto err;

> +		sg_split_mapped(splitters, nb_splits);

> +	}

>  

>  	for (i = 0; i < nb_splits; i++) {

>  		out[i] = splitters[i].out_sg;

> 


Hi Jens,

I saw you are the committer of sg_splite.c, could you help to take this patch?

Many thanks,
Zhou
Zhou Wang Aug. 6, 2019, 1:46 a.m. UTC | #2
On 2019/7/29 9:44, Zhou Wang wrote:
> On 2019/7/24 11:54, Zhou Wang wrote:

>> In function sg_split, the second sg_calculate_split will return -EINVAL

>> when in_mapped_nents is 0.

>>

>> Indeed there is no need to do second sg_calculate_split and sg_split_mapped

>> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in

>> original sgl.

>>

>> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>

>> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

>> ---

>> v2: Just add Acked-by from Robert.

>>

>>  lib/sg_split.c | 12 +++++++-----

>>  1 file changed, 7 insertions(+), 5 deletions(-)

>>

>> diff --git a/lib/sg_split.c b/lib/sg_split.c

>> index 9982c63..60a0bab 100644

>> --- a/lib/sg_split.c

>> +++ b/lib/sg_split.c

>> @@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,

>>  	 * The order of these 3 calls is important and should be kept.

>>  	 */

>>  	sg_split_phys(splitters, nb_splits);

>> -	ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>> -				 split_sizes, splitters, true);

>> -	if (ret < 0)

>> -		goto err;

>> -	sg_split_mapped(splitters, nb_splits);

>> +	if (in_mapped_nents) {

>> +		ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>> +					 split_sizes, splitters, true);

>> +		if (ret < 0)

>> +			goto err;

>> +		sg_split_mapped(splitters, nb_splits);

>> +	}

>>  

>>  	for (i = 0; i < nb_splits; i++) {

>>  		out[i] = splitters[i].out_sg;

>>

> 

> Hi Jens,

> 

> I saw you are the committer of sg_splite.c, could you help to take this patch?

> 

> Many thanks,

> Zhou

>


Anyone can help to take this fix?

Best,
Zhou
Jens Axboe Aug. 8, 2019, 1:40 p.m. UTC | #3
On 7/28/19 6:44 PM, Zhou Wang wrote:
> On 2019/7/24 11:54, Zhou Wang wrote:

>> In function sg_split, the second sg_calculate_split will return -EINVAL

>> when in_mapped_nents is 0.

>>

>> Indeed there is no need to do second sg_calculate_split and sg_split_mapped

>> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in

>> original sgl.

>>

>> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>

>> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

>> ---

>> v2: Just add Acked-by from Robert.

>>

>>   lib/sg_split.c | 12 +++++++-----

>>   1 file changed, 7 insertions(+), 5 deletions(-)

>>

>> diff --git a/lib/sg_split.c b/lib/sg_split.c

>> index 9982c63..60a0bab 100644

>> --- a/lib/sg_split.c

>> +++ b/lib/sg_split.c

>> @@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,

>>   	 * The order of these 3 calls is important and should be kept.

>>   	 */

>>   	sg_split_phys(splitters, nb_splits);

>> -	ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>> -				 split_sizes, splitters, true);

>> -	if (ret < 0)

>> -		goto err;

>> -	sg_split_mapped(splitters, nb_splits);

>> +	if (in_mapped_nents) {

>> +		ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>> +					 split_sizes, splitters, true);

>> +		if (ret < 0)

>> +			goto err;

>> +		sg_split_mapped(splitters, nb_splits);

>> +	}

>>   

>>   	for (i = 0; i < nb_splits; i++) {

>>   		out[i] = splitters[i].out_sg;

>>

> 

> Hi Jens,

> 

> I saw you are the committer of sg_splite.c, could you help to take this patch?


Yes, I can take it for 5.4, it looks fine to me. 

-- 
Jens Axboe
Zhou Wang Aug. 8, 2019, 2:01 p.m. UTC | #4
On 2019/8/8 21:40, Jens Axboe wrote:
> On 7/28/19 6:44 PM, Zhou Wang wrote:

>> On 2019/7/24 11:54, Zhou Wang wrote:

>>> In function sg_split, the second sg_calculate_split will return -EINVAL

>>> when in_mapped_nents is 0.

>>>

>>> Indeed there is no need to do second sg_calculate_split and sg_split_mapped

>>> when in_mapped_nents is 0, as in_mapped_nents indicates no mapped entry in

>>> original sgl.

>>>

>>> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>

>>> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

>>> ---

>>> v2: Just add Acked-by from Robert.

>>>

>>>   lib/sg_split.c | 12 +++++++-----

>>>   1 file changed, 7 insertions(+), 5 deletions(-)

>>>

>>> diff --git a/lib/sg_split.c b/lib/sg_split.c

>>> index 9982c63..60a0bab 100644

>>> --- a/lib/sg_split.c

>>> +++ b/lib/sg_split.c

>>> @@ -176,11 +176,13 @@ int sg_split(struct scatterlist *in, const int in_mapped_nents,

>>>   	 * The order of these 3 calls is important and should be kept.

>>>   	 */

>>>   	sg_split_phys(splitters, nb_splits);

>>> -	ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>>> -				 split_sizes, splitters, true);

>>> -	if (ret < 0)

>>> -		goto err;

>>> -	sg_split_mapped(splitters, nb_splits);

>>> +	if (in_mapped_nents) {

>>> +		ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,

>>> +					 split_sizes, splitters, true);

>>> +		if (ret < 0)

>>> +			goto err;

>>> +		sg_split_mapped(splitters, nb_splits);

>>> +	}

>>>   

>>>   	for (i = 0; i < nb_splits; i++) {

>>>   		out[i] = splitters[i].out_sg;

>>>

>>

>> Hi Jens,

>>

>> I saw you are the committer of sg_splite.c, could you help to take this patch?

> 

> Yes, I can take it for 5.4, it looks fine to me. 


Thanks a lot for taking this patch :)

>
diff mbox series

Patch

diff --git a/lib/sg_split.c b/lib/sg_split.c
index 9982c63..60a0bab 100644
--- a/lib/sg_split.c
+++ b/lib/sg_split.c
@@ -176,11 +176,13 @@  int sg_split(struct scatterlist *in, const int in_mapped_nents,
 	 * The order of these 3 calls is important and should be kept.
 	 */
 	sg_split_phys(splitters, nb_splits);
-	ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
-				 split_sizes, splitters, true);
-	if (ret < 0)
-		goto err;
-	sg_split_mapped(splitters, nb_splits);
+	if (in_mapped_nents) {
+		ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
+					 split_sizes, splitters, true);
+		if (ret < 0)
+			goto err;
+		sg_split_mapped(splitters, nb_splits);
+	}
 
 	for (i = 0; i < nb_splits; i++) {
 		out[i] = splitters[i].out_sg;