/* Add extent, set up for the next call. */
error = add_swap_extent(isi->sis, isi->nr_pages, nr_pages, first_ppage); if (error < 0) return error;
isi->nr_extents += error;
isi->nr_pages += nr_pages; return0;
}
/* *Accumulateiomapsforthisswapfile.Wehavetoaccumulateiomapsbecause *swaponlycaresaboutcontiguouspage-alignedphysicalextentsandmakesno *distinctionbetweenwrittenandunwrittenextents.
*/ staticint iomap_swapfile_iter(struct iomap_iter *iter, struct iomap *iomap, struct iomap_swapfile_info *isi)
{ switch (iomap->type) { case IOMAP_MAPPED: case IOMAP_UNWRITTEN: /* Only real or unwritten extents. */ break; case IOMAP_INLINE: /* No inline data. */ return iomap_swapfile_fail(isi, "is inline"); default: return iomap_swapfile_fail(isi, "has unallocated extents");
}
/* No uncommitted metadata or shared blocks. */ if (iomap->flags & IOMAP_F_DIRTY) return iomap_swapfile_fail(isi, "is not committed"); if (iomap->flags & IOMAP_F_SHARED) return iomap_swapfile_fail(isi, "has shared extents");
/* Only one bdev per swap file. */ if (iomap->bdev != isi->sis->bdev) return iomap_swapfile_fail(isi, "outside the main device");
if (isi->iomap.length == 0) { /* No accumulated extent, so just store it. */
memcpy(&isi->iomap, iomap, sizeof(isi->iomap));
} elseif (isi->iomap.addr + isi->iomap.length == iomap->addr) { /* Append this to the accumulated extent. */
isi->iomap.length += iomap->length;
} else { /* Otherwise, add the retained iomap and store this one. */ int error = iomap_swapfile_add_extent(isi); if (error) return error;
memcpy(&isi->iomap, iomap, sizeof(isi->iomap));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.