From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9847FC432BE for ; Wed, 25 Aug 2021 23:57:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E522604DB for ; Wed, 25 Aug 2021 23:57:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E522604DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 1F4526B006C; Wed, 25 Aug 2021 19:57:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17DA16B0072; Wed, 25 Aug 2021 19:57:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01E558D0001; Wed, 25 Aug 2021 19:57:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id D8FF56B006C for ; Wed, 25 Aug 2021 19:57:47 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 55ED2181D207A for ; Wed, 25 Aug 2021 23:57:47 +0000 (UTC) X-FDA: 78515268174.22.7953ABB Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf01.hostedemail.com (Postfix) with ESMTP id D99A65020C2C for ; Wed, 25 Aug 2021 23:57:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6BB631FE48; Wed, 25 Aug 2021 23:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1629935865; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I40F1Ns6CjlAVY0PznK3OmulJyL43m13XHPvZUd5jz8=; b=K8qWBKmbnO1H4ORX2OHYExgn1jqze6koUTO/cM9qlFAXdYLmRGS+L5p4TfK4HiLsg1lVA7 oBt2vFBgAJwl38W5vKAAhfUjBVgxAPeGU0E3a7LKr7hBzyUe5dGs54PHN4Xo0SG6uBA5PP o9c0G1ueVdrf7IKZEdntNGeDzpZezOs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1629935865; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I40F1Ns6CjlAVY0PznK3OmulJyL43m13XHPvZUd5jz8=; b=xOszmIOTkgVXruiwQ1+T/zXVvLxwxhR41SdK93mC1A6MK/bDh1PjwKWXCFkZ3A/TLadEsL +hOrg1rHr2QHIgBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C077413C3B; Wed, 25 Aug 2021 23:57:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QehoH/bYJmEQdQAAMHmgww (envelope-from ); Wed, 25 Aug 2021 23:57:42 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: Darrick J. Wong , Christoph Hellwig , David Howells , torvalds@linux-foundation.org, trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Don't block writes to swap-files with ETXTBSY. Date: Thu, 26 Aug 2021 09:57:39 +1000 Message-id: <162993585927.7591.10174443410031404560@noble.neil.brown.name> Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=K8qWBKmb; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=xOszmIOT; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf01.hostedemail.com: domain of neilb@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=neilb@suse.de X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D99A65020C2C X-Stat-Signature: m6f8abshgbonpy3pnrbgaoxkkxmo3a9a X-HE-Tag: 1629935866-841742 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Commit dc617f29dbe5 ("vfs: don't allow writes to swap files") broke swap-over-NFS as it introduced an ETXTBSY error when NFS tries to swap-out using ->direct_IO(). There is no sound justification for this error. File permissions are sufficient to stop non-root users from writing to a swap file, and root must always be cautious not to do anything dangerous. These checks effectively provide a mandatory write lock on swap, and mandatory locks are not supported in Linux. So remove all the checks that return ETXTBSY when attempts are made to write to swap. Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files") Signed-off-by: NeilBrown --- fs/block_dev.c | 3 --- fs/read_write.c | 6 ------ 2 files changed, 9 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 9ef4f1fc2cb0..e5605c88e6e9 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1623,9 +1623,6 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, st= ruct iov_iter *from) if (bdev_read_only(I_BDEV(bd_inode))) return -EPERM; =20 - if (IS_SWAPFILE(bd_inode) && !is_hibernate_resume_dev(bd_inode->i_rdev)) - return -ETXTBSY; - if (!iov_iter_count(from)) return 0; =20 diff --git a/fs/read_write.c b/fs/read_write.c index 9db7adf160d2..14f1c622a066 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1442,9 +1442,6 @@ static int generic_copy_file_checks(struct file *file_i= n, loff_t pos_in, if (IS_IMMUTABLE(inode_out)) return -EPERM; =20 - if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out)) - return -ETXTBSY; - /* Ensure offsets don't wrap. */ if (pos_in + count < pos_in || pos_out + count < pos_out) return -EOVERFLOW; @@ -1646,9 +1643,6 @@ ssize_t generic_write_checks(struct kiocb *iocb, struct= iov_iter *from) loff_t count; int ret; =20 - if (IS_SWAPFILE(inode)) - return -ETXTBSY; - if (!iov_iter_count(from)) return 0; =20 --=20 2.32.0