Received: by 10.192.165.156 with SMTP id m28csp531564imm; Wed, 11 Apr 2018 03:17:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx48vEXW/qqCy9DwqeiGkAo7uZs0nJmwOzv/+7ObpLTACO9BlanDtLjL8kHFMn76H9Sa+3iew X-Received: by 2002:a17:902:6889:: with SMTP id i9-v6mr4364476plk.301.1523441832101; Wed, 11 Apr 2018 03:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523441832; cv=none; d=google.com; s=arc-20160816; b=aSlZPDDKzbr4gVONxvv7/Q5Wodj+zS0VZP6/BIZTC1sP/vT2DATX7q5Apk6zPqL1uJ dqdD/1bF1jwfpaYwt3jnZwWEYbTej2a+YuVkfO1BrFI9SqGfCsa6PdXp5CUMQXCOh4pC vrUafcpsWyC0AmActDpZ82ebtXhGoMzD6Fwynm0c63qhsWP3+7/WcxzIFlaQpleBO9nC XLra0WZJJ+orjjeXaHB2wirCeOcWRLvlUZ8v9OF7grup5l1Y6cvaY1JKaJ320dE+nlji fWji0hI7aCzCy1t9/Su455AzAALLWBkpokmDz52XrvqdgRbgq0kfwk8cxj9R/vnTeGsi c9oA== 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:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+oAcoc4Ejbdw+FY2JEamnx3cSM7lKozYFZjT+qUowmk=; b=IMiU2tM6h4JPdR1/12Qwol+EnnDRt/rb7627G6WqVfM6ofUNNg5sVjx5DJTj18RjXr gfPrrp/eAYDI75o18gvKfTx1InVLBCUq0Ndx/9kcbo++LjEnnJo9/o+FHdQiaau/XfW4 bnl+Oynm8dFUgGv3qPq0z6YxeUmuFBekuxSFNH5BrxOyW5vmogDe2X2c6DwjWuez++xb Wd9CTCHer1SdMzgjzNXgrhTV/PJkfabdMjAWzKxIAByiZqRGFV6J8lPEZS6uFXMJazy/ YyLZycmUdUD9PKjoCWgzHb14Oh/2Uwd+0C8E5bVBb3f/BBEIIAIEOV7gWZXMMCRUtCbB 1TLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cijl2ye0; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si534116pgf.512.2018.04.11.03.16.35; Wed, 11 Apr 2018 03:17:12 -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=@gmail.com header.s=20161025 header.b=cijl2ye0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbeDKKNK (ORCPT + 99 others); Wed, 11 Apr 2018 06:13:10 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36434 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351AbeDKKNF (ORCPT ); Wed, 11 Apr 2018 06:13:05 -0400 Received: by mail-wr0-f194.google.com with SMTP id y55so1195663wry.3; Wed, 11 Apr 2018 03:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+oAcoc4Ejbdw+FY2JEamnx3cSM7lKozYFZjT+qUowmk=; b=cijl2ye0VKjP8Xg26+i415jS5RhEijAK97idlzy9Sa/6TU5evtyaXYEXUMX80sKJ95 dHDeHWZrwKAGxVzyouHfpII/kpSeodgwYr6iCmgK3fprzG/FD/b89cdYLZi6t6WY7D2v vfseVDO4EVXWFp17hqvAc6eHuthwqRbftHGYrA9Hze2iuM1Zfr0oNOnoLAk4lcIXe9f2 p5S+1d+u6Zokg33ltr/FDrYuKLvt4PxIiBKqzrv09NMb9oFMqh4y8usmuAcYSFwiZwz/ WMtdXUIPXTCFqnpdif65A9LJsyhtsPLMmp/FmraudyOIvIdBSf7u4kPFuYDX8+Xfw9I5 couQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+oAcoc4Ejbdw+FY2JEamnx3cSM7lKozYFZjT+qUowmk=; b=fQXBEeu7oamEljtlP/T8osKsri7D12+Y9gz6ztfGndJ7eGJDt2BO5mSAz8Qp8GR/uy Jh+PmrRa7AQgO6JzPKNitxohrBz768U/0VJY7CZOlyjctmZbWMyqJ2DPAlAjnJlkaYU1 9EuVHSWYbreCgFCIv1w/ry8nfmhF50j0yuHsKI9gMaGZSqF9vlE2b+AuvD2XEUKJRgGh BJNgfgMeEhh8WpWa16NvLhamZkL+6MVAaVOHvFfhgUhnVt5OxNtCAeSGxUxUu8QYr/le g4mpHyoGWLpvXmHZS3hpC8BbV82T4h9xirv1tFbuzEQRaSCqIqvRnzSqAUGHrDaJiGXn o2Jw== X-Gm-Message-State: ALQs6tBbhebbbXEa0LfEu65ArCLnlKVHSXo8FumMRKX8dQOHsk3nVWFX 5sD7v9HhepuiWcvIUXbRdk0= X-Received: by 10.223.150.39 with SMTP id b36mr1147643wra.79.1523441584374; Wed, 11 Apr 2018 03:13:04 -0700 (PDT) Received: from gmail.com (51B6C0F5.dsl.pool.telekom.hu. [81.182.192.245]) by smtp.gmail.com with ESMTPSA id s21sm588625wra.66.2018.04.11.03.13.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Apr 2018 03:13:03 -0700 (PDT) Date: Wed, 11 Apr 2018 12:12:56 +0200 From: Alexandru Moise <00moses.alexander00@gmail.com> To: Tejun Heo Cc: axboe@kernel.dk, shli@fb.com, nborisov@suse.com, arnd@arndb.de, gregkh@linuxfoundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Joseph Qi Subject: Re: [PATCH v2] blk-cgroup: remove entries in blkg_tree before queue release Message-ID: <20180411101242.GA2322@gmail.com> References: <20180407102148.GA9729@gmail.com> <20180409220938.GI3126663@devbig577.frc2.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409220938.GI3126663@devbig577.frc2.facebook.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 09, 2018 at 03:09:38PM -0700, Tejun Heo wrote: > (cc'ing Joseph as he worked on the area recently, hi!) > > Hello, > > On Sat, Apr 07, 2018 at 12:21:48PM +0200, Alexandru Moise wrote: > > The q->id is used as an index within the blkg_tree radix tree. > > > > If the entry is not released before reclaiming the blk_queue_ida's id > > blkcg_init_queue() within a different driver from which this id > > was originally for can fail due to the entry at that index within > > the radix tree already existing. > > > > Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> > > --- > > v2: Added no-op for !CONFIG_BLK_CGROUP > > > > block/blk-cgroup.c | 2 +- > > block/blk-sysfs.c | 4 ++++ > > include/linux/blk-cgroup.h | 3 +++ > > 3 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > > index 1c16694ae145..224e937dbb59 100644 > > --- a/block/blk-cgroup.c > > +++ b/block/blk-cgroup.c > > @@ -369,7 +369,7 @@ static void blkg_destroy(struct blkcg_gq *blkg) > > * > > * Destroy all blkgs associated with @q. > > */ > > -static void blkg_destroy_all(struct request_queue *q) > > +void blkg_destroy_all(struct request_queue *q) > > { > > struct blkcg_gq *blkg, *n; > > > > diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c > > index d00d1b0ec109..a72866458f22 100644 > > --- a/block/blk-sysfs.c > > +++ b/block/blk-sysfs.c > > @@ -816,6 +816,10 @@ static void __blk_release_queue(struct work_struct *work) > > if (q->bio_split) > > bioset_free(q->bio_split); > > > > + spin_lock_irq(q->queue_lock); > > + blkg_destroy_all(q); > > + spin_unlock_irq(q->queue_lock); > > + > > ida_simple_remove(&blk_queue_ida, q->id); > > call_rcu(&q->rcu_head, blk_free_queue_rcu); > > But we already do this through calling blkcg_exit_queue() from > __blk_release_queue(). What's missing? Hi, It might be the jetlag but I can't see how you end up calling blkcg_exit_queue() from __blk_release_queue(). As I see it the only way to reach blkcg_exit_queue() is from blk_cleanup_queue(), which I don't see anywhere in __blk_release_queue(). I suspect that I'm just fixing a corner case though and the general case is what you describe or similar. ../Alex > > Thanks. > > -- > tejun