From patchwork Wed May 16 17:54:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10404559 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 4B959601C8 for ; Wed, 16 May 2018 17:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A745285B7 for ; Wed, 16 May 2018 17:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE9C285F7; Wed, 16 May 2018 17:54:29 +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 C6CA5285B7 for ; Wed, 16 May 2018 17:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751620AbeEPRy1 (ORCPT ); Wed, 16 May 2018 13:54:27 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45579 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751254AbeEPRyX (ORCPT ); Wed, 16 May 2018 13:54:23 -0400 Received: by mail-pf0-f195.google.com with SMTP id c10-v6so722553pfi.12 for ; Wed, 16 May 2018 10:54:23 -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=bGtHhWQvn6h0VJkri+BYj8d6WeyMZJifKCoKlQTL+Q4=; b=XkkRNwNbQgETqqvDYfdzvU5D2T8RACcwNf4ooFi5ivf4lkrReKfjKabknlQZesKMgw qfn+pmHhTLkwecqtQfZ0lV00M4yy8BL/8fRLa9yDBCDjfApeCmB7RRP9oKpIT42gqw0b eRRdlFeZ5o4lS7dfWLHXjotGz9vXQmutJh9OfzD7rBHJqCts/P+2ASgu7xixX7X/Zf3f zrTLj6TKOIZ2RniIHdDTYGcPanpe28KcoH2KtSGvZfHmog7J5+bABHniaDymotF/s37H GdCTpxJWt6U7NK/ODBUuQrGd1uAo0kNnkYm5FP+bV3zQAQENC4Zt4RglrmF1tLVmLtwY 40GQ== 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=bGtHhWQvn6h0VJkri+BYj8d6WeyMZJifKCoKlQTL+Q4=; b=ECVd/sgrEQDxroAkODHLDsahQYT3uotK3g7BnYU8m6VwzeCz7wjlFGN3/5nhE2jeUp jY8OK8WA2ZzqrD99FUMzwqlOAQPZpLyb44sE00IGR549hEzvHm3yTQjnP/0z3IeXr1ZM U0cqbv6VryGLRRWwMMPwvGaOF0KFVGB76arv/lsy4sZsKZN1JkJaUptPa6Flb/5rfsdc HDKbxnU9d7IB+MXBPb7++0oPDHCHXOLsjnXZlvJv4LjP+ICgv3CZqhhpHC0+h+3zO3uO VD64Fy3C7NyocQpNdVB6Wj4Ecz5kmuTaKc4L4U7B3HlyyeuzESy6hcTfAVTPoickiJIs 4jTg== X-Gm-Message-State: ALKqPwcviftx8cf5LsljH5P9yXiWMiI0wHfNeIK398ly0XFQijTYNgRJ LxUaG4B2EQOjLm5x1gNU0tXAeA== X-Google-Smtp-Source: AB8JxZqiGURojjU1mWICqF5DecWI5nDpu4qnMhYaYprlXHYhknWPfTrNaTBGlWBxCDIt2aztqL8lHQ== X-Received: by 2002:a62:20c7:: with SMTP id m68-v6mr1918255pfj.110.1526493262421; Wed, 16 May 2018 10:54:22 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id f13-v6sm4134213pgs.84.2018.05.16.10.54.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 10:54:21 -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 v3 2/2] iomap: don't allow holes in swapfiles Date: Wed, 16 May 2018 10:54:11 -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 Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara --- fs/iomap.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 89517442e296..f2456d0d8ddd 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1220,10 +1220,6 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos, return -EINVAL; } - /* Skip holes. */ - if (iomap->type == IOMAP_HOLE) - goto out; - /* Only real or unwritten extents. */ if (iomap->type != IOMAP_MAPPED && iomap->type != IOMAP_UNWRITTEN) { pr_err("swapon: file has unallocated extents\n"); @@ -1259,7 +1255,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; }