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 226841 Details for
Bug 277271
O(n^2) blkdev scanning makes bootup intorelably slow (looks like frozen) in some configurations
[?]
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]
Patch that speeds up mkblkdevs on my (running) desktop from 19.5 down to 4 minutes
mkinitrd-devtree-cache-slaves.patch (text/plain), 4.17 KB, created by
Alexandre Oliva
on 2007-10-15 02:04:29 UTC
(
hide
)
Description:
Patch that speeds up mkblkdevs on my (running) desktop from 19.5 down to 4 minutes
Filename:
MIME Type:
Creator:
Alexandre Oliva
Created:
2007-10-15 02:04:29 UTC
Size:
4.17 KB
patch
obsolete
>Index: nash/devtree.c >=================================================================== >--- nash/devtree.c.orig 2007-10-14 22:37:10.000000000 -0200 >+++ nash/devtree.c 2007-10-14 23:56:03.000000000 -0200 >@@ -1125,6 +1125,23 @@ static const struct devtree_constraint { > { DEV_TYPE_NONE, DEV_TYPE_NONE, 0, 0 } > }; > >+struct nash_slave_list { >+ const char *name; >+ int valid; >+ dev_t devno; >+ struct nash_slave_list *next; >+}; >+ >+/* Setting this to zero rather than one ups the mkblkdevs time on a >+ * certain box (*) from 4 minutes to 5.2 minutes (nearly zero system >+ * time), compared with 19.5 minutes without any caching whatsoever >+ * (more than 2/3rd of which on system CPU use). >+ * >+ * (*) 4 disks, 15 partitions each, combined in RAID 1 pairs, almost >+ * all of which used as physical volumes of a single volume group >+ * containing 6 logical volumes. */ >+#define CACHE_SLAVES_ONCE 1 >+ > static int is_sysfs_slave(struct nash_dev_node *adult, > struct nash_dev_node *child) > { >@@ -1133,43 +1150,91 @@ static int is_sysfs_slave(struct nash_de > struct stat sb; > int rc = 0; > char slaves[strlen(child->bdev->sysfs_path) + strlen("/slaves") + 1]; >+ struct nash_slave_list **slavepp = &child->slave_cache, *slavep; >+ >+#if CACHE_SLAVES_ONCE >+ if (*slavepp == (void*)-1) >+ return 0; >+#endif >+ >+ for (slavep = *slavepp; slavep; slavep = slavep->next) >+ if (slavep->valid && slavep->devno == adult->bdev->devno) >+ return 1; >+ >+#if CACHE_SLAVES_ONCE >+ if (*slavepp) >+ return 0; >+#endif > > strcpy(slaves, child->bdev->sysfs_path); > strcat(slaves, "/slaves"); > >- if (!(dir = opendir(slaves))) >+ if (!(dir = opendir(slaves))) { >+#if CACHE_SLAVES_ONCE >+ child->slave_cache = (void*)-1; >+#endif > return 0; >+ } > > while ((entry = readdir(dir))) { >- char slave[strlen(slaves) + 1 + strlen(entry->d_name) + 1]; >- char devpath[sizeof(slave) + strlen("/dev") + 1]; >- char devbuf[32] = ""; >- int maj, min; >- FILE *df; >- >- strcpy(slave, slaves); >- strcat(slave, "/"); >- strcat(slave, entry->d_name); >- strcpy(devpath, slave); >- strcat(devpath, "/dev"); >+ dev_t devno; > >- lstat(slave, &sb); >- if (!S_ISLNK(sb.st_mode)) >- continue; >- >- if (!(df = fopen(devpath, "r"))) >- continue; >- >- if (!fgets(devbuf, 31, df)) { >- fclose(df); >- continue; >- } >- fclose(df); >- >- if (sscanf(devbuf, "%d:%d", &maj, &min) != 2) >- continue; >+ while (*slavepp && >+ strcmp(entry->d_name, (slavep = *slavepp)->name) != 0) { >+ *slavepp = slavep->next; >+ free(slavep); >+ } >+ >+ if (!*slavepp) { >+ char slave[strlen(slaves) + 1 + strlen(entry->d_name) + 1]; >+ char devpath[sizeof(slave) + strlen("/dev") + 1]; >+ char devbuf[32] = ""; >+ int maj, min; >+ FILE *df; >+ >+ *slavepp = slavep = calloc (1, sizeof (*slavep)); >+ if (slavep) { >+ slavep->name = strdup(entry->d_name); >+ slavep->next = NULL; >+ slavep->valid = 0; >+ slavepp = &slavep->next; >+ } >+ >+ strcpy(slave, slaves); >+ strcat(slave, "/"); >+ strcat(slave, entry->d_name); >+ strcpy(devpath, slave); >+ strcat(devpath, "/dev"); >+ >+ lstat(slave, &sb); >+ if (!S_ISLNK(sb.st_mode)) >+ continue; >+ >+ if (!(df = fopen(devpath, "r"))) >+ continue; >+ >+ if (!fgets(devbuf, 31, df)) { >+ fclose(df); >+ continue; >+ } >+ fclose(df); >+ >+ if (sscanf(devbuf, "%d:%d", &maj, &min) != 2) >+ continue; >+ >+ devno = makedev(maj,min); >+ if (slavep) { >+ slavep->valid = 1; >+ slavep->devno = devno; >+ } >+ } else { >+ slavepp = &slavep->next; >+ if (!slavep->valid) >+ continue; >+ devno = slavep->devno; >+ } > >- if (makedev(maj,min) == adult->bdev->devno) { >+ if (devno == adult->bdev->devno) { > rc = 1; > break; > } >Index: nash/devtree.h >=================================================================== >--- nash/devtree.h.orig 2007-09-21 05:03:03.000000000 -0300 >+++ nash/devtree.h 2007-10-14 22:39:37.000000000 -0200 >@@ -53,6 +53,8 @@ struct nash_dev_node { > > struct nash_dev_tree *tree; > >+ struct nash_slave_list *slave_cache; >+ > int probe_mask; > }; >
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 277271
: 226841