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 A0677C7EE33 for ; Thu, 25 May 2023 10:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240478AbjEYKGK (ORCPT ); Thu, 25 May 2023 06:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbjEYKGJ (ORCPT ); Thu, 25 May 2023 06:06:09 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF8310B; Thu, 25 May 2023 03:06:04 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 45E6C68AFE; Thu, 25 May 2023 12:05:58 +0200 (CEST) Date: Thu, 25 May 2023 12:05:57 +0200 From: Christoph Hellwig To: Miklos Szeredi Cc: Christoph Hellwig , Matthew Wilcox , Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , Theodore Ts'o , Jaegeuk Kim , Chao Yu , Andreas Gruenbacher , "Darrick J. Wong" , Trond Myklebust , Anna Schumaker , Damien Le Moal , Andrew Morton , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 09/11] fs: factor out a direct_write_fallback helper Message-ID: <20230525100557.GA30242@lst.de> References: <20230524063810.1595778-1-hch@lst.de> <20230524063810.1595778-10-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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..