From: Jeremy Allison Date: Thu, 17 Jun 2021 19:31:19 +0000 (-0700) Subject: s3: VFS: syncops. Do early return in syncops_linkat() X-Git-Tag: tevent-0.11.0~233 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=d76abb322390609766b6463e64ff83289f8361c0;p=thirdparty%2Fsamba.git s3: VFS: syncops. Do early return in syncops_linkat() We should always do the operation first, then try the sync. Failure to sync is not reported as an error, so failure to create the full_fnames shouldn't fail the operation either. Makes the code path clearer. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c index feb9dde2615..09b270d0918 100644 --- a/source3/modules/vfs_syncops.c +++ b/source3/modules/vfs_syncops.c @@ -220,19 +220,6 @@ static int syncops_linkat(vfs_handle_struct *handle, struct syncops_config_data, return -1); - old_full_fname = full_path_from_dirfsp_atname(talloc_tos(), - srcfsp, - old_smb_fname); - if (old_full_fname == NULL) { - return -1; - } - new_full_fname = full_path_from_dirfsp_atname(talloc_tos(), - dstfsp, - new_smb_fname); - if (new_full_fname == NULL) { - TALLOC_FREE(old_full_fname); - return -1; - } ret = SMB_VFS_NEXT_LINKAT(handle, srcfsp, old_smb_fname, @@ -240,11 +227,32 @@ static int syncops_linkat(vfs_handle_struct *handle, new_smb_fname, flags); - if (ret == 0 && config->onmeta && !config->disable) { - syncops_two_names(handle->conn, - old_full_fname, - new_full_fname); + if (ret == -1) { + return ret; + } + if (config->disable) { + return ret; + } + if (!config->onmeta) { + return ret; + } + + old_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + srcfsp, + old_smb_fname); + if (old_full_fname == NULL) { + return ret; + } + new_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dstfsp, + new_smb_fname); + if (new_full_fname == NULL) { + TALLOC_FREE(old_full_fname); + return ret; } + syncops_two_names(handle->conn, + old_full_fname, + new_full_fname); TALLOC_FREE(old_full_fname); TALLOC_FREE(new_full_fname); return ret;