All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-unionfs@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Amir Goldstein <amir73il@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 5/6] bcachefs: Hook up d_casefold_enable()
Date: Tue, 20 May 2025 01:15:57 -0400	[thread overview]
Message-ID: <20250520051600.1903319-6-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20250520051600.1903319-1-kent.overstreet@linux.dev>

Hook up BCH_INODE_has_case_insensitive -> S_NO_CASEFOLD, and call the
new dcache methods for exclusion with overlayfs when the flag is
changing.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 fs/bcachefs/fs.c | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index 0b5d52895e05..a02f787a6d05 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -68,6 +68,11 @@ static inline void bch2_inode_flags_to_vfs(struct bch_fs *c, struct bch_inode_in
 		inode->v.i_flags |= S_CASEFOLD;
 	else
 		inode->v.i_flags &= ~S_CASEFOLD;
+
+	if (inode->ei_inode.bi_flags & BCH_INODE_has_case_insensitive)
+		inode->v.i_flags &= ~S_NO_CASEFOLD;
+	else
+		inode->v.i_flags |= S_NO_CASEFOLD;
 }
 
 void bch2_inode_update_after_write(struct btree_trans *trans,
@@ -916,6 +921,8 @@ static int bch2_rename2(struct mnt_idmap *idmap,
 	struct bch_inode_info *dst_inode = to_bch_ei(dst_dentry->d_inode);
 	struct bch_inode_unpacked dst_dir_u, src_dir_u;
 	struct bch_inode_unpacked src_inode_u, dst_inode_u, *whiteout_inode_u;
+	struct d_casefold_enable casefold_enable_src = {};
+	struct d_casefold_enable casefold_enable_dst = {};
 	struct btree_trans *trans;
 	enum bch_rename_mode mode = flags & RENAME_EXCHANGE
 		? BCH_RENAME_EXCHANGE
@@ -940,6 +947,21 @@ static int bch2_rename2(struct mnt_idmap *idmap,
 			 src_inode,
 			 dst_inode);
 
+	if (src_dir != dst_dir) {
+		if (bch2_inode_casefold(c, &src_inode->ei_inode)) {
+			ret = d_casefold_enable(dst_dentry, &casefold_enable_dst);
+			if (ret)
+				goto err;
+		}
+
+		if (mode == BCH_RENAME_EXCHANGE &&
+		    bch2_inode_casefold(c, &dst_inode->ei_inode)) {
+			ret = d_casefold_enable(src_dentry, &casefold_enable_src);
+			if (ret)
+				goto err;
+		}
+	}
+
 	trans = bch2_trans_get(c);
 
 	ret   = bch2_subvol_is_ro_trans(trans, src_dir->ei_inum.subvol) ?:
@@ -1044,6 +1066,9 @@ static int bch2_rename2(struct mnt_idmap *idmap,
 			   src_inode,
 			   dst_inode);
 
+	d_casefold_enable_commit(&casefold_enable_dst, ret);
+	d_casefold_enable_commit(&casefold_enable_src, ret);
+
 	return bch2_err_class(ret);
 }
 
@@ -1710,6 +1735,7 @@ static int bch2_fileattr_set(struct mnt_idmap *idmap,
 	struct bch_inode_info *inode = to_bch_ei(d_inode(dentry));
 	struct bch_fs *c = inode->v.i_sb->s_fs_info;
 	struct flags_set s = {};
+	struct d_casefold_enable casefold_enable = {};
 	int ret;
 
 	if (fa->fsx_valid) {
@@ -1742,9 +1768,17 @@ static int bch2_fileattr_set(struct mnt_idmap *idmap,
 		s.casefold = (fa->flags & FS_CASEFOLD_FL) != 0;
 		fa->flags &= ~FS_CASEFOLD_FL;
 
+		if (s.casefold) {
+			ret = d_casefold_enable(dentry, &casefold_enable);
+			if (ret)
+				goto err;
+		}
+
 		s.flags |= map_flags_rev(bch_flags_to_uflags, fa->flags);
-		if (fa->flags)
-			return -EOPNOTSUPP;
+		if (fa->flags) {
+			ret = -EOPNOTSUPP;
+			goto err;
+		}
 	}
 
 	mutex_lock(&inode->ei_update_lock);
@@ -1755,6 +1789,9 @@ static int bch2_fileattr_set(struct mnt_idmap *idmap,
 		bch2_write_inode(c, inode, fssetxattr_inode_update_fn, &s,
 			       ATTR_CTIME);
 	mutex_unlock(&inode->ei_update_lock);
+err:
+	d_casefold_enable_commit(&casefold_enable, ret);
+
 	return ret;
 }
 
-- 
2.49.0


  parent reply	other threads:[~2025-05-20  5:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20  5:15 [PATCH 0/6] overlayfs + casefolding Kent Overstreet
2025-05-20  5:15 ` [PATCH 1/6] bcachefs: BCH_INODE_has_case_insensitive Kent Overstreet
2025-05-20  5:15 ` [PATCH 2/6] darray: lift from bcachefs Kent Overstreet
2025-05-20  5:15 ` [PATCH 3/6] fs: SB_CASEFOLD Kent Overstreet
2025-05-20  5:15 ` [PATCH 4/6] fs: dcache locking for exlusion between overlayfs, casefolding Kent Overstreet
2025-05-20 15:25   ` Al Viro
2025-05-20 15:27     ` Kent Overstreet
2025-05-23 11:54   ` [PATCH v2] fs: dcache " Kent Overstreet
2025-05-20  5:15 ` Kent Overstreet [this message]
2025-05-20  5:15 ` [PATCH 6/6] overlayfs: Support casefolded filesystems Kent Overstreet
2025-05-20  8:05 ` [PATCH 0/6] overlayfs + casefolding Amir Goldstein
2025-05-20 12:25   ` Kent Overstreet
2025-05-20 12:40     ` Amir Goldstein
2025-05-20 12:43       ` Kent Overstreet
2025-05-20 14:03         ` Amir Goldstein
2025-05-20 14:12           ` Kent Overstreet
2025-05-20 14:33             ` Amir Goldstein
2025-05-20 14:44               ` Kent Overstreet
2025-05-20 15:13                 ` Amir Goldstein
2025-05-20 15:21                   ` Kent Overstreet
2025-05-20 16:40                     ` Miklos Szeredi
2025-05-20 16:49                       ` Kent Overstreet
2025-05-23 14:10               ` Kent Overstreet
2025-05-23 17:14                 ` Amir Goldstein
2025-05-23 20:30                   ` Amir Goldstein
2025-05-23 21:09                     ` Kent Overstreet
2025-05-24 13:01                       ` Amir Goldstein
2025-05-25 18:27                         ` Kent Overstreet
2025-05-27  8:57                           ` Amir Goldstein
2025-05-27 18:07                             ` Kent Overstreet
2025-05-20 18:49             ` John Stoffel
2025-05-21  1:49               ` Kent Overstreet
2025-05-22 21:44                 ` John Stoffel
2025-05-21 11:26               ` Malte Schröder
2025-05-22  7:53                 ` Christopher Snowhill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250520051600.1903319-6-kent.overstreet@linux.dev \
    --to=kent.overstreet@linux.dev \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.