From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Date: Thu, 25 May 2023 12:05:57 +0200 Subject: [Cluster-devel] [PATCH 09/11] fs: factor out a direct_write_fallback helper In-Reply-To: References: <20230524063810.1595778-1-hch@lst.de> <20230524063810.1595778-10-hch@lst.de> Message-ID: <20230525100557.GA30242@lst.de> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, May 24, 2023 at 09:00:36AM +0200, Miklos Szeredi wrote: > > +ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter, > > + ssize_t direct_written, ssize_t buffered_written) > > +{ > > + struct address_space *mapping = iocb->ki_filp->f_mapping; > > + loff_t pos = iocb->ki_pos - buffered_written; > > + loff_t end = iocb->ki_pos - 1; > > + int err; > > + > > + /* > > + * If the buffered write fallback returned an error, we want to return > > + * the number of bytes which were written by direct I/O, or the error > > + * code if that was zero. > > + * > > + * Note that this differs from normal direct-io semantics, which will > > + * return -EFOO even if some bytes were written. > > + */ > > + if (unlikely(buffered_written < 0)) > > + return buffered_written; > > Comment/code mismatch. The comment says: > > if (buffered_written < 0) > return direct_written ?: buffered_written; Yeah. And the old code matches the comment, so I'll update to that. I'm really wondering how I could come up with a good test case for this..