vfs_fileid: add fileid:nolockinode parameter
authorRalph Boehme <slow@samba.org>
Thu, 4 Jan 2018 16:09:21 +0000 (17:09 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 5 Jan 2018 23:07:17 +0000 (00:07 +0100)
Based-on-a-patch-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
docs-xml/manpages/vfs_fileid.8.xml
source3/modules/vfs_fileid.c

index 9e8becb6b0c21e44f0df65c81624b9093b993df5..78f054aa0e581e4086f2c14223cec02ca52cb585 100644 (file)
                </listitem>
                </varlistentry>
 
+               <varlistentry>
+               <term>fileid:nolockinode</term>
+               <listitem>
+               <para>This option triggers use of the fileid hostname algorithm
+               for the configured inode which can be used to deliberately break
+               lock coherency for the corresponding file or directory in a
+               cluster.
+               </para>
+               </listitem>
+               </varlistentry>
        </variablelist>
 </refsect1>
 
index 4752bc5528684e884edd2192541fcd195b09da23..bac8ff08731a714574309d19a389113e727fcfda 100644 (file)
@@ -44,6 +44,7 @@ struct fileid_handle_data {
        char **mntdir_allow_list;
        unsigned num_mount_entries;
        struct fileid_mount_entry *mount_entries;
+       ino_t nolockinode;
 };
 
 /* check if a mount entry is allowed based on fstype and mount directory */
@@ -378,6 +379,9 @@ static int fileid_connect(struct vfs_handle_struct *handle,
                }
        }
 
+       data->nolockinode = lp_parm_ulong(SNUM(handle->conn), "fileid",
+                                         "nolockinode", 0);
+
        SMB_VFS_HANDLE_SET_DATA(handle, data, NULL,
                                struct fileid_handle_data,
                                return -1);
@@ -401,6 +405,7 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
 {
        struct fileid_handle_data *data;
        struct file_id id;
+       uint64_t devid;
 
        ZERO_STRUCT(id);
 
@@ -408,8 +413,14 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
                                struct fileid_handle_data,
                                return id);
 
-       id.devid        = data->device_mapping_fn(data, sbuf);
+       if ((data->nolockinode != 0) && (id.inode == data->nolockinode)) {
+               devid = fileid_device_mapping_hostname(data, sbuf);
+       } else {
+               devid = data->device_mapping_fn(data, sbuf);
+       }
+
        id.inode        = sbuf->st_ex_ino;
+       id.devid        = devid;
 
        DBG_DEBUG("Returning dev [%jx] inode [%jx]\n",
                  (uintmax_t)id.devid, (uintmax_t)id.inode);