I'm trying to understand the purpose of this function in the SCSI generic
driver (sg.c):
sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish)
{
struct scatterlist *sg = rsv_schp->buffer;
struct page *page;
int k, m;
SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, scatg=%d\n",
startFinish, rsv_schp->k_use_sg));
/* N.B. correction _not_ applied to base page of each allocation */
for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) {
for (m = PAGE_SIZE; m < sg->length; m += PAGE_SIZE) {
page = sg->page;
if (startFinish)
get_page(page);
else {
if (page_count(page) > 0)
__put_page(page);
}
}
}
}
Judging from the comment, it would seem that the intention is to get/put
every page in a scatterlist except the first one. But that isn't what it
does; if 2*PAGE_SIZE <= sg->length < N*PAGE_SIZE, then this logic will
call get_page (or __put_page) N-2 times on the same page, rather than once
on each of the N-2 pages after the first.
More generally, why is this operation needed at all, when the
sg_vma_nopage function will presumably do the required get_page?
Chip
--
Charles M. "Chip" Coldwell
Senior Software Engineer
Red Hat, Inc
-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html