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: 10404439 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 E609C602C2 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 D582527F7F for ; Wed, 16 May 2018 16:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA0FA284FC; 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.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 6F52B27F7F for ; Wed, 16 May 2018 16:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751717AbeEPQqE (ORCPT ); Wed, 16 May 2018 12:46:04 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35602 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751649AbeEPQqC (ORCPT ); Wed, 16 May 2018 12:46:02 -0400 Received: by mail-pl0-f67.google.com with SMTP id i5-v6so758791plt.2 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=YghClbRkpUa18BZXNr+BpgH9f5mwy0BEaFOl3QirIzDVStmuhvvVDz8EAa9nfFW9pm UzimlE74sVka8KN1l1c42VmpFNLJT0973+4aL0dZw1renhw/1BVqQyQ7VLiaBJAzMXFu +tkjDdvVtKXlWlQRk7yfU9jtxIo6kGok0FP0VWREh3/mc4oRNwVhXveY6HvKj8ZM09+s sJJi1ZgQzDsLhE7u6tqsFofR8eX0QlVNAUdkx/NW7PEg5ML4owZuDA0TpoNdTyPa1V24 zYxGoxh/nEENBopY6iv8iL8TNz7/ZimhvntG9XJQY0sYLdPD2sf0JEdtyjeJ5lWBBitt Q3/A== X-Gm-Message-State: ALKqPwePOc8kvvIXP9K/UgxB6mGHk980ZCkLBFgX6Cwy/df6pK0PyzK5 g5LbJZ6lmRy5n16+8Pul0Vawgg== 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-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") 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; }