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 3D5F6C6FD18 for ; Wed, 29 Mar 2023 08:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbjC2IPM (ORCPT ); Wed, 29 Mar 2023 04:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjC2IOy (ORCPT ); Wed, 29 Mar 2023 04:14:54 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02A1449D3 for ; Wed, 29 Mar 2023 01:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=if1Hi/Sps7b6+QdgC4Nxbvy8tS+IM4P01ucXO7CleDo=; b=Aowup5PGvf8g2n2WD8zyFU9IzC Kyby3DVwUTZzgTvDHy4thA0JGHHNm6hmc9UIE5zlQvyZ4Ri+iIORH3rYuVoXmH8v3h8Fx8l2jpyz4 PrN896+WaAyWRQj1MCBrWK5veTO00U/XaCCqd8swSW4s9jcXlDm7CfhCyVn/VK/bLaESh7Knp1uv+ OoaxE+hM5NqsUmYN64APpnio5mecBBfoeAhc/mhOuJtRepe/dnKlLVKVybKgBCxuNaCq7k79oqYON ezJE++M4QOHdQKume6EKFBrwOy5BClu8NNsDNMjNY+lPjrN42LHExrgli7SDLpqsMkoebXJiOavXy vL37RwVQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1phQx3-00H2uU-04; Wed, 29 Mar 2023 08:14:37 +0000 Date: Wed, 29 Mar 2023 01:14:36 -0700 From: Christoph Hellwig To: Damien Le Moal Cc: linux-fsdevel@vger.kernel.org, Johannes Thumshirn , Hans Holmberg Subject: Re: [PATCH] zonefs: Always invalidate last cache page on append write Message-ID: References: <20230329055823.1677193-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230329055823.1677193-1-damien.lemoal@opensource.wdc.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Mar 29, 2023 at 02:58:23PM +0900, Damien Le Moal wrote: > + /* > + * If the inode block size (sector size) is smaller than the > + * page size, we may be appending data belonging to an already > + * cached last page of the inode. So make sure to invalidate that > + * last cached page. This will always be a no-op for the case where > + * the block size is equal to the page size. > + */ > + ret = invalidate_inode_pages2_range(inode->i_mapping, > + iocb->ki_pos >> PAGE_SHIFT, -1); > + if (ret) > + return ret; The missing truncate here obviously is a bug and needs fixing. But why does this not follow the logic in __iomap_dio_rw to to return -ENOTBLK for any error so that the write falls back to buffered I/O. Also as far as I can tell from reading the code, -1 is not a valid end special case for invalidate_inode_pages2_range, so you'll actually have to pass a valid end here.