From: наб Date: Sat, 13 Jan 2024 22:35:31 +0000 (+0100) Subject: libfdisk: fdisk_deassign_device: only sync(2) blockdevs X-Git-Tag: v2.40-rc1~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=101dca2f18eb1435332a3faa8e15a1787f814887;p=thirdparty%2Futil-linux.git libfdisk: fdisk_deassign_device: only sync(2) blockdevs When not editing a blockdev, syncing disks provides no benefit (we already fsync() above), takes a long time, and affects unrelated caches. BLKRRPART is similarly gated on !S_ISBLK(st_mode) in fdisk_reread_partition_table. --- diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 0d221242e5..463a60f863 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -773,7 +773,7 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync) cxt->dev_path); return -errno; } - if (!nosync) { + if (S_ISBLK(cxt->dev_st.st_mode) && !nosync) { fdisk_info(cxt, _("Syncing disks.")); sync(); }