From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38200C4360C for ; Tue, 8 Oct 2019 10:52:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E6B320673 for ; Tue, 8 Oct 2019 10:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730218AbfJHKwK (ORCPT ); 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