Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp444881pxb; Thu, 19 Aug 2021 03:27:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5sqs7IUnUZyeiotsxS0+RxLPT+O48YNOTbIp2e8poqB7N6up+Ezr4BCX4Mo8BTZJbzBDS X-Received: by 2002:a05:6402:1b9c:: with SMTP id cc28mr15464037edb.297.1629368860042; Thu, 19 Aug 2021 03:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629368860; cv=none; d=google.com; s=arc-20160816; b=CrZNzxEyLZaosVq8uEq2tqVGYSgom9hHmwzYUZ1QPpj12LWPYvkjOL7dey+A1VW41W 0uTiG86JHFDcGU5V+Ox8ViixWND7ByRAZgEIOq+zAbqXRNDnKaEMulZy/ZPAPLIk4u0e 7hJQ4ZV1f/eG3UwdOmdCP9TLS+RS8edWN1XvE7yNmRqsvg09AstcQzV6z9kSyxPY8kyb jjDYqnhKxIeEmQelxsGcr8Z7s7gZOcSJisz0Xdb7uxLFFcuq2vyQZnVq0R+UzJ4qRajQ LJuyp5guiI8sNaXTczDrovjV+XG633uug+9Rl59rFmaGC3L8PhXCExmKz54wlaGRbX6L Q1Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=dSDuwTm/rdxvSKGgmTHoO82+8/F3OMOJA4M/ZMsGgXo=; b=ahIB4uUoAmpsfjzTiIw6bxukhzJWQCH7wgcPmr93E8gEdnJpm5PsLbXHFHrcLE9pBG 4/0mIXIRTs3nt1hPI0cc/9J++zYZZZQikVeOOjeLyoUYIzqRP8wXTfBmukFuTb+z4N+U SxbR0B9jtbaPW7gOCTCppGIrHPXKHiCXN0XlF4Lt8Hu2Vc4tCYJizaGB8nRedifeJRcj b+Njf7/BKEnZmDGGZtsObLmmr5rEkMW4LxfvCChVC2KqLWIYZoAcRebBJTijaCGAFeZI VzGzazMJf6QExclW4SV3hBYS2ZGIscGC2w9Dv+H0Xg2VLJKEu/O0UKrUKklYzCswsYVU n1UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qxX3jlDG; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=R6hamqo9; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd21si2711564edb.266.2021.08.19.03.27.09; Thu, 19 Aug 2021 03:27:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qxX3jlDG; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=R6hamqo9; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238150AbhHSK0w (ORCPT + 99 others); Thu, 19 Aug 2021 06:26:52 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:44670 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238219AbhHSK0w (ORCPT ); Thu, 19 Aug 2021 06:26:52 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5BA1F1FD87; Thu, 19 Aug 2021 10:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1629368775; 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=dSDuwTm/rdxvSKGgmTHoO82+8/F3OMOJA4M/ZMsGgXo=; b=qxX3jlDGyN04MBkQWmxyW5jXYeQtMCy2qeb4pi3OnPnfBt7RohLl1N/Ffnr5PftLg3Vwb3 hRXjlwz0lr3accwMNuthmYpd7iqS4iNZIuLhvUeVAVYDKZeJSY6AOo30IMiGVOQO855Umx SWpVvYI/aMQ+l5hCjv5L55gdDPHPlmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1629368775; 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=dSDuwTm/rdxvSKGgmTHoO82+8/F3OMOJA4M/ZMsGgXo=; b=R6hamqo9r0rxFp6SSl1xX6RTNzktujMu008CGAI1ccnj3Qn4TsZgVwGcBMUeW2qTMF2dh0 TQ/Chd4KxrflGdBQ== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 7E0C2A3BC1; Thu, 19 Aug 2021 10:25:57 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id C0FAE1E0679; Thu, 19 Aug 2021 12:26:14 +0200 (CEST) Date: Thu, 19 Aug 2021 12:26:14 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [PATCH v2 3/4] ext4: don't return error if huge_file feature mismatch Message-ID: <20210819102614.GA32435@quack2.suse.cz> References: <20210819065704.1248402-1-yi.zhang@huawei.com> <20210819065704.1248402-4-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210819065704.1248402-4-yi.zhang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 19-08-21 14:57:03, Zhang Yi wrote: > In ext4_inode_blocks_set(), huge_file feature should exist when setting > i_blocks beyond a 32 bit variable could be represented, return EFBIG if > not. This error should never happen in theory since sb->s_maxbytes should > not have allowed this, and we have already init sb->s_maxbytes according > to this feature in ext4_fill_super(). So switch to use WARN_ON_ONCE > instead. > > Signed-off-by: Zhang Yi > --- One comment below: > @@ -4918,10 +4918,15 @@ static int ext4_inode_blocks_set(handle_t *handle, > raw_inode->i_blocks_lo = cpu_to_le32(i_blocks); > raw_inode->i_blocks_high = 0; > ext4_clear_inode_flag(inode, EXT4_INODE_HUGE_FILE); > - return 0; > + return; > } > - if (!ext4_has_feature_huge_file(sb)) > - return -EFBIG; > + > + /* > + * This should never happen since sb->s_maxbytes should not have > + * allowed this, which was set according to the huge_file feature > + * in ext4_fill_super(). > + */ > + WARN_ON_ONCE(!ext4_has_feature_huge_file(sb)); Thinking about this a bit more, this could also happen due to fs corruption. So we probably need to call ext4_error_inode() here instead of WARN_ON_ONCE(). Also it will result in properly marking fs as having errors. But since we hold i_raw_lock at this call site we need to keep the error bail out from ext4_inode_blocks_set() and in ext4_do_update_inode() finish updating inode and then call ext4_error_inode() after dropping i_raw_lock. Honza -- Jan Kara SUSE Labs, CR