diff options
Diffstat (limited to 'xlators/features/bit-rot')
6 files changed, 40 insertions, 22 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.c index 0afd7ea05b1..2f9aaf31a52 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.c @@ -55,9 +55,12 @@ void br_update_scrub_finish_time (br_scrub_stats_t *scrub_stat, char *timestr, struct timeval *tv) { + int lst_size = 0; + if (!scrub_stat) return; + lst_size = sizeof (scrub_stat->last_scrub_time); pthread_mutex_lock (&scrub_stat->lock); { scrub_stat->scrub_end_tv.tv_sec = tv->tv_sec; @@ -67,7 +70,8 @@ br_update_scrub_finish_time (br_scrub_stats_t *scrub_stat, char *timestr, scrub_stat->scrub_start_tv.tv_sec; strncpy (scrub_stat->last_scrub_time, timestr, - sizeof (scrub_stat->last_scrub_time)); + lst_size-1); + scrub_stat->last_scrub_time[lst_size-1] = '\0'; } pthread_mutex_unlock (&scrub_stat->lock); } diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c index 8812e99535a..0e706c92dff 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -1632,10 +1632,9 @@ br_read_bad_object_dir (xlator_t *this, br_child_t *child, fd_t *fd, NULL, NULL))) { if (ret < 0) goto out; - if (ret == 0) - break; - list_for_each_entry (entry, &entries.list, list) { - offset = entry->d_off; + + list_for_each_entry (entry, &entries.list, list) { + offset = entry->d_off; snprintf (key, sizeof (key), "quarantine-%d", count); @@ -1648,10 +1647,10 @@ br_read_bad_object_dir (xlator_t *this, br_child_t *child, fd_t *fd, entry->d_name); if (!ret) count++; - } + } - gf_dirent_free (&entries); - } + gf_dirent_free (&entries); + } ret = count; ret = dict_set_int32 (dict, "count", count); diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c index c5b4037ee98..04ccc013cda 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot.c @@ -1988,7 +1988,7 @@ init (xlator_t *this) goto out; } - GF_OPTION_INIT ("scrubber", priv->iamscrubber, bool, out); + GF_OPTION_INIT ("scrubber", priv->iamscrubber, bool, free_priv); ret = br_init_children (this, priv); if (ret) diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h index a33577cf598..1652a3ebf8d 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h @@ -28,6 +28,7 @@ enum br_mem_types { gf_br_stub_mt_br_scanner_freq_t, gf_br_stub_mt_sigstub_t, gf_br_mt_br_child_event_t, + gf_br_stub_mt_misc, gf_br_stub_mt_end, }; diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 10a1d81a6fa..8571789540f 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -139,7 +139,8 @@ init (xlator_t *this) GF_OPTION_INIT ("bitrot", priv->do_versioning, bool, free_mempool); GF_OPTION_INIT ("export", tmp, str, free_mempool); - strncpy (priv->export, tmp, sizeof (priv->export)); + strncpy (priv->export, tmp, PATH_MAX-1); + priv->export[PATH_MAX-1] = '\0'; (void) snprintf (priv->stub_basepath, sizeof (priv->stub_basepath), "%s/%s", priv->export, BR_STUB_QUARANTINE_DIR); @@ -1304,6 +1305,28 @@ br_stub_handle_internal_xattr (call_frame_t *frame, xlator_t *this, fd_t *fd, return 0; } +static void +br_stub_dump_xattr (xlator_t *this, dict_t *dict, int *op_errno) +{ + char *format = "(%s:%s)"; + char *dump = NULL; + + dump = GF_CALLOC (1, BR_STUB_DUMP_STR_SIZE, gf_br_stub_mt_misc); + if (!dump) { + *op_errno = ENOMEM; + goto out; + } + dict_dump_to_str (dict, dump, BR_STUB_DUMP_STR_SIZE, format); + gf_msg (this->name, GF_LOG_ERROR, 0, + BRS_MSG_SET_INTERNAL_XATTR, "fsetxattr called on " + "internal xattr %s", dump); + out: + if (dump) { + GF_FREE (dump); + } + return; +} + int br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, int flags, dict_t *xdata) @@ -1314,18 +1337,13 @@ br_stub_fsetxattr (call_frame_t *frame, xlator_t *this, br_stub_private_t *priv = NULL; int32_t op_ret = -1; int32_t op_errno = EINVAL; - char *format = "(%s:%s)"; - char dump[64*1024] = {0,}; priv = this->private; if ((frame->root->pid != GF_CLIENT_PID_BITD && frame->root->pid != GF_CLIENT_PID_SCRUB) && br_stub_internal_xattr (dict)) { - dict_dump_to_str (dict, dump, sizeof(dump), format); - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_SET_INTERNAL_XATTR, "fsetxattr called on " - "internal xattr %s", dump); + br_stub_dump_xattr (this, dict, &op_errno); goto unwind; } @@ -1405,14 +1423,9 @@ br_stub_setxattr (call_frame_t *frame, xlator_t *this, { int32_t op_ret = -1; int32_t op_errno = EINVAL; - char dump[64*1024] = {0,}; - char *format = "(%s:%s)"; if (br_stub_internal_xattr (dict)) { - dict_dump_to_str (dict, dump, sizeof(dump), format); - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_SET_INTERNAL_XATTR, "setxattr called on " - "internal xattr %s", dump); + br_stub_dump_xattr (this, dict, &op_errno); goto unwind; } diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index d8c8b6beb9e..27a84e3218d 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -24,6 +24,7 @@ #include "glusterfs3-xdr.h" #define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024*1024)) +#define BR_STUB_DUMP_STR_SIZE 65536 #define BR_PATH_MAX_EXTRA (PATH_MAX+1024) #define BR_PATH_MAX_PLUS (PATH_MAX+2048) |