From: Ralph Boehme Date: Thu, 4 Jan 2018 16:02:53 +0000 (+0100) Subject: vfs_fileid: add fileid:algorithm = fsname_nodirs X-Git-Tag: talloc-2.1.11~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b599cb216815415a63504ec69be3f70f08ea58d5;p=thirdparty%2Fsamba.git vfs_fileid: add fileid:algorithm = fsname_nodirs Enabling fileid:algorithm = fsname_nodirs uses the hostname algorithm for directories and thus breaks cluster lock coherence for directories. Based-on-a-patch-by: Christian Ambach Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/docs-xml/manpages/vfs_fileid.8.xml b/docs-xml/manpages/vfs_fileid.8.xml index 6a09f16cf79..9e8becb6b0c 100644 --- a/docs-xml/manpages/vfs_fileid.8.xml +++ b/docs-xml/manpages/vfs_fileid.8.xml @@ -61,12 +61,18 @@ fileid:algorithm = ALGORITHM Available algorithms are fsname, - fsid and hostname. The - default value is fsname. + fsname_nodirs, fsid and + hostname. The default value is + fsname. The fsname algorithm generates device id by hashing the kernel device name. + The fsname_nodirs algorithm generates + device id by hashing the kernel device name for files and by hashing + the hostname for directories. This can be used to deliberately + break lock coherency for directories in a cluster. + The fsid algorithm generates the device id from the f_fsid returned from the statfs() syscall. diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c index 76f08f31a9e..4752bc55286 100644 --- a/source3/modules/vfs_fileid.c +++ b/source3/modules/vfs_fileid.c @@ -238,6 +238,18 @@ static uint64_t fileid_device_mapping_hostname(struct fileid_handle_data *data, return id; } +/* a device mapping using a fsname for files and hostname for dirs */ +static uint64_t fileid_device_mapping_fsname_nodirs( + struct fileid_handle_data *data, + const SMB_STRUCT_STAT *sbuf) +{ + if (S_ISDIR(sbuf->st_ex_mode)) { + return fileid_device_mapping_hostname(data, sbuf); + } + + return fileid_device_mapping_fsname(data, sbuf); +} + /* device mapping functions using a fsid */ static uint64_t fileid_device_mapping_fsid(struct fileid_handle_data *data, const SMB_STRUCT_STAT *sbuf) @@ -302,6 +314,8 @@ static int fileid_connect(struct vfs_handle_struct *handle, algorithm); if (strcmp("fsname", algorithm) == 0) { data->device_mapping_fn = fileid_device_mapping_fsname; + } else if (strcmp("fsname_nodirs", algorithm) == 0) { + data->device_mapping_fn = fileid_device_mapping_fsname_nodirs; } else if (strcmp("fsid", algorithm) == 0) { data->device_mapping_fn = fileid_device_mapping_fsid; } else if (strcmp("hostname", algorithm) == 0) {