From mboxrd@z Thu Jan 1 00:00:00 1970 From: Damien Le Moal Date: Mon, 22 May 2023 09:16:54 +0900 Subject: [Cluster-devel] [PATCH 10/13] fs: factor out a direct_write_fallback helper In-Reply-To: <20230519093521.133226-11-hch@lst.de> References: <20230519093521.133226-1-hch@lst.de> <20230519093521.133226-11-hch@lst.de> Message-ID: List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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