lib: scatterlist: Fix to support no mapped sg
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> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
ba6f7da99a
commit
79e178f438
|
@ -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.
|
* The order of these 3 calls is important and should be kept.
|
||||||
*/
|
*/
|
||||||
sg_split_phys(splitters, nb_splits);
|
sg_split_phys(splitters, nb_splits);
|
||||||
ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
|
if (in_mapped_nents) {
|
||||||
split_sizes, splitters, true);
|
ret = sg_calculate_split(in, in_mapped_nents, nb_splits, skip,
|
||||||
if (ret < 0)
|
split_sizes, splitters, true);
|
||||||
goto err;
|
if (ret < 0)
|
||||||
sg_split_mapped(splitters, nb_splits);
|
goto err;
|
||||||
|
sg_split_mapped(splitters, nb_splits);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nb_splits; i++) {
|
for (i = 0; i < nb_splits; i++) {
|
||||||
out[i] = splitters[i].out_sg;
|
out[i] = splitters[i].out_sg;
|
||||||
|
|
Loading…
Reference in New Issue