diff options
author | Naohiro Aota <[email protected]> | 2019-11-30 17:49:56 -0800 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2019-12-01 06:29:18 -0800 |
commit | 12d2966d854bb0be1433032cedcb71b6b620bfc7 (patch) | |
tree | 2704a905b2e9904e0028f111be94720789db18a4 | |
parent | d2dfbe47fa0e9753f560b75cfcd4654e40ab903b (diff) |
mm, swap: disallow swapon() on zoned block devices
A zoned block device consists of a number of zones. Zones are either
conventional and accepting random writes or sequential and requiring
that writes be issued in LBA order from each zone write pointer
position. For the write restriction, zoned block devices are not
suitable for a swap device. Disallow swapon on them.
[[email protected]: reflow and reword comment, per Christoph]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Naohiro Aota <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: "Theodore Y. Ts'o" <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/swapfile.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index dab43523afdd..bb3261d45b6a 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2887,6 +2887,13 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode) error = set_blocksize(p->bdev, PAGE_SIZE); if (error < 0) return error; + /* + * Zoned block devices contain zones that have a sequential + * write only restriction. Hence zoned block devices are not + * suitable for swapping. Disallow them here. + */ + if (blk_queue_is_zoned(p->bdev->bd_queue)) + return -EINVAL; p->flags |= SWP_BLKDEV; } else if (S_ISREG(inode->i_mode)) { p->bdev = inode->i_sb->s_bdev; |