summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2010-01-06 11:12:43 +0100
committerKarel Zak2010-01-06 11:12:43 +0100
commite90709421ac86e2e81498143f75734e0b79f76d1 (patch)
treeee6cac22d8b65cea4b9363b3a5371a70dd24c16d
parentmount: fix typo in mount.8 (diff)
downloadkernel-qcow2-util-linux-e90709421ac86e2e81498143f75734e0b79f76d1.tar.gz
kernel-qcow2-util-linux-e90709421ac86e2e81498143f75734e0b79f76d1.tar.xz
kernel-qcow2-util-linux-e90709421ac86e2e81498143f75734e0b79f76d1.zip
fdisk: sleep-after-sync and fsync usage
It seems that sleep() after sync() is unnecessary legacy. It's very probably unnecessary since kernel 1.3.20. For example the libparted does not to use sleep() at all. It seems that more important is fsync() usage in fdisks. For more details see http://marc.theaimsgroup.com/?l=linux-kernel&m=105545785306867&w=3 http://marc.theaimsgroup.com/?l=linux-kernel&m=105545848607353&w=3 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Currently we use fsync() in fdisk only. This patch also add fsync() to sfdisk and cfdisk. Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276369 Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=502639 Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisk/cfdisk.c8
-rw-r--r--fdisk/fdisk.c2
-rw-r--r--fdisk/sfdisk.c4
3 files changed, 5 insertions, 9 deletions
diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index 0405e1261..eec16893c 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -406,9 +406,11 @@ partition_type_text(int i) {
static void
fdexit(int ret) {
- if (opened)
+ if (opened) {
+ if (changed)
+ fsync(fd);
close(fd);
-
+ }
if (changed) {
fprintf(stderr, _("Disk has been changed.\n"));
#if 0
@@ -1912,12 +1914,10 @@ write_part_table(void) {
if (is_bdev) {
#ifdef BLKRRPART
sync();
- sleep(2);
if (!ioctl(fd,BLKRRPART))
changed = TRUE;
#endif
sync();
- sleep(4);
clear_warning();
if (changed)
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index af525badd..5ef24f665 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -2519,7 +2519,6 @@ reread_partition_table(int leave) {
i = fstat(fd, &statbuf);
if (i == 0 && S_ISBLK(statbuf.st_mode)) {
sync();
- sleep(2);
#ifdef BLKRRPART
printf(_("Calling ioctl() to re-read partition table.\n"));
i = ioctl(fd, BLKRRPART);
@@ -2550,7 +2549,6 @@ reread_partition_table(int leave) {
printf(_("Syncing disks.\n"));
sync();
- sleep(4); /* for sync() */
exit(!!i);
}
}
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 0652cfa3a..6ac91f07b 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -806,14 +806,13 @@ reread_disk_partition(char *dev, int fd) {
printf(_("Re-reading the partition table ...\n"));
fflush(stdout);
sync();
- sleep(3); /* superfluous since 1.3.20 */
if (reread_ioctl(fd) && is_blockdev(fd))
do_warn(_("The command to re-read the partition table failed.\n"
"Run partprobe(8), kpartx(8) or reboot your system now,\n"
"before using mkfs\n"));
- if (close(fd)) {
+ if (fsync(fd) || close(fd)) {
perror(dev);
do_warn(_("Error closing %s\n"), dev);
}
@@ -3103,6 +3102,5 @@ do_fdisk(char *dev){
"(See fdisk(8).)\n"));
sync(); /* superstition */
- sleep(3);
exit(exit_status);
}