From 2c827e546ecd6ca81b75fc4a37c4bf13a7220661 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 4 Jul 2022 09:27:09 +0300 Subject: [PATCH] libglusterfs: add function to unlink but tolerate ENOENT (#3573) Introduce 'gf_unlink()' to wrap 'sys_unlink()' but tolerate ENOENT, and use the former where appropriate. Related cleanups as usual. Signed-off-by: Dmitry Antipov Updates: #1000 --- libglusterfs/src/common-utils.c | 17 +++++++++++++++ libglusterfs/src/glusterfs/common-utils.h | 3 +++ .../src/glusterfs/libglusterfs-messages.h | 5 +++++ libglusterfs/src/libglusterfs.sym | 1 + libglusterfs/src/store.c | 8 +------ xlators/cluster/dht/src/dht-messages.h | 3 +-- xlators/cluster/dht/src/dht-rebalance.c | 20 ++++-------------- .../bit-rot/src/stub/bit-rot-stub-helpers.c | 5 +---- .../bit-rot/src/stub/bit-rot-stub-messages.h | 4 +--- xlators/features/index/src/index.c | 8 +------ .../mgmt/glusterd/src/glusterd-proc-mgmt.c | 6 ++---- .../glusterd/src/glusterd-shd-svc-helper.c | 2 +- xlators/mgmt/glusterd/src/glusterd-shd-svc.c | 4 ++-- xlators/mgmt/glusterd/src/glusterd-store.c | 15 ++----------- .../mgmt/glusterd/src/glusterd-svc-helper.c | 2 +- xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c | 2 +- xlators/mgmt/glusterd/src/glusterd-utils.c | 21 +------------------ xlators/mgmt/glusterd/src/glusterd-utils.h | 3 --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 10 +-------- xlators/mount/fuse/src/fuse-bridge.c | 8 +------ xlators/nfs/server/src/nfs-messages.h | 2 +- xlators/nfs/server/src/nlm4.c | 12 ++++------- 22 files changed, 52 insertions(+), 109 deletions(-) diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 9afa117d48d..b325dfbaba0 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4304,3 +4304,20 @@ gf_set_nofile(rlim_t high, rlim_t low) } #endif /* not GF_DARWIN_HOST_OS */ + +/* Like sys_unlink() but tolerate ENOENT. */ + +gf_boolean_t +gf_unlink(const char *path) +{ + int ret = 0; + + GF_ASSERT(path); + ret = sys_unlink(path); + + if (ret && errno != ENOENT) { + GF_LOG_W(THIS->name, LG_MSG_UNLINK_FAILED(path)); + return _gf_false; + } + return _gf_true; +} diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h index 6395b5a37ed..567e27b19d7 100644 --- a/libglusterfs/src/glusterfs/common-utils.h +++ b/libglusterfs/src/glusterfs/common-utils.h @@ -1119,6 +1119,9 @@ fop_log_level(glusterfs_fop_t fop, int op_errno); int recursive_rmdir(const char *delete_path); +gf_boolean_t +gf_unlink(const char *path); + int gf_get_index_by_elem(char **array, char *elem); diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h index 751dd41fdc8..7b62bea705b 100644 --- a/libglusterfs/src/glusterfs/libglusterfs-messages.h +++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h @@ -344,6 +344,11 @@ GLFS_NEW(LIBGLUSTERFS, LG_MSG_NOFILE_FAILED, GLFS_I64(low), GLFS_I64(high) ) +GLFS_NEW(LIBGLUSTERFS, LG_MSG_UNLINK_FAILED, + "Failed to remove file", 1, + GLFS_STR(path) +) + #define LG_MSG_EPOLL_FD_CREATE_FAILED_STR "epoll fd creation failed" #define LG_MSG_INVALID_POLL_IN_STR "invalid poll_in value" #define LG_MSG_INVALID_POLL_OUT_STR "invalid poll_out value" diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym index 53fb26a8c63..045263ce82d 100644 --- a/libglusterfs/src/libglusterfs.sym +++ b/libglusterfs/src/libglusterfs.sym @@ -708,6 +708,7 @@ gf_tw_mod_timer gf_tw_mod_timer_pending gf_uint64_2human_readable gf_umount_lazy +gf_unlink gf_update_latency gf_uuid_clear gf_uuid_compare diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c index 63aae76ebcc..3da8bec6e6b 100644 --- a/libglusterfs/src/store.c +++ b/libglusterfs/src/store.c @@ -167,13 +167,7 @@ gf_store_unlink_tmppath(gf_store_handle_t *shandle) GF_VALIDATE_OR_GOTO("store", shandle->path, out); snprintf(tmppath, sizeof(tmppath), "%s.tmp", shandle->path); - ret = sys_unlink(tmppath); - if (ret && (errno != ENOENT)) { - gf_msg("", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED, - "Failed to mv %s to %s", tmppath, shandle->path); - } else { - ret = 0; - } + ret = gf_unlink(tmppath) ? 0 : -1; out: if (shandle && shandle->tmp_fd >= 0) { sys_close(shandle->tmp_fd); diff --git a/xlators/cluster/dht/src/dht-messages.h b/xlators/cluster/dht/src/dht-messages.h index a7cfb551a30..38945ce555e 100644 --- a/xlators/cluster/dht/src/dht-messages.h +++ b/xlators/cluster/dht/src/dht-messages.h @@ -45,7 +45,7 @@ GLFS_MSGID( DHT_MSG_CHUNK_SIZE_INFO, DHT_MSG_LAYOUT_FORM_FAILED, DHT_MSG_SUBVOL_ERROR, DHT_MSG_REGEX_INFO, DHT_MSG_FOPEN_FAILED, DHT_MSG_SET_HOSTNAME_FAILED, DHT_MSG_BRICK_ERROR, DHT_MSG_SYNCOP_FAILED, - DHT_MSG_MIGRATE_INFO, DHT_MSG_SOCKET_ERROR, DHT_MSG_CREATE_FD_FAILED, + DHT_MSG_MIGRATE_INFO, DHT_MSG_UNUSED_PLACEHOLDER, DHT_MSG_CREATE_FD_FAILED, DHT_MSG_READDIR_ERROR, DHT_MSG_CHILD_LOC_BUILD_FAILED, DHT_MSG_SET_SWITCH_PATTERN_ERROR, DHT_MSG_COMPUTE_HASH_FAILED, DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR, DHT_MSG_ANOMALIES_INFO, @@ -205,7 +205,6 @@ GLFS_MSGID( #define DHT_MSG_CLANUP_SOURCE_FILE_FAILED_STR "failed to cleanup source file" #define DHT_MSG_UNLOCK_FILE_FAILED_STR "failed to unlock file" #define DHT_MSG_REMOVE_XATTR_FAILED_STR "remove xattr failed" -#define DHT_MSG_SOCKET_ERROR_STR "Failed to unlink listener socket" #define DHT_MSG_HASHED_SUBVOL_GET_FAILED_STR "Failed to get hashed subvolume" #define DHT_MSG_CACHED_SUBVOL_GET_FAILED_STR "Failed to get cached subvolume" #define DHT_MSG_MIGRATE_DATA_FAILED_STR "migrate-data failed" diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 82a55fffdd5..edc68d8113c 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -2403,30 +2403,19 @@ dht_start_rebalance_task(xlator_t *this, call_frame_t *frame) return ret; } -int +static void gf_listener_stop(xlator_t *this) { glusterfs_ctx_t *ctx = NULL; cmd_args_t *cmd_args = NULL; - int ret = 0; ctx = this->ctx; GF_ASSERT(ctx); cmd_args = &ctx->cmd_args; - if (cmd_args->sock_file) { - ret = sys_unlink(cmd_args->sock_file); - if (ret && (ENOENT == errno)) { - ret = 0; - } - } + GF_ASSERT(cmd_args); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, errno, DHT_MSG_SOCKET_ERROR, - "Failed to unlink listener " - "socket %s", - cmd_args->sock_file); - } - return ret; + if (cmd_args->sock_file) + gf_unlink(cmd_args->sock_file); } static void @@ -4390,7 +4379,6 @@ static int gf_defrag_done(int ret, call_frame_t *sync_frame, void *data) { gf_listener_stop(sync_frame->this); - STACK_DESTROY(sync_frame->root); kill(getpid(), SIGTERM); return 0; diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c b/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c index 1cf4ea7f7f1..025fb68e2f6 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c @@ -156,10 +156,7 @@ br_stub_del(xlator_t *this, uuid_t gfid) EINVAL); snprintf(gfid_path, sizeof(gfid_path), "%s/%s", priv->stub_basepath, uuid_utoa(gfid)); - ret = sys_unlink(gfid_path); - if (ret && (errno != ENOENT)) { - gf_smsg(this->name, GF_LOG_ERROR, errno, BRS_MSG_BAD_OBJ_UNLINK_FAIL, - "path=%s", gfid_path, NULL); + if (!gf_unlink(gfid_path)) { ret = -errno; goto out; } diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h index 6c15a166f18..a8ab60f3b47 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h @@ -38,7 +38,7 @@ GLFS_MSGID(BITROT_STUB, BRS_MSG_NO_MEMORY, BRS_MSG_SET_EVENT_FAILED, BRS_MSG_BAD_OBJECT_DIR_READ_FAIL, BRS_MSG_GET_FD_CONTEXT_FAILED, BRS_MSG_BAD_HANDLE_DIR_NULL, BRS_MSG_BAD_OBJ_THREAD_FAIL, BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL, BRS_MSG_LINK_FAIL, - BRS_MSG_BAD_OBJ_UNLINK_FAIL, BRS_MSG_DICT_SET_FAILED, + BRS_MSG_UNUSED_PLACEHOLDER, BRS_MSG_DICT_SET_FAILED, BRS_MSG_PATH_GET_FAILED, BRS_MSG_NULL_LOCAL, BRS_MSG_SPAWN_SIGN_THRD_FAILED, BRS_MSG_KILL_SIGN_THREAD, BRS_MSG_NON_BITD_PID, BRS_MSG_SIGN_PREPARE_FAIL, @@ -90,8 +90,6 @@ GLFS_MSGID(BITROT_STUB, BRS_MSG_NO_MEMORY, BRS_MSG_SET_EVENT_FAILED, #define BRS_MSG_CREATE_FRAME_FAILED_STR "create_frame() failure" #define BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL_STR "closedir error" #define BRS_MSG_LINK_FAIL_STR "failed to record gfid" -#define BRS_MSG_BAD_OBJ_UNLINK_FAIL_STR \ - "failed to delete bad object link from quaratine directory" #define BRS_MSG_BAD_OBJECT_DIR_FAIL_STR "failed stub directory" #define BRS_MSG_BAD_OBJECT_DIR_SEEK_FAIL_STR \ "seekdir failed. Invalid argument (offset reused from another DIR * " \ diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index ad5a1ed9c66..202a6ebdbf3 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -898,7 +898,6 @@ index_entry_create(xlator_t *this, inode_t *inode, char *filename) int index_entry_delete(xlator_t *this, uuid_t pgfid, char *filename) { - int ret = 0; int op_errno = 0; char pgfid_path[PATH_MAX] = {0}; char entry_path[PATH_MAX] = {0}; @@ -929,13 +928,8 @@ index_entry_delete(xlator_t *this, uuid_t pgfid, char *filename) goto out; } - ret = sys_unlink(entry_path); - if (ret && (errno != ENOENT)) { + if (!gf_unlink(entry_path)) op_errno = errno; - gf_msg(this->name, GF_LOG_ERROR, op_errno, INDEX_MSG_INDEX_DEL_FAILED, - "%s: failed to delete from index/entry-changes", entry_path); - } - out: return -op_errno; } diff --git a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c index c93aaa13aee..b40e02a53f9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-proc-mgmt.c @@ -104,7 +104,7 @@ glusterd_proc_stop(glusterd_proc_t *proc, int sig, int flags) proc->name, strerror(errno)); } } else { - (void)glusterd_unlink_file(proc->pidfile); + gf_unlink(proc->pidfile); } if (flags != PROC_STOP_FORCE) goto out; @@ -129,9 +129,7 @@ glusterd_proc_stop(glusterd_proc_t *proc, int sig, int flags) pid, strerror(errno)); goto out; } - ret = glusterd_unlink_file(proc->pidfile); - if (ret) - goto out; + gf_unlink(proc->pidfile); } ret = 0; diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c index 2bab163355b..8184bec8871 100644 --- a/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c +++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc-helper.c @@ -103,7 +103,7 @@ glusterd_shd_svcproc_cleanup(glusterd_shdsvc_t *shd) svc->svc_proc = NULL; svc->inited = _gf_false; cds_list_del_init(&svc->mux_svc); - glusterd_unlink_file(svc->proc.pidfile); + gf_unlink(svc->proc.pidfile); if (svc_proc && cds_list_empty(&svc_proc->svcs)) { cds_list_del_init(&svc_proc->svc_proc_list); diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c index 0dacaedbb5c..3d9ea1c46b5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c @@ -156,7 +156,7 @@ glusterd_shdsvc_create_volfile(glusterd_volinfo_t *volinfo) /* If volfile exist, delete it. This case happens when we * change from replica/ec to distribute. */ - (void)glusterd_unlink_file(filepath); + gf_unlink(filepath); ret = 0; goto out; } @@ -774,7 +774,7 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig) volinfo->volname, glusterd_proc_get_pid(&svc->proc)); } svc->online = _gf_false; - (void)glusterd_unlink_file((char *)svc->proc.pidfile); + gf_unlink(svc->proc.pidfile); glusterd_shd_svcproc_cleanup(shd); ret = 0; glusterd_volinfo_unref(volinfo); diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 919a5a0e10d..bf689980904 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -646,17 +646,8 @@ glusterd_store_delete_brick(glusterd_brickinfo_t *brickinfo, char *delete_path) GF_FREE(tmppath); - ret = sys_unlink(brickpath); + ret = gf_unlink(brickpath) ? 0 : -1; - if ((ret < 0) && (errno != ENOENT)) { - gf_msg_debug(this->name, 0, "Unlink failed on %s", brickpath); - ret = -1; - goto out; - } else { - ret = 0; - } - -out: if (brickinfo->shandle) { gf_store_handle_destroy(brickinfo->shandle); brickinfo->shandle = NULL; @@ -4335,9 +4326,7 @@ glusterd_store_delete_peerinfo(glusterd_peerinfo_t *peerinfo) goto out; } - ret = sys_unlink(filepath); - if (ret && (errno == ENOENT)) - ret = 0; + ret = gf_unlink(filepath) ? 0 : -1; out: if (peerinfo && peerinfo->shandle) { diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c index 996962e0d3f..82aec77a99d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c @@ -562,7 +562,7 @@ glusterd_shd_svc_mux_init(glusterd_volinfo_t *volinfo, glusterd_svc_t *svc) out: if (stop_daemon) { glusterd_proc_stop(&svc->proc, SIGTERM, PROC_STOP_FORCE); - glusterd_unlink_file(pidfile); + gf_unlink(pidfile); } return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c index 212b459d4b9..c3648d90e92 100644 --- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c @@ -260,7 +260,7 @@ glusterd_svc_stop(glusterd_svc_t *svc, int sig) if (ret == 0) { svc->online = _gf_false; - (void)glusterd_unlink_file((char *)svc->conn.sockpath); + gf_unlink(svc->conn.sockpath); } gf_msg(THIS->name, GF_LOG_INFO, 0, GD_MSG_SVC_STOP_SUCCESS, "%s service is stopped", svc->name); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 3ac5a72526f..bb1bb01a25b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1802,7 +1802,7 @@ glusterd_volume_start_glusterfs(glusterd_volinfo_t *volinfo, */ glusterd_set_brick_socket_filepath(volinfo, brickinfo, socketpath, sizeof(socketpath)); - (void)glusterd_unlink_file(socketpath); + gf_unlink(socketpath); rpc = brickinfo->rpc; if (rpc) { brickinfo->rpc = NULL; @@ -5350,25 +5350,6 @@ glusterd_pending_node_put_rpc(glusterd_pending_node_t *pending_node) } } -int32_t -glusterd_unlink_file(char *sockfpath) -{ - int ret = 0; - - ret = sys_unlink(sockfpath); - if (ret) { - if (ENOENT == errno) - ret = 0; - else - gf_msg(THIS->name, GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED, - "Failed to remove %s" - " error: %s", - sockfpath, strerror(errno)); - } - - return ret; -} - #ifdef BUILD_GNFS void glusterd_nfs_pmap_deregister() diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index bc30b72b215..70a72b05916 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -538,9 +538,6 @@ glusterd_launch_synctask(synctask_fn_t fn, void *opaque); int glusterd_enable_default_options(glusterd_volinfo_t *volinfo, char *option); -int -glusterd_unlink_file(char *sock_file_path); - int32_t glusterd_find_brick_mount_path(char *brick_path, char **brick_mount_path); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 6365b875586..48f1e0b2cbd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -5539,16 +5539,8 @@ generate_brick_volfiles(glusterd_volinfo_t *volinfo) } } } else { - ret = sys_unlink(tstamp_file); - if (ret == -1 && errno == ENOENT) - ret = 0; - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED, - "failed to unlink " - "%s", - tstamp_file); + if (!gf_unlink(tstamp_file)) return -1; - } } ret = glusterd_volume_brick_for_each(volinfo, NULL, diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index f9a64ab2e71..5649d9872cd 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -6841,14 +6841,8 @@ init(xlator_t *this_xl) priv->fuse_dump_fd = -1; ret = dict_get_str(options, "dump-fuse", &value_string); if (ret == 0) { - ret = sys_unlink(value_string); - if (ret == -1 && errno != ENOENT) { - gf_log("glusterfs-fuse", GF_LOG_ERROR, - "failed to remove old fuse dump file %s: %s", value_string, - strerror(errno)); - + if (!gf_unlink(value_string)) goto cleanup_exit; - } ret = open(value_string, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); if (ret == -1) { gf_log("glusterfs-fuse", GF_LOG_ERROR, diff --git a/xlators/nfs/server/src/nfs-messages.h b/xlators/nfs/server/src/nfs-messages.h index 04e15cbe78c..5590cf61123 100644 --- a/xlators/nfs/server/src/nfs-messages.h +++ b/xlators/nfs/server/src/nfs-messages.h @@ -86,7 +86,7 @@ GLFS_MSGID( NFS_MSG_CLNT_CREATE_ERROR, NFS_MSG_NLM_GRACE_PERIOD, NFS_MSG_RPC_CLNT_ERROR, NFS_MSG_GET_PORT_ERROR, NFS_MSG_NLMCLNT_NOT_FOUND, NFS_MSG_FD_LOOKUP_NULL, NFS_MSG_SM_NOTIFY, NFS_MSG_NLM_INIT_FAIL, NFS_MSG_START_ERROR, - NFS_MSG_UNLINK_ERROR, NFS_MSG_SHARE_LIST_STORE_FAIL, + NFS_MSG_UNUSED_PLACEHOLDER, NFS_MSG_SHARE_LIST_STORE_FAIL, NFS_MSG_CLIENT_NOT_FOUND, NFS_MSG_SHARE_CALL_FAIL, NFS_MSG_UNSHARE_CALL_FAIL, NFS_MSG_GET_PID_FAIL, NFS_MSG_ARG_FREE_FAIL, NFS_MSG_PMAP_UNSET_FAIL, NFS_MSG_UDP_SERV_FAIL, NFS_MSG_REG_NLMCBK_FAIL, diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index 2495781ec93..c41b994b523 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -2664,10 +2664,8 @@ nlm4svc_init(xlator_t *nfsx) instead. This is still a theory but we need to thoroughly test it out. Until then NLM support is non-existent on OSX. */ - ret = sys_unlink(GF_SM_NOTIFY_PIDFILE); - if (ret == -1 && errno != ENOENT) { - gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_UNLINK_ERROR, - "unable to unlink %s: %d", GF_SM_NOTIFY_PIDFILE, errno); + if (!gf_unlink(GF_SM_NOTIFY_PIDFILE)) { + ret = -1; goto err; } /* temporary work around to restart statd, not distro/OS independent. @@ -2701,10 +2699,8 @@ nlm4svc_init(xlator_t *nfsx) ret = runcmd(KILLALL_CMD, "-9", "rpc.statd", NULL); } - ret = sys_unlink(GF_RPC_STATD_PIDFILE); - if (ret == -1 && errno != ENOENT) { - gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_UNLINK_ERROR, - "unable to unlink %s", pid_file); + if (!gf_unlink(GF_RPC_STATD_PIDFILE)) { + ret = -1; goto err; }