vfs_fileid: add "fsname_norootdir_ext" option
authorRalph Boehme <slow@samba.org>
Tue, 3 Sep 2019 13:33:42 +0000 (15:33 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 25 Sep 2019 00:48:45 +0000 (00:48 +0000)
This can be used to deliberately break lock coherency between all smbd processes
in the whole cluster for the root directory of a share.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Sep 25 00:48:45 UTC 2019 on sn-devel-184

docs-xml/manpages/vfs_fileid.8.xml
source3/modules/vfs_fileid.c

index 8ab1e30c490f22cb54e8895ac8dd8a63475875c5..defb71229e9cb48ce6469bafaf594079cbd15351 100644 (file)
                algorithm. This can be used to deliberately break lock coherency
                in a cluster for the root directory of a share.
                </para>
+               <para>The <command>fsname_norootdir_ext</command> algorithm
+               generates device ids by hashing the kernel device name, except
+               for the root directory of shares where it will use the hostname
+               algorithm. Additionally it generates an extid based on the
+               process pid. This can be used to deliberately break lock
+               coherency between all smbd processes in the whole cluster for
+               the root directory of a share.
+               </para>
                </listitem>
                </varlistentry>
 
index dca219120692a14e49ab18a7488f725d9f71142f..d7e9090bc18ca8eae79c7911ef131e51afbbe8f9 100644 (file)
@@ -288,6 +288,12 @@ static uint64_t fileid_extid_mapping_zero(struct fileid_handle_data *data,
        return 0;
 }
 
+static uint64_t fileid_extid_mapping_pid(struct fileid_handle_data *data,
+                                        const SMB_STRUCT_STAT *sbuf)
+{
+       return getpid();
+}
+
 static int get_connectpath_ino(struct vfs_handle_struct *handle,
                               ino_t *ino)
 {
@@ -370,6 +376,17 @@ static int fileid_connect(struct vfs_handle_struct *handle,
                data->device_mapping_fn = fileid_device_mapping_fsname;
                data->extid_mapping_fn = fileid_extid_mapping_zero;
 
+               ret = get_connectpath_ino(handle, &data->nolockinode);
+               if (ret != 0) {
+                       saved_errno = errno;
+                       SMB_VFS_NEXT_DISCONNECT(handle);
+                       errno = saved_errno;
+                       return -1;
+               }
+       } else if (strcmp("fsname_norootdir_ext", algorithm) == 0) {
+               data->device_mapping_fn = fileid_device_mapping_fsname;
+               data->extid_mapping_fn = fileid_extid_mapping_pid;
+
                ret = get_connectpath_ino(handle, &data->nolockinode);
                if (ret != 0) {
                        saved_errno = errno;