Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2927911rwb; Mon, 15 Aug 2022 14:13:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wq8cAmRQZWh1wir7TZ/RDWcyDWSVB7qLp7xBHcjMuvbeuJNkEvTgZbPEFAh96yIIWL4wU X-Received: by 2002:a17:903:244c:b0:171:59be:6762 with SMTP id l12-20020a170903244c00b0017159be6762mr17070178pls.20.1660598004200; Mon, 15 Aug 2022 14:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598004; cv=none; d=google.com; s=arc-20160816; b=zTd0NgJc0rM9gSxmsmKs1qlmiL7sDk+KsjFxPt1CXnIuTPToWksFcs8Hm5/bC6oP3l t7TvuskpiyhFqdme08KVYHSwRfRGiGq2yhMgIhzro+ScBilVRThcJIEpK/MSR4IEhIVo QMoNDBFmz+V4GyQESM0Vs7tOUFgjtUQyKlrQSAaLXvBtJxVKr9rsM1IeI0ZFQDu5BjHE lVGTPSTzCLFRE1DhBHq5FkTZZ3Ak7B+YwunMltUUuSH8y2WCC2++roKVx5L46iLkURCC gCcTDnAcgAGlB+DIL5CiX96HTZoaOLyLZDfDMH9YVHHQLCBDEQzoA+W+hfBtmYN50s/d sRfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h2xgmp+L5x2EEtPa8uQ+9JeqHFqjLRckT4kJFkCk9R4=; b=XCfccH+LmqdbBvvAunbqfNVV2hoEf6mIhT7pSsGdKSWSUOzNCNu+PMcPBxg7fTBOHG WV8yKg5IcwGWDBUs+8AKjbxYQJXGfeNMh9agFLFHoZ2oD1IOOMqUW1Q8PBVLjLC+evo2 coDpKY/+FHAF9lekdvx4/IulOzWNWapwuc2wJ2UnV2YIYLSVG08gSS6zs0h4CCvsp9kB +mV1dIAcKBiGS0cFK83BNtpnfxBxtQgzHAXiJYxEkO+/8lvntvqRHbYesr4EwB0KHo7u RTp49kAQf/1PV7CA0IdZ476ERM3dcM3d+4xvtT7kkf4ptZmA+93ewzlUbJqg4UV6hN/+ YBBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="l/xJm9Mx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a656d96000000b00423c60eedc8si8676461pgb.24.2022.08.15.14.13.12; Mon, 15 Aug 2022 14:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="l/xJm9Mx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345950AbiHOUt2 (ORCPT + 99 others); Mon, 15 Aug 2022 16:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346584AbiHOUs1 (ORCPT ); Mon, 15 Aug 2022 16:48:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70CCB8F0D; Mon, 15 Aug 2022 12:09:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BE41BB81106; Mon, 15 Aug 2022 19:09:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2469DC433C1; Mon, 15 Aug 2022 19:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590539; bh=dC3DNuwK+mEw99lMl/mt9cbWGoqxAMyTQd+LbtZwKyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l/xJm9MxQVD4dr/fQBCzIJL3zGriHhm7NaCGlvRRoXvYE7sB9yozci2vrK1jQISnj U9ijWmr2sDD5Ilf1yEDwRp8SiO7DVArW/TdS7ldYy2kFsaBP93M9+TZcdCcDWEvKEL 2H5A17xZZlxL+7gIn+cnGNyFIPOkdNYcxK4vRR30= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuwen Chen , Gao Xiang , Sasha Levin Subject: [PATCH 5.18 0264/1095] erofs: wake up all waiters after z_erofs_lzma_head ready Date: Mon, 15 Aug 2022 19:54:23 +0200 Message-Id: <20220815180440.666998143@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yuwen Chen [ Upstream commit 2df7c4bd7c1d2bc5ece5e9ed19dbd386810c2a65 ] When the user mounts the erofs second times, the decompression thread may hung. The problem happens due to a sequence of steps like the following: 1) Task A called z_erofs_load_lzma_config which obtain all of the node from the z_erofs_lzma_head. 2) At this time, task B called the z_erofs_lzma_decompress and wanted to get a node. But the z_erofs_lzma_head was empty, the Task B had to sleep. 3) Task A release nodes and push nodes into the z_erofs_lzma_head. But task B was still sleeping. One example report when the hung happens: task:kworker/u3:1 state:D stack:14384 pid: 86 ppid: 2 flags:0x00004000 Workqueue: erofs_unzipd z_erofs_decompressqueue_work Call Trace: __schedule+0x281/0x760 schedule+0x49/0xb0 z_erofs_lzma_decompress+0x4bc/0x580 ? cpu_core_flags+0x10/0x10 z_erofs_decompress_pcluster+0x49b/0xba0 ? __update_load_avg_se+0x2b0/0x330 ? __update_load_avg_se+0x2b0/0x330 ? update_load_avg+0x5f/0x690 ? update_load_avg+0x5f/0x690 ? set_next_entity+0xbd/0x110 ? _raw_spin_unlock+0xd/0x20 z_erofs_decompress_queue.isra.0+0x2e/0x50 z_erofs_decompressqueue_work+0x30/0x60 process_one_work+0x1d3/0x3a0 worker_thread+0x45/0x3a0 ? process_one_work+0x3a0/0x3a0 kthread+0xe2/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 Signed-off-by: Yuwen Chen Fixes: 622ceaddb764 ("erofs: lzma compression support") Reviewed-by: Gao Xiang Link: https://lore.kernel.org/r/20220626224041.4288-1-chenyuwen1@meizu.com Signed-off-by: Gao Xiang Signed-off-by: Sasha Levin --- fs/erofs/decompressor_lzma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/erofs/decompressor_lzma.c b/fs/erofs/decompressor_lzma.c index 05a3063cf2bc..5e59b3f523eb 100644 --- a/fs/erofs/decompressor_lzma.c +++ b/fs/erofs/decompressor_lzma.c @@ -143,6 +143,7 @@ int z_erofs_load_lzma_config(struct super_block *sb, DBG_BUGON(z_erofs_lzma_head); z_erofs_lzma_head = head; spin_unlock(&z_erofs_lzma_lock); + wake_up_all(&z_erofs_lzma_wq); z_erofs_lzma_max_dictsize = dict_size; mutex_unlock(&lzma_resize_mutex); -- 2.35.1