]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: refactor error-case in cephmount_mount_fs
authorShachar Sharon <ssharon@redhat.com>
Wed, 4 Sep 2024 11:55:50 +0000 (14:55 +0300)
committerJule Anger <janger@samba.org>
Mon, 17 Feb 2025 16:09:09 +0000 (16:09 +0000)
Align code-style of 'cephmount_mount_fs' with rest of the code: use
'goto' for bail-out upon error case (with proper cleanups). For the
common case of successful operation complete execution and return final
value. Added extra debug-logging for good-path case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15703

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit d9b872afeee4dee49de2e6eb86e4b59e07804363)

source3/modules/vfs_ceph_new.c

index e5517a98298a265fd3a9b69115b11774430fe9aa..e5afac20be169e5f1ea01116d2c55b7a65661300 100644 (file)
@@ -266,24 +266,24 @@ static struct ceph_mount_info *cephmount_mount_fs(
                  (config->conf_file == NULL ? "default path" : config->conf_file));
        ret = config->ceph_conf_read_file_fn(mnt, config->conf_file);
        if (ret) {
-               goto err_cm_release;
+               goto out;
        }
 
        DBG_DEBUG("[CEPH] calling: ceph_conf_get\n");
        ret = config->ceph_conf_get_fn(mnt, "log file", buf, sizeof(buf));
        if (ret < 0) {
-               goto err_cm_release;
+               goto out;
        }
 
        /* libcephfs disables POSIX ACL support by default, enable it... */
        ret = config->ceph_conf_set_fn(mnt, "client_acl_type", "posix_acl");
        if (ret < 0) {
-               goto err_cm_release;
+               goto out;
        }
        /* tell libcephfs to perform local permission checks */
        ret = config->ceph_conf_set_fn(mnt, "fuse_default_permissions", "false");
        if (ret < 0) {
-               goto err_cm_release;
+               goto out;
        }
        /*
         * select a cephfs file system to use:
@@ -293,26 +293,30 @@ static struct ceph_mount_info *cephmount_mount_fs(
        if (config->fsname != NULL) {
                ret = config->ceph_select_filesystem_fn(mnt, config->fsname);
                if (ret < 0) {
-                       goto err_cm_release;
+                       goto out;
                }
        }
 
        DBG_DEBUG("[CEPH] calling: ceph_mount\n");
        ret = config->ceph_mount_fn(mnt, NULL);
-       if (ret >= 0) {
-               goto cm_done;
+       if (ret < 0) {
+               goto out;
        }
+       ret = 0;
 
-      err_cm_release:
-       config->ceph_release_fn(mnt);
-       mnt = NULL;
-       DBG_DEBUG("[CEPH] Error mounting fs: %s\n", strerror(-ret));
-      cm_done:
-       /*
-        * Handle the error correctly. Ceph returns -errno.
-        */
-       if (ret) {
+out:
+       if (ret != 0) {
+               config->ceph_release_fn(mnt);
+               mnt = NULL;
+               DBG_ERR("[CEPH] mount failed: user_id='%s' fsname='%s' %s",
+                       (config->user_id != NULL) ? config->user_id : "",
+                       (config->fsname != NULL) ? config->fsname : "",
+                       strerror(-ret));
                errno = -ret;
+       } else {
+               DBG_DEBUG("[CEPH] mount done: user_id='%s' fsname='%s'",
+                         (config->user_id != NULL) ? config->user_id : "",
+                         (config->fsname != NULL) ? config->fsname : "");
        }
        return mnt;
 }