Skip to content

Commit

Permalink
NAS-130743 / 25.04 / Improve handling for renames in case insensitive…
Browse files Browse the repository at this point in the history
… filesystems (#403)

Bypass optimization to avoid renames in case target of rename
matches the original name used to open file handle if the underlying
filesystem is case-insensitive.
  • Loading branch information
anodos325 authored Aug 21, 2024
1 parent 681b5ba commit aa643d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions source3/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ typedef struct files_struct {
#define TCON_FLAG_STAT_FAILED 0x01
#define TCON_FLAG_STREAMS_XATTR 0x02
#define TCON_FLAG_STREAMS_FILE 0x04
#define TCON_FLAG_CASE_INSENSTIVE_FS 0x08

#define FSP_POSIX_FLAGS_OPEN 0x01
#define FSP_POSIX_FLAGS_RENAME 0x02
Expand Down
4 changes: 4 additions & 0 deletions source3/modules/vfs_zfs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ static int zfs_core_connect(struct vfs_handle_struct *handle,
return ret;
}

if (config->ds->properties->casesens == SMBZFS_INSENSITIVE) {
handle->conn->internal_tcon_flags |= TCON_FLAG_CASE_INSENSTIVE_FS;
}

base_quota_str = lp_parm_const_string(SNUM(handle->conn),
"zfs_core", "base_user_quota", NULL);

Expand Down
3 changes: 2 additions & 1 deletion source3/smbd/smb2_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,8 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
* don't do the rename, just return success.
*/

if (strcsequal(fsp->fsp_name->base_name, smb_fname_dst->base_name) &&
if ((conn->internal_tcon_flags & TCON_FLAG_CASE_INSENSTIVE_FS) == 0 &&
strcsequal(fsp->fsp_name->base_name, smb_fname_dst->base_name) &&
strcsequal(fsp->fsp_name->stream_name,
smb_fname_dst->stream_name)) {
DEBUG(3, ("rename_internals_fsp: identical names in rename %s "
Expand Down

0 comments on commit aa643d5

Please sign in to comment.