- /* test if we have seen the disk in diskstats */
- if (ds->poll_count != local_poll_count) {
- diskstats_t *old_ds = ds;
- /* free the ds */
- if (pre_ds == disklist) {
- /* first element */
- disklist = ds->next;
- ds = disklist;
- pre_ds = ds;
- } else {
- pre_ds->next = ds->next;
- ds = ds->next;
- }
- free(old_ds);
- } else {
- pre_ds = ds;
- ds = ds->next;
- }
+ /* Disk exists */
+ if (ds->poll_count == poll_count) {
+ pre_ds = ds;
+ ds = ds->next;
+ continue;
+ }
+
+ /* Disk is missing, remove it */
+ diskstats_t *missing_ds = ds;
+ if (ds == disklist) {
+ pre_ds = disklist = ds->next;
+ } else {
+ pre_ds->next = ds->next;
+ }
+ ds = ds->next;
+
+ DEBUG("disk plugin: Disk %s disappeared.", missing_ds->name);
+ free(missing_ds->name);
+ free(missing_ds);