From patchwork Wed May 16 06:45:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10402859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92C56601D2 for ; Wed, 16 May 2018 06:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82E382845C for ; Wed, 16 May 2018 06:45:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77173287AE; Wed, 16 May 2018 06:45:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 264D32845C for ; Wed, 16 May 2018 06:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752520AbeEPGpt (ORCPT ); Wed, 16 May 2018 02:45:49 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:47093 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752433AbeEPGps (ORCPT ); Wed, 16 May 2018 02:45:48 -0400 Received: by mail-pf0-f194.google.com with SMTP id p12-v6so1291148pff.13 for ; Tue, 15 May 2018 23:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Hx8Fz0/DbKCbIskCicrWb3Ct0X+u4Bdi2ry/OEWUI70=; b=sYr8V4PrM4vdvPdXqv0NmHJDtSLE+HgCGvJsJJU7ReQK0PnliQb/sz2QqlaUWpQhF3 K4vHfGSynaCWpiEMJSq0lglAULHRcadvdDXQiMwN+YvxJQ4K6bRvIZu+gxJNLF2jXBZB 1pjungrT2+6iGBlFozSDD9+TU5bHlNpNBv3N8NlF9fAaF8RxeDLd+VBiyFUq/aWvfoev KlpJoNtWZT7suOrlNpbXTJLZv1wLLSi3p/TAF8kdGVoPYJFtlRmi+UaHtYnNjO0pRYaK 9JWGnfSBEUoLDATY9oad4MsC7O+noIl5uzdfqXgKcAVsneJ7CcqEYCnRnvTDwPxkH41V NL2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Hx8Fz0/DbKCbIskCicrWb3Ct0X+u4Bdi2ry/OEWUI70=; b=AWpTUsihi7CfFnEQyWk4hddPY+RoUk2RqvEg+y834NAF1hwdCKvl2XoNX9OZM775Qf s8OVz3wBmiXg3X4q9I9vcGtZdOywT4zM5l41DqD8X2OCULInfRC85ZERlkXz3DN7AoDx H2lKVHWDn3AnV5AkD516DUcU+wqHkLOhXNcl9FDaQ19YUgI36Z77JCPak7DDFh/QOjv4 VbjY8RrsDlk3xhASFZA17u1o4WN1epneOcXskbMDpcNZHmfXZv56DUqi/iWc0AV/q3am t4DwCyovL2kiYBTH8+067HhZufXW4Lu/Rc0aJuKGseZfNPIpe7W6klBsGTWJOyG8AO3/ P8UQ== X-Gm-Message-State: ALKqPwdN1Y9Ouoh9V04dzoHzZlve5TZLjDLLgl6IdsnrtASdZiR9Glmt fV7IhnOXQj79B5xEr4rImrR+lg== X-Google-Smtp-Source: AB8JxZrSIfEfIwg0+F2TzrkJPVGm1dqvUfQBWY7xe2Ghce0BHobMoVlAWlBzpos0IoT/79nIotA4CQ== X-Received: by 2002:aa7:828c:: with SMTP id s12-v6mr18549507pfm.136.1526453147315; Tue, 15 May 2018 23:45:47 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id k2-v6sm2993255pfg.82.2018.05.15.23.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 23:45:46 -0700 (PDT) From: Omar Sandoval To: "Darrick J . Wong" , linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Jan Kara Subject: [PATCH] iomap: don't allow holes in swapfiles Date: Tue, 15 May 2018 23:45:38 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval 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 Reviewed-by: Darrick J. Wong --- 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)