Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1135263pxj; Tue, 18 May 2021 22:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvURIKUnMImQY+9KGQdU6qEJjhkaDI+yW/SxnCWQvoOqlgJQRDI2WYANrqe+0Hmiugk2VY X-Received: by 2002:a05:6402:2788:: with SMTP id b8mr12186651ede.140.1621402652389; Tue, 18 May 2021 22:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621402652; cv=none; d=google.com; s=arc-20160816; b=RHe3mMN+VXG0fEAk0beckuPpaSunj3DylmJH6I3GxObBxyQpQa/YUvJ+zfbSsoDaPQ Xcm/x9euTzS/tYpla4rdF3BS/A6yObxFJsB0L4cpaNsp3v/mV0z+RG6ROAo7/jNKGAN0 rjYH2VZB35V/4JX+t8jJ51xA093VaQmlwYHILgYkGsYxJ6O+2TC3Z0aEyy68AnQEGOyc 41xOzWSjWUZ45tyZnH7VqIkAF41g6zq1Prk/6wrWIFaxTmwxyjCrYRVh9J0G+2S19N7+ L8FXJAMBhHMLJEorJ7TGiyc6q+5o2PwDluxYg/4Q7aNCGc6NiIntnYByb8Jh+xpISADA nfhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=aouQKh036Ya2eKwL9c7TDRmniuxaLcoY3uYrUl1w5zg=; b=qIcJjGjZ50kL+5mNQt0kXO8KTMsCEogpPKbp/qywcpBjtJPqiKoNxKcNdA8QoPYzvE cjtcr+dBujYk/ON4b7UDcZnoyQQpeTIpYjffE6v6H3xunPll+FlRRLTNQqwX96RjXGGV dlAEiLhhW+mgooJa+YB72urp2jImHJTFBVn8cYW3g6PGlkYU6S/mUDGgSDcHUK6VuKBk zWbNwOcPyJ21qkIKmQpb8RAF2SSJGL6oyzHCzwjyx/eSsIAU+WIYRgVXhflKi9wN5YjG CUFnKwlRrOeIME2X5YoYcsEUQm2ywbkIqzOrUnPbBDeQ/7QgmL0Gx5Rnf+ouBt67EM60 F8Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df11si2460412edb.250.2021.05.18.22.37.01; Tue, 18 May 2021 22:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242813AbhEQUxd (ORCPT + 99 others); Mon, 17 May 2021 16:53:33 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:60428 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237148AbhEQUxd (ORCPT ); Mon, 17 May 2021 16:53:33 -0400 Received: from callcc.thunk.org (96-72-102-169-static.hfc.comcastbusiness.net [96.72.102.169] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 14HKqATe012357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 16:52:12 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id 650BB420119; Mon, 17 May 2021 16:52:10 -0400 (EDT) Date: Mon, 17 May 2021 16:52:10 -0400 From: "Theodore Y. Ts'o" To: Wang Jianchao Cc: Andreas Dilger , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ext4: get discard out of jbd2 commit kthread Message-ID: References: <53146e54-af36-0c32-cad8-433460461237@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53146e54-af36-0c32-cad8-433460461237@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, May 17, 2021 at 11:57:09AM +0800, Wang Jianchao wrote: > Right now, discard is issued and waited to be completed in jbd2 > commit kthread context after the logs are committed. When large > amount of files are deleted and discard is flooding, jbd2 commit > kthread can be blocked for long time. Then all of the metadata > operations can be blocked to wait the log space. > > One case is the page fault path with read mm->mmap_sem held, which > wants to update the file time but has to wait for the log space. > When other threads in the task wants to do mmap, then write mmap_sem > is blocked. Finally all of the following read mmap_sem requirements > are blocked, even the ps command which need to read the /proc/pid/ > -cmdline. Our monitor service which needs to read /proc/pid/cmdline > used to be blocked for 5 mins. > > This patch moves the discard out of jbd2 kthread context and do it > in kworker. And drain the kwork when cannot get space in mb buddy. > This is done out of jbd2 handle and won't block the commit process. > After that, we could use blk-wbt or other method to throttle the > discard and needn't to worry it block the jbd2 commit kthread any > more. Wouldn't be much simpler to do something like this? if (discard_bio) { - submit_bio_wait(discard_bio); - bio_put(discard_bio); + submit_bio(discard_bio); } We're throwing away the return value from submit_bio_wait(), so there's no real need to wait for I/O to complete so we can fetch the I/O status. That way we don't need to move all of this to a kworker context. - Ted