From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udevd: avoid overhead of calling rmdir on non-empty directories
Date: Sat, 18 Oct 2008 12:39:04 +0000 [thread overview]
Message-ID: <48F9D8E8.8060300@tuffmail.co.uk> (raw)
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>
diff --git a/udev/udevd.c b/udev/udevd.c
index 576f9e8..4b0c2e8 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -109,8 +109,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);
@@ -131,12 +131,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 */
@@ -144,7 +147,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;
}
next reply other threads:[~2008-10-18 12:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-18 12:39 Alan Jenkins [this message]
2008-10-18 13:30 ` [PATCH] udevd: avoid overhead of calling rmdir on non-empty directories Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48F9D8E8.8060300@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).