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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 EAAA0C433B4 for ; Fri, 16 Apr 2021 00:43:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C46A161132 for ; Fri, 16 Apr 2021 00:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236944AbhDPAoE (ORCPT ); Thu, 15 Apr 2021 20:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236917AbhDPAoE (ORCPT ); Thu, 15 Apr 2021 20:44:04 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D7E0C061574; Thu, 15 Apr 2021 17:43:40 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lXCa3-005daQ-S7; Fri, 16 Apr 2021 00:43:31 +0000 Date: Fri, 16 Apr 2021 00:43:31 +0000 From: Al Viro To: Jan Kara Cc: Chao Yu , jack@suse.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH] direct-io: use read lock for DIO_LOCKING flag Message-ID: References: <20210415094332.37231-1-yuchao0@huawei.com> <20210415102413.GA25217@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415102413.GA25217@quack2.suse.cz> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Apr 15, 2021 at 12:24:13PM +0200, Jan Kara wrote: > On Thu 15-04-21 17:43:32, Chao Yu wrote: > > 9902af79c01a ("parallel lookups: actual switch to rwsem") changes inode > > lock from mutex to rwsem, however, we forgot to adjust lock for > > DIO_LOCKING flag in do_blockdev_direct_IO(), The change in question had nothing to do with the use of ->i_mutex for regular files data access. > > so let's change to hold read > > lock to mitigate performance regression in the case of read DIO vs read DIO, > > meanwhile it still keeps original functionality of avoiding buffered access > > vs direct access. > > > > Signed-off-by: Chao Yu > > Thanks for the patch but this is not safe. Originally we had exclusive lock > (with i_mutex), switching to rwsem doesn't change that requirement. It may > be OK for some filesystems to actually use shared acquisition of rwsem for > DIO reads but it is not clear that is fine for all filesystems (and I > suspect those filesystems that actually do care already don't use > DIO_LOCKING flag or were already converted to iomap_dio_rw()). So unless > you do audit of all filesystems using do_blockdev_direct_IO() with > DIO_LOCKING flag and make sure they are all fine with inode lock in shared > mode, this is a no-go. Aye. Frankly, I would expect that anyone bothering with that kind of analysis for given filesystem (and there are fairly unpleasant ones in the list) would just use the fruits of those efforts to convert it over to iomap. "Read DIO" does not mean that accesses to private in-core data structures used by given filesystem can be safely done in parallel. So blanket patch like that is not safe at all.