Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2046460pxb; Sun, 30 Jan 2022 03:40:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJKvo5XNhV/Qod777cX4WEQgP/hhoVjbgmRtjX1PO6y3sQXCkf1ruv5az06lBpi6Ox7Qcp X-Received: by 2002:a05:6a00:1306:: with SMTP id j6mr15961622pfu.32.1643542829605; Sun, 30 Jan 2022 03:40:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643542829; cv=none; d=google.com; s=arc-20160816; b=iSZzU/rd5+0/x2FffDfahvdhhKa1om9VWvka3tUBVQ93idxYqSCGwCPSl+0NIBV8Tz rWgGdMl8y4xGb4ayhKAvfQWwXk8FRdixPLJPJ3deYopD2QcjmHfPEVRTCwJ7fVeroAW6 EFUkz/WwFlMnp124O1gHEehNdMCxOEw6sRQCnFEhl5V0gpUz34XxgLssTTNuskcT8MGY MvHBe+rPjhdxOQWYiBjhqaFIq8VnxrFGaIRfuMZfgeexR+dkWZqc43RlwZz4g4Hr23fy Z6di+0g1yXkYAmVLsaeipq2smDIGBgL9JDhSHMVOUQX/Xahua9sxRSVNFrr2DilAg2yz MymQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=u8U0/Ai5mbQzGHpMhOzTxk2dLwnQvDLgWPnPvMcwTlA=; b=dzre76uA7bKB4FtjpkjUA5UBrGRY8c+vhXZi4NxzfvyopXB3K8OkXr7CtUVNbh6cqX U0kJDbDkpcIPC2YUj5EIA8vamSwNxQW2127gD1Dt3o59zoorssmcWsmLRxJAcgBzfVE4 ESHQ8Nokv29MZfSGztp5LvxcbHZxvEFuXP+IEYSCVLjL0BbYNsa2Kbs0EYhGgfq6A3qF ByQYwRBGENi1m61hfru630qL4qoaTrbSAlb6IO8eOMQ/rBFqRMX1JIxAWFmng5BgrE5C Jt7ZrHjTwwTwSTySZ7jau6agExl8aTZYreto7aYmh0/X7kSumSo5//XOOe/Ilt/3d5tM g3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=oqnQD992; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si10449198pga.785.2022.01.30.03.40.18; Sun, 30 Jan 2022 03:40:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=oqnQD992; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346988AbiA1Hrm (ORCPT + 99 others); Fri, 28 Jan 2022 02:47:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346853AbiA1Hrh (ORCPT ); Fri, 28 Jan 2022 02:47:37 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78217C06173B; Thu, 27 Jan 2022 23:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=u8U0/Ai5mbQzGHpMhOzTxk2dLwnQvDLgWPnPvMcwTlA=; b=oqnQD992oMMsoVP2DYTG8sHVk/ Oxf214lSUukxCU1DjtlMOsUsh31Aa9sSIsDtcfKE+tmzK8XSWJof8Yyy+4ZwKhEejcqae1CDROjqA zxdNl6BSBmyiL8rgq7NfvH6ZyN2nJDWnDA+ftM5ULiS+AKfPMACXuw+anwE4HfJDJlx6w9NTad0VR zR2fqiOYed9wlHBKzycsbnYzTOOYxEVJ5QMEmgUe8922Re7d+4LK4KqEhJKuChAPM8OaNSR/9DktO McB1DnXCbPyZ+GQM5J4Jsc5MAFqqzMfhyj2gUFu8EWb0rXtmZsXk61IfjF7ePZJzrXcxsZGuSU/nN +Ns0bUMA==; Received: from [2001:4bb8:180:4c4c:73e:e8c7:4199:32d7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDLyn-000rEN-TG; Fri, 28 Jan 2022 07:47:34 +0000 From: Christoph Hellwig To: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, dhowells@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Amir Goldstein Subject: [PATCH v2] fs: rename S_KERNEL_FILE Date: Fri, 28 Jan 2022 08:47:31 +0100 Message-Id: <20220128074731.1623738-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org S_KERNEL_FILE is grossly misnamed. We have plenty of files hold open by the kernel kernel using filp_open. This flag OTOH signals the inode as being a special snowflake that cachefiles holds onto that can't be unlinked because of ..., erm, pixie dust. So clearly mark it as such. Signed-off-by: Christoph Hellwig Reviewed-by: Amir Goldstein --- Changes since v1: - fix commit message typos fs/cachefiles/namei.c | 12 ++++++------ fs/namei.c | 2 +- include/linux/fs.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 9bd692870617c..599dc13a7d9ab 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -20,8 +20,8 @@ static bool __cachefiles_mark_inode_in_use(struct cachefiles_object *object, struct inode *inode = d_backing_inode(dentry); bool can_use = false; - if (!(inode->i_flags & S_KERNEL_FILE)) { - inode->i_flags |= S_KERNEL_FILE; + if (!(inode->i_flags & S_CACHEFILE)) { + inode->i_flags |= S_CACHEFILE; trace_cachefiles_mark_active(object, inode); can_use = true; } else { @@ -51,7 +51,7 @@ static void __cachefiles_unmark_inode_in_use(struct cachefiles_object *object, { struct inode *inode = d_backing_inode(dentry); - inode->i_flags &= ~S_KERNEL_FILE; + inode->i_flags &= ~S_CACHEFILE; trace_cachefiles_mark_inactive(object, inode); } @@ -742,7 +742,7 @@ static struct dentry *cachefiles_lookup_for_cull(struct cachefiles_cache *cache, goto lookup_error; if (d_is_negative(victim)) goto lookup_put; - if (d_inode(victim)->i_flags & S_KERNEL_FILE) + if (d_inode(victim)->i_flags & S_CACHEFILE) goto lookup_busy; return victim; @@ -789,11 +789,11 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir, /* check to see if someone is using this object */ inode = d_inode(victim); inode_lock(inode); - if (inode->i_flags & S_KERNEL_FILE) { + if (inode->i_flags & S_CACHEFILE) { ret = -EBUSY; } else { /* Stop the cache from picking it back up */ - inode->i_flags |= S_KERNEL_FILE; + inode->i_flags |= S_CACHEFILE; ret = 0; } inode_unlock(inode); diff --git a/fs/namei.c b/fs/namei.c index d81f04f8d8188..7402277ecc1f5 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3959,7 +3959,7 @@ int vfs_rmdir(struct user_namespace *mnt_userns, struct inode *dir, error = -EBUSY; if (is_local_mountpoint(dentry) || - (dentry->d_inode->i_flags & S_KERNEL_FILE)) + (dentry->d_inode->i_flags & S_CACHEFILE)) goto out; error = security_inode_rmdir(dir, dentry); diff --git a/include/linux/fs.h b/include/linux/fs.h index c8510da6cc6dc..099d7e03d46e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2173,7 +2173,7 @@ struct super_operations { #define S_ENCRYPTED (1 << 14) /* Encrypted file (using fs/crypto/) */ #define S_CASEFOLD (1 << 15) /* Casefolded file */ #define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */ -#define S_KERNEL_FILE (1 << 17) /* File is in use by the kernel (eg. fs/cachefiles) */ +#define S_CACHEFILE (1 << 17) /* In use as cachefile, can't be unlinked */ /* * Note that nosuid etc flags are inode-specific: setting some file-system -- 2.30.2