| author | Hans de Goede <hdegoede@redhat.com> | |
| Thu, 27 Aug 2009 18:16:09 +0000 (20:16 +0200) | ||
| committer | Jim Meyering <meyering@redhat.com> | |
| Fri, 28 Aug 2009 07:41:39 +0000 (09:41 +0200) | ||
| commit | ad25892bb995f61b0ddf801ed1f74e0b1e7390ce | |
| tree | 5eb83d2eaf16966bafc3ecfe34ad266daec8f3be | tree | snapshot |
| parent | c3d0c29999af4f3a08e9f5cc7f950f3fd4d2fb53 | commit | diff |
parted: avoid unnecessary open/close on commit, and thus udev activity
* libparted/disk.c (ped_disk_commit): Open/close the underlying file
descriptor in this function, so that callees, ped_disk_commit_to_dev
and ped_disk_commit_to_os do not each perform open/close syscalls.
This saves an open/close pair, and thus avoids unneeded udev
activity on Linux.
Before this change, when calling commit() on a ped_disk, the
following would happen:
open /dev/sda
write partition table
close /dev/sda
open /dev/sda
ioctl (BLKRRPART)
close /dev/sda
This is rather inefficient, and causes 2 udev change events to be fired
for /dev/sda (+ the change events from the BLKRRPART), causing all kind
of scanning (blkid & friends) twice.
This patch fixes things to only open the device once.
* libparted/disk.c (ped_disk_commit): Open/close the underlying file
descriptor in this function, so that callees, ped_disk_commit_to_dev
and ped_disk_commit_to_os do not each perform open/close syscalls.
This saves an open/close pair, and thus avoids unneeded udev
activity on Linux.
Before this change, when calling commit() on a ped_disk, the
following would happen:
open /dev/sda
write partition table
close /dev/sda
open /dev/sda
ioctl (BLKRRPART)
close /dev/sda
This is rather inefficient, and causes 2 udev change events to be fired
for /dev/sda (+ the change events from the BLKRRPART), causing all kind
of scanning (blkid & friends) twice.
This patch fixes things to only open the device once.
| libparted/disk.c | diff | blob | history |
