minor optimizations at diskstats
Costa Tsaousis (ktsaou) committed
Oct 23, 2016 at 02:31 UTC
13da861a81b48d7828ca27a12ff817b2be40371b
2 files changed
+9
-8
src/proc_diskstats.c
+8
-7
@@ -260,13 +260,13 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
260
261
// mountinfo_find() can be called with NULL disk_mountinfo_root
262
struct mountinfo *mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
263
- if(unlikely(!mi)) {
263
+/* if(unlikely(!mi)) {
264
mountinfo_reload(1);
265
266
// search again for this disk
267
mi = mountinfo_find(disk_mountinfo_root, d->major, d->minor);
268
}
269
-
269
+*/
270
if(mi) {
271
d->mount_point = strdupz(mi->mount_point);
272
d->mount_point_hash = mi->mount_point_hash;
@@ -770,14 +770,14 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
770
}
771
}
772
773
- /*
773
+/*
774
// --------------------------------------------------------------------------
775
// space metrics
776
777
if(d->mount_point && (d->do_space || d->do_inodes) ) {
778
do_disk_space_stats(d, d->mount_point, disk, disk, family, update_every, dt);
779
}
780
- */
780
+*/
781
}
782
783
// --------------------------------------------------------------------------
@@ -785,10 +785,10 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
785
786
struct mountinfo *mi;
787
for(mi = disk_mountinfo_root; mi ;mi = mi->next) {
788
- if(unlikely(mi->flags & MOUNTINFO_IS_DUMMY || mi->flags & MOUNTINFO_IS_BIND || mi->flags & MOUNTINFO_IS_SAME_DEV || mi->flags & MOUNTINFO_NO_STAT || mi->flags & MOUNTINFO_NO_SIZE))
788
+ if(unlikely(mi->flags & (MOUNTINFO_IS_DUMMY|MOUNTINFO_IS_BIND|MOUNTINFO_IS_SAME_DEV|MOUNTINFO_NO_STAT|MOUNTINFO_NO_SIZE)))
789
continue;
790
791
- /*
791
+/*
792
// skip the ones with block devices
793
int skip = 0;
794
struct disk *d;
@@ -801,9 +801,10 @@ int do_proc_diskstats(int update_every, unsigned long long dt) {
801
802
if(unlikely(skip))
803
continue;
804
- */
804
805
// fprintf(stderr, "Will process mount point '%s', source '%s', filesystem '%s'\n", mi->mount_point, mi->mount_source, mi->filesystem);
806
+*/
807
+
808
do_disk_space_stats(NULL, mi->mount_point, mi->mount_source, mi->persistent_id, mi->mount_point , update_every, dt);
809
}
810
src/proc_self_mountinfo.c
+1
-1
@@ -343,7 +343,7 @@ struct mountinfo *mountinfo_read() {
343
*/
344
}
345
346
-/*
346
+/* find if the mount options have "bind" in them
347
{
348
FILE *fp = setmntent(MOUNTED, "r");
349
if (fp != NULL) {