Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp672173ybz; Wed, 15 Apr 2020 16:22:28 -0700 (PDT) X-Google-Smtp-Source: APiQypI+Bs5rCeFXFdppu6VcP7t0psZp+EcXHCgIdI9ddqAsp5yRgyc/X4cavW+Zj3fPAhX8orNN X-Received: by 2002:a17:907:361:: with SMTP id rs1mr7384392ejb.228.1586992947920; Wed, 15 Apr 2020 16:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586992947; cv=none; d=google.com; s=arc-20160816; b=F+cE+UGlLaXLz/pBUfaoJfRiTJ4QqkSrWtePGV0Rrx3Nm8B1rBtQjxh9gl7IqHe7vu 3Ta8/+WJzBRCygtBTnWYXJp2Mom+y74EjdHpdqKHTyv2GfJDfJ8aqOQ1MWpvvBEXa5Qb hc0TrRmGzFrXXkU5jwWhADJnogjoGbsM2+11adDoRDqAqFGTdC39f6vluXb3OTnKgkm0 dxJ84m3Q4M+/insSnDa+1MO1xUThfYJfrhWwFCYwdvKnVFqN/v0AUVysZOyf49/8Td7i eT8n0s0vUmXEhQ50cbm4EPBQsogB2N09PoU0fLqePEoV5S/4YHra7PgazflOdEGdpUFc LqfA== 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; bh=rcRovzoWQ44rccZ9H/a7flVu7Tih9ve+r3FKd13LlAQ=; b=SS2vNHanfyy6s6M36//rl5uXGWdQ3ypLMCBacnqOabzs6nh/VcZZMqlO2Ct/vc84lz 9fZAYVuCPWhaKOy4w2+1T/WPjYBQcZ0r0/PC6+L31ySRsOibP4/GAUHU89MKw0lz6OcH QxNDd47TU7LcX2IiPBNjY7CHKp+SBe24G/KZHzHPi/6QcT2aq23sFm5Q96C670vyVgZx GGl5a+hqwLyiLi4UUK1ho/uwxML8+EOXVMfebDzPALcpg3a0j/yxanIsFgc/pO/Q3Vgb fJ3o6+2zdjxzMk94jOgUxinFhdIWlgluBzXod6PIoBKeOaYo6NW2ELT/KZmygkGX3HDy GfXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f1si11251140ejl.164.2020.04.15.16.22.04; Wed, 15 Apr 2020 16:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S369826AbgDOMfy (ORCPT + 99 others); Wed, 15 Apr 2020 08:35:54 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46280 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S369768AbgDOMeh (ORCPT ); Wed, 15 Apr 2020 08:34:37 -0400 Received: by mail-pg1-f194.google.com with SMTP id 188so1401864pgj.13; Wed, 15 Apr 2020 05:34:36 -0700 (PDT) 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=rcRovzoWQ44rccZ9H/a7flVu7Tih9ve+r3FKd13LlAQ=; b=iyKCCZfsqg0xkZHoekMMOYD9rKj9JjHmxgHZmU1o+NpkH1lCzQKZPkQ4mgaAxdj+kq IB9lEHqyRGLg4LzgKPwwLKPiYDhqLwsXLiV1TRRkPZhNNXxkIRxdViBJ3yS3K6d7U+5x Ew3msygGyukvDjsHv2sIcFXuI5Asfmg7xW7GY3XQgdjkBw18ofn8Y7cFdGWG6K0yhrj9 mVZXfanMdzT632HdhZoBIYCdRdn6jyrad2huEo1QPmjLR+dSrZR7bLqDS2Cxipd2UI1C MFtt37Hr9ZEsVae3uf0naN6jhA041uC+AIuszUo62me9feE1IM2A6wAQnAKY4WQl7ahP m6dw== X-Gm-Message-State: AGi0PuYP6Uc1Y1haWX3woBilWZqsrYb4Ehu9c9UEzVHEz+mKKkMSv0zt r0KpinT/mgLr+Z5LLkZPpgI= X-Received: by 2002:a63:cd08:: with SMTP id i8mr22905838pgg.55.1586954076359; Wed, 15 Apr 2020 05:34:36 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id o15sm12562445pgj.60.2020.04.15.05.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 05:34:35 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 1649340277; Wed, 15 Apr 2020 12:34:34 +0000 (UTC) Date: Wed, 15 Apr 2020 12:34:34 +0000 From: Luis Chamberlain To: Christoph Hellwig Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org, mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Omar Sandoval , Hannes Reinecke , Michal Hocko Subject: Re: [PATCH 3/5] blktrace: refcount the request_queue during ioctl Message-ID: <20200415123434.GU11244@42.do-not-panic.com> References: <20200414041902.16769-1-mcgrof@kernel.org> <20200414041902.16769-4-mcgrof@kernel.org> <20200414154044.GB25765@infradead.org> <20200415061649.GS11244@42.do-not-panic.com> <20200415071425.GA21099@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200415071425.GA21099@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 15, 2020 at 12:14:25AM -0700, Christoph Hellwig wrote: > On Wed, Apr 15, 2020 at 06:16:49AM +0000, Luis Chamberlain wrote: > > The BLKTRACESETUP above works on request_queue which later > > LOOP_CTL_DEL races on and sweeps the debugfs dir underneath us. > > If you use this commit alone though, this doesn't fix the race issue > > however, and that's because of both still the debugfs_lookup() use > > and that we're still using asynchronous removal at this point. > > > > refcounting will just ensure we don't take the request_queue underneath > > our noses. > > > > Should I just add this to the commit log? > > That sounds much more useful than the trace. > > Btw, Isn't blk_get_queue racy as well? Shouldn't we check > blk_queue_dying after getting the reference and undo it if the queue is > indeeed dying? Yes that race should be possible: bool blk_get_queue(struct request_queue *q) { if (likely(!blk_queue_dying(q))) { ----------> we can get the queue to go dying here <--------- __blk_get_queue(q); return true; } return false; } EXPORT_SYMBOL(blk_get_queue); I'll pile up a fix. I've also considered doing a full review of callers outside of the core block layer using it, and maybe just unexporting this. It was originally exported due to commit d86e0e83b ("block: export blk_{get,put}_queue()") to fix a scsi bug, but I can't find such respective fix. I suspec that using bdgrab()/bdput() seems more likely what drivers should be using. That would allow us to keep this functionality internal. Think that's worthy review? Luis