From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5E5E127B70; Thu, 4 Apr 2024 16:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249606; cv=none; b=Nrki/NpXSJzIcszwFT/lATM0SOGWhp+BRik9Mqm09s3E6kO18Z4nz1k/v/bhR9ynyErfW83HyY+UnhW9/hksvbrlPAqy8CZDwDazuSIT8OxGN+YNA/s7/OCsM22C/OOHwaNgO0AvJABGFdVIzrcu0huso7p9aouNqXAO3rpEtkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249606; c=relaxed/simple; bh=SdH54DHBbllrzcbHGYDWtbkgYem6p5gDUyIgqd2Vsy0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JpjEpXvC4hZcuR7GUJ9XHYw+k47luaqN5lO69PWAKqqF5rEr22kLB4qpWSK+5H8nprwGzP4xGaEVhpma7YQwG6aY6dTqrEwY6r/k2ie4auPtLb28KcABbuqJQXNibXDIikuYIrOT19TWdUXUOwMAJgkpZiAJjA/eKNijV2NdwjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=x6xybBpb; arc=none smtp.client-ip=199.89.1.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="x6xybBpb" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4V9SP00GDKzlgTGW; Thu, 4 Apr 2024 16:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:references:content-language:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1712249589; x=1714841590; bh=ZDHIypNAZMTo+VzP8iaJudcx +oAEkGDyDOLcGqvzK2U=; b=x6xybBpbU7doAbetK6BxrMB/jZL/nTWFcpNORO6H io8W0ddeWENBxGFBRtHAfTjBs5gbFUi91BTmwYOOuEDu5ZOKKgkFX59QF8J7/Odd TPrhccLRXWXF5Trlh6f8oErGIRlojrsu6je9HsPPp0emWSd2pomXeVn2Aa0WMaVI R0mfEVdUDbdMXY3EbwFF3ALOIc2NpQ6hWf7LbAyfd+ULeIvuQyFdS/bAoLFv14LB HbkWbG/veVURXO256b47z/ScW3gmmSeaBDvg82/5/HihGZF29+nIKgEF9da+8S99 ivJ7tZl5BmbmlXX0jWkmH9elXjPqz1wouAxTXsQtwdmr7w== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id O2BQcxkjvo_y; Thu, 4 Apr 2024 16:53:09 +0000 (UTC) Received: from [100.96.154.173] (unknown [104.132.1.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 009.lax.mailroute.net (Postfix) with ESMTPSA id 4V9SNd04btzlgTHp; Thu, 4 Apr 2024 16:53:04 +0000 (UTC) Message-ID: Date: Thu, 4 Apr 2024 09:53:03 -0700 Precedence: bulk X-Mailing-List: linux-ide@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/23] block: add a helper to cancel atomic queue limit updates Content-Language: en-US To: Christoph Hellwig , Jens Axboe , "Martin K. Petersen" Cc: Damien Le Moal , Niklas Cassel , Takashi Sakamoto , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , "Juergen E. Fischer" , Xiang Chen , HighPoint Linux Team , Tyrel Datwyler , Brian King , Lee Duncan , Chris Leech , Mike Christie , John Garry , Jason Yan , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , Jack Wang , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Greg Kroah-Hartman , Alim Akhtar , Avri Altman , Krzysztof Kozlowski , Alan Stern , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, linux1394-devel@lists.sourceforge.net, MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, megaraidlinux.pdl@broadcom.com, mpi3mr-linuxdrv.pdl@broadcom.com, linux-samsung-soc@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net References: <20240402130645.653507-1-hch@lst.de> <20240402130645.653507-2-hch@lst.de> From: Bart Van Assche In-Reply-To: <20240402130645.653507-2-hch@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/2/24 06:06, Christoph Hellwig wrote: > Drivers might have to perform complex actions to determine queue limits, > and those might fail. Add a helper to cancel a queue limit update > that can be called in those cases. > > Signed-off-by: Christoph Hellwig > --- > include/linux/blkdev.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index c3e8f7cf96be9e..ded7f66dc4b964 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q, > struct queue_limits *lim); > int queue_limits_set(struct request_queue *q, struct queue_limits *lim); > > +/** > + * queue_limits_cancel_update - cancel an atomic update of queue limits > + * @q: queue to update > + * > + * This functions cancels an atomic update of the queue limits started by > + * queue_limits_start_update() and should be used when an error occurs after > + * starting update. > + */ > +static inline void queue_limits_cancel_update(struct request_queue *q) > +{ > + mutex_unlock(&q->limits_lock); > +} At least in scsi_add_lun() there are multiple statements between queue_limits_start_update(), queue_limits_cancel_update() and queue_limits_commit_update(). Has it been considered to use __cleanup() to invoke queue_limits_commit_update() when the end of the current scope is reached? I think that would make code that uses the queue_limits_*_update() functions easier to verify. For an example of how to use the __cleanup() macro, see e.g. the __free() and no_free_ptr() macros in . Thanks, Bart.