Skip to content

Commit 1ec7504

Browse files
mohit84xhernandez
authored andcommitted
io-stat: xlator Segmentation fault
The process is getting crashed during call ios_bump_stats in cbk code path. After checked the code it seems the process is getting crashed because the ios_stat_head list is destroyed by the function ios_destroy_top_stats without taking a list mutex while receive a clear profile event from the client. If at the same time a process is trying to access the list it can be crash. Change-Id: I1b4d56517fa405eb84da7fffca61e15530652204 Solution: Destroy the ios_stat under the list mutex. Fixes: gluster#3901 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
1 parent 68856f7 commit 1ec7504

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

xlators/debug/io-stats/src/io-stats.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,32 +3619,42 @@ ios_destroy_top_stats(struct ios_conf *conf)
36193619
list_head = &conf->list[i];
36203620
if (!list_head)
36213621
continue;
3622-
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list, list)
3622+
LOCK(&list_head->lock);
36233623
{
3624-
list = entry;
3625-
stat = list->iosstat;
3626-
ios_stat_unref(stat);
3627-
list_del(&list->list);
3628-
GF_FREE(list);
3629-
list_head->members--;
3624+
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list,
3625+
list)
3626+
{
3627+
list = entry;
3628+
stat = list->iosstat;
3629+
ios_stat_unref(stat);
3630+
list_del(&list->list);
3631+
GF_FREE(list);
3632+
list_head->members--;
3633+
}
3634+
GF_FREE(list_head->iosstats);
36303635
}
3631-
GF_FREE(list_head->iosstats);
3636+
UNLOCK(&list_head->lock);
36323637
}
36333638

36343639
for (i = 0; i < IOS_STATS_THRU_MAX; i++) {
36353640
list_head = &conf->thru_list[i];
36363641
if (!list_head)
36373642
continue;
3638-
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list, list)
3643+
LOCK(&list_head->lock);
36393644
{
3640-
list = entry;
3641-
stat = list->iosstat;
3642-
ios_stat_unref(stat);
3643-
list_del(&list->list);
3644-
GF_FREE(list);
3645-
list_head->members--;
3645+
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list,
3646+
list)
3647+
{
3648+
list = entry;
3649+
stat = list->iosstat;
3650+
ios_stat_unref(stat);
3651+
list_del(&list->list);
3652+
GF_FREE(list);
3653+
list_head->members--;
3654+
}
3655+
GF_FREE(list_head->iosstats);
36463656
}
3647-
GF_FREE(list_head->iosstats);
3657+
UNLOCK(&list_head->lock);
36483658
}
36493659

36503660
UNLOCK(&conf->lock);

0 commit comments

Comments
 (0)