From patchwork Wed May 16 16:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10404437 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 2C037602C2 for ; Wed, 16 May 2018 16:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BB9C27F7F for ; Wed, 16 May 2018 16:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10618284FC; Wed, 16 May 2018 16:46:08 +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 7C7FC27F7F for ; Wed, 16 May 2018 16:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751649AbeEPQqE (ORCPT ); Wed, 16 May 2018 12:46:04 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:45122 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751665AbeEPQqC (ORCPT ); Wed, 16 May 2018 12:46:02 -0400 Received: by mail-pl0-f68.google.com with SMTP id bi12-v6so746660plb.12 for ; Wed, 16 May 2018 09:46:01 -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:in-reply-to:references :in-reply-to:references; bh=XowhTr4/KNWF+jDuEzOaiWUwvsgDoLFjk5W6jB6at2Q=; b=LhpzLsZFJ40BI0++cX//IPugSQP1A44jWRQwARbXAFuKIH0vEw0tGcmmBKNP1q/lWS waq/Bk0CbxqRKH0EvKPfiJmft/bO5TqKTMTFWs6h0Qna1a6BeutCp7NV6kDD1Ygj+EAE j9i1WfRR+ppnuqIdjwD3ukG0QaaQyQ8bkAgy/h7TNTdaHxbuUbZ/xXN4BcKqGSxZEqff TFVZnDuWtyhBymx0EoCrWfXVfH7/mOTjKFdsOEZKFX9dUVp2LELB8BidawU46JZE78e7 DE+UkFDOXXjnPTzLeN5MLQ81VhNzLh6hxQlhzXFi497J8q+yH/yY4S1KX9IBtat7IPvU EBKg== 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:in-reply-to :references:in-reply-to:references; bh=XowhTr4/KNWF+jDuEzOaiWUwvsgDoLFjk5W6jB6at2Q=; b=DVQr4dTJnLqCvfeDVvM02aJmdW5KpY/uTlonESNVx80a7doy51iV7S/CYq4MePdYdo NBdTZs1iJgeHfIoLk06kvBE2vxSRXgrtGYhsc3UWJ4if3jTIk/OiclCwAJpSIgffad6P GSXhsMuq0oAMEwsyYJmtxJO2DJHNJteQrvopQYHjRqvI+8OfKeikLFDEGE6UKba+sW79 DG+iR4nF2xQWm1ZSzi3INUmeKeehBioT4EbmFW8am1kYXudVbP9ZP2HZpNvPVyPYHA4k EPpdddce2fE7qxc3sRdaySgYghg+KPzQW5wxK91oBI8udcnIt4DczD8/F9Ceg/cRje0b iEhA== X-Gm-Message-State: ALKqPwcCGIRaZ4WOmrbg/ar3T9OALUeV16e9hWVkq2mN91EfReObc+8B G/33NHsPgBxgd/rUznBctlN2hw== X-Google-Smtp-Source: AB8JxZpFALO6QvmzZg5aeaeTPlT27PVFMuFQtZlWAffjpOpPGgK5CeHpslJCz70SkBB1ilQHEY4PnA== X-Received: by 2002:a17:902:57c7:: with SMTP id g7-v6mr1661886plj.222.1526489161364; Wed, 16 May 2018 09:46:01 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id u4-v6sm7914441pgn.10.2018.05.16.09.45.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 09:46:00 -0700 (PDT) From: Omar Sandoval To: "Darrick J . Wong" , linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Jan Kara , Christoph Hellwig , Aleksei Besogonov , kernel-team@fb.com Subject: [PATCH v2 2/2] iomap: don't allow holes in swapfiles Date: Wed, 16 May 2018 09:45:51 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: 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") Reviewed-by: Darrick J. Wong Signed-off-by: Omar Sandoval --- fs/iomap.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 318724375ffe..5a1099d935c3 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1214,10 +1214,6 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos, struct iomap_swapfile_info *isi = data; int error; - /* Skip holes. */ - if (iomap->type == IOMAP_HOLE) - goto out; - /* Only real or unwritten extents. */ if ((iomap->type != IOMAP_MAPPED && iomap->type != IOMAP_UNWRITTEN) || iomap->addr == IOMAP_NULL_ADDR) { @@ -1258,7 +1254,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; }