From: Ralph Boehme Date: Thu, 12 Mar 2020 18:23:40 +0000 (+0100) Subject: smbd: flush pending writetime update when flushing file X-Git-Tag: ldb-2.2.0~1398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d99d5bf2c6d0a818ef2f3920e0c93fac38761c36;p=thirdparty%2Fsamba.git smbd: flush pending writetime update when flushing file Cf the explanations in the previous commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14150 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/selftest/knownfail.d/samba3.smb2.timestamps b/selftest/knownfail.d/samba3.smb2.timestamps index c7d0ff2849e..8a52d4a2ad6 100644 --- a/selftest/knownfail.d/samba3.smb2.timestamps +++ b/selftest/knownfail.d/samba3.smb2.timestamps @@ -1,2 +1 @@ -^samba3.smb2.timestamps.delayed-write-vs-flush\(.*\)$ ^samba3.smb2.timestamps.delayed-write-vs-setbasic\(.*\)$ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index be7c170cd1f..f809837f1cb 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -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); diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c index 86d5bbc58f0..08539e95807 100644 --- a/source3/smbd/smb2_flush.c +++ b/source3/smbd/smb2_flush.c @@ -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); }