From 081d00f9e57c8234817a3e810c7ae4b3e7e68949 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Oct 2012 10:54:27 +0200 Subject: [PATCH 1/4] s3:smbd/durable: trigger pending write_time updates before disconnecting the file We need to call the pending write time update handler immediately. Which means we don't wait exactly 2 seconds before updating the write time after the first write. metze Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 9e7bce53707732700928eaf2bb53a5f1cc5d7784) Signed-off-by: Stefan Metzmacher --- source3/smbd/durable.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 42ad18e..feec0da 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -173,6 +173,14 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, return NT_STATUS_NOT_SUPPORTED; } + /* Ensure any pending write time updates are done. */ + if (fsp->update_write_time_event) { + update_write_time_handler(fsp->conn->sconn->ev_ctx, + fsp->update_write_time_event, + timeval_current(), + (void *)fsp); + } + /* * The above checks are done in mark_share_mode_disconnected() too * but we want to avoid getting the lock if possible -- 1.7.9.5 From 6ae0aed160a52ad8a0bd62d959bfab9472d2c31e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Oct 2012 10:58:47 +0200 Subject: [PATCH 2/4] s3:smbd/durable: update the low level write_time before disconnecting the file. If we close the low level FD, we should better update the write_time if needed. It's not unlikely that the client doesn't reclaim the durable handle, in that case we may not close the after the durable timeout. In such a case we should make sure that we at least update the write time on disconnect, this makes sure backup applications notice that the file was changed. metze Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 137376391d5642c0a18ff70a5184dac4b402fa42) Signed-off-by: Stefan Metzmacher --- source3/smbd/durable.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index feec0da..f8e82c2 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -187,6 +187,25 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, */ lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); if (lck != NULL) { + struct smb_file_time ft; + + ZERO_STRUCT(ft); + + if (fsp->write_time_forced) { + ft.mtime = lck->data->changed_write_time; + } else if (fsp->update_write_time_on_close) { + if (null_timespec(fsp->close_write_time)) { + ft.mtime = timespec_current(); + } else { + ft.mtime = fsp->close_write_time; + } + } + + if (!null_timespec(ft.mtime)) { + round_timespec(conn->ts_res, &ft.mtime); + file_ntimes(conn, fsp->fsp_name, &ft); + } + ok = mark_share_mode_disconnected(lck, fsp); if (!ok) { TALLOC_FREE(lck); -- 1.7.9.5 From 80a4ef4bfcd563259bfb89670329e5d47ecff2c5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Oct 2012 11:12:05 +0200 Subject: [PATCH 3/4] s3:open_files.idl: add write_time specific stuff to vfs_default_durable_cookie metze Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 506249b86382331c39676b8632ad33b535f9fb03) Signed-off-by: Stefan Metzmacher --- source3/librpc/idl/open_files.idl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source3/librpc/idl/open_files.idl b/source3/librpc/idl/open_files.idl index eb0dfa0..0dd9859 100644 --- a/source3/librpc/idl/open_files.idl +++ b/source3/librpc/idl/open_files.idl @@ -61,5 +61,9 @@ interface open_files [string,charset(UTF8)] char *base_name; hyper initial_allocation_size; hyper position_information; + boolean8 update_write_time_triggered; + boolean8 update_write_time_on_close; + boolean8 write_time_forced; + timespec close_write_time; } vfs_default_durable_cookie; } -- 1.7.9.5 From e0c1762bc66e9e16b0e9584dd66bc90c66c5985e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Oct 2012 11:12:05 +0200 Subject: [PATCH 4/4] s3:smbd/durable: add write_time specific stuff to vfs_default_durable_cookie metze Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Fri Oct 19 17:12:29 CEST 2012 on sn-devel-104 (cherry picked from commit 24d225f44ee4958ed5e2bd934125a9b0c4fc3323) Signed-off-by: Stefan Metzmacher The last 4 patches address bug 9318 - fix write time updates for durable handles --- source3/smbd/durable.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index f8e82c2..348135c 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -99,6 +99,10 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp, cookie.base_name = fsp->fsp_name->base_name; cookie.initial_allocation_size = fsp->initial_allocation_size; cookie.position_information = fsp->fh->position_information; + cookie.update_write_time_triggered = fsp->update_write_time_triggered; + cookie.update_write_time_on_close = fsp->update_write_time_on_close; + cookie.write_time_forced = fsp->write_time_forced; + cookie.close_write_time = fsp->close_write_time; ndr_err = ndr_push_struct_blob(cookie_blob, mem_ctx, &cookie, (ndr_push_flags_fn_t)ndr_push_vfs_default_durable_cookie); @@ -229,6 +233,10 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, cookie.base_name = fsp->fsp_name->base_name; cookie.initial_allocation_size = fsp->initial_allocation_size; cookie.position_information = fsp->fh->position_information; + cookie.update_write_time_triggered = fsp->update_write_time_triggered; + cookie.update_write_time_on_close = fsp->update_write_time_on_close; + cookie.write_time_forced = fsp->write_time_forced; + cookie.close_write_time = fsp->close_write_time; ndr_err = ndr_push_struct_blob(&new_cookie_blob, mem_ctx, &cookie, (ndr_push_flags_fn_t)ndr_push_vfs_default_durable_cookie); @@ -453,6 +461,10 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, fsp->initial_allocation_size = cookie.initial_allocation_size; fsp->fh->position_information = cookie.position_information; + fsp->update_write_time_triggered = cookie.update_write_time_triggered; + fsp->update_write_time_on_close = cookie.update_write_time_on_close; + fsp->write_time_forced = cookie.write_time_forced; + fsp->close_write_time = cookie.close_write_time; status = fsp_set_smb_fname(fsp, smb_fname); if (!NT_STATUS_IS_OK(status)) { -- 1.7.9.5