diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2008-10-18 13:39:04 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-18 15:28:49 +0200 |
commit | 836dcf951c0f6c4f76f7b194d5bb96d1cbb5366f (patch) | |
tree | fdad6d8324b7ccd2e8edb737c313f0c8645d2562 /udev | |
parent | d0db192fa5a50eee27bce3e92c89f3ec1294638d (diff) |
udevd: avoid overhead of calling rmdir on non-empty directories
Unfortunately the linux rmdir implementation unhashes the dentry
even when the directory is not removed. This is apparently by
design (for filesystems that don't allow deleting open files).
Results from time(1) and oprofile follow.
Before:
0.35user 0.90system
samples % image name symbol name
608 9.6738 vmlinux shrink_dcache_parent
293 4.6619 vmlinux copy_page_c
271 4.3119 vmlinux copy_page_range
257 4.0891 udevd udev_rules_iter_next
After:
0.31user 0.67system
samples % image name symbol name
361 5.0419 vmlinux copy_page_range
322 4.4972 udevd udev_rules_iter_next
300 4.1899 vmlinux copy_page_c
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Diffstat (limited to 'udev')
-rw-r--r-- | udev/udevd.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/udev/udevd.c b/udev/udevd.c index 918825ae50..d5c12ad56c 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -108,8 +108,8 @@ static void export_event_state(struct udev_event *event, enum event_state state) switch (state) { case EVENT_QUEUED: - unlink(filename_failed); - delete_path(event->udev, filename_failed); + if(unlink(filename_failed) == 0) + delete_path(event->udev, filename_failed); create_path(event->udev, filename); udev_selinux_setfscreatecon(event->udev, filename, S_IFLNK); symlink(udev_device_get_devpath(event->dev), filename); @@ -130,12 +130,15 @@ static void export_event_state(struct udev_event *event, enum event_state state) info(event->udev, "renamed devpath, moved failed state of '%s' to %s'\n", udev_device_get_devpath_old(event->dev), udev_device_get_devpath(event->dev)); } else { - unlink(filename_failed); - delete_path(event->udev, filename_failed); + if (unlink(filename_failed) == 0) + delete_path(event->udev, filename_failed); } unlink(filename); - delete_path(event->udev, filename); + + /* clean up possibly empty queue directory */ + if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list)) + delete_path(event->udev, filename); break; case EVENT_FAILED: /* move failed event to the failed directory */ @@ -143,7 +146,8 @@ static void export_event_state(struct udev_event *event, enum event_state state) rename(filename, filename_failed); /* clean up possibly empty queue directory */ - delete_path(event->udev, filename); + if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list)) + delete_path(event->udev, filename); break; } |