From 101dca2f18eb1435332a3faa8e15a1787f814887 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 13 Jan 2024 23:35:31 +0100 Subject: [PATCH] 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. --- libfdisk/src/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); } -- 2.47.3