From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:43136 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbeHBBIJ (ORCPT ); Wed, 1 Aug 2018 21:08:09 -0400 Date: Thu, 2 Aug 2018 00:19:56 +0100 From: Al Viro To: Christoph Hellwig Cc: Avi Kivity , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] aio: add a iocb refcount Message-ID: <20180801231956.GS30522@ZenIV.linux.org.uk> References: <20180730071544.23998-1-hch@lst.de> <20180730071544.23998-3-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180730071544.23998-3-hch@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Jul 30, 2018 at 09:15:42AM +0200, Christoph Hellwig wrote: > This is needed to prevent races caused by the way the ->poll API works. > To avoid introducing overhead for other users of the iocbs we initialize > it to zero and only do refcount operations if it is non-zero in the > completion path. refcount_t looks like a bad match - you, AFAICS, have count 0 for everything except poll, while for poll you start with 2. That looks like if (iocb->shared && test_and_clear_bit(0, &iocb->shared)) return; kill the sucker in your iocb_put() and initializing it to 1 in poll. No?