Received: by 10.213.65.68 with SMTP id h4csp3149078imn; Mon, 9 Apr 2018 15:19:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49b1rygg44vWqQdOXqe45V8SrdwYmnjEDlDjNFAq/7eDep0GhYd6zsbvQMG9XVZhb+yMWBS X-Received: by 2002:a17:902:bc4b:: with SMTP id t11-v6mr10709007plz.343.1523312394958; Mon, 09 Apr 2018 15:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523312394; cv=none; d=google.com; s=arc-20160816; b=oAu3r4FWW8QWjXGQToL72o9JFehfFlGiftU6Wh5uFOr0YNk5udpYSlQbDMKBvvZHzE klR53AKY2mBU+L/mrhHkhX3CRV70nqcdYKmF3LqEDnXzJjgX8+8oAIDdBuexRJG/UhVY aQ73DiOrTEZeTkbXW2SGoj/48kXWA9VXBznTA9DJYgS5GPNYyKVvWUQP0ZPVw3RdImi/ pOh/Mu69Ibv/S7hTZHZIZLI/zIXOKGhN4xaYODqmFJlZIF7V3cX7jrF0grbcq/X14W5k X9gsP972V+DyL4r3KkoH//ZI65s6ygGDdK2eKY4hkXsofZpSjxNZBKfefSdXHjfaC8Vz 7fpw== 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=LhLNyhzXx7j/lV5qQ52D5ZqKvxI/qzFrxTHlHbSdOfA=; b=m9uJafnhiM/QwY41Qfd+0GfUMCEroNkgS6WU1wiHWeBeFTAyt4/ONOwCi42Cv3fWRS OF3Gmv/xcXbiLGszYwgFa+uf/p8cqy7KNAJu+sLXdWKsEq44tewEZE1IbAPR7UOkR9e1 6B1mCsN3e05ooNWPjiZslOPdXadlLeh6J2YDbXOasx1p9ynGsFA06ZzfFwTlno28FGve swbfyKtAqZttg1miYc4gL1P8oGkqRqMo5QFtY8VkYIINsLogPF6awShj/RcfmuCsbROI S4RXw0XsKSXqwndVmjkw89wi2kdYzdnidp4XuwxSzoiQkkn8J6UvgvfaunekRkiEA+mR Cgjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=atA9IBoI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m65si946606pfb.130.2018.04.09.15.19.17; Mon, 09 Apr 2018 15:19:54 -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=fail header.i=@gmail.com header.s=20161025 header.b=atA9IBoI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbeDIWJr (ORCPT + 99 others); Mon, 9 Apr 2018 18:09:47 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:41102 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbeDIWJm (ORCPT ); Mon, 9 Apr 2018 18:09:42 -0400 Received: by mail-yb0-f195.google.com with SMTP id p126-v6so3593593ybg.8; Mon, 09 Apr 2018 15:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LhLNyhzXx7j/lV5qQ52D5ZqKvxI/qzFrxTHlHbSdOfA=; b=atA9IBoIu9J9Fc1eVKvsZoJr5wO0aMgJpBT+wfwpOZH5eY2u4mCcPUapUEjT2E6+o7 eUDVYvDjsOkoR8j+S3EV9At7J4BEzHgs2hO+oL1sFKZjRK+EavMNGSrDS1GCQcjFbx5k jBWBw+f6A519u5yKy4vES/EOq8yuxgYJjOg84oFcTT2NSr7vM4j8214gzFD55dW9cRpa /NmS0isTc6kasjQg0YnNPAwYYjNotrbaxk8rjz8lkl+lEL4JG7/IVV0KmZRH+KF8qyUw l5YQxbOljyaX0mvUsgiH9K9CbN9zuLWqdaGiCr4YZWFgjLLU/88uSmXdgEPIBi3IlElS eHRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=LhLNyhzXx7j/lV5qQ52D5ZqKvxI/qzFrxTHlHbSdOfA=; b=T3tq0sdMYyMJC4pg71O/rWngdMfzkxtsFLWjJ1K1UhGPNYSix26XzGDfTSaCUYfhHL 3ZtrficbdwGfDOw1ltMfZPtgQrIFYXFLsU/fdogmC+Py1XrDUJydUTk9olJGcMu8kTd+ avkpabRxIQfYFX910eoz79quBX9K3nq1iqJL+fCN5o0yKqWJP4bRoFjAsgSNQufpoci3 UmXsuw5CL1fZQufLPaD3MMOLwxCBFrRrmVGzGN3saoLHrnLFzwd1JD0R3lQ/vwego0aV kbsxD5SOGm94W3EWeEV/ImYyUZtgAo09Yti5f+1buM+bows7Kx+ryZ/4wQ/iWR0tOxfL 6tGQ== X-Gm-Message-State: AElRT7FdNdBUx5lXDsEgZfoK6GupNX2opj5Ki4FgGd7j5gJxtGryW1JO IaEFhqyI6xu+ruuMJ5dLSaA= X-Received: by 2002:a25:9707:: with SMTP id d7-v6mr20532884ybo.259.1523311781515; Mon, 09 Apr 2018 15:09:41 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::1:ce92]) by smtp.gmail.com with ESMTPSA id e187sm551539ywb.23.2018.04.09.15.09.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 15:09:40 -0700 (PDT) Date: Mon, 9 Apr 2018 15:09:38 -0700 From: Tejun Heo To: Alexandru Moise <00moses.alexander00@gmail.com> 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: <20180409220938.GI3126663@devbig577.frc2.facebook.com> References: <20180407102148.GA9729@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180407102148.GA9729@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (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? Thanks. -- tejun