Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbdITTFm convert rfc822-to-8bit (ORCPT ); Wed, 20 Sep 2017 15:05:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52266 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbdITTFl (ORCPT ); Wed, 20 Sep 2017 15:05:41 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B4EFE7E426 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=longman@redhat.com Subject: Re: [PATCH v7] blktrace: Fix potentail deadlock between delete & sysfs ops To: Christoph Hellwig Cc: Jens Axboe , Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nilfs@vger.kernel.org, cluster-devel@redhat.com, Bart Van Assche References: <1505928371-27829-1-git-send-email-longman@redhat.com> <20170920173552.GA14611@infradead.org> From: Waiman Long Organization: Red Hat Message-ID: <76cc6fea-fd1a-04fb-b18b-04ea5d69dde9@redhat.com> Date: Wed, 20 Sep 2017 15:05:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170920173552.GA14611@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Sep 2017 19:05:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1272 Lines: 27 On 09/20/2017 01:35 PM, Christoph Hellwig wrote: >> +/* >> + * When reading or writing the blktrace sysfs files, the references to the >> + * opened sysfs or device files should prevent the underlying block device >> + * from being removed. So no further delete protection is really needed. >> + * >> + * Protection from multiple readers and writers accessing blktrace data >> + * concurrently is still required. The bd_mutex was used for this purpose. >> + * That could lead to deadlock with concurrent block device deletion and >> + * sysfs access. As a result, a new blk_trace_mutex is now added to be >> + * used solely by the blktrace code. >> + */ > Comments about previous locking schemes really don't have a business > in the code - those are remarks for the commit logs. And in general > please explain the locking scheme near the data that they proctect > it, as locks should always protected data, not code and the comments > should follow that. It seems to be a general practice that we don't put detailed comments in the header files. The comment was put above the function with the first instance of the blk_trace_mutex. Yes, I agree that talking about the past history may not be applicable here. I will keep that in mind in the future. Thanks, Longman