From fb00ab4c56b201b26c97e1db9faf1036c852b924 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 15 Mar 2020 15:51:18 +0100 Subject: [PATCH 1/3] smbd: remove stat call from mark_file_modified() This stat dates back to d03453864ab1bc5fd3b4a3abaf96176a006c102b where the call to trigger_write_time_update() had been to the file IO codepath. It was present there for other reasons: to setup the write-cache based on the file's size. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 2c19d27113036d607850f370bb9afd62856d671e) --- source3/smbd/fileio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 067ce5a9ad4..fa1c884f617 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -283,9 +283,6 @@ void mark_file_modified(files_struct *fsp) fsp->modified = true; - if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) { - return; - } trigger_write_time_update(fsp); if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { -- 2.20.1 From 19ce639376cd67c09bdfe85eee8d8a947d7d1d5c Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 15 Mar 2020 08:30:21 +0100 Subject: [PATCH 2/3] smbd: let mark_file_modified() always call trigger_write_time_update() Preperatory change: the next commit will reset fsp->update_write_time_on_close in the event handler, so this change ensures it gets set again for any subsequent write. This will NOT always result in a write-time update because trigger_write_time_update() has its own only-once logic using the internal variable fsp->update_write_time_triggered. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 53de2da7acfc24513082190502d93306c12b7434) --- source3/smbd/fileio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index fa1c884f617..8e3412613d0 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -277,14 +277,14 @@ void mark_file_modified(files_struct *fsp) { int dosmode; + trigger_write_time_update(fsp); + if (fsp->modified) { return; } fsp->modified = true; - trigger_write_time_update(fsp); - if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { return; } -- 2.20.1 From b2158365cd489ee5a3e40d878f946750753cd8be Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 15 Mar 2020 08:30:21 +0100 Subject: [PATCH 3/3] smbd: let delayed update handler also update on-disk timestamps Let delayed update handler also update on-disk timestamps by calling trigger_write_time_update_immediate(). trigger_write_time_update_immediate() sets fsp->update_write_time_on_close to false which prevents updating the write-time on close if there was ever only one write to the file. Besides resetting fsp->update_write_time_on_close and setting the on-disk timestamps trigger_write_time_update_immediate() takes the same steps as the removed code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Mar 19 03:05:40 UTC 2020 on sn-devel-184 (back ported from commit 81c1a14e3271aeed7ed4fe6311171b19ba963555) --- source3/smbd/fileio.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 8e3412613d0..36ff6344a5d 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -169,15 +169,7 @@ void fsp_flush_write_time_update(struct files_struct *fsp) DEBUG(5, ("Update write time on %s\n", fsp_str_dbg(fsp))); - /* change the write time in the open file db. */ - (void)set_write_time(fsp->file_id, timespec_current()); - - /* And notify. */ - notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED, - FILE_NOTIFY_CHANGE_LAST_WRITE, fsp->fsp_name->base_name); - - /* Remove the timed event handler. */ - TALLOC_FREE(fsp->update_write_time_event); + trigger_write_time_update_immediate(fsp); } static void update_write_time_handler(struct tevent_context *ctx, -- 2.20.1