1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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 <ambi@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2018-01-04 17:02:53 +01:00 committed by Jeremy Allison
parent 495c646ec5
commit b599cb2168
2 changed files with 22 additions and 2 deletions

View File

@ -61,12 +61,18 @@
<term>fileid:algorithm = ALGORITHM</term>
<listitem>
<para>Available algorithms are <command>fsname</command>,
<command>fsid</command> and <command>hostname</command>. The
default value is <command>fsname</command>.
<command>fsname_nodirs</command>, <command>fsid</command> and
<command>hostname</command>. The default value is
<command>fsname</command>.
</para>
<para>The <command>fsname</command> algorithm generates
device id by hashing the kernel device name.
</para>
<para>The <command>fsname_nodirs</command> 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.
</para>
<para>The <command>fsid</command> algorithm generates
the device id from the <command>f_fsid</command> returned
from the <command>statfs()</command> syscall.

View File

@ -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) {