From nobody Tue Jun 30 01:42:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AE9CC433F5 for ; Fri, 28 Jan 2022 07:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346991AbiA1Hrm (ORCPT ); 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: quoted-printable 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 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Chaitanya Kulkarni --- 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 cachefi= les_object *object, struct inode *inode =3D d_backing_inode(dentry); bool can_use =3D false; =20 - if (!(inode->i_flags & S_KERNEL_FILE)) { - inode->i_flags |=3D S_KERNEL_FILE; + if (!(inode->i_flags & S_CACHEFILE)) { + inode->i_flags |=3D S_CACHEFILE; trace_cachefiles_mark_active(object, inode); can_use =3D true; } else { @@ -51,7 +51,7 @@ static void __cachefiles_unmark_inode_in_use(struct cache= files_object *object, { struct inode *inode =3D d_backing_inode(dentry); =20 - inode->i_flags &=3D ~S_KERNEL_FILE; + inode->i_flags &=3D ~S_CACHEFILE; trace_cachefiles_mark_inactive(object, inode); } =20 @@ -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; =20 @@ -789,11 +789,11 @@ int cachefiles_cull(struct cachefiles_cache *cache, s= truct dentry *dir, /* check to see if someone is using this object */ inode =3D d_inode(victim); inode_lock(inode); - if (inode->i_flags & S_KERNEL_FILE) { + if (inode->i_flags & S_CACHEFILE) { ret =3D -EBUSY; } else { /* Stop the cache from picking it back up */ - inode->i_flags |=3D S_KERNEL_FILE; + inode->i_flags |=3D S_CACHEFILE; ret =3D 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, stru= ct inode *dir, =20 error =3D -EBUSY; if (is_local_mountpoint(dentry) || - (dentry->d_inode->i_flags & S_KERNEL_FILE)) + (dentry->d_inode->i_flags & S_CACHEFILE)) goto out; =20 error =3D 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/ca= chefiles) */ +#define S_CACHEFILE (1 << 17) /* In use as cachefile, can't be unlinked */ =20 /* * Note that nosuid etc flags are inode-specific: setting some file-system --=20 2.30.2