]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:vfs_fileid: introduce 'fileid:nolock_paths'
authorStefan Metzmacher <metze@samba.org>
Wed, 29 Jun 2022 15:14:22 +0000 (17:14 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Jul 2022 15:09:35 +0000 (15:09 +0000)
This brings much more flexibility compared to:
- 'fsname_norootdir', 'fsname_norootdir_ext',
  which only allow the nolock behavior for the share root
- 'fileid:nolockinode', which only gets a single inode number,
  and ignores the devide id completely.

You can specify path names, which are relative to the shareroot
or absolute.

These names are only evaluated at SMB_VFS_CONNECT() time,
where they are converted into devide and inode pairs.
It means they are completely ignored if the path doesn't
exist yet, or is replaced by a new inode later.

This allows:

- 'fileid:algorithm = fsname_norootdir'
  to be replaced by:
  'fileid:algorithm = fsname' (the default)
  'fileid:nolock_paths = .'

- 'fileid:algorithm = fsname_norootdir_ext'
  to be replaced by:
  'fileid:algorithm = fsname' (the default)
  'fileid:nolock_paths = .'
  'fileid:nolock_max_slots = 18446744073709551615'

And 'fileid:nolockinode = 1234567' and be replaced by
'fileid:nolock_paths = Very/Contended/Path' or
'fileid:nolock_paths = . Very/Contended/Path1 /data/conteded.dir',
if the share root and two additional inodes should be handled
by the 'nolock' behavior.

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

index f9472c275ee2a587c448b3ec8d248140f2899a8d..4f7e2371bd1daef55fb1320f6f6a3c2a70f465c9 100644 (file)
@@ -471,6 +471,8 @@ static int fileid_connect(struct vfs_handle_struct *handle,
        ino_t nolockinode;
        uint64_t max_slots = 0;
        bool rootdir_nolock = false;
+       const char **nolock_paths = NULL;
+       size_t i;
        int saved_errno;
        int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
 
@@ -615,6 +617,34 @@ static int fileid_connect(struct vfs_handle_struct *handle,
                }
        }
 
+       nolock_paths = lp_parm_string_list(SNUM(handle->conn), "fileid", "nolock_paths", NULL);
+       for (i = 0; nolock_paths != NULL && nolock_paths[i] != NULL; i++) {
+               SMB_STRUCT_STAT tmpsbuf;
+
+               ret = get_connectpath_ino(handle, nolock_paths[i], &tmpsbuf);
+               if (ret == -1 && errno == ENOENT) {
+                       DBG_ERR("ignoring non existing nolock_paths[%zu]='%s'\n",
+                               i, nolock_paths[i]);
+                       continue;
+               }
+               if (ret != 0) {
+                       saved_errno = errno;
+                       SMB_VFS_NEXT_DISCONNECT(handle);
+                       errno = saved_errno;
+                       return -1;
+               }
+
+               ret = fileid_add_nolock_inode(data, &tmpsbuf);
+               if (ret != 0) {
+                       saved_errno = errno;
+                       SMB_VFS_NEXT_DISCONNECT(handle);
+                       errno = saved_errno;
+                       return -1;
+               }
+               DBG_DEBUG("Adding nolock_paths[%zu]='%s'\n",
+                         i, nolock_paths[i]);
+       }
+
        SMB_VFS_HANDLE_SET_DATA(handle, data, NULL,
                                struct fileid_handle_data,
                                return -1);