From 3724f6745435a4c54fe420f86bb97343d6095fd8 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 11 Jan 2012 18:52:17 +0000 Subject: [PATCH] repair: fix an ABBA deadlock in inode prefetching MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The inode prefetching code has a fixed limit of inodes that might are submitted at a time. Unfortunately the buffers for them get locked once the prefetching starts. That way the threads processing the inode might get stuck on buffer locked, but not submitted for reading yet. Fix this by kicking the queue as soon as we would have to wait on the ra_count semaphore. Reviewed-by: Dave Chinner Reported-by: Arkadiusz Miśkiewicz Tested-by: Arkadiusz Miśkiewicz Signed-off-by: Christoph Hellwig --- repair/prefetch.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/repair/prefetch.c b/repair/prefetch.c index 0e1167ec6..c0b100225 100644 --- a/repair/prefetch.c +++ b/repair/prefetch.c @@ -641,7 +641,18 @@ pf_queuing_worker( pftrace("queuing irec %p in AG %d, sem count = %d", irec, args->agno, i); #endif - sem_wait(&args->ra_count); + err = sem_trywait(&args->ra_count); + if (err == EAGAIN) { + /* + * Kick the queue once we have reached the limit; + * without this the threads processing the inodes + * might get stuck on a buffer that has been locked + * and added to the I/O queue but is waiting for + * the thread to be woken. + */ + pf_start_io_workers(args); + sem_wait(&args->ra_count); + } num_inos = 0; bno = XFS_AGINO_TO_AGBNO(mp, cur_irec->ino_startnum); -- 2.47.2