Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1117955ybx; Wed, 30 Oct 2019 10:07:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpGVrz0Cwpbh+QtehlmPaW1MDs5AidHshPiuOoWoemCZMBsdnUN1qaiz5JSP30N+LM3VEt X-Received: by 2002:a17:906:c44f:: with SMTP id ck15mr117591ejb.7.1572455277293; Wed, 30 Oct 2019 10:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572455277; cv=none; d=google.com; s=arc-20160816; b=BMEhzE1PHHhS7S6HGihd+ZOmE9ytCOeeafeBDr5bveQHH67Oko/On4DQ5ujpSGR4xk R7wHBGgrzYl6By1KlO8yJ4D+CYSJGOCl/JS3B+sZa/y6I82Ny+aTQgUo8GQkqIUf2BbT 8afOWNm3cnqYZR9l61TtaKuOyjiCdTWkDPtEUAK1iVCy+tdfIB88l95wcsOnb8gqT+ys ZfnAUXvIeJQipKbs6iksaFPDn30UEwGBw1/OJusMvqvtyWod1FG0z3c5Funny/u9t3LS /2CSqkyP7Sr+CwAwSipx+Etb6lMMcZaCaS6E5RnYVvqh3Te9lL55Eg8hj8cwIvjUmiKM 1SYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=fvyvxoRwDboaoj51ITGUwr/ZtYUfTwPK1LoJUkOwM6I=; b=Tw+aF5006t8uPcoBzBCO9Uq+hdozKw8/pylcb5RkhEN95cawV9BHkJ+8/Kdk9Q/Hpd QlGLOCVAdA7UPvcmWDnPp/sNOBjqO07qumkMikfrRpxEHG+VIvuWUP6EBLwKf3brJtuH 0MJInzMfOvSQnH57ZUlYxjf065YIZqWQGU8vSf5OhFlmH2HRZEWzUNXOD2FwBd5gfjhg xi/xJPZZU4DbwMhyNzirhYzT7CrCBFq/y9tiNfWXbH7MqJmZV/+sokaahMjwOvUjqIEp Y9Z3q21/iRJ/g7fIUPPEW+/9IRorPBJTht8X3ivaOTKZp6kVt6Di+B5xYmDMcRnFDVV0 qjXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qlid3cbS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16si1653022eji.304.2019.10.30.10.07.33; Wed, 30 Oct 2019 10:07:57 -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=Qlid3cbS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbfJ3RCu (ORCPT + 99 others); Wed, 30 Oct 2019 13:02:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbfJ3RCt (ORCPT ); Wed, 30 Oct 2019 13:02:49 -0400 Received: from sol.localdomain (c-24-5-143-220.hsd1.ca.comcast.net [24.5.143.220]) (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 6A82020650; Wed, 30 Oct 2019 17:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572454968; bh=pDmWHhgixxSGSlKcG7JAEENyJI4HshThaEn6KOyP4vo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Qlid3cbSHifQ5VBTBwWCswcADBqOYlpYNTDwf18VN+2n0WwB98+Zk2NE12TtkO7VZ RchFjNgMFSiOxgytvgE1gHS8eoJ3KsezXMVzIY3ylNRKv/nww7t/trpPdz5rgY1je/ OjWRmIQCVFBnYSuVgOMHOUMuDJqxFspxdMM4fUak= Date: Wed, 30 Oct 2019 10:02:46 -0700 From: Eric Biggers To: Chao Yu Cc: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH 2/2] f2fs: support data compression Message-ID: <20191030170246.GB693@sol.localdomain> Mail-Followup-To: Chao Yu , Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20191022171602.93637-1-jaegeuk@kernel.org> <20191022171602.93637-2-jaegeuk@kernel.org> <20191027225006.GA321938@sol.localdomain> <20191030025512.GA4791@sol.localdomain> <97c33fa1-15af-b319-29a1-22f254a26c0a@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97c33fa1-15af-b319-29a1-22f254a26c0a@huawei.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 30, 2019 at 04:43:52PM +0800, Chao Yu wrote: > >>>> static void bio_post_read_processing(struct bio_post_read_ctx *ctx) > >>>> { > >>>> - /* > >>>> - * We use different work queues for decryption and for verity because > >>>> - * verity may require reading metadata pages that need decryption, and > >>>> - * we shouldn't recurse to the same workqueue. > >>>> - */ > >>> > >>> Why is it okay (i.e., no deadlocks) to no longer use different work queues for > >>> decryption and for verity? See the comment above which is being deleted. > >> > >> Could you explain more about how deadlock happen? or share me a link address if > >> you have described that case somewhere? > >> > > > > The verity work can read pages from the file which require decryption. I'm > > concerned that it could deadlock if the work is scheduled on the same workqueue. > > I assume you've tried one workqueue, and suffered deadlock.. > > > Granted, I'm not an expert in Linux workqueues, so if you've investigated this > > and determined that it's safe, can you explain why? > > I'm not familiar with workqueue... I guess it may not safe that if the work is > scheduled to the same cpu in where verity was waiting for data? if the work is > scheduled to other cpu, it may be safe. > > I can check that before splitting the workqueue for verity and decrypt/decompress. > Yes this is a real problem, try 'kvm-xfstests -c f2fs/encrypt generic/579'. The worker thread gets deadlocked in f2fs_read_merkle_tree_page() waiting for the Merkle tree page to be decrypted. This is with the v2 compression patch; it works fine on current mainline. INFO: task kworker/u5:0:61 blocked for more than 30 seconds. Not tainted 5.4.0-rc1-00119-g464e31ba60d0 #13 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u5:0 D 0 61 2 0x80004000 Workqueue: f2fs_post_read_wq f2fs_post_read_work Call Trace: context_switch kernel/sched/core.c:3384 [inline] __schedule+0x299/0x6c0 kernel/sched/core.c:4069 schedule+0x44/0xd0 kernel/sched/core.c:4136 io_schedule+0x11/0x40 kernel/sched/core.c:5780 wait_on_page_bit_common mm/filemap.c:1174 [inline] wait_on_page_bit mm/filemap.c:1223 [inline] wait_on_page_locked include/linux/pagemap.h:527 [inline] wait_on_page_locked include/linux/pagemap.h:524 [inline] wait_on_page_read mm/filemap.c:2767 [inline] do_read_cache_page+0x407/0x660 mm/filemap.c:2810 read_cache_page+0xd/0x10 mm/filemap.c:2894 f2fs_read_merkle_tree_page+0x2e/0x30 include/linux/pagemap.h:396 verify_page+0x110/0x560 fs/verity/verify.c:120 fsverity_verify_bio+0xe6/0x1a0 fs/verity/verify.c:239 verity_work fs/f2fs/data.c:142 [inline] f2fs_post_read_work+0x36/0x50 fs/f2fs/data.c:160 process_one_work+0x225/0x550 kernel/workqueue.c:2269 worker_thread+0x4b/0x3c0 kernel/workqueue.c:2415 kthread+0x125/0x140 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 INFO: task kworker/u5:1:1140 blocked for more than 30 seconds. Not tainted 5.4.0-rc1-00119-g464e31ba60d0 #13 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u5:1 D 0 1140 2 0x80004000 Workqueue: f2fs_post_read_wq f2fs_post_read_work Call Trace: context_switch kernel/sched/core.c:3384 [inline] __schedule+0x299/0x6c0 kernel/sched/core.c:4069 schedule+0x44/0xd0 kernel/sched/core.c:4136 io_schedule+0x11/0x40 kernel/sched/core.c:5780 wait_on_page_bit_common mm/filemap.c:1174 [inline] wait_on_page_bit mm/filemap.c:1223 [inline] wait_on_page_locked include/linux/pagemap.h:527 [inline] wait_on_page_locked include/linux/pagemap.h:524 [inline] wait_on_page_read mm/filemap.c:2767 [inline] do_read_cache_page+0x407/0x660 mm/filemap.c:2810 read_cache_page+0xd/0x10 mm/filemap.c:2894 f2fs_read_merkle_tree_page+0x2e/0x30 include/linux/pagemap.h:396 verify_page+0x110/0x560 fs/verity/verify.c:120 fsverity_verify_bio+0xe6/0x1a0 fs/verity/verify.c:239 verity_work fs/f2fs/data.c:142 [inline] f2fs_post_read_work+0x36/0x50 fs/f2fs/data.c:160 process_one_work+0x225/0x550 kernel/workqueue.c:2269 worker_thread+0x4b/0x3c0 kernel/workqueue.c:2415 kthread+0x125/0x140 kernel/kthread.c:255 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352 Showing all locks held in the system: 1 lock held by khungtaskd/21: #0: ffffffff82250520 (rcu_read_lock){....}, at: rcu_lock_acquire.constprop.0+0x0/0x30 include/trace/events/lock.h:13 2 locks held by kworker/u5:0/61: #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: set_work_data kernel/workqueue.c:619 [inline] #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline] #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: process_one_work+0x1ad/0x550 kernel/workqueue.c:2240 #1: ffffc90000253e50 ((work_completion)(&ctx->work)){+.+.}, at: set_work_data kernel/workqueue.c:619 [inline] #1: ffffc90000253e50 ((work_completion)(&ctx->work)){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline] #1: ffffc90000253e50 ((work_completion)(&ctx->work)){+.+.}, at: process_one_work+0x1ad/0x550 kernel/workqueue.c:2240 2 locks held by kworker/u5:1/1140: #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: set_work_data kernel/workqueue.c:619 [inline] #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline] #0: ffff88807b78eb28 ((wq_completion)f2fs_post_read_wq){+.+.}, at: process_one_work+0x1ad/0x550 kernel/workqueue.c:2240 #1: ffffc9000174be50 ((work_completion)(&ctx->work)){+.+.}, at: set_work_data kernel/workqueue.c:619 [inline] #1: ffffc9000174be50 ((work_completion)(&ctx->work)){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:647 [inline] #1: ffffc9000174be50 ((work_completion)(&ctx->work)){+.+.}, at: process_one_work+0x1ad/0x550 kernel/workqueue.c:2240