aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-11-20 13:53:56 -0600
committerEric Sandeen <sandeen@redhat.com>2017-11-20 13:53:56 -0600
commit255c38f87394bc38b0e35b60627f7cb26a4a80bb (patch)
tree683554a05411fafea4bfb16dd956b2e6f2ca65ec
parentac9a7bc98eecf7589fcc21568527ce00719b24c0 (diff)
downloadxfsprogs-dev-255c38f87394bc38b0e35b60627f7cb26a4a80bb.tar.gz
xfs_copy: don't hang if /all/ the targets hit write errors
If xfs_copy is told to copy a filesystem and /all/ the writer threads hit an write error, there won't be any threads to unlock mainwait, which means that write_wbuf will deadlock with itself trying to lock mainwait. Therefore, if we discover that all the writer threads are dead, just bail out. Discovered by running xfs/073 with a tiny test device. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--copy/xfs_copy.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 33e05dfd36..fb37375db0 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -476,6 +476,7 @@ void
write_wbuf(void)
{
int i;
+ int badness = 0;
/* verify target threads */
for (i = 0; i < num_targets; i++)
@@ -486,6 +487,17 @@ write_wbuf(void)
for (i = 0; i < num_targets; i++)
if (target[i].state != INACTIVE)
pthread_mutex_unlock(&targ[i].wait); /* wake up */
+ else
+ badness++;
+
+ /*
+ * If all the targets are inactive then there won't be any io
+ * threads left to release mainwait. We're screwed, so bail out.
+ */
+ if (badness == num_targets) {
+ check_errors();
+ exit(1);
+ }
signal_maskfunc(SIGCHLD, SIG_UNBLOCK);
pthread_mutex_lock(&mainwait);