mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
vfs_ceph_new: refactor error-case in cephmount_mount_fs
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>
This commit is contained in:
parent
e4e3f05cd7
commit
d9b872afee
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user