From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:35828 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729787AbeKVABv (ORCPT ); Wed, 21 Nov 2018 19:01:51 -0500 Received: by mail-pl1-f195.google.com with SMTP id v1-v6so5573336plo.2 for ; Wed, 21 Nov 2018 05:27:28 -0800 (PST) Subject: Re: [PATCH 3/8] iomap/xfs: wire up file_operations ->iopoll() To: Benny Halevy , linux-block@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org References: <20181120171953.1258-1-axboe@kernel.dk> <20181120171953.1258-4-axboe@kernel.dk> From: Jens Axboe Message-ID: <62aca28d-fd54-ae4e-d4d4-44c7232f23da@kernel.dk> Date: Wed, 21 Nov 2018 06:27:25 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 11/21/18 2:15 AM, Benny Halevy wrote: >> +int iomap_dio_iopoll(struct kiocb *kiocb, bool spin) >> +{ >> + struct iomap_dio *dio = kiocb->private; >> + struct request_queue *q = READ_ONCE(dio->last_queue); >> + >> + if (!q || dio->cookie == BLK_QC_T_NONE) >> + return 0; >> + return blk_poll(q, READ_ONCE(dio->cookie), spin); > > How about: > blk_qc_t cookie = READ_ONCE(dio->cookie); > > if (!q || cookie == BLK_QC_T_NONE) > return 0; > return blk_poll(q, cookie, spin); > > Is there a chance the dio->cookie in the if () condition > will be stale? I've rewritten this one, more importantly it needs to guard against submission by ensuring that 'dio' is valid. -- Jens Axboe