From: Shachar Sharon Date: Sun, 23 Jun 2024 10:08:25 +0000 (+0300) Subject: vfs_ceph_new: use low-level APIs for mknodat X-Git-Tag: tdb-1.4.12~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e714e5ddc50a771e743f5e63f686c106abe33b75;p=thirdparty%2Fsamba.git vfs_ceph_new: use low-level APIs for mknodat Implement mknodat operations using libcephfs' low-level APIs. Requires parent directory to have valid inode-ref associated with its fsp extension. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon Reviewed-by: Guenther Deschner Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 986c66372a4..4bb6cb59d1f 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -970,6 +970,35 @@ static int vfs_ceph_ll_rename(const struct vfs_handle_struct *handle, newparent->uperm); } +static int vfs_ceph_ll_mknod(const struct vfs_handle_struct *handle, + const struct vfs_ceph_fh *parent, + const char *name, + mode_t mode, + dev_t rdev, + struct vfs_ceph_iref *iref) +{ + struct ceph_statx stx = {.stx_ino = 0}; + struct Inode *inode = NULL; + int ret = -1; + + ret = ceph_ll_mknod(cmount_of(handle), + parent->iref.inode, + name, + mode, + rdev, + &inode, + &stx, + CEPH_STATX_INO, + 0, + parent->uperm); + if (ret == 0) { + iref->inode = inode; + iref->ino = stx.stx_ino; + iref->owner = true; + } + return ret; +} + /* Ceph Inode-refernce get/put wrappers */ static int vfs_ceph_iget(const struct vfs_handle_struct *handle, uint64_t ino, @@ -2249,25 +2278,26 @@ static int vfs_ceph_mknodat(struct vfs_handle_struct *handle, mode_t mode, SMB_DEV_T dev) { - struct smb_filename *full_fname = NULL; + struct vfs_ceph_iref iref = {0}; + struct vfs_ceph_fh *dircfh = NULL; + const char *name = smb_fname->base_name; int result = -1; - full_fname = full_path_from_dirfsp_atname(talloc_tos(), - dirfsp, - smb_fname); - if (full_fname == NULL) { - return -1; + result = vfs_ceph_fetch_fh(handle, dirfsp, &dircfh); + if (result != 0) { + goto out; } - DBG_DEBUG("[CEPH] mknodat(%p, %s)\n", handle, full_fname->base_name); - result = ceph_mknod(cmount_of(handle), - full_fname->base_name, - mode, - dev); - DBG_DEBUG("[CEPH] mknodat(...) = %d\n", result); + DBG_DEBUG("[CEPH] mknodat(%p, %s)\n", handle, name); - TALLOC_FREE(full_fname); + result = vfs_ceph_ll_mknod(handle, dircfh, name, mode, dev, &iref); + if (result != 0) { + goto out; + } + vfs_ceph_iput(handle, &iref); +out: + DBG_DEBUG("[CEPH] mknodat(...) = %d\n", result); return status_code(result); }