From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3BD9C636D4 for ; Mon, 13 Feb 2023 08:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbjBMIiI (ORCPT ); Mon, 13 Feb 2023 03:38:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjBMIiG (ORCPT ); Mon, 13 Feb 2023 03:38:06 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0EDC64F for ; Mon, 13 Feb 2023 00:37:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676277441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/1U70nDIhh0wWRn6i+OpLdwoCB9WNkYfM0LMTWRS+vc=; b=Fs1Fk8oPb0/nyJBYb8TnqdWpFChwzosGCoa4BMPRfIeDPOIkQm945474IF2cehkBbar2jf hGjiqMKoWJI8/N8JqnJxb8Yz8jpD1q8FMjm/MXlQ0D4ZRaWTHR1M+sK3vsN3cKURvn5VLV 5E9nyWcnXpRtfasZm96rC3BCIKub9D8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-230-NwLkK3r0NWKVmM2L7bqWkQ-1; Mon, 13 Feb 2023 03:37:18 -0500 X-MC-Unique: NwLkK3r0NWKVmM2L7bqWkQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2184A858F09; Mon, 13 Feb 2023 08:37:18 +0000 (UTC) Received: from T590 (ovpn-8-31.pek2.redhat.com [10.72.8.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E74BE492B15; Mon, 13 Feb 2023 08:37:14 +0000 (UTC) Date: Mon, 13 Feb 2023 16:37:09 +0800 From: Ming Lei To: Christoph Hellwig Cc: axboe@kernel.dk, linux-block@vger.kernel.org, ming.lei@redhat.com Subject: Re: [PATCH] blk-cgroup: delay calling blkcg_exit_disk until disk_release Message-ID: References: <20230208063514.171485-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Fri, Feb 10, 2023 at 01:05:11PM +0800, Ming Lei wrote: > On Wed, Feb 08, 2023 at 07:35:14AM +0100, Christoph Hellwig wrote: > > While del_gendisk ensures there is no outstanding I/O on the queue, > > it can't prevent block layer users from building new I/O. > > > > This leads to a NULL ->root_blkg reference in bio_associate_blkg when > > allocating a new bio on a shut down file system. Delay freeing the > > blk-cgroup subsystems from del_gendisk until disk_release to make > > sure the blkg and throttle information is still avaŃ–lable for bio > > submitters, even if those bios will immediately fail. > > > > This now can cause a case where disk_release is called on a disk > > that hasn't been added. That's mostly harmless, except for a case > > in blk_throttl_exit that now needs to check for a NULL ->td pointer. > > > > Fixes: 178fa7d49815 ("blk-cgroup: delay blk-cgroup initialization until add_disk") > > Reported-by: Ming Lei > > Signed-off-by: Christoph Hellwig > > hammmmmm, this patch actually causes bigger trouble. > > After commit 84d7d462b16d ("blk-cgroup: pin the gendisk in struct blkcg_gq"), > blkcg_gq instance grabs disk's reference, so moving blkcg_exit_disk > into disk_release() just causes reference cross-dependency, both are > leaked. Hi Christoph & Jens, This issue is a bit serious, both blkg & disk & request_queue are leaked by commit c43332fe028c ("blk-cgroup: delay calling blkcg_exit_disk until disk_release"). Can we solve it before merging for-6.3/block into v6.3-rc1? Thanks, Ming