Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5225154ybl; Tue, 27 Aug 2019 01:06:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFUoK8OlnwkiS7PTs1wxWOAODV5RqF07nZ009yMKfEA775/uFLXW7ylsdukV8RDPY5DuES X-Received: by 2002:a17:902:1024:: with SMTP id b33mr22583928pla.325.1566893163293; Tue, 27 Aug 2019 01:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893163; cv=none; d=google.com; s=arc-20160816; b=szfKNd/P4X4lJ0pdsQWGsiSe0PWqjvYi3Zz21xcyGOtqGImanhHmKtGEHPY7bs1HKP LRrfK6zXDfzjpIxcGuP2RFA/1Ka9ytFueGsqcE3o9R4snk0CgndHCyf7+4Q7Q/O40KVL gXmH+/cmQapDju0D2yTWDeBM1UkxNe8U1+cgPXOsZ7G6ejKWjzMHOUSwtET13/rEw9m1 6LUnXl7Ai39MK+aj3r6/d8rUM2GqIltMC5RLrk3AepbTeMzB+9UrqvM/dQlWacAORS4E Zp4HPyCYv6vn6G9zFUFBSIOa71K0j1cx7lA6PsA0KRJv+6X6anQ7y1wdEtf9632xzQHk xR3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=In8gEI4hmxGlWxZbLOZYrbFviU3UaNpk3Aj5OqiuKSk=; b=t988l8R3wViwT7pLzhd961xMfrouwkDl/OBgwEWBasI+QLzXkMhY4zgttBhpzd9Qlt /LnmH/0g8Ku5swSst5pD/NvEbBbhASTIKmFNT+Yu48ibQnvDoHFNpWyNXJOUyZ7oYq6x x0JxpQFNB7PH1TzC2oaIt8NCjKPgxR5Tf3X5Bf6qJtZtDSNwtNrhBtaUaWkmzOP3lSiI 52QABunudtJ0S44aBNKCr7/2RJJg0uYAF198b5P0UJ1aybLVBm4c27fJ9uf0N+JgSfh4 y/mPN43fAaFlfodB52gNjRrxwo9USfpdJGk3LGxMHp+qyl6QeQb8nVAGDZwC81OHzWQ4 oHZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=clqZXhBa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si11684370pls.424.2019.08.27.01.05.48; Tue, 27 Aug 2019 01:06:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=clqZXhBa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732618AbfH0IEn (ORCPT + 99 others); Tue, 27 Aug 2019 04:04:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:34212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732596AbfH0IEk (ORCPT ); Tue, 27 Aug 2019 04:04:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F2BD2206BA; Tue, 27 Aug 2019 08:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566893079; bh=oGMu7964CB6be4jEUfkBOIoFb1y40DkPzf6AAwMwvEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=clqZXhBaH5ehpuWCbOQ5iES8WLKFjLeGKQ3hHGq1NhNYgeNbmGivd2wb0ABkZwdjO gAljKX9B0Lzhhazz0Ou5rllauq176kgzitEmXaVyKKM/BuXidSkB8H2HjgWHubpbpC ZarrokGLPZVN7B59ep0tEXI4RhmBpIO1dgnlMLkk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.2 114/162] Revert "dm bufio: fix deadlock with loop device" Date: Tue, 27 Aug 2019 09:50:42 +0200 Message-Id: <20190827072742.370068838@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka commit cf3591ef832915892f2499b7e54b51d4c578b28c upstream. Revert the commit bd293d071ffe65e645b4d8104f9d8fe15ea13862. The proper fix has been made available with commit d0a255e795ab ("loop: set PF_MEMALLOC_NOIO for the worker thread"). Note that the fix offered by commit bd293d071ffe doesn't really prevent the deadlock from occuring - if we look at the stacktrace reported by Junxiao Bi, we see that it hangs in bit_wait_io and not on the mutex - i.e. it has already successfully taken the mutex. Changing the mutex from mutex_lock to mutex_trylock won't help with deadlocks that happen afterwards. PID: 474 TASK: ffff8813e11f4600 CPU: 10 COMMAND: "kswapd0" #0 [ffff8813dedfb938] __schedule at ffffffff8173f405 #1 [ffff8813dedfb990] schedule at ffffffff8173fa27 #2 [ffff8813dedfb9b0] schedule_timeout at ffffffff81742fec #3 [ffff8813dedfba60] io_schedule_timeout at ffffffff8173f186 #4 [ffff8813dedfbaa0] bit_wait_io at ffffffff8174034f #5 [ffff8813dedfbac0] __wait_on_bit at ffffffff8173fec8 #6 [ffff8813dedfbb10] out_of_line_wait_on_bit at ffffffff8173ff81 #7 [ffff8813dedfbb90] __make_buffer_clean at ffffffffa038736f [dm_bufio] #8 [ffff8813dedfbbb0] __try_evict_buffer at ffffffffa0387bb8 [dm_bufio] #9 [ffff8813dedfbbd0] dm_bufio_shrink_scan at ffffffffa0387cc3 [dm_bufio] #10 [ffff8813dedfbc40] shrink_slab at ffffffff811a87ce #11 [ffff8813dedfbd30] shrink_zone at ffffffff811ad778 #12 [ffff8813dedfbdc0] kswapd at ffffffff811ae92f #13 [ffff8813dedfbec0] kthread at ffffffff810a8428 #14 [ffff8813dedfbf50] ret_from_fork at ffffffff81745242 Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Fixes: bd293d071ffe ("dm bufio: fix deadlock with loop device") Depends-on: d0a255e795ab ("loop: set PF_MEMALLOC_NOIO for the worker thread") Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-bufio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -1599,7 +1599,9 @@ dm_bufio_shrink_scan(struct shrinker *sh unsigned long freed; c = container_of(shrink, struct dm_bufio_client, shrinker); - if (!dm_bufio_trylock(c)) + if (sc->gfp_mask & __GFP_FS) + dm_bufio_lock(c); + else if (!dm_bufio_trylock(c)) return SHRINK_STOP; freed = __scan(c, sc->nr_to_scan, sc->gfp_mask);