From ff6387430660848fe250a05dc0372a306938dabd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 9 Dec 2024 10:01:19 +0100 Subject: [PATCH] vfs: Slightly speed up stream_dir() lp_parm_bool() is a relatively expensive string-based operation. Do it only when needed. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/modules/vfs_streams_depot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 1c909512950..408ff02e559 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -160,7 +160,6 @@ static char *stream_dir(vfs_handle_struct *handle, uint8_t first, second; struct file_id id; uint8_t id_buf[16]; - bool check_valid; char id_hex[sizeof(id_buf) * 2 + 1]; char *rootdir = NULL; struct smb_filename *rootdir_fname = NULL; @@ -168,9 +167,6 @@ static char *stream_dir(vfs_handle_struct *handle, struct vfs_rename_how rhow = { .flags = 0, }; int ret; - check_valid = lp_parm_bool(SNUM(handle->conn), - "streams_depot", "check_valid", true); - rootdir = stream_rootdir(handle, talloc_tos()); if (rootdir == NULL) { @@ -247,13 +243,18 @@ static char *stream_dir(vfs_handle_struct *handle, if (SMB_VFS_NEXT_STAT(handle, smb_fname_hash) == 0) { struct smb_filename *smb_fname_new = NULL; char *newname; - bool delete_lost; + bool check_valid, delete_lost; if (!S_ISDIR(smb_fname_hash->st.st_ex_mode)) { errno = EINVAL; goto fail; } + check_valid = lp_parm_bool(SNUM(handle->conn), + "streams_depot", + "check_valid", + true); + if (!check_valid || file_is_valid(handle, smb_fname)) { return result; -- 2.47.3