[Pkg-libvirt-commits] [libguestfs] 07/12: daemon: Run udev_settle after pwrite-device finishes (RHBZ#1141451).
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:45:28 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.45-1
in repository libguestfs.
commit 4515413217c7d4a6fe026254bffa6f82746047c4
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Thu Jan 19 13:54:50 2012 +0000
daemon: Run udev_settle after pwrite-device finishes (RHBZ#1141451).
When you call close on any block device, udev kicks off a rule which
runs blkid to reexamine the device. We need to wait for this rule to
finish running since it holds the device open and can cause other
operations to fail, notably mkfs.
(cherry picked from commit a9c8123c72db47bcab8dd738e8d5256a9ae87f11)
---
daemon/file.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/daemon/file.c b/daemon/file.c
index f1be51a..cdf1661 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -378,7 +378,7 @@ do_pread_device (const char *device, int count, int64_t offset, size_t *size_r)
static int
pwrite_fd (int fd, const char *content, size_t size, int64_t offset,
- const char *display_path)
+ const char *display_path, int settle)
{
ssize_t r;
@@ -394,6 +394,18 @@ pwrite_fd (int fd, const char *content, size_t size, int64_t offset,
return -1;
}
+ /* When you call close on any block device, udev kicks off a rule
+ * which runs blkid to reexamine the device. We need to wait for
+ * this rule to finish running since it holds the device open and
+ * can cause other operations to fail, notably BLKRRPART. 'settle'
+ * flag is only set on block devices.
+ *
+ * XXX We should be smarter about when we do this or should get rid
+ * of the udev rules since we don't use blkid in cached mode.
+ */
+ if (settle)
+ udev_settle ();
+
return r;
}
@@ -416,7 +428,7 @@ do_pwrite (const char *path, const char *content, size_t size, int64_t offset)
return -1;
}
- return pwrite_fd (fd, content, size, offset, path);
+ return pwrite_fd (fd, content, size, offset, path, 0);
}
int
@@ -434,7 +446,7 @@ do_pwrite_device (const char *device, const char *content, size_t size,
return -1;
}
- return pwrite_fd (fd, content, size, offset, device);
+ return pwrite_fd (fd, content, size, offset, device, 1);
}
/* This runs the 'file' command. */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list