VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   1) // SPDX-License-Identifier: GPL-2.0
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   2) /*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   3)  * Copyright (C) 2018 Oracle.  All Rights Reserved.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   4)  * Author: Darrick J. Wong <darrick.wong@oracle.com>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   5)  */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   6) #include <linux/module.h>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   7) #include <linux/compiler.h>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   8) #include <linux/fs.h>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700   9) #include <linux/iomap.h>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  10) #include <linux/swap.h>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  11) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  12) /* Swapfile activation */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  13) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  14) struct iomap_swapfile_info {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  15) 	struct iomap iomap;		/* accumulated iomap */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  16) 	struct swap_info_struct *sis;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  17) 	uint64_t lowest_ppage;		/* lowest physical addr seen (pages) */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  18) 	uint64_t highest_ppage;		/* highest physical addr seen (pages) */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  19) 	unsigned long nr_pages;		/* number of pages collected */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  20) 	int nr_extents;			/* extent count */
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  21) 	struct file *file;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  22) };
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  23) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  24) /*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  25)  * Collect physical extents for this swap file.  Physical extents reported to
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  26)  * the swap code must be trimmed to align to a page boundary.  The logical
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  27)  * offset within the file is irrelevant since the swapfile code maps logical
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  28)  * page numbers of the swap device to the physical page-aligned extents.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  29)  */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  30) static int iomap_swapfile_add_extent(struct iomap_swapfile_info *isi)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  31) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  32) 	struct iomap *iomap = &isi->iomap;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  33) 	unsigned long nr_pages;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  34) 	uint64_t first_ppage;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  35) 	uint64_t first_ppage_reported;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  36) 	uint64_t next_ppage;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  37) 	int error;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  38) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  39) 	/*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  40) 	 * Round the start up and the end down so that the physical
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  41) 	 * extent aligns to a page boundary.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  42) 	 */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  43) 	first_ppage = ALIGN(iomap->addr, PAGE_SIZE) >> PAGE_SHIFT;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  44) 	next_ppage = ALIGN_DOWN(iomap->addr + iomap->length, PAGE_SIZE) >>
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  45) 			PAGE_SHIFT;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  46) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  47) 	/* Skip too-short physical extents. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  48) 	if (first_ppage >= next_ppage)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  49) 		return 0;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  50) 	nr_pages = next_ppage - first_ppage;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  51) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  52) 	/*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  53) 	 * Calculate how much swap space we're adding; the first page contains
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  54) 	 * the swap header and doesn't count.  The mm still wants that first
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  55) 	 * page fed to add_swap_extent, however.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  56) 	 */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  57) 	first_ppage_reported = first_ppage;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  58) 	if (iomap->offset == 0)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  59) 		first_ppage_reported++;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  60) 	if (isi->lowest_ppage > first_ppage_reported)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  61) 		isi->lowest_ppage = first_ppage_reported;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  62) 	if (isi->highest_ppage < (next_ppage - 1))
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  63) 		isi->highest_ppage = next_ppage - 1;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  64) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  65) 	/* Add extent, set up for the next call. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  66) 	error = add_swap_extent(isi->sis, isi->nr_pages, nr_pages, first_ppage);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  67) 	if (error < 0)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  68) 		return error;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  69) 	isi->nr_extents += error;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  70) 	isi->nr_pages += nr_pages;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  71) 	return 0;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  72) }
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  73) 
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  74) static int iomap_swapfile_fail(struct iomap_swapfile_info *isi, const char *str)
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  75) {
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  76) 	char *buf, *p = ERR_PTR(-ENOMEM);
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  77) 
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  78) 	buf = kmalloc(PATH_MAX, GFP_KERNEL);
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  79) 	if (buf)
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  80) 		p = file_path(isi->file, buf, PATH_MAX);
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  81) 	pr_err("swapon: file %s %s\n", IS_ERR(p) ? "<unknown>" : p, str);
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  82) 	kfree(buf);
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  83) 	return -EINVAL;
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  84) }
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700  85) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  86) /*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  87)  * Accumulate iomaps for this swap file.  We have to accumulate iomaps because
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  88)  * swap only cares about contiguous page-aligned physical extents and makes no
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  89)  * distinction between written and unwritten extents.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  90)  */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  91) static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos,
c039b99792726 (Goldwyn Rodrigues 2019-10-18 16:44:10 -0700  92) 		loff_t count, void *data, struct iomap *iomap,
c039b99792726 (Goldwyn Rodrigues 2019-10-18 16:44:10 -0700  93) 		struct iomap *srcmap)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  94) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  95) 	struct iomap_swapfile_info *isi = data;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  96) 	int error;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  97) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  98) 	switch (iomap->type) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700  99) 	case IOMAP_MAPPED:
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 100) 	case IOMAP_UNWRITTEN:
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 101) 		/* Only real or unwritten extents. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 102) 		break;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 103) 	case IOMAP_INLINE:
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 104) 		/* No inline data. */
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 105) 		return iomap_swapfile_fail(isi, "is inline");
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 106) 	default:
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 107) 		return iomap_swapfile_fail(isi, "has unallocated extents");
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 108) 	}
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 109) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 110) 	/* No uncommitted metadata or shared blocks. */
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 111) 	if (iomap->flags & IOMAP_F_DIRTY)
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 112) 		return iomap_swapfile_fail(isi, "is not committed");
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 113) 	if (iomap->flags & IOMAP_F_SHARED)
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 114) 		return iomap_swapfile_fail(isi, "has shared extents");
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 115) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 116) 	/* Only one bdev per swap file. */
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 117) 	if (iomap->bdev != isi->sis->bdev)
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 118) 		return iomap_swapfile_fail(isi, "outside the main device");
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 119) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 120) 	if (isi->iomap.length == 0) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 121) 		/* No accumulated extent, so just store it. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 122) 		memcpy(&isi->iomap, iomap, sizeof(isi->iomap));
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 123) 	} else if (isi->iomap.addr + isi->iomap.length == iomap->addr) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 124) 		/* Append this to the accumulated extent. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 125) 		isi->iomap.length += iomap->length;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 126) 	} else {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 127) 		/* Otherwise, add the retained iomap and store this one. */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 128) 		error = iomap_swapfile_add_extent(isi);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 129) 		if (error)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 130) 			return error;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 131) 		memcpy(&isi->iomap, iomap, sizeof(isi->iomap));
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 132) 	}
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 133) 	return count;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 134) }
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 135) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 136) /*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 137)  * Iterate a swap file's iomaps to construct physical extents that can be
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 138)  * passed to the swapfile subsystem.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 139)  */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 140) int iomap_swapfile_activate(struct swap_info_struct *sis,
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 141) 		struct file *swap_file, sector_t *pagespan,
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 142) 		const struct iomap_ops *ops)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 143) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 144) 	struct iomap_swapfile_info isi = {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 145) 		.sis = sis,
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 146) 		.lowest_ppage = (sector_t)-1ULL,
ad89b66cbad18 (Christoph Hellwig 2021-03-26 10:55:40 -0700 147) 		.file = swap_file,
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 148) 	};
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 149) 	struct address_space *mapping = swap_file->f_mapping;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 150) 	struct inode *inode = mapping->host;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 151) 	loff_t pos = 0;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 152) 	loff_t len = ALIGN_DOWN(i_size_read(inode), PAGE_SIZE);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 153) 	loff_t ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 154) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 155) 	/*
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 156) 	 * Persist all file mapping metadata so that we won't have any
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 157) 	 * IOMAP_F_DIRTY iomaps.
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 158) 	 */
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 159) 	ret = vfs_fsync(swap_file, 1);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 160) 	if (ret)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 161) 		return ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 162) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 163) 	while (len > 0) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 164) 		ret = iomap_apply(inode, pos, len, IOMAP_REPORT,
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 165) 				ops, &isi, iomap_swapfile_activate_actor);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 166) 		if (ret <= 0)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 167) 			return ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 168) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 169) 		pos += ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 170) 		len -= ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 171) 	}
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 172) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 173) 	if (isi.iomap.length) {
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 174) 		ret = iomap_swapfile_add_extent(&isi);
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 175) 		if (ret)
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 176) 			return ret;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 177) 	}
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 178) 
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 179) 	/*
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 180) 	 * If this swapfile doesn't contain even a single page-aligned
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 181) 	 * contiguous range of blocks, reject this useless swapfile to
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 182) 	 * prevent confusion later on.
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 183) 	 */
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 184) 	if (isi.nr_pages == 0) {
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 185) 		pr_warn("swapon: Cannot find a single usable page in file.\n");
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 186) 		return -EINVAL;
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 187) 	}
5808fecc57239 (Ritesh Harjani    2021-03-09 09:29:11 -0800 188) 
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 189) 	*pagespan = 1 + isi.highest_ppage - isi.lowest_ppage;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 190) 	sis->max = isi.nr_pages;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 191) 	sis->pages = isi.nr_pages - 1;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 192) 	sis->highest_bit = isi.nr_pages - 1;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 193) 	return isi.nr_extents;
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 194) }
a45c0eccc5646 (Darrick J. Wong   2019-07-15 08:50:57 -0700 195) EXPORT_SYMBOL_GPL(iomap_swapfile_activate);