]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: syncops. Do early return in syncops_linkat()
authorJeremy Allison <jra@samba.org>
Thu, 17 Jun 2021 19:31:19 +0000 (12:31 -0700)
committerNoel Power <npower@samba.org>
Tue, 22 Jun 2021 13:44:34 +0000 (13:44 +0000)
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 <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/modules/vfs_syncops.c

index feb9dde2615111587d4c3851db9c13499c70abc1..09b270d091836e5c9a57acca2e1fa327577c2ee0 100644 (file)
@@ -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;