Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5495211ybp; Tue, 8 Oct 2019 03:53:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDtSE9VKndbJh3x4bQv6H1LueQzgZm9m9+E1vCX+kSHlKY+xDDFoqIJ/974fCphdFlUFCw X-Received: by 2002:a17:906:5bc1:: with SMTP id w1mr27451302ejs.143.1570531989753; Tue, 08 Oct 2019 03:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570531989; cv=none; d=google.com; s=arc-20160816; b=l0yR0r2Wjq0Ni8LPmWOsiJxunG1GjqeDIawuPghFVqJi+96SXD65cl3Rm+Q6N5KMZl ZYMAG2MWExYKSrhzK84MMSmrDw2ib1AKA7oDXy1HBTwAULUyplVMX0arlS0huMZi6mTe iRUCjkVGAon3AQBvCILUxnYUmOF29BPXWTP/H8eTVc+3yRczI1BFSw+GHrkSyAP1slmN e/S7f5/AYx5VVPyJ+6yJ0APS3MI4Y0sHBZrl/LhtRJqA5Da5srsLzbj8SqIyX6EjxKcS VzRVvQ9iInsEcRm9Aavu0A4KIsna1ExPI3kzG1DM0CMwdwXzbI6W4wxsZJv6B/vl9//B C5Cg== 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=t/7dWqSHsA1Vnqjmc2lCrOzJHbErMzY4+pNnpljo5L0=; b=yXYL4HEv/Y7YXwFUuj2bmwR2llbkIHoKYP9vOduQIHEjhOEYv4h8vb8DsHx9ZuIDmZ 67CECGMIv9gheIIrKozzWquszj3+tEabZJpsi3/EUae0pAEswvq4dNaN5nxuIAgvpVgs sztsQQMzX2VnqlSMFQB7gF4XN2PT1eh/4kJq7t7P8JTTKUN7JIBTZ9EwjnZAVJNS830p DThud6VRTfPWBFaID/LrxcgYax/1IOa5Wgyrny0nVAie8L7R7nwGo4+SHdsuD7NfuK6y 1CnhPiG/koztvBgTf6NSlYfpx8a2iU1qu7d7TFhtW+X5ptIV0tWsFCYZEz6G8LSjpDp+ p4wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y27si11046391edd.249.2019.10.08.03.52.39; Tue, 08 Oct 2019 03:53:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730093AbfJHKwK (ORCPT + 99 others); Tue, 8 Oct 2019 06:52:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:48054 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729876AbfJHKwK (ORCPT ); Tue, 8 Oct 2019 06:52:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3EFD1B0F2; Tue, 8 Oct 2019 10:52:08 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B1B391E4827; Tue, 8 Oct 2019 12:52:07 +0200 (CEST) Date: Tue, 8 Oct 2019 12:52:07 +0200 From: Jan Kara To: Matthew Bobrowski Cc: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Subject: Re: [PATCH v4 4/8] ext4: introduce direct I/O read path using iomap infrastructure Message-ID: <20191008105207.GG5078@quack2.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 03-10-19 21:34:00, Matthew Bobrowski wrote: > This patch introduces a new direct I/O read path that makes use of the > iomap infrastructure. > > The new function ext4_dio_read_iter() is responsible for calling into > the iomap infrastructure via iomap_dio_rw(). If the read operation > being performed on the inode does not pass the preliminary checks > performed within ext4_dio_supported(), then we simply fallback to > buffered I/O in order to fulfil the request. > > Existing direct I/O read buffer_head code has been removed as it's now > redundant. > > Signed-off-by: Matthew Bobrowski The patch looks good to me. Just one small nit below. With that fixed, you can add: Reviewed-by: Jan Kara > + /* > + * Get exclusion from truncate and other inode operations. > + */ > + if (!inode_trylock_shared(inode)) { > + if (iocb->ki_flags & IOCB_NOWAIT) > + return -EAGAIN; > + inode_lock_shared(inode); > + } I've noticed here you actually introduce new trylock pattern - previously we had unconditional inode_lock_shared() in ext4_direct_IO_read(). So the cleanest would be to just use unconditional inode_lock_shared() here and then fixup IOCB_NOWAIT handling (I agree that was missing in the original code) in a separate patch. And the pattern should rather look like: if (iocb->ki_flags & IOCB_NOWAIT) { if (!inode_trylock_shared(inode)) return -EAGAIN; } else { inode_lock_shared(inode); } to avoid two atomical operations instead of one in the fast path. No need to repeat old mistakes when we know better :). Honza -- Jan Kara SUSE Labs, CR