Any objection against the patch below? Karel >From e90709421ac86e2e81498143f75734e0b79f76d1 Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@xxxxxxxxxx> Date: Wed, 6 Jan 2010 11:12:43 +0100 Subject: [PATCH] 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@xxxxxxxxxx> --- fdisk/cfdisk.c | 8 ++++---- fdisk/fdisk.c | 2 -- fdisk/sfdisk.c | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 0405e12..eec1689 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 af525ba..5ef24f6 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 0652cfa..6ac91f0 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); } -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html