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: 10404561 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 4FC61601F7 for ; Wed, 16 May 2018 17:54:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F1F1285B7 for ; Wed, 16 May 2018 17:54:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 336CC285F7; Wed, 16 May 2018 17:54:31 +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 1407E285B7 for ; Wed, 16 May 2018 17:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbeEPRy1 (ORCPT ); Wed, 16 May 2018 13:54:27 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34104 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbeEPRyX (ORCPT ); Wed, 16 May 2018 13:54:23 -0400 Received: by mail-pf0-f196.google.com with SMTP id a14-v6so737987pfi.1 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=Bqw2YSyzTd+HVQHKtECl8lt58eSwszygeRkSCcoqY0BkG8iGsaRcX1WxjvMRcdWTTL 1AfQVuiFHv6Ks3Mrm3gPtpJQ+PBuxAwt9xfaOq5UvSiOLfyyNlqUQrsjdnf73RXWmC7m HoWQeS9WGahvcxcp8zxO/F+4283XKeeQ+f6pt2yAdEjtsyn3CXB+KkdMhE4vfql/Y82O 2zjeqstfm6CPSweE0OiIWpyDNT3moq1EEanB3zykzbsbGpz6fzv+DdP/SuY111E68/ij u9v1gM3dSW0ehy+ud0p6H14DhRXEnpIOkhjIlu+Oq7lDQ6OQivlQicduL5zmURKE5XMS 5pDw== X-Gm-Message-State: ALKqPwdI9ZTenoxj+IG1FWHW6Fx/BghB1HFu6e/RKmhqKBBBhbL57VgG S16omyc4i5hRHmZKax5RebmJyw== 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-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 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; }