提交 19e12961 编写于 作者: O Omar Sandoval 提交者: Darrick J. Wong

iomap: don't allow holes in swapfiles

generic_swapfile_activate() doesn't allow holes, so we should be
consistent here. This is also a bit safer: if the user creates a
swapfile with, say, truncate -s $SIZE followed by mkswap, they should
really get an error and not much less swap space than they expected.
swapon(8) will error out before calling swapon(2) if the file has holes,
anyways.

Fixes: 9d93388b0afe ("iomap: add a swapfile activation function")
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NOmar Sandoval <osandov@fb.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NJan Kara <jack@suse.cz>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
上级 ec601924
......@@ -1220,10 +1220,6 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos,
return -EINVAL;
}
/* Skip holes. */
if (iomap->type == IOMAP_HOLE)
goto out;
/* Only real or unwritten extents. */
if (iomap->type != IOMAP_MAPPED && iomap->type != IOMAP_UNWRITTEN) {
pr_err("swapon: file has unallocated extents\n");
......@@ -1259,7 +1255,6 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos,
return error;
memcpy(&isi->iomap, iomap, sizeof(isi->iomap));
}
out:
return count;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册