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>
Subject: [PATCH] iomap: don't allow holes in swapfiles
Date: Tue, 15 May 2018 23:45:38 -0700	[thread overview]
Message-ID: <e722c29f7291b9c31533fd8b2e84d7f469c3ac88.1526452889.git.osandov@fb.com> (raw)

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")
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
Hey, Darrick, I noticed this while writing up a generic xfstest to test
that the Btrfs swap support patches don't allow a swapfile with holes.
It'd be nice if we were all consistent :) This is based on
xfs-linux/for-next. Feel free to fold it in to your patch or apply it
separately as you see fit. Thanks!

 fs/iomap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index d193390a1c20..ba559adaa327 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1214,9 +1214,9 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos,
 	struct iomap_swapfile_info *isi = data;
 	int error;
 
-	/* Skip holes. */
+	/* No holes. */
 	if (iomap->type == IOMAP_HOLE)
-		goto out;
+		goto err;
 
 	/* Only one bdev per swap file. */
 	if (iomap->bdev != isi->sis->bdev)
-- 
2.17.0

             reply	other threads:[~2018-05-16  6:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  6:45 Omar Sandoval [this message]
2018-05-16 15:50 ` Darrick J. Wong
2018-05-16 15:51   ` Christoph Hellwig
2018-05-16 15:56     ` Darrick J. Wong
2018-05-16 16:19       ` Omar Sandoval
2018-05-16 16:24         ` Christoph Hellwig
2018-05-16 16:23 ` Christoph Hellwig
2018-05-16 16:26   ` Omar Sandoval

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=e722c29f7291b9c31533fd8b2e84d7f469c3ac88.1526452889.git.osandov@fb.com \
    --to=osandov@osandov.com \
    --cc=darrick.wong@oracle.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --subject='Re: [PATCH] iomap: don'\''t allow holes in swapfiles' \
    /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

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).