Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1050492rdf; Wed, 22 Nov 2023 04:31:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo81T8EMJbFXu1ZlvPLBF/4yfTPBD61wVcW63QaEs1CAp3wM/gBQqVaOsInuj701e1yWCj X-Received: by 2002:a5d:87c8:0:b0:787:8cf:fe8a with SMTP id q8-20020a5d87c8000000b0078708cffe8amr1962597ios.2.1700656277937; Wed, 22 Nov 2023 04:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700656277; cv=none; d=google.com; s=arc-20160816; b=yu8i22PIfc/I8au1XOtyS/0t9vQHD6G//oNVf1FQ/Gs6Lj7LrJmUiV1einBz+VzWDZ BYnN/nFp+krZ5AsmOdfhrRJUxi3v7hI5Od36o9JJJc8e1wfxlfPY7xdz2oQVDTGfMRt9 ccdJNI1kC3A4LX7XTKK6NYIa6Ylg840lHYtdrX8uYH2Du4IO2KID7JmF6VNEVZQ/KLQj w/8frPaIUmZ0s5L+Hn3i3sU3kvhnmOLODj3NJIa6pRot26Lsw/HwY+LsTZJWABFcZpg/ 7SKhzF3mIlVGRjRl5V5IiFFQE9h4cmFFaVvUkFmia9xrHOSznqCZchwbVL3KPdAwdpKh NmPg== 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:dkim-signature; bh=xuFT61rMAuWU8L3b6RjlAfH9ryapgGUCzXO0AJs9dd8=; fh=FW3K8SsatDsWIpbiCVYsxhuaXmltdDjxfyWwgebVeiU=; b=WGDHsQBwCn/wNFXnp664WpF+qt9dv3fwFsqNcovKhGrEKbnrgXooivoPJPu8YllyOP TKBXYTpVtKH1XJcJgW0FBlNsVBsMKYFFAnIHaodEjmvzDnrAdh293bmC8seIGudkqM+4 qnIqjcgdjzKhAmHA7d88fgV7HF9bgJgN5I/ifOuxkFfNNCI1wOiYlE4WkwQjovfGfvk5 vV0ZR1Ys60VNfw+F5/XwnnBcp5NghXKwVDYu0IpTQZmYzY7EkDjqy8Ntk5T4sKmVAIAC n4gEYsOuEVRUKCTkkvcTqu96aVZzLfqoawquJOhfqDgcUEGSa0jDGHsKx6ulMqQU46An J8VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=NsPKAhuS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aQDW0Dtl; spf=pass (google.com: domain of linux-ext4+bounces-80-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-80-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f10-20020a6547ca000000b005b32ca3f714si11891732pgs.718.2023.11.22.04.31.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-80-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=NsPKAhuS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aQDW0Dtl; spf=pass (google.com: domain of linux-ext4+bounces-80-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-80-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B34DA280E7E for ; Wed, 22 Nov 2023 12:30:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 038834D136; Wed, 22 Nov 2023 12:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="NsPKAhuS"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="aQDW0Dtl" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4162F92; Wed, 22 Nov 2023 04:29:49 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3017C21940; Wed, 22 Nov 2023 12:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700656187; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xuFT61rMAuWU8L3b6RjlAfH9ryapgGUCzXO0AJs9dd8=; b=NsPKAhuSLvGv93y/RDHG3xIxBmzpVnXRcAS45PTw0AP+CwgGOMfUUs7Bw4REs2SxdDfrR4 fqzUUnrlpfoue/0R6+XcB4JOuD34TeSvC2i4wMkmdgFjuSk06cC7DuWLsCwf6NpgI9vKWL wFFfV8tdVReycVhHv/9DWY34Kpk3AVI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700656187; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xuFT61rMAuWU8L3b6RjlAfH9ryapgGUCzXO0AJs9dd8=; b=aQDW0DtlhYxecQH4V+PnyDQB7+NZy3dh5S+Uq6OT0hdCJcld1yxOEWxOiARsqNhkeMctyH S1OMjUR3tOgKujCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 16DC613461; Wed, 22 Nov 2023 12:29:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iMqKBTv0XWVxTgAAMHmgww (envelope-from ); Wed, 22 Nov 2023 12:29:47 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9B8ACA07DC; Wed, 22 Nov 2023 13:29:46 +0100 (CET) Date: Wed, 22 Nov 2023 13:29:46 +0100 From: Jan Kara 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: <20231122122946.wg3jqvem6fkg3tgw@quack3> 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: Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -3.80 X-Spamd-Result: default: False [-3.80 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] On Tue 21-11-23 00:35:20, Ritesh Harjani (IBM) wrote: > This patch converts ext2 regular file's buffered-io path to use iomap. > - buffered-io path using iomap_file_buffered_write > - DIO fallback to buffered-io now uses iomap_file_buffered_write > - writeback path now uses a new aops - ext2_file_aops > - truncate now uses iomap_truncate_page > - mmap path of ext2 continues to use generic_file_vm_ops > > Signed-off-by: Ritesh Harjani (IBM) Looks nice and simple. Just one comment below: > +static void ext2_file_readahead(struct readahead_control *rac) > +{ > + return iomap_readahead(rac, &ext2_iomap_ops); > +} As Matthew noted, the return of void here looks strange. > +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); > +} So this will end up mapping blocks for writeback one block at a time if I'm understanding things right because ext2_iomap_begin() never sets extent larger than 'length' in the iomap result. Hence the wpc checking looks pointless (and actually dangerous - see below). So this will probably get more expensive than necessary by calling into ext2_get_blocks() for each block? Perhaps we could first call ext2_iomap_begin() for reading with high length to get as many mapped blocks as we can and if we find unmapped block (should happen only for writes through mmap), we resort to what you have here... Hum, but this will not work because of the races with truncate which could remove blocks whose mapping we have cached in wpc. We can safely provide a mapping under a folio only once it is locked or has writeback bit set. XFS plays the revalidation sequence counter games because of this so we'd have to do something similar for ext2. Not that I'd care as much about ext2 writeback performance but it should not be that hard and we'll definitely need some similar solution for ext4 anyway. Can you give that a try (as a followup "performance improvement" patch). Honza -- Jan Kara SUSE Labs, CR