Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1264040pxb; Thu, 15 Apr 2021 19:22:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI5mhnqE0lTYv1XoCK5+6F1zUybGwPUMXuoMDvLDiY8o0Ewcxc492Fhvdrn6ThZw6dE9hc X-Received: by 2002:a05:6402:5252:: with SMTP id t18mr7661589edd.258.1618539764553; Thu, 15 Apr 2021 19:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618539764; cv=none; d=google.com; s=arc-20160816; b=Vb+HPk07Ei4sXF3l6Niwd30dSgnhrRXaoVQgCZVgGDSp2m9EhJlJ/VGTulIl7tsMt7 hSlwS8YVVg8fDzOeWIG9R8WI+xPrVFfUGEgPAp4DIZup2cY4gUmNbCAmyV18610qom8S pX/M2dJnWmq7EmPwfprbK5wOp5jAgVAuZ7v6b+LaLLJ6h/e/ShdSY9u0RGr4y2OPO7PQ PPQvYMTGXTBpSCTo2ErLbXUwR+DXyAoC/R1NIgVN+CBlh32HqPYq+mW20qmDM7Sw6COC SmxrcHv/KNPq1eN4AhoV37VKNx/TKWTkEM75KK2F/v/nCNroZhB/yeHH41QIX3I8I2xR mzSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=KtsjY3i9JfV1pMoLDxr15gkyXFW0mfYmotf2mvtdxrY=; b=xZV0CwHAXFCdYZG7iE1NZuDg0GOIq1iBbWyH+Ge5WYi0TJkyVGfDKW4VnFoipOgWKQ bcDJbDEtWB0RBZHT9twrD7l9y1bEQ+lfQdXiDiTXanvAsy5AEiyc2DUqB3QR2bxyRwko 6PQEsfg0AR2SZYjvhig6y0pYiV2/wnys4dShcifBK1AK7jR0MiDc+SwC7RDQb+rs7E57 b9YM21PCLjDAnSZvmqEIh6xs3mn8zioRirdkz8bW44AnBuZ2ht6BIbHI2o1uJxolPjbr B5FG7jmk6VFcPwCV4l+tuL74lTjbIEdipwlu1+wjw86cfTG75AUlR4sS9fG8kr2zlyYD 6VpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si3989500ejx.637.2021.04.15.19.22.20; Thu, 15 Apr 2021 19:22:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236951AbhDPAoE (ORCPT + 99 others); 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-kernel@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.