Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4717038ioa; Wed, 27 Apr 2022 09:33:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcvvpWV+pPhBzpLiN0W1dS0GVAkuO++jvI83+KCIgd8CA/p3UTvt8adSt+xKd3oshMDK2a X-Received: by 2002:a17:902:bf07:b0:158:d334:852f with SMTP id bi7-20020a170902bf0700b00158d334852fmr29390404plb.136.1651077189538; Wed, 27 Apr 2022 09:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077189; cv=none; d=google.com; s=arc-20160816; b=SYHL0Km0e0rNnufewaXNefG2DoWk9HPjvl77UIZCll4sA5tu74Yg2cuqetuI1Ih/Qr WcdARv5AbiH9UsSr0Z5vXUaGtAbrcQWFhZkph/07aHE249Bec6qVV9UukBEd4dqaiiG5 VBtbvsxK5eWpWwu4Db3N1JBDuRsN5kjnMjyDbVU9Vb26gdSClkEZgGwiX4B1jy0nW6Rf or62AOIo5TYFn32Ox9ZIztM71dWgxD8KycAHKHYyjPvIYSJVISoOSP6q8TfnUoljzS7M wSlQHYyLFmAQHurQaVlsi3UEN9cmxgttoFdmLSUuXB20p466aKKmiytEqGOX0g4zVSOE PXNw== 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=L5vTUanWsKPlOJsN/BDsIkrXDb1hhhLYOpNUCOVkBSM=; b=0tmMRYEWAuvqtt6c9I0P0h1g0kB4FRZTtryX5tLhDhGMSZFrb982kOP507iEfp/Gbs A/ONmLNZf8DYrGPbqwpqC1CNc4LuzFegmVt2kba/lVY+Vz5LyVJy7MQ/eLSr8901pXZ2 g1RK8pRTZQ13ZIpLntusr2S8Vqpdp8RtVIgIpgbn58nTq+j6jVY0h0W8DPfWLf/L3iM9 7E06fwcKybmbtGrZj2oYsCCa2QzoDhYaaYbrqC2N4ESsohLHpBNPpFdFj4hf1l472V3F 1/UN05SQ4mPGUOWfo76/43vtMuWkOhZX496oIot35QRKgSDOeAtBw/P8YWf5HvOhJ1Bc PAmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jK5n8fKr; dkim=neutral (no key) header.i=@suse.cz header.b=Z7ISKZyG; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w4-20020a170902e88400b00153b2d165f5si2365136plg.509.2022.04.27.09.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:33:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jK5n8fKr; dkim=neutral (no key) header.i=@suse.cz header.b=Z7ISKZyG; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A16543C9D6D; Wed, 27 Apr 2022 09:02:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241342AbiD0QF4 (ORCPT + 99 others); Wed, 27 Apr 2022 12:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243213AbiD0QFg (ORCPT ); Wed, 27 Apr 2022 12:05:36 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89DC017FBDE for ; Wed, 27 Apr 2022 09:02:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AE0CD1F37F; Wed, 27 Apr 2022 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651075326; 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=L5vTUanWsKPlOJsN/BDsIkrXDb1hhhLYOpNUCOVkBSM=; b=jK5n8fKrRuWt4xlfRr3l96fwVnP7TB5Ih9kBd31JaFGRgBg0+iblAH5ShSEpM/5fdCJEFp u6uO2GmEILjxUyJbLP/6Dns2LxhxsLpeCPx0W/syDwriQI4vsCjrEEExmrNXxuQl8V6MPS TisYvho7iH3C3vQkYrz15+oiuOWiLfQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651075326; 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=L5vTUanWsKPlOJsN/BDsIkrXDb1hhhLYOpNUCOVkBSM=; b=Z7ISKZyGQqQpqbvdiSceUSHRKVaRyKrKC8U50R/IQrW9wj0QWW5N+s03VXzt6mpzizlSYQ ACf2cu4r8TutGsCQ== Received: from quack3.suse.cz (unknown [10.100.224.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9FB2E2C142; Wed, 27 Apr 2022 16:02:06 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 5F62DA061C; Wed, 27 Apr 2022 18:02:06 +0200 (CEST) Date: Wed, 27 Apr 2022 18:02:06 +0200 From: Jan Kara To: Harshad Shirwadkar Cc: linux-ext4@vger.kernel.org, riteshh@linux.ibm.com, jack@suse.cz, tytso@mit.edu Subject: Re: [PATCH v3 3/6] ext4: mark inode dirty before grabbing i_data_sem in ext4_setattr Message-ID: <20220427160206.icjjrhqlsf42bega@quack3.lan> References: <20220419173143.3564144-1-harshads@google.com> <20220419173143.3564144-4-harshads@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220419173143.3564144-4-harshads@google.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 Tue 19-04-22 10:31:40, Harshad Shirwadkar wrote: > From: Harshad Shirwadkar > > Mark inode dirty first and then grab i_data_sem in ext4_setattr(). > > Signed-off-by: Harshad Shirwadkar > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index e88940251afd..6eae0804c6fd 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -5455,11 +5455,12 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, > (attr->ia_size > 0 ? attr->ia_size - 1 : 0) >> > inode->i_sb->s_blocksize_bits); > > - down_write(&EXT4_I(inode)->i_data_sem); > - EXT4_I(inode)->i_disksize = attr->ia_size; > rc = ext4_mark_inode_dirty(handle, inode); > if (!error) > error = rc; > + down_write(&EXT4_I(inode)->i_data_sem); > + EXT4_I(inode)->i_disksize = attr->ia_size; > + Hum, this isn't going to fly because ext4_mark_inode_dirty() copies data from ext4_inode_info to the on-disk buffer and thus new i_disksize will not be stored on the disk after your change. Honza -- Jan Kara SUSE Labs, CR