]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: trigger notification for file and directory creation will be sent a wee bit...
authorRalph Boehme <slow@samba.org>
Mon, 9 Sep 2024 19:27:45 +0000 (21:27 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
This will be a common pattern in the upcoming code dealing with Directory Lease
breaks: when checking for Directory Lease breaks on the parent directory, we
take the sharemode lock on the parent and hence by then must have dropped the
sharemode lock on the object that performs the Directory Lease break check. That
functionality will be later added to notify_fname().

This means the notification will be sent a wee bit later, but that's something
the change notification protocol has to live with anyway.

For Directory Leases the sequence to check for Directory Lease breaks is to call
MS-FSA 2.1.4.12 "Algorithm to Check for an Oplock Break" with
flags=PARENT_OBJECT at the end of each relevant operation, eg creating a file
asf, when processing of the operation that will call 2.1.4.12 is already
completed.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/open.c

index 17618749a92785a95dd71c499aaf11025beb576a..16276caf4480a46388b3917039bd1e535893d54c 100644 (file)
@@ -1508,10 +1508,6 @@ static NTSTATUS open_file(
                                        return status;
                                }
                        }
-
-                       notify_fname(conn, NOTIFY_ACTION_ADDED,
-                                    FILE_NOTIFY_CHANGE_FILE_NAME,
-                                    smb_fname->base_name);
                }
        } else {
                if (!file_existed) {
@@ -4652,6 +4648,13 @@ unlock:
                smb_panic("share_mode_entry_prepare_unlock() failed!");
        }
 
+       if (info == FILE_WAS_CREATED) {
+               notify_fname(conn,
+                            NOTIFY_ACTION_ADDED,
+                            FILE_NOTIFY_CHANGE_FILE_NAME,
+                            smb_fname->base_name);
+       }
+
        if (!NT_STATUS_IS_OK(status)) {
                fd_close(fsp);
                return status;
@@ -5092,9 +5095,6 @@ done:
        DBG_DEBUG("Created directory '%s'\n",
                  smb_fname_str_dbg(smb_dname));
 
-       notify_fname(conn, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME,
-                    smb_dname->base_name);
-
        TALLOC_FREE(frame);
        return NT_STATUS_OK;
 
@@ -5521,6 +5521,13 @@ unlock:
                smb_panic("share_mode_entry_prepare_unlock() failed!");
        }
 
+       if (info == FILE_WAS_CREATED) {
+               notify_fname(conn,
+                            NOTIFY_ACTION_ADDED,
+                            FILE_NOTIFY_CHANGE_DIR_NAME,
+                            smb_dname->base_name);
+       }
+
        if (!NT_STATUS_IS_OK(status)) {
                fd_close(fsp);
                return status;