From: Stefan Metzmacher Date: Wed, 29 Jun 2022 15:14:22 +0000 (+0200) Subject: s3:vfs_fileid: introduce 'fileid:nolock_paths' X-Git-Tag: tevent-0.13.0~197 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0d9732acd3dff2511f5a9c0a80aba372b6255e2;p=thirdparty%2Fsamba.git s3:vfs_fileid: introduce 'fileid:nolock_paths' 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_fileid.c b/source3/modules/vfs_fileid.c index f9472c275ee..4f7e2371bd1 100644 --- a/source3/modules/vfs_fileid.c +++ b/source3/modules/vfs_fileid.c @@ -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);