]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: flush pending writetime update when flushing file
authorRalph Boehme <slow@samba.org>
Thu, 12 Mar 2020 18:23:40 +0000 (19:23 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 19 Mar 2020 01:20:34 +0000 (01:20 +0000)
Cf the explanations in the previous commit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14150

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.smb2.timestamps
source3/smbd/reply.c
source3/smbd/smb2_flush.c

index c7d0ff2849e33345d39196d4343e98fbc765f660..8a52d4a2ad677c27336264845b9ec9a70e578ea7 100644 (file)
@@ -1,2 +1 @@
-^samba3.smb2.timestamps.delayed-write-vs-flush\(.*\)$
 ^samba3.smb2.timestamps.delayed-write-vs-setbasic\(.*\)$
index be7c170cd1f4142290eef3a7f1278829decb27b0..f809837f1cbfe7b6e871ede8e2dcf9b62c837899 100644 (file)
@@ -5714,6 +5714,10 @@ static struct files_struct *file_sync_one_fn(struct files_struct *fsp,
        }
        sync_file(conn, fsp, True /* write through */);
 
+       if (fsp->modified) {
+               trigger_write_time_update_immediate(fsp);
+       }
+
        return NULL;
 }
 
@@ -5752,6 +5756,9 @@ void reply_flush(struct smb_request *req)
                        END_PROFILE(SMBflush);
                        return;
                }
+               if (fsp->modified) {
+                       trigger_write_time_update_immediate(fsp);
+               }
        }
 
        reply_outbuf(req, 0, 0);
index 86d5bbc58f0e64b2db21a3cfad9c6a9d5d9af20f..08539e9580769f9b9db39893d34dc4807af6d0e9 100644 (file)
@@ -112,6 +112,7 @@ static void smbd_smb2_request_flush_done(struct tevent_req *subreq)
 
 struct smbd_smb2_flush_state {
        struct smbd_smb2_request *smb2req;
+       struct files_struct *fsp;
 };
 
 static void smbd_smb2_flush_done(struct tevent_req *subreq);
@@ -132,6 +133,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
        state->smb2req = smb2req;
+       state->fsp = fsp;
 
        DEBUG(10,("smbd_smb2_flush: %s - %s\n",
                  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
@@ -207,6 +209,8 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq)
 {
        struct tevent_req *req = tevent_req_callback_data(
                subreq, struct tevent_req);
+       struct smbd_smb2_flush_state *state = tevent_req_data(
+               req, struct smbd_smb2_flush_state);
        int ret;
        struct vfs_aio_state vfs_aio_state;
 
@@ -216,6 +220,9 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq)
                tevent_req_nterror(req, map_nt_error_from_unix(vfs_aio_state.error));
                return;
        }
+       if (state->fsp->modified) {
+               trigger_write_time_update_immediate(state->fsp);
+       }
        tevent_req_done(req);
 }