From: Ralph Boehme Date: Tue, 3 Sep 2019 13:33:42 +0000 (+0200) Subject: vfs_fileid: add "fsname_norootdir_ext" option X-Git-Tag: talloc-2.3.1~688 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=517ec63004f6708c9e6b29cb33bd789b1936997b;p=thirdparty%2Fsamba.git vfs_fileid: add "fsname_norootdir_ext" option 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 Reviewed-by: Volker Lendecke Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Sep 25 00:48:45 UTC 2019 on sn-devel-184 --- diff --git a/docs-xml/manpages/vfs_fileid.8.xml b/docs-xml/manpages/vfs_fileid.8.xml index 8ab1e30c490..defb71229e9 100644 --- a/docs-xml/manpages/vfs_fileid.8.xml +++ b/docs-xml/manpages/vfs_fileid.8.xml @@ -87,6 +87,14 @@ algorithm. This can be used to deliberately break lock coherency in a cluster for the root directory of a share. + The fsname_norootdir_ext 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. + diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c index dca21912069..d7e9090bc18 100644 --- a/source3/modules/vfs_fileid.c +++ b/source3/modules/vfs_fileid.c @@ -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;