mirror of
https://github.com/schoebel/mars
synced 2025-03-11 07:47:41 +00:00
light: workaround flying IO before reporting memory leaks
We report an error if there are unfreed mrefs after the device brick has been switched to power off. Instead of reporting an error at once, we report only warnings in the first 20 seconds. If there are still unfreed mrefs after that time an error is reported.
This commit is contained in:
parent
74e12ad531
commit
08e5803cd1
@ -1044,6 +1044,8 @@ int mars_free_brick(struct mars_brick *brick)
|
||||
int i;
|
||||
int count;
|
||||
int status;
|
||||
int sleeptime;
|
||||
int maxsleep;
|
||||
|
||||
if (!brick) {
|
||||
MARS_ERR("bad brick parameter\n");
|
||||
@ -1067,9 +1069,22 @@ int mars_free_brick(struct mars_brick *brick)
|
||||
}
|
||||
}
|
||||
|
||||
count = atomic_read(&brick->mref_object_layout.alloc_count);
|
||||
if (count > 0) {
|
||||
MARS_ERR("MEMLEAK: brick '%s' has %d mrefs allocated (total = %d)\n", brick->brick_path, count, atomic_read(&brick->mref_object_layout.total_alloc_count));
|
||||
// Should not happen, but workaround: wait until flying IO has vanished
|
||||
maxsleep = 20000;
|
||||
sleeptime = 1000;
|
||||
for (;;) {
|
||||
count = atomic_read(&brick->mref_object_layout.alloc_count);
|
||||
if (likely(!count)) {
|
||||
break;
|
||||
}
|
||||
if (maxsleep > 0) {
|
||||
MARS_WRN("MEMLEAK: brick '%s' has %d mrefs allocated (total = %d, maxsleep = %d)\n", brick->brick_path, count, atomic_read(&brick->mref_object_layout.total_alloc_count), maxsleep);
|
||||
} else {
|
||||
MARS_ERR("MEMLEAK: brick '%s' has %d mrefs allocated (total = %d)\n", brick->brick_path, count, atomic_read(&brick->mref_object_layout.total_alloc_count));
|
||||
break;
|
||||
}
|
||||
brick_msleep(sleeptime);
|
||||
maxsleep -= sleeptime;
|
||||
}
|
||||
|
||||
MARS_DBG("===> freeing brick name = '%s' path = '%s'\n", brick->brick_name, brick->brick_path);
|
||||
|
Loading…
Reference in New Issue
Block a user