Linux-mm Archive on
 help / color / Atom feed
* [patch 016/158] mm, swap: disallow swapon() on zoned block devices
@ 2019-12-01  1:49 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2019-12-01  1:49 UTC (permalink / raw)
  To: akpm, hare, hch, hughd, linux-mm, mm-commits, naohiro.aota,
	torvalds, tytso, willy

From: Naohiro Aota <>
Subject: 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.

[ reflow and reword comment, per Christoph]
Signed-off-by: Naohiro Aota <>
Reviewed-by: Christoph Hellwig <>
Cc: Matthew Wilcox <>
Cc: "Theodore Y. Ts'o" <>
Cc: Hannes Reinecke <>
Cc: Hugh Dickins <>
Signed-off-by: Andrew Morton <>

 mm/swapfile.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/mm/swapfile.c~mm-swap-disallow-swapon-on-zoned-block-devices
+++ a/mm/swapfile.c
@@ -2887,6 +2887,13 @@ static int claim_swapfile(struct swap_in
 		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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  1:49 [patch 016/158] mm, swap: disallow swapon() on zoned block devices akpm

Linux-mm Archive on

Archives are clonable:
	git clone --mirror linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ \
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone