* [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers
@ 2026-11-18 0:28 Thorsten Blum
2026-11-18 0:28 ` [PATCH 1/4] fscrypt: Add FSTR() helper macro Thorsten Blum
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-11-18 0:28 UTC (permalink / raw)
To: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Eric Biggers,
Theodore Y. Ts'o
Cc: linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt, Thorsten Blum
Similar to QSTR(), add FSTR() to initialize struct fscrypt_str from a
NUL-terminated string without specifying its length.
Use the helper for 8 initializers in btrfs, F2FS, and UBIFS, replacing
hard-coded lengths and explicit strlen() calls.
Thorsten Blum (4):
fscrypt: Add FSTR() helper macro
btrfs: Use FSTR() for the "default" name
f2fs: Use FSTR() in f2fs_do_make_empty_dir()
ubifs: Use FSTR() in ubifs_xattr_{set,get,remove}()
fs/btrfs/inode.c | 3 +--
fs/btrfs/ioctl.c | 3 +--
fs/btrfs/super.c | 3 +--
fs/f2fs/dir.c | 7 ++-----
fs/ubifs/xattr.c | 6 +++---
include/linux/fscrypt.h | 1 +
6 files changed, 9 insertions(+), 14 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] fscrypt: Add FSTR() helper macro
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
@ 2026-11-18 0:28 ` Thorsten Blum
2026-11-18 0:28 ` [PATCH 2/4] btrfs: Use FSTR() for the "default" name Thorsten Blum
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-11-18 0:28 UTC (permalink / raw)
To: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Eric Biggers,
Theodore Y. Ts'o
Cc: linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt, Thorsten Blum
Similar to QSTR(), add FSTR() to initialize struct fscrypt_str from a
NUL-terminated string without specifying its length.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
include/linux/fscrypt.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 28f2108e29f3..84d9147fda2f 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -50,6 +50,7 @@ struct fscrypt_name {
};
#define FSTR_INIT(n, l) { .name = n, .len = l }
+#define FSTR(n) ((struct fscrypt_str)FSTR_INIT(n, strlen(n)))
#define FSTR_TO_QSTR(f) QSTR_INIT((f)->name, (f)->len)
#define fname_name(p) ((p)->disk_name.name)
#define fname_len(p) ((p)->disk_name.len)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] btrfs: Use FSTR() for the "default" name
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
2026-11-18 0:28 ` [PATCH 1/4] fscrypt: Add FSTR() helper macro Thorsten Blum
@ 2026-11-18 0:28 ` Thorsten Blum
2026-11-18 0:28 ` [PATCH 3/4] f2fs: Use FSTR() in f2fs_do_make_empty_dir() Thorsten Blum
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-11-18 0:28 UTC (permalink / raw)
To: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Eric Biggers,
Theodore Y. Ts'o
Cc: linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt, Thorsten Blum
Replace FSTR_INIT() with FSTR() and drop the hard-coded length argument.
Use FSTR() directly and remove the temporary name variables.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
fs/btrfs/inode.c | 3 +--
fs/btrfs/ioctl.c | 3 +--
fs/btrfs/super.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index abaa33471456..1ffdcdd16bb5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4640,7 +4640,6 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_dir_item *di;
struct btrfs_key key;
- struct fscrypt_str name = FSTR_INIT("default", 7);
u64 dir_id;
int ret;
@@ -4651,7 +4650,7 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
/* Make sure this root isn't set as the default subvol */
dir_id = btrfs_super_root_dir(fs_info->super_copy);
di = btrfs_lookup_dir_item(NULL, fs_info->tree_root, path,
- dir_id, &name, 0);
+ dir_id, &FSTR("default"), 0);
if (!IS_ERR_OR_NULL(di)) {
btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key);
if (key.objectid == btrfs_root_id(root)) {
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6ba883db107b..6c371621f014 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2825,7 +2825,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
struct btrfs_trans_handle *trans;
struct btrfs_path *path = NULL;
struct btrfs_disk_key disk_key;
- struct fscrypt_str name = FSTR_INIT("default", 7);
u64 objectid = 0;
u64 dir_id;
int ret;
@@ -2869,7 +2868,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
dir_id = btrfs_super_root_dir(fs_info->super_copy);
di = btrfs_lookup_dir_item(trans, fs_info->tree_root, path,
- dir_id, &name, 1);
+ dir_id, &FSTR("default"), 1);
if (IS_ERR_OR_NULL(di)) {
btrfs_release_path(path);
btrfs_end_transaction(trans);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b424cc836bd4..0b8b808872c7 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -911,7 +911,6 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objec
struct btrfs_dir_item *di;
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key location;
- struct fscrypt_str name = FSTR_INIT("default", 7);
u64 dir_id;
path = btrfs_alloc_path();
@@ -924,7 +923,7 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objec
* to mount.
*/
dir_id = btrfs_super_root_dir(fs_info->super_copy);
- di = btrfs_lookup_dir_item(NULL, root, path, dir_id, &name, 0);
+ di = btrfs_lookup_dir_item(NULL, root, path, dir_id, &FSTR("default"), 0);
if (IS_ERR(di)) {
return PTR_ERR(di);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] f2fs: Use FSTR() in f2fs_do_make_empty_dir()
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
2026-11-18 0:28 ` [PATCH 1/4] fscrypt: Add FSTR() helper macro Thorsten Blum
2026-11-18 0:28 ` [PATCH 2/4] btrfs: Use FSTR() for the "default" name Thorsten Blum
@ 2026-11-18 0:28 ` Thorsten Blum
2026-11-18 0:28 ` [PATCH 4/4] ubifs: Use FSTR() in ubifs_xattr_{set,get,remove}() Thorsten Blum
2026-11-18 5:01 ` [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Eric Biggers
4 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-11-18 0:28 UTC (permalink / raw)
To: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Eric Biggers,
Theodore Y. Ts'o
Cc: linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt, Thorsten Blum
Replace FSTR_INIT() with FSTR() and drop the hard-coded length argument.
Use FSTR() directly and remove the temporary variables.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
fs/f2fs/dir.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 97f7fef6b068..469c4cc7a3b7 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -515,14 +515,11 @@ static void init_dent_inode(struct inode *dir, struct inode *inode,
void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent,
struct f2fs_dentry_ptr *d)
{
- struct fscrypt_str dot = FSTR_INIT(".", 1);
- struct fscrypt_str dotdot = FSTR_INIT("..", 2);
-
/* update dirent of "." */
- f2fs_update_dentry(inode->i_ino, inode->i_mode, d, &dot, 0, 0);
+ f2fs_update_dentry(inode->i_ino, inode->i_mode, d, &FSTR("."), 0, 0);
/* update dirent of ".." */
- f2fs_update_dentry(parent->i_ino, parent->i_mode, d, &dotdot, 0, 1);
+ f2fs_update_dentry(parent->i_ino, parent->i_mode, d, &FSTR(".."), 0, 1);
}
static int make_empty_dir(struct inode *inode,
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] ubifs: Use FSTR() in ubifs_xattr_{set,get,remove}()
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
` (2 preceding siblings ...)
2026-11-18 0:28 ` [PATCH 3/4] f2fs: Use FSTR() in f2fs_do_make_empty_dir() Thorsten Blum
@ 2026-11-18 0:28 ` Thorsten Blum
2026-11-18 5:01 ` [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Eric Biggers
4 siblings, 0 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-11-18 0:28 UTC (permalink / raw)
To: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Eric Biggers,
Theodore Y. Ts'o
Cc: linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt, Thorsten Blum
Replace FSTR_INIT() with FSTR() and drop the explicit length argument.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
fs/ubifs/xattr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 3b0e8a270f59..036eb7e2be0b 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -252,7 +252,7 @@ int ubifs_xattr_set(struct inode *host, const char *name, const void *value,
{
struct inode *inode;
struct ubifs_info *c = host->i_sb->s_fs_info;
- struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
+ struct fscrypt_name nm = { .disk_name = FSTR((char *)name) };
struct ubifs_dent_node *xent;
union ubifs_key key;
int err;
@@ -315,7 +315,7 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
{
struct inode *inode;
struct ubifs_info *c = host->i_sb->s_fs_info;
- struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
+ struct fscrypt_name nm = { .disk_name = FSTR((char *)name) };
struct ubifs_inode *ui;
struct ubifs_dent_node *xent;
union ubifs_key key;
@@ -557,7 +557,7 @@ static int ubifs_xattr_remove(struct inode *host, const char *name)
{
struct inode *inode;
struct ubifs_info *c = host->i_sb->s_fs_info;
- struct fscrypt_name nm = { .disk_name = FSTR_INIT((char *)name, strlen(name))};
+ struct fscrypt_name nm = { .disk_name = FSTR((char *)name) };
struct ubifs_dent_node *xent;
union ubifs_key key;
int err;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
` (3 preceding siblings ...)
2026-11-18 0:28 ` [PATCH 4/4] ubifs: Use FSTR() in ubifs_xattr_{set,get,remove}() Thorsten Blum
@ 2026-11-18 5:01 ` Eric Biggers
4 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2026-11-18 5:01 UTC (permalink / raw)
To: Thorsten Blum
Cc: David Sterba, Chris Mason, Jaegeuk Kim, Chao Yu,
Richard Weinberger, Zhihao Cheng, Theodore Y. Ts'o,
linux-btrfs, linux-kernel, linux-f2fs-devel, linux-mtd,
linux-fscrypt
On Wed, Nov 18, 2026 at 01:28:46AM +0100, Thorsten Blum wrote:
> Similar to QSTR(), add FSTR() to initialize struct fscrypt_str from a
> NUL-terminated string without specifying its length.
>
> Use the helper for 8 initializers in btrfs, F2FS, and UBIFS, replacing
> hard-coded lengths and explicit strlen() calls.
It would be worth stating explicitly that the new strlen() calls are
constant-folded in most configurations (if they indeed are).
- Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-18 5:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 0:28 [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Thorsten Blum
2026-11-18 0:28 ` [PATCH 1/4] fscrypt: Add FSTR() helper macro Thorsten Blum
2026-11-18 0:28 ` [PATCH 2/4] btrfs: Use FSTR() for the "default" name Thorsten Blum
2026-11-18 0:28 ` [PATCH 3/4] f2fs: Use FSTR() in f2fs_do_make_empty_dir() Thorsten Blum
2026-11-18 0:28 ` [PATCH 4/4] ubifs: Use FSTR() in ubifs_xattr_{set,get,remove}() Thorsten Blum
2026-11-18 5:01 ` [PATCH 0/4] fscrypt: Add FSTR() helper macro and convert initializers Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox