Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 862934 Details for
Bug 804890
[rhel5]: sar can not show correct name for virtio devices.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
sysstat-7.0.2-devname.patch
sysstat-7.0.2-devname.patch (text/plain), 5.74 KB, created by
Peter Schiffer
on 2014-02-13 17:44:03 UTC
(
hide
)
Description:
sysstat-7.0.2-devname.patch
Filename:
MIME Type:
Creator:
Peter Schiffer
Created:
2014-02-13 17:44:03 UTC
Size:
5.74 KB
patch
obsolete
>diff -up sysstat-7.0.2/common.c.devname sysstat-7.0.2/common.c >--- sysstat-7.0.2/common.c.devname 2014-02-13 18:19:29.652132000 +0100 >+++ sysstat-7.0.2/common.c 2014-02-13 18:17:19.815079000 +0100 >@@ -426,6 +426,37 @@ int get_nfs_mount_nr(void) > return nfs; > } > >+/* >+*************************************************************************** >+* Read /proc/devices file and get device-mapper major number. >+* If device-mapper entry is not found in file, use DEFAULT_DEMAP_MAJOR >+* number. >+* >+* RETURNS: >+* Device-mapper major number. >+*************************************************************************** >+*/ >+unsigned int get_devmap_major(void) >+{ >+ FILE *fp; >+ char line[128]; >+ unsigned int dm_major = DEVMAP_MAJOR; >+ >+ if ((fp = fopen("/proc/devices", "r")) == NULL) >+ return dm_major; >+ >+ while (fgets(line, sizeof(line), fp) != NULL) { >+ >+ if (strstr(line, "device-mapper")) { >+ /* Read device-mapper major number */ >+ sscanf(line, "%u", &dm_major); >+ } >+ } >+ >+ fclose(fp); >+ >+ return dm_major; >+} > > /* > *************************************************************************** >diff -up sysstat-7.0.2/common.h.devname sysstat-7.0.2/common.h >--- sysstat-7.0.2/common.h.devname 2014-02-13 18:19:29.625132000 +0100 >+++ sysstat-7.0.2/common.h 2014-02-13 18:18:14.445682000 +0100 >@@ -85,6 +85,7 @@ extern unsigned int kb_shift; > /* Functions */ > extern char *device_name(char *); > extern void get_HZ(void); >+extern unsigned int get_devmap_major(void); > extern unsigned int get_disk_io_nr(void); > extern void get_kb_shift(void); > extern time_t get_localtime(struct tm *); >diff -up sysstat-7.0.2/iostat.c.devname sysstat-7.0.2/iostat.c >--- sysstat-7.0.2/iostat.c.devname 2014-02-13 18:19:29.665131000 +0100 >+++ sysstat-7.0.2/iostat.c 2014-02-13 18:23:33.383399271 +0100 >@@ -869,7 +869,7 @@ void read_diskstats_stat(int curr, int f > strcpy(dev_name, ioc_dname); > } > >- if ((DISPLAY_DEVMAP_NAME(flags)) && (major == DEVMAP_MAJOR)) { >+ if ((DISPLAY_DEVMAP_NAME(flags)) && (major == get_devmap_major())) { > /* > * If the device is a device mapper device, try to get its > * assigned name of its logical device. >@@ -938,7 +938,7 @@ void read_ppartitions_stat(int curr, int > strcpy(dev_name, ioc_dname); > } > >- if ((DISPLAY_DEVMAP_NAME(flags)) && (major == DEVMAP_MAJOR)) { >+ if ((DISPLAY_DEVMAP_NAME(flags)) && (major == get_devmap_major())) { > /* Get device mapper logical name */ > dm_name = transform_devmapname(major, minor); > if (dm_name) { >diff -up sysstat-7.0.2/sa_common.c.devname sysstat-7.0.2/sa_common.c >--- sysstat-7.0.2/sa_common.c.devname 2014-02-13 18:19:29.657131970 +0100 >+++ sysstat-7.0.2/sa_common.c 2014-02-13 18:19:29.681131794 +0100 >@@ -27,8 +27,11 @@ > #include <unistd.h> /* For STDOUT_FILENO, among others */ > #include <dirent.h> > #include <fcntl.h> >+#include <libgen.h> > #include <sys/types.h> > #include <sys/ioctl.h> >+#include <sys/stat.h> >+#include <linux/kdev_t.h> > > #include "sa.h" > #include "common.h" >@@ -150,6 +153,47 @@ void salloc_disk_array(struct disk_stats > > /* > *************************************************************************** >+ * Try to get device real name from /dev. >+ * >+ * IN: >+ * @major Major number of the device. >+ * @minor Minor number of the device. >+ * >+ * RETURNS: >+ * The name of the device, which may be the real name (as it appears in /dev) >+ * or NULL. >+ *************************************************************************** >+ */ >+char *get_devname_from_dev(unsigned int major, unsigned int minor) >+{ >+ DIR *d; >+ struct dirent *dir; >+ struct stat buf; >+ char *devname = NULL, path[PATH_MAX]; >+ >+ d = opendir("/dev"); >+ if (d) { >+ while ((dir = readdir(d))) { >+ snprintf(path, PATH_MAX, "/dev/%s", dir->d_name); >+ if (stat(path, &buf) == 0) { >+ if (MAJOR(buf.st_rdev) == major && MINOR(buf.st_rdev) == minor) { >+ devname = basename(dir->d_name); >+ break; >+ } >+ } >+ } >+ closedir(d); >+ } >+ >+ if (!devname || !strlen(devname)) { >+ return (NULL); >+ } >+ >+ return (devname); >+} >+ >+/* >+ *************************************************************************** > * Get device real name if possible. > * Warning: This routine may return a bad name on 2.4 kernels where > * disk activities are read from /proc/stat. >@@ -164,10 +208,12 @@ char *get_devname(unsigned int major, un > > if (!pretty) > return (buf); >- if ((name = ioc_name(major, minor)) == NULL) >- return (buf); >+ if ((name = get_devname_from_dev(major, minor)) != NULL) >+ return (name); >+ if ((name = ioc_name(major, minor)) != NULL) >+ return (name); > >- return (name); >+ return (buf); > } > > >diff -up sysstat-7.0.2/sar.c.devname sysstat-7.0.2/sar.c >--- sysstat-7.0.2/sar.c.devname 2014-02-13 18:19:29.676131831 +0100 >+++ sysstat-7.0.2/sar.c 2014-02-13 18:23:23.886456691 +0100 >@@ -28,6 +28,7 @@ > > #include "sa.h" > #include "common.h" >+#include "ioconf.h" > > > #ifdef USE_NLS >@@ -710,10 +711,18 @@ void write_stats_core(short prev, short > ((sdi->rd_sect - sdj->rd_sect) + (sdi->wr_sect - sdj->wr_sect)) / > ((double) (sdi->nr_ios - sdj->nr_ios)) : 0.0; > >+ char *dev_name = NULL; >+ if ((USE_PRETTY_OPTION(flags)) && (sdi->major == get_devmap_major())) { >+ dev_name = transform_devmapname(sdi->major, sdi->minor); >+ } >+ if (!dev_name) { >+ dev_name = get_devname(sdi->major, sdi->minor, USE_PRETTY_OPTION(flags)); >+ } >+ > printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", > curr_string, > /* Confusion possible here between index and minor numbers */ >- get_devname(sdi->major, sdi->minor, USE_PRETTY_OPTION(flags)), >+ dev_name, > S_VALUE(sdj->nr_ios, sdi->nr_ios, itv), > ll_s_value(sdj->rd_sect, sdi->rd_sect, itv), > ll_s_value(sdj->wr_sect, sdi->wr_sect, itv),
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 804890
:
593779
| 862934