Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2272629rwd; Sun, 21 May 2023 17:25:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7fUDbJ+rsOOursZPqaywrczVFyg/WEQGP23cLjB4nyFYCIKNLhCRPElOH2rEFvx/sftn0s X-Received: by 2002:a17:90a:6506:b0:24e:4c8:3ae5 with SMTP id i6-20020a17090a650600b0024e04c83ae5mr9677092pjj.28.1684715139691; Sun, 21 May 2023 17:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684715139; cv=none; d=google.com; s=arc-20160816; b=HoT4M+GmJxwQyn21cPpQQifC/HXVM/gnL/znQ0uQ0/V1G29HbnUU1J81W67Ff4AqkI C5Y8EVawZh1I6qgZ0RgA1ebiPAVT23+InAUMj0VqAFGgpM+RoKg4J9NfG87Z3Gr8q07V +6QVhTKZKMXnl48NYfXJ9mQS0enykjid8nrki+5d22UEf0rBx0w5TL+UBc5ta0eP27w8 MXc6HEro5dprNHGsUVY6vHpSNJmW8G8t7fHc9Trsf7bV7fklXT3Utt95bY7iP/BF/VgF a1OUngeXhhldE8hmciVuCn7/CxMwj1Yi7h1FVpZM//nuZo4fZqb7opcmCrnTPZ5g6D0z z+rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=BI96jBpMNhYORRa/BJuhrUinBsb8UIUmPFVsaftuGrc=; b=n8oFbW6C/OkztocEnRXz91TAO3rsRq8MA9VJtWt5JMdJ+4WXRq5QbhDcMPlouVUubk eLosyRVHdiIl5pObOxvhfRpd5AucRkI9reLHe9SGiw/sx1EC9XevJi6QkYnml6QrOyH+ 8BBipUjJu4uB8OsIqe/TPHFvQD2w4A/rSoYeVXqBixflIkn9AWMym4O+5gPD5nYo3f1U Hv0lmvVT2hJRDgRy89zziVc2JguMFRVKn//W5kfE4MENKpazdlCCjPKQ2CAzJmucdfvg 9idUwdk3xQVTMJJaFAtAmG2wll/PRiaYH/wwBrHnfh+2gKQ98+l3amClXFvUfxqii9lu L+PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BXAriNGx; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ms16-20020a17090b235000b00252779bf264si5807336pjb.52.2023.05.21.17.25.27; Sun, 21 May 2023 17:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BXAriNGx; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjEVARA (ORCPT + 99 others); Sun, 21 May 2023 20:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjEVARA (ORCPT ); Sun, 21 May 2023 20:17:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F8EDCE; Sun, 21 May 2023 17:16:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A2E761880; Mon, 22 May 2023 00:16:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B4DBC433D2; Mon, 22 May 2023 00:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684714618; bh=pynMqTKclwPIt+cST9RZwiWCLVo4HSNzTZHy4TzJIsc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BXAriNGxpa+JuaO2vxwOc9RNJOKNUssZmct2fcZwWAWp3X0h0H6VbL8sSHwWS4Nlz 4FFrrfLZBOK1xbCl0c1T84fG3aCpvtIPLwDvQzrlNxDwJfLv9BoGEpX1hZmWMVH90/ dCZXRY3nh+vkQyvlEnLs3BwteEN+wNZb3bwJHXJ1Wh6zmCmoh60OUOzjMfheU+87DF MtWTLuia8tNf1tD4dLRjHDec5dxMHfNkmfksktoiwmUe4k2hWaELWrz+GqPuNs9Zw5 8kiY+kVYzuuVS7cmiIzONousu4OZfEQyxVy6h9qY1nQPLDSUdpM78qRyPx4NabhlFy D6sDWIqYSxOIw== Message-ID: Date: Mon, 22 May 2023 09:16:54 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 10/13] fs: factor out a direct_write_fallback helper Content-Language: en-US To: Christoph Hellwig , Matthew Wilcox Cc: Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , Theodore Ts'o , Jaegeuk Kim , Chao Yu , Miklos Szeredi , Andreas Gruenbacher , "Darrick J. Wong" , Trond Myklebust , Anna Schumaker , Andrew Morton , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, "open list:F2FS FILE SYSTEM" , cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org References: <20230519093521.133226-1-hch@lst.de> <20230519093521.133226-11-hch@lst.de> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20230519093521.133226-11-hch@lst.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 5/19/23 18:35, Christoph Hellwig wrote: > Add a helper dealing with handling the syncing of a buffered write fallback > for direct I/O. > > Signed-off-by: Christoph Hellwig Looks OK. One comment below. Reviewed-by: Damien Le Moal > + /* > + * We need to ensure that the page cache pages are written to disk and > + * invalidated to preserve the expected O_DIRECT semantics. > + */ > + end = pos + buffered_written - 1; > + err = filemap_write_and_wait_range(mapping, pos, end); > + if (err < 0) { > + /* > + * We don't know how much we wrote, so just return the number of > + * bytes which were direct-written > + */ > + return err; > + } > + invalidate_mapping_pages(mapping, pos >> PAGE_SHIFT, end >> PAGE_SHIFT); > + return direct_written + buffered_written; Why not adding here something like: if (buffered_written != iov_iter_count(from)) return -EIO; return direct_written + buffered_written; to have the same semantic as plain DIO ? -- Damien Le Moal Western Digital Research