Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp150936rdf; Mon, 20 Nov 2023 20:45:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZx6stEV3JnjizmYkvB605lz4pm0N5YsWFP+Iqv9SAFJne4pUzfogoBKa7zZyQBFw3h0LY X-Received: by 2002:a05:622a:1896:b0:41c:c3ad:922d with SMTP id v22-20020a05622a189600b0041cc3ad922dmr11262751qtc.52.1700541921254; Mon, 20 Nov 2023 20:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700541921; cv=none; d=google.com; s=arc-20160816; b=xZQvrmmuU9jvh2Up8TgV4uOdsV9+PF9uGC0agZ+PTgD35mg5+PVczJFBjlGoBNjDZe 1OFDPtEFSZvsYHvOeo5ta7fOZInfEEN6R1p+so5jxKMuEESE/uccGiTt63GIgpXsT7j/ 0EGA2VxR+Lh/ZbR5ctNMzKnDwI8tm9si5Z/IUQXhHFHFGdeC4cj21awtETYv5XAMUWDr Qp08Xgqb3siJH8+nOlH0rP7U+9d0OBIe9mm6mw5+YynGBkM61NW24pmOnRiUZvJ320ZQ cpPb7D7EJq0t0ivx8Hbu+Kh4Cqokr2JHFKkvmn0JEqjgVdbiUfQ2S4nfr/tYQ4cKrxHs w2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ew2km67eAiikun7xkP35RhIFrsku7QzUiSyeUEeOQZ0=; fh=FW3K8SsatDsWIpbiCVYsxhuaXmltdDjxfyWwgebVeiU=; b=z41eJ/UJO7OHalTn8rlRyLqzyCsdTOZ6skxA6M5FR5hnOqkzBlQd2P9eOFXKQxu1XS SbUOYHjrjjlb/La2PzSToUlBdQouPyyBqt+wt6ZmVnqt8d608gQ0DeUzylc5mBjXReYW ZDVvT2gg5QL8UvpRO6yzCY22OE/+a2Md6HUukZzSQruu4ty8JBgJVwKhby8XRJ6kK/Np 7K91/X89GkM1p2m0cgBSR64Euw1ShdudUvQuedNfb59FiUuMmT7ZsDWw3jP6Vi9tEWOV TFBq+YZDUmt9FUqYc6gz7CG/oJ/+vqB3p7G5rOstR7cVlxTpqlGZZbkT+vxmWs4fq9rj HsIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=TUhQ808i; spf=pass (google.com: domain of linux-ext4+bounces-61-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-61-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fb16-20020a05622a481000b004236ea5cb4asi850943qtb.332.2023.11.20.20.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 20:45:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-61-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=TUhQ808i; spf=pass (google.com: domain of linux-ext4+bounces-61-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-61-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9B6611C218D3 for ; Tue, 21 Nov 2023 04:45:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 533777487; Tue, 21 Nov 2023 04:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="TUhQ808i" X-Original-To: linux-ext4@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55892BD; Mon, 20 Nov 2023 20:44:56 -0800 (PST) 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=Ew2km67eAiikun7xkP35RhIFrsku7QzUiSyeUEeOQZ0=; b=TUhQ808izwWLTqqqk5RRp4WQhd OHodLXsU7fEBZyNUI18FGrS1h6du8gsJ84fHRzJV5h5s01XN20N+mVrAwCa5IxRprXkWmkTCyJjlR gJJak+Lwyf6Tb+aX79gSpvgtAcOLNfFKnDgmAp5JfTKMHT+TP3avKlVTy24xWVVqZWBAVmZSMrPim lNeKGjkO9ZNyPBk78CjX0rC0QzrHDlbDG3hhd1rlugPuaCKCUfj/AfJ6u/om1rv3poe7bgzJerLva uFi29uC+JaiA4epbyJx+A1U3tmQDdXGNEggDMmGi5aZCi7SmSPpOauNDbei8EcrlQnUqOec4KZlc9 hXc/rVRw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r5Id5-00Fc8E-1p; Tue, 21 Nov 2023 04:44:55 +0000 Date: Mon, 20 Nov 2023 20:44:55 -0800 From: Christoph Hellwig To: "Ritesh Harjani (IBM)" Cc: linux-ext4@vger.kernel.org, Jan Kara , linux-fsdevel@vger.kernel.org Subject: Re: [RFC 2/3] ext2: Convert ext2 regular file buffered I/O to use iomap Message-ID: References: Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html On Tue, Nov 21, 2023 at 12:35:20AM +0530, Ritesh Harjani (IBM) wrote: > - mmap path of ext2 continues to use generic_file_vm_ops So this means there are not space reservations taken at write fault time. While iomap was written with the assumption those exist, I can't instantly spot anything that relies on them - you are just a lot more likely to hit an -ENOSPC from ->map_blocks now. Maybe we should add an xfstests that covers the case where we use up more then the existing free space through writable mmaps to ensure it fully works (where works means at least as good as the old behavior)? > +static ssize_t ext2_buffered_write_iter(struct kiocb *iocb, > + struct iov_iter *from) > +{ > + ssize_t ret = 0; > + struct inode *inode = file_inode(iocb->ki_filp); > + > + inode_lock(inode); > + ret = generic_write_checks(iocb, from); > + if (ret > 0) > + ret = iomap_file_buffered_write(iocb, from, &ext2_iomap_ops); > + inode_unlock(inode); > + if (ret > 0) > + ret = generic_write_sync(iocb, ret); > + return ret; > +} Not for now, but if we end up doing a bunch of conversation of trivial file systems, it might be worth to eventually add a wrapper for the above code with just the iomap_ops passed in. Only once we see a few duplicates, though. > +static int ext2_write_map_blocks(struct iomap_writepage_ctx *wpc, > + struct inode *inode, loff_t offset) > +{ > + if (offset >= wpc->iomap.offset && > + offset < wpc->iomap.offset + wpc->iomap.length) > + return 0; > + > + return ext2_iomap_begin(inode, offset, inode->i_sb->s_blocksize, > + IOMAP_WRITE, &wpc->iomap, NULL); > +} Looking at gfs2 this also might become a pattern. But I'm fine with waiting for now. > @@ -1372,7 +1428,7 @@ void ext2_set_file_ops(struct inode *inode) > if (IS_DAX(inode)) > inode->i_mapping->a_ops = &ext2_dax_aops; > else > - inode->i_mapping->a_ops = &ext2_aops; > + inode->i_mapping->a_ops = &ext2_file_aops; > } Did yo run into issues in using the iomap based aops for the other uses of ext2_aops, or are just trying to address the users one at a time?