The Samba-Bugzilla – Attachment 18417 Details for
Bug 15686
Add new vfs_ceph module (based on low level API)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch from master for v4-20-test (part 2)
tmp.patch (text/plain), 35.00 KB, created by
Anoop C S
on 2024-08-21 10:49:04 UTC
(
hide
)
Description:
patch from master for v4-20-test (part 2)
Filename:
MIME Type:
Creator:
Anoop C S
Created:
2024-08-21 10:49:04 UTC
Size:
35.00 KB
patch
obsolete
>From 23720c1b11bdf046fa6b382fe37983bada652b0a Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Sun, 26 May 2024 16:24:06 +0300 >Subject: [PATCH 1/5] vfs_ceph: align lines-length with coding standard > >Coding standard requires following Linux kernel style guide, with an >explicit statement that "Maximum Line Width is 80 Characters". Align >vfs_ceph.c with this convention: split long lines into multiple lines >and use 'git clang-format' to do auto-formatting based on Samba project >'.clang-format' settings. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> >Reviewed-by: Anoop C S <anoopcs@samba.org> >(cherry picked from commit b7e3f93ef0f17a5c85385f2e5a333fcf965766b5) >--- > source3/modules/vfs_ceph.c | 190 ++++++++++++++++++++++++++----------- > 1 file changed, 136 insertions(+), 54 deletions(-) > >diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c >index c9ee5414f03..0d7637b8251 100644 >--- a/source3/modules/vfs_ceph.c >+++ b/source3/modules/vfs_ceph.c >@@ -49,7 +49,8 @@ > #endif > > /* >- * Use %llu whenever we have a 64bit unsigned int, and cast to (long long unsigned) >+ * Use %llu whenever we have a 64bit unsigned int, and cast to (long long >+ * unsigned) > */ > #define llu(_var) ((long long unsigned)_var) > >@@ -221,8 +222,8 @@ static struct ceph_mount_info *cephmount_mount_fs(const int snum) > } > /* > * select a cephfs file system to use: >- * In ceph, multiple file system support has been stable since 'pacific'. >- * Permit different shares to access different file systems. >+ * In ceph, multiple file system support has been stable since >+ * 'pacific'. Permit different shares to access different file systems. > */ > if (fsname != NULL) { > ret = cephmount_select_fs(mnt, fsname); >@@ -373,7 +374,10 @@ static int cephwrap_get_quota(struct vfs_handle_struct *handle, > #endif > } > >-static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt) >+static int cephwrap_set_quota(struct vfs_handle_struct *handle, >+ enum SMB_QUOTA_TYPE qtype, >+ unid_t id, >+ SMB_DISK_QUOTA *qt) > { > /* libcephfs: Ceph does not implement this */ > #if 0 >@@ -412,15 +416,19 @@ static int cephwrap_statvfs(struct vfs_handle_struct *handle, > statbuf->TotalFileNodes = statvfs_buf.f_files; > statbuf->FreeFileNodes = statvfs_buf.f_ffree; > statbuf->FsIdentifier = statvfs_buf.f_fsid; >- DBG_DEBUG("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, f_bavail: %ld\n", >- (long int)statvfs_buf.f_bsize, (long int)statvfs_buf.f_blocks, >- (long int)statvfs_buf.f_bfree, (long int)statvfs_buf.f_bavail); >+ DBG_DEBUG("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, " >+ "f_bavail: %ld\n", >+ (long int)statvfs_buf.f_bsize, >+ (long int)statvfs_buf.f_blocks, >+ (long int)statvfs_buf.f_bfree, >+ (long int)statvfs_buf.f_bavail); > > return ret; > } > >-static uint32_t cephwrap_fs_capabilities(struct vfs_handle_struct *handle, >- enum timestamp_set_resolution *p_ts_res) >+static uint32_t cephwrap_fs_capabilities( >+ struct vfs_handle_struct *handle, >+ enum timestamp_set_resolution *p_ts_res) > { > uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; > >@@ -618,12 +626,20 @@ static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp) > WRAP_RETURN(result); > } > >-static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fsp, void *data, >- size_t n, off_t offset) >+static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ void *data, >+ size_t n, >+ off_t offset) > { > ssize_t result; > >- DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)); >+ DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", >+ handle, >+ fsp, >+ data, >+ llu(n), >+ llu(offset)); > > result = ceph_read(handle->data, fsp_get_io_fd(fsp), data, n, offset); > DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result)); >@@ -682,12 +698,20 @@ static ssize_t cephwrap_pread_recv(struct tevent_req *req, > return state->bytes_read; > } > >-static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *fsp, const void *data, >- size_t n, off_t offset) >+static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ const void *data, >+ size_t n, >+ off_t offset) > { > ssize_t result; > >- DBG_DEBUG("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)); >+ DBG_DEBUG("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", >+ handle, >+ fsp, >+ data, >+ llu(n), >+ llu(offset)); > result = ceph_write(handle->data, fsp_get_io_fd(fsp), data, n, offset); > DBG_DEBUG("[CEPH] pwrite(...) = %llu\n", llu(result)); > WRAP_RETURN(result); >@@ -745,7 +769,10 @@ static ssize_t cephwrap_pwrite_recv(struct tevent_req *req, > return state->bytes_written; > } > >-static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence) >+static off_t cephwrap_lseek(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ off_t offset, >+ int whence) > { > off_t result = 0; > >@@ -754,8 +781,12 @@ static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp, > WRAP_RETURN(result); > } > >-static ssize_t cephwrap_sendfile(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, >- off_t offset, size_t n) >+static ssize_t cephwrap_sendfile(struct vfs_handle_struct *handle, >+ int tofd, >+ files_struct *fromfsp, >+ const DATA_BLOB *hdr, >+ off_t offset, >+ size_t n) > { > /* > * We cannot support sendfile because libcephfs is in user space. >@@ -873,7 +904,8 @@ static int cephwrap_fsync_recv(struct tevent_req *req, > > #define SAMBA_STATX_ATTR_MASK (CEPH_STATX_BASIC_STATS|CEPH_STATX_BTIME) > >-static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct ceph_statx *stx) >+static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, >+ const struct ceph_statx *stx) > { > DBG_DEBUG("[CEPH]\tstx = {dev = %llx, ino = %llu, mode = 0x%x, " > "nlink = %llu, uid = %d, gid = %d, rdev = %llx, size = %llu, " >@@ -887,8 +919,11 @@ static void init_stat_ex_from_ceph_statx(struct stat_ex *dst, const struct ceph_ > llu(stx->stx_btime.tv_sec)); > > if ((stx->stx_mask & SAMBA_STATX_ATTR_MASK) != SAMBA_STATX_ATTR_MASK) { >- DBG_WARNING("%s: stx->stx_mask is incorrect (wanted %x, got %x)\n", >- __func__, SAMBA_STATX_ATTR_MASK, stx->stx_mask); >+ DBG_WARNING("%s: stx->stx_mask is incorrect " >+ "(wanted %x, got %x)\n", >+ __func__, >+ SAMBA_STATX_ATTR_MASK, >+ stx->stx_mask); > } > > dst->st_ex_dev = stx->stx_dev; >@@ -913,7 +948,9 @@ static int cephwrap_stat(struct vfs_handle_struct *handle, > int result = -1; > struct ceph_statx stx = { 0 }; > >- DBG_DEBUG("[CEPH] stat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)); >+ DBG_DEBUG("[CEPH] stat(%p, %s)\n", >+ handle, >+ smb_fname_str_dbg(smb_fname)); > > if (smb_fname->stream_name) { > errno = ENOENT; >@@ -932,7 +969,9 @@ static int cephwrap_stat(struct vfs_handle_struct *handle, > return result; > } > >-static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf) >+static int cephwrap_fstat(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ SMB_STRUCT_STAT *sbuf) > { > int result = -1; > struct ceph_statx stx = { 0 }; >@@ -1002,7 +1041,9 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle, > int result = -1; > struct ceph_statx stx = { 0 }; > >- DBG_DEBUG("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)); >+ DBG_DEBUG("[CEPH] lstat(%p, %s)\n", >+ handle, >+ smb_fname_str_dbg(smb_fname)); > > if (smb_fname->stream_name) { > errno = ENOENT; >@@ -1126,7 +1167,9 @@ static int cephwrap_unlinkat(struct vfs_handle_struct *handle, > #endif > } > >-static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp, mode_t mode) >+static int cephwrap_fchmod(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ mode_t mode) > { > int result; > >@@ -1148,7 +1191,10 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp, > WRAP_RETURN(result); > } > >-static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid) >+static int cephwrap_fchown(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ uid_t uid, >+ gid_t gid) > { > int result; > >@@ -1181,7 +1227,11 @@ static int cephwrap_lchown(struct vfs_handle_struct *handle, > gid_t gid) > { > int result; >- DBG_DEBUG("[CEPH] lchown(%p, %s, %d, %d)\n", handle, smb_fname->base_name, uid, gid); >+ DBG_DEBUG("[CEPH] lchown(%p, %s, %d, %d)\n", >+ handle, >+ smb_fname->base_name, >+ uid, >+ gid); > result = ceph_lchown(handle->data, smb_fname->base_name, uid, gid); > DBG_DEBUG("[CEPH] lchown(...) = %d\n", result); > WRAP_RETURN(result); >@@ -1202,15 +1252,12 @@ static struct smb_filename *cephwrap_getwd(struct vfs_handle_struct *handle, > { > const char *cwd = ceph_getcwd(handle->data); > DBG_DEBUG("[CEPH] getwd(%p) = %s\n", handle, cwd); >- return synthetic_smb_fname(ctx, >- cwd, >- NULL, >- NULL, >- 0, >- 0); >+ return synthetic_smb_fname(ctx, cwd, NULL, NULL, 0, 0); > } > >-static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len) >+static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ off_t len) > { > off_t space_to_write; > int result; >@@ -1238,12 +1285,17 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str > } > > space_to_write = len - pst->st_ex_size; >- result = ceph_fallocate(handle->data, fsp_get_io_fd(fsp), 0, pst->st_ex_size, >+ result = ceph_fallocate(handle->data, >+ fsp_get_io_fd(fsp), >+ 0, >+ pst->st_ex_size, > space_to_write); > WRAP_RETURN(result); > } > >-static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len) >+static int cephwrap_ftruncate(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ off_t len) > { > int result = -1; > >@@ -1268,12 +1320,18 @@ static int cephwrap_fallocate(struct vfs_handle_struct *handle, > DBG_DEBUG("[CEPH] fallocate(%p, %p, %u, %llu, %llu\n", > handle, fsp, mode, llu(offset), llu(len)); > /* unsupported mode flags are rejected by libcephfs */ >- result = ceph_fallocate(handle->data, fsp_get_io_fd(fsp), mode, offset, len); >+ result = ceph_fallocate( >+ handle->data, fsp_get_io_fd(fsp), mode, offset, len); > DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result); > WRAP_RETURN(result); > } > >-static bool cephwrap_lock(struct vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type) >+static bool cephwrap_lock(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ int op, >+ off_t offset, >+ off_t count, >+ int type) > { > DBG_DEBUG("[CEPH] lock\n"); > return true; >@@ -1319,7 +1377,12 @@ err_out: > return -1; > } > >-static bool cephwrap_getlock(struct vfs_handle_struct *handle, files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid) >+static bool cephwrap_getlock(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ off_t *poffset, >+ off_t *pcount, >+ int *ptype, >+ pid_t *ppid) > { > DBG_DEBUG("[CEPH] getlock returning false and errno=0\n"); > >@@ -1332,8 +1395,9 @@ static bool cephwrap_getlock(struct vfs_handle_struct *handle, files_struct *fsp > * be accessible from libcephfs (which is a user-space client) but the fd might > * be for some file the kernel knows about. > */ >-static int cephwrap_linux_setlease(struct vfs_handle_struct *handle, files_struct *fsp, >- int leasetype) >+static int cephwrap_linux_setlease(struct vfs_handle_struct *handle, >+ files_struct *fsp, >+ int leasetype) > { > int result = -1; > >@@ -1424,7 +1488,10 @@ static int cephwrap_readlinkat(struct vfs_handle_struct *handle, > DBG_DEBUG("[CEPH] readlink(%p, %s, %p, %llu)\n", handle, > full_fname->base_name, buf, llu(bufsiz)); > >- result = ceph_readlink(handle->data, full_fname->base_name, buf, bufsiz); >+ result = ceph_readlink(handle->data, >+ full_fname->base_name, >+ buf, >+ bufsiz); > TALLOC_FREE(full_fname); > DBG_DEBUG("[CEPH] readlink(...) = %d\n", result); > WRAP_RETURN(result); >@@ -1528,12 +1595,7 @@ static struct smb_filename *cephwrap_realpath(struct vfs_handle_struct *handle, > } > > DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle, path, result); >- result_fname = synthetic_smb_fname(ctx, >- result, >- NULL, >- NULL, >- 0, >- 0); >+ result_fname = synthetic_smb_fname(ctx, result, NULL, NULL, 0, 0); > SAFE_FREE(result); > return result_fname; > } >@@ -1606,7 +1668,10 @@ static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, > return (ssize_t)ret; > } > >-static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size) >+static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, >+ struct files_struct *fsp, >+ char *list, >+ size_t size) > { > int ret; > DBG_DEBUG("[CEPH] flistxattr(%p, %p, %p, %llu)\n", >@@ -1635,7 +1700,9 @@ static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct file > return (ssize_t)ret; > } > >-static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name) >+static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, >+ struct files_struct *fsp, >+ const char *name) > { > int ret; > DBG_DEBUG("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name); >@@ -1656,10 +1723,21 @@ static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_ > WRAP_RETURN(ret); > } > >-static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags) >+static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, >+ struct files_struct *fsp, >+ const char *name, >+ const void *value, >+ size_t size, >+ int flags) > { > int ret; >- DBG_DEBUG("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags); >+ DBG_DEBUG("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", >+ handle, >+ fsp, >+ name, >+ value, >+ llu(size), >+ flags); > if (!fsp->fsp_flags.is_pathref) { > /* > * We can use an io_fd to set xattrs. >@@ -1685,14 +1763,18 @@ static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_str > WRAP_RETURN(ret); > } > >-static bool cephwrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp) >+static bool cephwrap_aio_force(struct vfs_handle_struct *handle, >+ struct files_struct *fsp) > { > > /* > * We do not support AIO yet. > */ > >- DBG_DEBUG("[CEPH] cephwrap_aio_force(%p, %p) = false (errno = ENOTSUP)\n", handle, fsp); >+ DBG_DEBUG("[CEPH] cephwrap_aio_force(%p, %p) = false " >+ "(errno = ENOTSUP)\n", >+ handle, >+ fsp); > errno = ENOTSUP; > return false; > } >-- >2.46.0 > > >From 1c81098b01ce48509a7fad5109656d31783533a8 Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Wed, 22 May 2024 16:11:57 +0300 >Subject: [PATCH 2/5] vfs_ceph: re-map unimplemented hooks > >Code cleanup: prefer standard convenience helpers for unimplemented >VFS hooks. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> >Reviewed-by: Anoop C S <anoopcs@samba.org> >(cherry picked from commit ee72f127c34f27ca496243631b2e7141de2bd59d) >--- > source3/modules/vfs_ceph.c | 104 ++++--------------------------------- > 1 file changed, 9 insertions(+), 95 deletions(-) > >diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c >index 0d7637b8251..813e51e5dce 100644 >--- a/source3/modules/vfs_ceph.c >+++ b/source3/modules/vfs_ceph.c >@@ -349,53 +349,6 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, > } > } > >-static int cephwrap_get_quota(struct vfs_handle_struct *handle, >- const struct smb_filename *smb_fname, >- enum SMB_QUOTA_TYPE qtype, >- unid_t id, >- SMB_DISK_QUOTA *qt) >-{ >- /* libcephfs: Ceph does not implement this */ >-#if 0 >-/* was ifdef HAVE_SYS_QUOTAS */ >- int ret; >- >- ret = ceph_get_quota(handle->conn->connectpath, qtype, id, qt); >- >- if (ret) { >- errno = -ret; >- ret = -1; >- } >- >- return ret; >-#else >- errno = ENOSYS; >- return -1; >-#endif >-} >- >-static int cephwrap_set_quota(struct vfs_handle_struct *handle, >- enum SMB_QUOTA_TYPE qtype, >- unid_t id, >- SMB_DISK_QUOTA *qt) >-{ >- /* libcephfs: Ceph does not implement this */ >-#if 0 >-/* was ifdef HAVE_SYS_QUOTAS */ >- int ret; >- >- ret = ceph_set_quota(handle->conn->connectpath, qtype, id, qt); >- if (ret) { >- errno = -ret; >- ret = -1; >- } >- >- return ret; >-#else >- WRAP_RETURN(-ENOSYS); >-#endif >-} >- > static int cephwrap_statvfs(struct vfs_handle_struct *handle, > const struct smb_filename *smb_fname, > struct vfs_statvfs_struct *statbuf) >@@ -1345,8 +1298,10 @@ static int cephwrap_filesystem_sharemode(struct vfs_handle_struct *handle, > DBG_ERR("[CEPH] filesystem sharemodes unsupported! Consider setting " > "\"kernel share modes = no\"\n"); > >- errno = ENOSYS; >- return -1; >+ return vfs_not_implemented_filesystem_sharemode(handle, >+ fsp, >+ share_access, >+ access_mask); > } > > static int cephwrap_fcntl(vfs_handle_struct *handle, >@@ -1390,22 +1345,6 @@ static bool cephwrap_getlock(struct vfs_handle_struct *handle, > return false; > } > >-/* >- * We cannot let this fall through to the default, because the file might only >- * be accessible from libcephfs (which is a user-space client) but the fd might >- * be for some file the kernel knows about. >- */ >-static int cephwrap_linux_setlease(struct vfs_handle_struct *handle, >- files_struct *fsp, >- int leasetype) >-{ >- int result = -1; >- >- DBG_DEBUG("[CEPH] linux_setlease\n"); >- errno = ENOSYS; >- return result; >-} >- > static int cephwrap_symlinkat(struct vfs_handle_struct *handle, > const struct smb_filename *link_target, > struct files_struct *dirfsp, >@@ -1600,15 +1539,6 @@ static struct smb_filename *cephwrap_realpath(struct vfs_handle_struct *handle, > return result_fname; > } > >- >-static int cephwrap_fchflags(struct vfs_handle_struct *handle, >- struct files_struct *fsp, >- unsigned int flags) >-{ >- errno = ENOSYS; >- return -1; >-} >- > static NTSTATUS cephwrap_get_real_filename_at( > struct vfs_handle_struct *handle, > struct files_struct *dirfsp, >@@ -1763,22 +1693,6 @@ static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, > WRAP_RETURN(ret); > } > >-static bool cephwrap_aio_force(struct vfs_handle_struct *handle, >- struct files_struct *fsp) >-{ >- >- /* >- * We do not support AIO yet. >- */ >- >- DBG_DEBUG("[CEPH] cephwrap_aio_force(%p, %p) = false " >- "(errno = ENOTSUP)\n", >- handle, >- fsp); >- errno = ENOTSUP; >- return false; >-} >- > static NTSTATUS cephwrap_create_dfs_pathat(struct vfs_handle_struct *handle, > struct files_struct *dirfsp, > const struct smb_filename *smb_fname, >@@ -1958,8 +1872,8 @@ static struct vfs_fn_pointers ceph_fns = { > .connect_fn = cephwrap_connect, > .disconnect_fn = cephwrap_disconnect, > .disk_free_fn = cephwrap_disk_free, >- .get_quota_fn = cephwrap_get_quota, >- .set_quota_fn = cephwrap_set_quota, >+ .get_quota_fn = vfs_not_implemented_get_quota, >+ .set_quota_fn = vfs_not_implemented_set_quota, > .statvfs_fn = cephwrap_statvfs, > .fs_capabilities_fn = cephwrap_fs_capabilities, > >@@ -2005,14 +1919,14 @@ static struct vfs_fn_pointers ceph_fns = { > .lock_fn = cephwrap_lock, > .filesystem_sharemode_fn = cephwrap_filesystem_sharemode, > .fcntl_fn = cephwrap_fcntl, >- .linux_setlease_fn = cephwrap_linux_setlease, >+ .linux_setlease_fn = vfs_not_implemented_linux_setlease, > .getlock_fn = cephwrap_getlock, > .symlinkat_fn = cephwrap_symlinkat, > .readlinkat_fn = cephwrap_readlinkat, > .linkat_fn = cephwrap_linkat, > .mknodat_fn = cephwrap_mknodat, > .realpath_fn = cephwrap_realpath, >- .fchflags_fn = cephwrap_fchflags, >+ .fchflags_fn = vfs_not_implemented_fchflags, > .get_real_filename_at_fn = cephwrap_get_real_filename_at, > .connectpath_fn = cephwrap_connectpath, > >@@ -2031,7 +1945,7 @@ static struct vfs_fn_pointers ceph_fns = { > .sys_acl_delete_def_fd_fn = posixacl_xattr_acl_delete_def_fd, > > /* aio operations */ >- .aio_force_fn = cephwrap_aio_force, >+ .aio_force_fn = vfs_not_implemented_aio_force, > }; > > static_decl_vfs; >-- >2.46.0 > > >From 1974fa41a567411db1d3065a9b636e078185044e Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Thu, 23 May 2024 17:15:40 +0300 >Subject: [PATCH 3/5] vfs_ceph: replace WRAP_RETURN macro with convenience > helpers > >The WRAP_RETURN is a non-hygienic macro, and as such has the potential >of creating bogus code (e.g. 'return WRAP_RETURN(ret);' which existed >in the code in the past but did not yield any compiler warning). Prefer >simple convenience helper functions instead, which are also type safe. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> >Reviewed-by: Anoop C S <anoopcs@samba.org> >(cherry picked from commit 691a397b2707f2924e3f6910c9c574e01d811a97) >--- > source3/modules/vfs_ceph.c | 109 ++++++++++++++++++++----------------- > 1 file changed, 58 insertions(+), 51 deletions(-) > >diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c >index 813e51e5dce..73c9a55fc6f 100644 >--- a/source3/modules/vfs_ceph.c >+++ b/source3/modules/vfs_ceph.c >@@ -55,16 +55,30 @@ > #define llu(_var) ((long long unsigned)_var) > > /* >- * Note, libcephfs's return code model is to return -errno! So we have to >- * convert to what Samba expects, which is to set errno to -return and return -1 >+ * Note, libcephfs's return code model is to return -errno. Thus we have to >+ * convert to what Samba expects: set errno to non-negative value and return -1. >+ * >+ * Using convenience helper functions to avoid non-hygienic macro. > */ >-#define WRAP_RETURN(_res) \ >- errno = 0; \ >- if (_res < 0) { \ >- errno = -_res; \ >- return -1; \ >- } \ >- return _res \ >+static inline int status_code(int ret) >+{ >+ if (ret < 0) { >+ errno = -ret; >+ return -1; >+ } >+ errno = 0; >+ return ret; >+} >+ >+static inline ssize_t lstatus_code(intmax_t ret) >+{ >+ if (ret < 0) { >+ errno = -((int)ret); >+ return -1; >+ } >+ errno = 0; >+ return (ssize_t)ret; >+} > > /* > * Track unique connections, as virtual mounts, to cephfs file systems. >@@ -345,7 +359,7 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, > return *dfree; > } else { > DBG_DEBUG("[CEPH] ceph_statfs returned %d\n", ret); >- WRAP_RETURN(ret); >+ return status_code(ret); > } > } > >@@ -358,7 +372,7 @@ static int cephwrap_statvfs(struct vfs_handle_struct *handle, > > ret = ceph_statfs(handle->data, smb_fname->base_name, &statvfs_buf); > if (ret < 0) { >- WRAP_RETURN(ret); >+ return status_code(ret); > } > > statbuf->OptimalTransferSize = statvfs_buf.f_frsize; >@@ -454,7 +468,7 @@ static int cephwrap_mkdirat(struct vfs_handle_struct *handle, > > DBG_DEBUG("[CEPH] mkdirat(...) = %d\n", result); > >- WRAP_RETURN(result); >+ return status_code(result); > #else > struct smb_filename *full_fname = NULL; > >@@ -472,7 +486,7 @@ static int cephwrap_mkdirat(struct vfs_handle_struct *handle, > > TALLOC_FREE(full_fname); > >- WRAP_RETURN(result); >+ return status_code(result); > #endif > } > >@@ -483,7 +497,7 @@ static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp) > DBG_DEBUG("[CEPH] closedir(%p, %p)\n", handle, dirp); > result = ceph_closedir(handle->data, (struct ceph_dir_result *) dirp); > DBG_DEBUG("[CEPH] closedir(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > /* File operations */ >@@ -565,7 +579,7 @@ out: > TALLOC_FREE(name); > fsp->fsp_flags.have_proc_fds = false; > DBG_DEBUG("[CEPH] open(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp) >@@ -575,8 +589,7 @@ static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp) > DBG_DEBUG("[CEPH] close(%p, %p)\n", handle, fsp); > result = ceph_close(handle->data, fsp_get_pathref_fd(fsp)); > DBG_DEBUG("[CEPH] close(...) = %d\n", result); >- >- WRAP_RETURN(result); >+ return status_code(result); > } > > static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, >@@ -596,7 +609,7 @@ static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, > > result = ceph_read(handle->data, fsp_get_io_fd(fsp), data, n, offset); > DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result)); >- WRAP_RETURN(result); >+ return lstatus_code(result); > } > > struct cephwrap_pread_state { >@@ -667,7 +680,7 @@ static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, > llu(offset)); > result = ceph_write(handle->data, fsp_get_io_fd(fsp), data, n, offset); > DBG_DEBUG("[CEPH] pwrite(...) = %llu\n", llu(result)); >- WRAP_RETURN(result); >+ return lstatus_code(result); > } > > struct cephwrap_pwrite_state { >@@ -731,7 +744,7 @@ static off_t cephwrap_lseek(struct vfs_handle_struct *handle, > > DBG_DEBUG("[CEPH] cephwrap_lseek\n"); > result = ceph_lseek(handle->data, fsp_get_io_fd(fsp), offset, whence); >- WRAP_RETURN(result); >+ return lstatus_code(result); > } > > static ssize_t cephwrap_sendfile(struct vfs_handle_struct *handle, >@@ -802,7 +815,7 @@ static int cephwrap_renameat(struct vfs_handle_struct *handle, > TALLOC_FREE(full_fname_src); > TALLOC_FREE(full_fname_dst); > >- WRAP_RETURN(result); >+ return status_code(result); > } > > /* >@@ -914,7 +927,7 @@ static int cephwrap_stat(struct vfs_handle_struct *handle, > SAMBA_STATX_ATTR_MASK, 0); > DBG_DEBUG("[CEPH] statx(...) = %d\n", result); > if (result < 0) { >- WRAP_RETURN(result); >+ return status_code(result); > } > > init_stat_ex_from_ceph_statx(&smb_fname->st, &stx); >@@ -935,7 +948,7 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, > SAMBA_STATX_ATTR_MASK, 0); > DBG_DEBUG("[CEPH] fstat(...) = %d\n", result); > if (result < 0) { >- WRAP_RETURN(result); >+ return status_code(result); > } > > init_stat_ex_from_ceph_statx(sbuf, &stx); >@@ -979,7 +992,7 @@ static int cephwrap_fstatat(struct vfs_handle_struct *handle, > > DBG_DEBUG("[CEPH] fstatat(...) = %d\n", result); > if (result < 0) { >- WRAP_RETURN(result); >+ return status_code(result); > } > > init_stat_ex_from_ceph_statx(sbuf, &stx); >@@ -1007,7 +1020,7 @@ static int cephwrap_lstat(struct vfs_handle_struct *handle, > SAMBA_STATX_ATTR_MASK, AT_SYMLINK_NOFOLLOW); > DBG_DEBUG("[CEPH] lstat(...) = %d\n", result); > if (result < 0) { >- WRAP_RETURN(result); >+ return status_code(result); > } > > init_stat_ex_from_ceph_statx(&smb_fname->st, &stx); >@@ -1089,7 +1102,7 @@ static int cephwrap_unlinkat(struct vfs_handle_struct *handle, > smb_fname->base_name, > flags); > DBG_DEBUG("[CEPH] unlinkat(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #else > struct smb_filename *full_fname = NULL; > >@@ -1116,7 +1129,7 @@ static int cephwrap_unlinkat(struct vfs_handle_struct *handle, > } > TALLOC_FREE(full_fname); > DBG_DEBUG("[CEPH] unlink(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #endif > } > >@@ -1141,7 +1154,7 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, > mode); > } > DBG_DEBUG("[CEPH] fchmod(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_fchown(struct vfs_handle_struct *handle, >@@ -1171,7 +1184,7 @@ static int cephwrap_fchown(struct vfs_handle_struct *handle, > } > > DBG_DEBUG("[CEPH] fchown(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_lchown(struct vfs_handle_struct *handle, >@@ -1187,7 +1200,7 @@ static int cephwrap_lchown(struct vfs_handle_struct *handle, > gid); > result = ceph_lchown(handle->data, smb_fname->base_name, uid, gid); > DBG_DEBUG("[CEPH] lchown(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_chdir(struct vfs_handle_struct *handle, >@@ -1197,7 +1210,7 @@ static int cephwrap_chdir(struct vfs_handle_struct *handle, > DBG_DEBUG("[CEPH] chdir(%p, %s)\n", handle, smb_fname->base_name); > result = ceph_chdir(handle->data, smb_fname->base_name); > DBG_DEBUG("[CEPH] chdir(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static struct smb_filename *cephwrap_getwd(struct vfs_handle_struct *handle, >@@ -1234,7 +1247,7 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, > /* Shrink - just ftruncate. */ > if (pst->st_ex_size > len) { > result = ceph_ftruncate(handle->data, fsp_get_io_fd(fsp), len); >- WRAP_RETURN(result); >+ return status_code(result); > } > > space_to_write = len - pst->st_ex_size; >@@ -1243,7 +1256,7 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, > 0, > pst->st_ex_size, > space_to_write); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_ftruncate(struct vfs_handle_struct *handle, >@@ -1259,7 +1272,7 @@ static int cephwrap_ftruncate(struct vfs_handle_struct *handle, > } > > result = ceph_ftruncate(handle->data, fsp_get_io_fd(fsp), len); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_fallocate(struct vfs_handle_struct *handle, >@@ -1276,7 +1289,7 @@ static int cephwrap_fallocate(struct vfs_handle_struct *handle, > result = ceph_fallocate( > handle->data, fsp_get_io_fd(fsp), mode, offset, len); > DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static bool cephwrap_lock(struct vfs_handle_struct *handle, >@@ -1365,7 +1378,7 @@ static int cephwrap_symlinkat(struct vfs_handle_struct *handle, > dirfd, > new_smb_fname->base_name); > DBG_DEBUG("[CEPH] symlinkat(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #else > struct smb_filename *full_fname = NULL; > >@@ -1385,7 +1398,7 @@ static int cephwrap_symlinkat(struct vfs_handle_struct *handle, > full_fname->base_name); > TALLOC_FREE(full_fname); > DBG_DEBUG("[CEPH] symlink(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #endif > } > >@@ -1413,7 +1426,7 @@ static int cephwrap_readlinkat(struct vfs_handle_struct *handle, > bufsiz); > > DBG_DEBUG("[CEPH] readlinkat(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #else > struct smb_filename *full_fname = NULL; > >@@ -1433,7 +1446,7 @@ static int cephwrap_readlinkat(struct vfs_handle_struct *handle, > bufsiz); > TALLOC_FREE(full_fname); > DBG_DEBUG("[CEPH] readlink(...) = %d\n", result); >- WRAP_RETURN(result); >+ return status_code(result); > #endif > } > >@@ -1472,7 +1485,7 @@ static int cephwrap_linkat(struct vfs_handle_struct *handle, > DBG_DEBUG("[CEPH] link(...) = %d\n", result); > TALLOC_FREE(full_fname_old); > TALLOC_FREE(full_fname_new); >- WRAP_RETURN(result); >+ return status_code(result); > } > > static int cephwrap_mknodat(struct vfs_handle_struct *handle, >@@ -1497,7 +1510,7 @@ static int cephwrap_mknodat(struct vfs_handle_struct *handle, > > TALLOC_FREE(full_fname); > >- WRAP_RETURN(result); >+ return status_code(result); > } > > /* >@@ -1592,10 +1605,7 @@ static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, > size); > } > DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret); >- if (ret < 0) { >- WRAP_RETURN(ret); >- } >- return (ssize_t)ret; >+ return lstatus_code(ret); > } > > static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, >@@ -1624,10 +1634,7 @@ static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, > size); > } > DBG_DEBUG("[CEPH] flistxattr(...) = %d\n", ret); >- if (ret < 0) { >- WRAP_RETURN(ret); >- } >- return (ssize_t)ret; >+ return lstatus_code(ret); > } > > static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, >@@ -1650,7 +1657,7 @@ static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, > name); > } > DBG_DEBUG("[CEPH] fremovexattr(...) = %d\n", ret); >- WRAP_RETURN(ret); >+ return status_code(ret); > } > > static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, >@@ -1690,7 +1697,7 @@ static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, > flags); > } > DBG_DEBUG("[CEPH] fsetxattr(...) = %d\n", ret); >- WRAP_RETURN(ret); >+ return status_code(ret); > } > > static NTSTATUS cephwrap_create_dfs_pathat(struct vfs_handle_struct *handle, >-- >2.46.0 > > >From 551841c835c4cab140ca86533221f846f0383dee Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Thu, 30 May 2024 11:02:37 +0300 >Subject: [PATCH 4/5] vfs_ceph: explicit cast to uint64_t upon failure of > ceph_statfs > >When a call to 'ceph_statfs' from with 'cephwrap_disk_free' returns >non-zero status do an explicit cast to uint64_t for the negative (-1) >value returned by 'status_code'. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Guenther Deschner <gd@samba.org> >Reviewed-by: Anoop C S <anoopcs@samba.org> >(cherry picked from commit a7d34ec597fe810090d28bfda636b7450ecb06e5) >--- > source3/modules/vfs_ceph.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c >index 73c9a55fc6f..4f4277cc3a2 100644 >--- a/source3/modules/vfs_ceph.c >+++ b/source3/modules/vfs_ceph.c >@@ -359,7 +359,7 @@ static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, > return *dfree; > } else { > DBG_DEBUG("[CEPH] ceph_statfs returned %d\n", ret); >- return status_code(ret); >+ return (uint64_t)status_code(ret); > } > } > >-- >2.46.0 > > >From 89f62734f081fb76f78a1a228602924d86f0a398 Mon Sep 17 00:00:00 2001 >From: Shachar Sharon <ssharon@redhat.com> >Date: Tue, 30 Jul 2024 09:55:44 +0300 >Subject: [PATCH 5/5] vfs_ceph{_new}: do not set errno upon successful call to > libcephfs > >There is code in Samba that expects errno from a previous system call >to be preserved through a subsequent system call. Thus, avoid setting >"errno = 0" in status_code() and lstatus_code() upon successful return >from libcephfs API call. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 > >Signed-off-by: Shachar Sharon <ssharon@redhat.com> >Reviewed-by: Guenther Deschner <gd@samba.org> >Reviewed-by: Anoop C S <anoopcs@samba.org> >(cherry picked from commit a7f4e2bd47c7f4728f3ac8d90af693156a69c557) >--- > source3/modules/vfs_ceph.c | 2 -- > 1 file changed, 2 deletions(-) > >diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c >index 4f4277cc3a2..6e2f893e872 100644 >--- a/source3/modules/vfs_ceph.c >+++ b/source3/modules/vfs_ceph.c >@@ -66,7 +66,6 @@ static inline int status_code(int ret) > errno = -ret; > return -1; > } >- errno = 0; > return ret; > } > >@@ -76,7 +75,6 @@ static inline ssize_t lstatus_code(intmax_t ret) > errno = -((int)ret); > return -1; > } >- errno = 0; > return (ssize_t)ret; > } > >-- >2.46.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
anoopcs
:
review+
Actions:
View
Attachments on
bug 15686
:
18398
|
18399
|
18400
|
18412
|
18414
| 18417 |
18428
|
18429