s3:vfs_fileid: also handle 'fsname_nodirs' via fileid_is_nolock_inode()
authorStefan Metzmacher <metze@samba.org>
Wed, 29 Jun 2022 15:02:32 +0000 (17:02 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Jul 2022 15:09:35 +0000 (15:09 +0000)
This means we'll be able to provide the 'nolock' feature for all
directories also with other algorithms than 'fsname' in future.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_fileid.c

index ff1432c8457cd16c6138c55df17b797069857415..c491320c253ed8860faf2d6defdff9f1975d779c 100644 (file)
@@ -51,6 +51,7 @@ struct fileid_handle_data {
        unsigned num_mount_entries;
        struct fileid_mount_entry *mount_entries;
        struct {
+               bool force_all_dirs;
                uint64_t extid;
                size_t num_inodes;
                struct fileid_nolock_inode *inodes;
@@ -276,6 +277,10 @@ static bool fileid_is_nolock_inode(struct fileid_handle_data *data,
 {
        size_t i;
 
+       if (S_ISDIR(sbuf->st_ex_mode) && data->nolock.force_all_dirs) {
+               return true;
+       }
+
        /*
         * We could make this a binary search over an sorted array,
         * but for now we keep things simple.
@@ -356,18 +361,6 @@ static uint64_t fileid_mapping_nolock_extid(uint64_t max_slots)
        return id;
 }
 
-/* a device mapping using a fsname for files and hostname for dirs */
-static struct file_id fileid_mapping_fsname_nodirs(
-       struct fileid_handle_data *data,
-       const SMB_STRUCT_STAT *sbuf)
-{
-       if (S_ISDIR(sbuf->st_ex_mode)) {
-               return fileid_mapping_hostname(data, sbuf);
-       }
-
-       return fileid_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)
@@ -503,7 +496,8 @@ static int fileid_connect(struct vfs_handle_struct *handle,
        if (strcmp("fsname", algorithm) == 0) {
                data->mapping_fn = fileid_mapping_fsname;
        } else if (strcmp("fsname_nodirs", algorithm) == 0) {
-               data->mapping_fn = fileid_mapping_fsname_nodirs;
+               data->mapping_fn = fileid_mapping_fsname;
+               data->nolock.force_all_dirs = true;
        } else if (strcmp("fsid", algorithm) == 0) {
                data->mapping_fn = fileid_mapping_fsid;
        } else if (strcmp("hostname", algorithm) == 0) {