Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5757489rwd; Mon, 5 Jun 2023 08:10:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qYGnw8k98N9XKXZz1v2jA1TS264pON/7fe+fWoLfaSD1l20xHlrzLyq3n4RXnxnywnuHl X-Received: by 2002:a05:6a20:2454:b0:106:c9b7:c93d with SMTP id t20-20020a056a20245400b00106c9b7c93dmr8722341pzc.19.1685977826844; Mon, 05 Jun 2023 08:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685977826; cv=none; d=google.com; s=arc-20160816; b=CQhlL7EX50TEXH9DuOlb1qg6rJUp6J4HI3Ckg7UXN1097w4ldMxKyt8ETidL1tEaZ/ zQazDywCGgX7pQmUUvwPR/H7H3v3Gfdn417qeKs26arFLCIQbPc6Li6KPxe0UxlRkM/i L7klmxal3wWhzdyq0ap4RaqHhtV+4SN4P+pFmNjzSXOz0TLw/1a58VG0XFRpuuhqCrtq 1os2cIDo9kKKQFcNHASqV4cT7WaIQI/g1iJsOrk+3TcJrVgWCl88Fo8A2CcXdGUxPHhp M282GozYZ0s8iEIXtb7hl6jT3kay6+Esq0tZI9MP/hW1FtuUX/LcZ+Q2k8TaUIcg/qUl xZ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=g6Fpv18tPkZl3njhXBvdawu8JHw6otAv8L2MKSyYslo=; b=KqBRdZ3alt6dUuyoQ2FwXkg9N/+5QvNkOEQCJUTutCWyUrdqzLrpzwmpOMU7jglOZ+ hDBwfLLMezpuL3vhaNJJLIUXF7EHpm1/0Yi0VcVpnqM8W3xEagdry9i+dIWrP2uYwYH8 jeyR7Re5MbT7GzyXT8Mu5k2LC4vJgUgVwWKkV4CSRbSJRofFW/U7gghlkWZJF3F7nuEv /OmG1VK6yMQ3m1dca6W8Ui/7f7b0UzasM66GXrR2BWvO5ARWUawoJ5WfE4duiDWk30MI NL+1X/Qo/PiaaF8Hxi+C4szebYqvWeheZ0wGI2fIGsRXVfa59CbGXKtyPKnGkZGclVOE RTqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zirSbKRW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020aa78bd0000000b00655079704afsi3847381pfd.119.2023.06.05.08.09.57; Mon, 05 Jun 2023 08:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=zirSbKRW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjFEPJN (ORCPT + 99 others); Mon, 5 Jun 2023 11:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232874AbjFEPJA (ORCPT ); Mon, 5 Jun 2023 11:09:00 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2BCAEA; Mon, 5 Jun 2023 08:08:57 -0700 (PDT) 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 5F4F821B77; Mon, 5 Jun 2023 15:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1685977736; 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=g6Fpv18tPkZl3njhXBvdawu8JHw6otAv8L2MKSyYslo=; b=zirSbKRWhfhtvxOs7QBUaHa9zQLlEc1gyBvl4SlcmMPoIXaYRFedTk2Ld7zq6EJHO6r+FZ AfvxJUGs4+GeP2Fs9rAAUFEbv8t2GOJmYexdw/dDiVpioOMdLGySXojNygfq/xIGslEgqK ju6S2u/3/ypu9NbMgGld5W6GBeKV+4E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1685977736; 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=g6Fpv18tPkZl3njhXBvdawu8JHw6otAv8L2MKSyYslo=; b=zhdG6TkIMVNl1iVrLLr0DVEvvNEQdqEzR7hOX5p1HLtF2gXg4ukoU5VZh7D/RS8jG0gPgm BL3LSYipgRoJ4dAw== 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 4B0ED139C8; Mon, 5 Jun 2023 15:08:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6dBCEoj6fWTvagAAMHmgww (envelope-from ); Mon, 05 Jun 2023 15:08:56 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C14D1A0754; Mon, 5 Jun 2023 17:08:55 +0200 (CEST) Date: Mon, 5 Jun 2023 17:08:55 +0200 From: Jan Kara To: Matthew Wilcox Cc: Jan Kara , Theodore Ts'o , Baokun Li , linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, ritesh.list@gmail.com, linux-kernel@vger.kernel.org, jun.nie@linaro.org, ebiggers@kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, yukuai3@huawei.com, syzbot+a158d886ca08a3fecca4@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: Re: [PATCH v2] ext4: fix race condition between buffer write and page_mkwrite Message-ID: <20230605150855.7oaiplp7r57dcww3@quack3> References: <20230530134405.322194-1-libaokun1@huawei.com> <20230604030445.GF1128744@mit.edu> <20230604210821.GA1257572@mit.edu> <20230605091655.24vl5fjesfskt3o5@quack3> <20230605122141.4njwwx3mrapqhvt4@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 05-06-23 15:55:35, Matthew Wilcox wrote: > On Mon, Jun 05, 2023 at 02:21:41PM +0200, Jan Kara wrote: > > On Mon 05-06-23 11:16:55, Jan Kara wrote: > > > Yeah, I agree, that is also the conclusion I have arrived at when thinking > > > about this problem now. We should be able to just remove the conversion > > > from ext4_page_mkwrite() and rely on write(2) or truncate(2) doing it when > > > growing i_size. > > > > OK, thinking more about this and searching through the history, I've > > realized why the conversion is originally in ext4_page_mkwrite(). The > > problem is described in commit 7b4cc9787fe35b ("ext4: evict inline data > > when writing to memory map") but essentially it boils down to the fact that > > ext4 writeback code does not expect dirty page for a file with inline data > > because ext4_write_inline_data_end() should have copied the data into the > > inode and cleared the folio's dirty flag. > > > > Indeed messing with xattrs from the writeback path to copy page contents > > into inline data xattr would be ... interesting. Hum, out of good ideas for > > now :-|. > > Is it so bad? Now that we don't have writepage in ext4, only > writepages, it seems like we have a considerably more benign locking > environment to work in. Well, yes, without ->writepage() it might be *possible*. But still rather ugly. The problem is that in ->writepages() i_size is not stable. Thus also whether the inode data is inline or not is not stable. We'd need inode_lock for that but that is not easily doable in the writeback path - inode lock would then become fs_reclaim unsafe... Honza -- Jan Kara SUSE Labs, CR