Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5186758rwb; Wed, 21 Sep 2022 04:33:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FyyDIS7be9wIeJrPex+WW9jNWNAqt5VwLSx67BOXPq+ljeWup7XgFmfFqwsdc7KCgTW92 X-Received: by 2002:aa7:de9a:0:b0:44d:8191:44c5 with SMTP id j26-20020aa7de9a000000b0044d819144c5mr24580276edv.232.1663760006282; Wed, 21 Sep 2022 04:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663760006; cv=none; d=google.com; s=arc-20160816; b=jooHra9DqVkxnARFHS6JYrIcMOVeyQN0qvSITlXf9N1MkKV+1D+74YAWC8nM2vsOlm aAu6ry1iRWC8AZiU/1AFwuXhZj9xcCxBm19xIr8XOjG0r8KSctAjh2eWS64alhp1F54r Qj7+huEE21vM9zXOzi/U34MwIqqUOMvb7Eemmi8n4941N8sDjOps5zNYJwbf4W+mvvEW YXi2+qUuJZA6ewZWYrQXsT1IK/5Yl3/nMEM7rNx4lqCq4Z+lAxkUlws3O3lRZEbV170t i8+5ybanLUIB0YYpeSLaeHqRavgQ1KNvacgcvbDiVE/4xl0l8+3ioPfRcXWbEWddEX7J ruUQ== 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=vlaKhHzIiNQlibAYkbq1JJIgnAIakxKuj8h+EiPGGVQ=; b=JkFhk+ou5f/j6Zz9+XjphNz9vt1QpzO+SYRjPJ/8YKVV0S6UnPo0d9j9gB8+QLpocb k0oaAzGSW1JyvuMdBOPBfqeQf6DoURtZ7+7C0FGmf/1EbuDKIQhXWiRiZBl+k8R1wvk7 cBMa4p87Xp92TFKbRDGOszBpNHiOuDnj1Lq0IPKBci+Lm55Wn825oFx6wCWMOSd2H2Ca A2kR2uqmj18p6JjaIA/cHtDohqB3khDN09D/zVISc3zLg+GwyfGHCM/CtS3j+bDTiiuJ byawHeZ8opXwZef5++AiENsQ7jhFuJ4lTPf9Dkp32Phhl3oPUn2HEWD0qeUGm5vtqUgg iBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=HNMUUe0M; dkim=neutral (no key) header.i=@suse.cz; 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 nd22-20020a170907629600b00741550f828bsi2225934ejc.919.2022.09.21.04.32.54; Wed, 21 Sep 2022 04:33: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=HNMUUe0M; dkim=neutral (no key) header.i=@suse.cz; 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 S229723AbiIULcc (ORCPT + 99 others); Wed, 21 Sep 2022 07:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbiIULca (ORCPT ); Wed, 21 Sep 2022 07:32:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE5CE8B2C8; Wed, 21 Sep 2022 04:32:29 -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 76B0221A59; Wed, 21 Sep 2022 11:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1663759948; 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=vlaKhHzIiNQlibAYkbq1JJIgnAIakxKuj8h+EiPGGVQ=; b=HNMUUe0MT1h6iEXUzRbRq7Dvoni4GSaWE95fG8q2F+/MI/UBxfkGPy8Zrb/5/SsvrAwpke 23NsdQKAhgZQJBjP1Bip2qkEebaD0h3pn5X/xKUzpe776VpmoqT+4sbjScOixI7v/c0/AE BmwqaKegt1G2WXtFn+kUqzyoJBNIRN0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1663759948; 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=vlaKhHzIiNQlibAYkbq1JJIgnAIakxKuj8h+EiPGGVQ=; b=+cNQkVODaXgKp8W/MCEKJWWUtz5RhjfvELFBygihfWCfvufPE8JjyKtz+BaoHXKPripoIB pgTzlSp2FVU+0lDw== 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 69CA313A00; Wed, 21 Sep 2022 11:32:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7+LVGUz2KmPPBAAAMHmgww (envelope-from ); Wed, 21 Sep 2022 11:32:28 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 057A7A0684; Wed, 21 Sep 2022 13:32:28 +0200 (CEST) Date: Wed, 21 Sep 2022 13:32:27 +0200 From: Jan Kara To: Ye Bin Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, jack@suse.cz Subject: Re: [PATCH -next v2 3/3] ext4: update 'state->fc_regions_size' after successful memory allocation Message-ID: <20220921113227.g3zfv474tmpzfw75@quack3> References: <20220921064040.3693255-1-yebin10@huawei.com> <20220921064040.3693255-4-yebin10@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220921064040.3693255-4-yebin10@huawei.com> 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 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 Wed 21-09-22 14:40:40, Ye Bin wrote: > To avoid to 'state->fc_regions_size' mismatch with 'state->fc_regions' > when fail to reallocate 'fc_reqions',only update 'state->fc_regions_size' > after 'state->fc_regions' is allocated successfully. > > Signed-off-by: Ye Bin Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/fast_commit.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c > index f5b0fc50ed47..694ab0627395 100644 > --- a/fs/ext4/fast_commit.c > +++ b/fs/ext4/fast_commit.c > @@ -1681,14 +1681,15 @@ int ext4_fc_record_regions(struct super_block *sb, int ino, > if (state->fc_regions_used == state->fc_regions_size) { > struct ext4_fc_alloc_region *fc_regions; > > - state->fc_regions_size += > - EXT4_FC_REPLAY_REALLOC_INCREMENT; > fc_regions = krealloc(state->fc_regions, > - state->fc_regions_size * > - sizeof(struct ext4_fc_alloc_region), > + sizeof(struct ext4_fc_alloc_region) * > + (state->fc_regions_size + > + EXT4_FC_REPLAY_REALLOC_INCREMENT), > GFP_KERNEL); > if (!fc_regions) > return -ENOMEM; > + state->fc_regions_size += > + EXT4_FC_REPLAY_REALLOC_INCREMENT; > state->fc_regions = fc_regions; > } > region = &state->fc_regions[state->fc_regions_used++]; > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR