Commit 1e905594 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

lazy-pages: add comments to update_lazy_iovecs

This function does weird things, so better have it at least somehow
documented.

travis-ci: success for lazy-pages: add comments to update_lazy_iovecs
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent ce5e1916
...@@ -302,6 +302,10 @@ static MmEntry *init_mm_entry(struct lazy_pages_info *lpi) ...@@ -302,6 +302,10 @@ static MmEntry *init_mm_entry(struct lazy_pages_info *lpi)
return mm; return mm;
} }
/*
* Purge range (addr, addr + len) from lazy_iovecs. The range may
* cover several continuous IOVs.
*/
static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr, static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
int len) int len)
{ {
...@@ -317,6 +321,13 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr, ...@@ -317,6 +321,13 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
if (addr < start || addr >= end) if (addr < start || addr >= end)
continue; continue;
/*
* The range completely fits into the current IOV.
* If addr equals iov_base we just "drop" the
* beginning of the IOV. Otherwise, we make the IOV to
* end at addr, and add a new IOV start starts at
* addr + len.
*/
if (addr + len < end) { if (addr + len < end) {
if (addr == start) { if (addr == start) {
lazy_iov->base += len; lazy_iov->base += len;
...@@ -338,6 +349,12 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr, ...@@ -338,6 +349,12 @@ static int update_lazy_iovecs(struct lazy_pages_info *lpi, unsigned long addr,
break; break;
} }
/*
* The range spawns beyond the end of the current IOV.
* If addr equals iov_base we just "drop" the entire
* IOV. Otherwise, we cut the beginning of the IOV
* and continue to the next one with the updated range
*/
if (addr == start) { if (addr == start) {
list_del(&lazy_iov->l); list_del(&lazy_iov->l);
xfree(lazy_iov); xfree(lazy_iov);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment