[PATCH RFC 29/35] scsi: core: drop nth_page() usage within SG entry
David Hildenbrand
david at redhat.com
Thu Aug 21 20:06:55 UTC 2025
It's no longer required to use nth_page() when iterating pages within a
single SG entry, so let's drop the nth_page() usage.
Cc: "James E.J. Bottomley" <James.Bottomley at HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen at oracle.com>
Cc: Doug Gilbert <dgilbert at interlog.com>
Signed-off-by: David Hildenbrand <david at redhat.com>
---
drivers/scsi/scsi_lib.c | 3 +--
drivers/scsi/sg.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0c65ecfedfbd6..f523f85828b89 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3148,8 +3148,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count,
/* Offset starting from the beginning of first page in this sg-entry */
*offset = *offset - len_complete + sg->offset;
- /* Assumption: contiguous pages can be accessed as "page + i" */
- page = nth_page(sg_page(sg), (*offset >> PAGE_SHIFT));
+ page = sg_page(sg) + *offset / PAGE_SIZE;
*offset &= ~PAGE_MASK;
/* Bytes in this sg-entry from *offset to the end of the page */
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3c02a5f7b5f39..2c653f2b21133 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1235,8 +1235,7 @@ sg_vma_fault(struct vm_fault *vmf)
len = vma->vm_end - sa;
len = (len < length) ? len : length;
if (offset < len) {
- struct page *page = nth_page(rsv_schp->pages[k],
- offset >> PAGE_SHIFT);
+ struct page *page = rsv_schp->pages[k] + offset / PAGE_SIZE;
get_page(page); /* increment page count */
vmf->page = page;
return 0; /* success */
--
2.50.1
More information about the Intel-gfx
mailing list