linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: "Darrick J . Wong" <darrick.wong@oracle.com>, linux-xfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Christoph Hellwig <hch@infradead.org>,
	Aleksei Besogonov <cyberax@amazon.com>,
	kernel-team@fb.com
Subject: [PATCH v3 2/2] iomap: don't allow holes in swapfiles
Date: Wed, 16 May 2018 10:54:11 -0700	[thread overview]
Message-ID: <cdb5dc22c56b30f693741361f6d6168f97f26bc1.1526493125.git.osandov@fb.com> (raw)
In-Reply-To: <cover.1526493125.git.osandov@fb.com>
In-Reply-To: <cover.1526493125.git.osandov@fb.com>

From: Omar Sandoval <osandov@fb.com>

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: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 fs/iomap.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 89517442e296..f2456d0d8ddd 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -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;
 }
 
-- 
2.17.0

  parent reply	other threads:[~2018-05-16 17:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 17:54 [PATCH v3 0/2] iomap: swapfile tweaks Omar Sandoval
2018-05-16 17:54 ` [PATCH v3 1/2] iomap: provide more useful errors for invalid swap files Omar Sandoval
2018-05-16 18:10   ` Christoph Hellwig
2018-05-17  8:58   ` Jan Kara
2018-05-16 17:54 ` Omar Sandoval [this message]
2018-05-16 18:11   ` [PATCH v3 2/2] iomap: don't allow holes in swapfiles Christoph Hellwig
2018-05-17  8:59   ` Jan Kara
2018-05-17 17:23 ` [PATCH v3 0/2] iomap: swapfile tweaks Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cdb5dc22c56b30f693741361f6d6168f97f26bc1.1526493125.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=cyberax@amazon.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=kernel-team@fb.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).