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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27C77C83F12 for ; Tue, 29 Aug 2023 13:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbjH2N2N (ORCPT ); Tue, 29 Aug 2023 09:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236041AbjH2N1s (ORCPT ); Tue, 29 Aug 2023 09:27:48 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBC3FCC4 for ; Tue, 29 Aug 2023 06:27:04 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 46ADC5C019D; Tue, 29 Aug 2023 09:27:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 29 Aug 2023 09:27:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1693315621; x=1693402021; bh=NiqF8kHsAHjDKuOge3BvRsuKwFBQqXsctIL RUtS4R5I=; b=Yh2WjS5JlEGOBc0hoC024bFo+GaTXhM2wIiii/vaxKXQQ71ZabB hqsCX+8C9tz3NWlmeNBCj+v2y/vh8/pihJy6AWI2LLQKt+ZG5o9hmxbW6WzZ4k5d eydQgyWarGxGl4+ZlVYXqMl4EITjO0NSYPk0bdCyB4ir373S9vLVzc7LamnnDDwB 2hyGH09kHze+3FChJRtJOuTu+qNLd+RJS/sevHwOMXJ83EOC6EBKo37nzmAPdDk9 9iAoKmpXRb2DAXjpiG4MLRWtY+USggdwkx7JRlEaPYlI3A1XpInas3IkQraRORbo l7ioqWI1j7SO+/LYh47Q5sRqKlUGWhnSR5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1693315621; x=1693402021; bh=NiqF8kHsAHjDKuOge3BvRsuKwFBQqXsctIL RUtS4R5I=; b=poGciUdaEw2BamlPZCCCfjdkFbGOrior6s32h+92DZsaI0aK67J esYxbn8wYPstIkizU4cTkxXCrhAqaZBnqrdUoOwF3aYou8eM4CTnVU+SRhiWozOE gLEnyWVUPoxWizJoGuBKL7ZxN0yFd2xHs2GbnP33vpR9etGXxsyzo1NzgiYWur50 ZxEZCHkoXetL8vmcwvcYbbEjBJE9BD4QjmHuxeahoXESIPKnvRU+Xv5Zp39a129I /r+er5r17Md7EomX4vRxjTP15r6GX2zYMf4HPFQdG4R7Z8a9dE50LbcLwaGRhmgl RBu7qE7CS6paAnOygk53XqFEIksudlmQjyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefiedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeeuvghr nhguucfutghhuhgsvghrthcuoegsvghrnhgurdhstghhuhgsvghrthesfhgrshhtmhgrih hlrdhfmheqnecuggftrfgrthhtvghrnhepfffhtddvveeivdduuedujeetffekkeelgfdv fefgueffieefjefgjeffhedttdefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepsggvrhhnugdrshgthhhusggvrhhtsehfrghsthhmrghilhdr fhhm X-ME-Proxy: Feedback-ID: id8a24192:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 29 Aug 2023 09:26:59 -0400 (EDT) Message-ID: <058bb99c-b722-c5f1-6f0c-759f194ed5ff@fastmail.fm> Date: Tue, 29 Aug 2023 15:26:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH 4/5] [RFC] fuse: Set and use IOCB_DIRECT when FOPEN_DIRECT_IO is set Content-Language: en-US, de-DE To: Miklos Szeredi Cc: Bernd Schubert , linux-fsdevel@vger.kernel.org, dsingh@ddn.com, Hao Xu References: <20230824150533.2788317-1-bschubert@ddn.com> <20230824150533.2788317-5-bschubert@ddn.com> <6e0cc058-7163-ffc6-3b7e-b459af4d6f8c@fastmail.fm> From: Bernd Schubert In-Reply-To: <6e0cc058-7163-ffc6-3b7e-b459af4d6f8c@fastmail.fm> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 8/29/23 15:08, Bernd Schubert wrote: > > > On 8/28/23 17:05, Miklos Szeredi wrote: >> On Mon, 28 Aug 2023 at 16:48, Bernd Schubert >> wrote: >>> >>> On 8/28/23 13:59, Miklos Szeredi wrote: >>>> On Thu, 24 Aug 2023 at 17:07, Bernd Schubert wrote: >> >>>>> -               if (!is_sync_kiocb(iocb) && iocb->ki_flags & >>>>> IOCB_DIRECT) { >>>>> -                       res = fuse_direct_IO(iocb, from); >>>>> -               } else { >>>>> -                       res = fuse_direct_io(&io, from, &iocb->ki_pos, >>>>> -                                            FUSE_DIO_WRITE); >>>>> -                       fuse_write_update_attr(inode, iocb->ki_pos, >>>>> res); >>>> >>>> While I think this is correct, I'd really like if the code to be >>>> replaced and the replacement are at least somewhat comparable. >>> >>> Sorry, I have a hard to time to understand "I'd really like if the code >>> to be replaced". >> >> What I meant is that generic_file_direct_write() is not an obvious >> replacement for the  above lines of code. >> >> The reason is that fuse_direct_IO() is handling the sync and async >> cases in one function, while the above splits handling it based on >> IOCB_DIRECT (which is now lost) and is_sync_kiocb(iocb).  If it's okay >> to lose IOCB_DIRECT then what's the explanation for the above >> condition?  It could be historic garbage, but we still need to >> understand what is exactly happening. > > While checking all code path again, I found an additional difference, > which I had missed before. FOPEN_DIRECT_IO will now act on > ff->fm->fc->async_dio when is is_sync_kiocb(iocb) is set. > > Do you think that is a problem? If so, I could fix it in fuse_direct_IO. What I mean is something like this diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 85f2f9d3813e..3b383dc8a944 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1635,8 +1635,10 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (FUSE_IS_DAX(inode)) return fuse_dax_write_iter(iocb, from); - if (ff->open_flags & FOPEN_DIRECT_IO) + if (ff->open_flags & FOPEN_DIRECT_IO) { iocb->ki_flags |= IOCB_DIRECT; + ff->iocb_direct = 1; + } return fuse_cache_write_iter(iocb, from); } @@ -2905,6 +2907,15 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) io->iocb = iocb; io->blocking = is_sync_kiocb(iocb); + /* FOPEN_DIRECT_IO historically does not use async for blocking O_DIRECT */ + if (ff->open_flags & FOPEN_DIRECT_IO) { + if (!is_sync_kiocb(iocb) && ff->iocb_direct) { + /* no change */ + } else { + io->async = 0; + } + } + /* optimization for short read */ if (io->async && !io->write && offset + count > i_size) { iov_iter_truncate(iter, fuse_round_up(ff->fm->fc, i_size - offset)); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index a56e83b7d29a..d77046875ad5 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -231,6 +231,9 @@ struct fuse_file { /** Has flock been performed on this file? */ bool flock:1; + + /** Has the file been opened with O_DIRECT? */ + bool iocb_direct:1; }; /** One input argument of a request */ Thanks, Bernd