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: 10402857 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 311BE601C8 for ; Wed, 16 May 2018 06:45:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F9AE2845C for ; Wed, 16 May 2018 06:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1212D287AE; Wed, 16 May 2018 06:45:51 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 8C8492845C for ; Wed, 16 May 2018 06:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbeEPGpt (ORCPT ); Wed, 16 May 2018 02:45:49 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37196 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbeEPGps (ORCPT ); Wed, 16 May 2018 02:45:48 -0400 Received: by mail-pf0-f196.google.com with SMTP id e9-v6so1301517pfi.4 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=uicxRezQ96+vDP4RBBK+VsYzXqcyGxYG0XUfQcPu8MKL0COcJP9EC9eW0FQ+M8ph4m yZmsnLk9IVbNtnARDeh4vq0NSM8E09WwG1hPqdQhIkKmlz7dhkVgqw22kdhY+lQ8m3kG AUKDwMVCTwGrknDad0+8//pRrlmxsTDAwd1J5o6xPoT0jIQWVsU4YhcKpyzhHIBnCVHt u1HWmY9yAuJdoE6tkb+UzRpq7gi5CtQA66+BOBcyCPhSERl1NgtiHW/gR3D/8FYtZzK+ qmwDlV2njSr+1nRo4XaVil8CTaE8pyLfJ5Awl3ACdOIctp774XZgXwTcaKKjq9+Zc21K zjLw== X-Gm-Message-State: ALKqPwdCj/efXMkhSSlUn/setIX0/UGyEonTtHjnix4d2+ii02FcnVGC tFHtGLYppBAHDNtC1EZ2dZtYJw== 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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)