diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-01-23 15:56:00 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-01-23 15:56:00 +0300 |
commit | 91f67b9a6472a243e2c0630f637ddff0af08038e (patch) | |
tree | 2ba948b5b9a9c13b3494efb3a4006c15db1cbb37 /lib/scatterlist.c | |
parent | 5670ebf54bd26482f57a094c53bdc562c106e0a9 (diff) | |
parent | 2475bf0250dee99b477e0c56d7dc9d7ac3f04117 (diff) | |
download | linux-91f67b9a6472a243e2c0630f637ddff0af08038e.tar.xz |
Merge remote-tracking branch 'torvalds/master' into perf/core
To pick fixes that went via perf/urgent.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'lib/scatterlist.c')
-rw-r--r-- | lib/scatterlist.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index f72aa50c6654..8d7519a8f308 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -470,22 +470,27 @@ int sg_alloc_append_table_from_pages(struct sg_append_table *sgt_append, return -EOPNOTSUPP; if (sgt_append->prv) { + unsigned long next_pfn = (page_to_phys(sg_page(sgt_append->prv)) + + sgt_append->prv->offset + sgt_append->prv->length) / PAGE_SIZE; + if (WARN_ON(offset)) return -EINVAL; /* Merge contiguous pages into the last SG */ prv_len = sgt_append->prv->length; - last_pg = sg_page(sgt_append->prv); - while (n_pages && pages_are_mergeable(pages[0], last_pg)) { - if (sgt_append->prv->length + PAGE_SIZE > max_segment) - break; - sgt_append->prv->length += PAGE_SIZE; - last_pg = pages[0]; - pages++; - n_pages--; + if (page_to_pfn(pages[0]) == next_pfn) { + last_pg = pfn_to_page(next_pfn - 1); + while (n_pages && pages_are_mergeable(pages[0], last_pg)) { + if (sgt_append->prv->length + PAGE_SIZE > max_segment) + break; + sgt_append->prv->length += PAGE_SIZE; + last_pg = pages[0]; + pages++; + n_pages--; + } + if (!n_pages) + goto out; } - if (!n_pages) - goto out; } /* compute number of contiguous chunks */ |