Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp561623pxb; Thu, 19 Aug 2021 06:13:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8F8Ri9Kbe6cb0Vq0bz5jYIFCFMTemFiO6aOB+RVI9MW67CctHn7sBbHtpXJaBMKpWBRuA X-Received: by 2002:a17:906:d9dc:: with SMTP id qk28mr7468154ejb.491.1629378802390; Thu, 19 Aug 2021 06:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629378802; cv=none; d=google.com; s=arc-20160816; b=BZyC2JF1lMK/lXplZJ4lbzHBhwfNprAE3OgYx7/mxUTv0Z7OflKxk2JKrEeF/6CA30 hYPOohNhHRObBOp9BJ5In2H8DO56xCyRAgcTk+mpvYRZEOZHbBftviCIA/BSy2Y5AKcR TOQzDL/Tvn+JlKCFSk668JkCK4NlO2pMz1tBkR1kM8NeO5cT09DCAUqi/aeb/SaBZix+ UQPAQFAvzBXOiXipzUjUo3jLBZGaptk5D9aT5VpFFmghcrJAJeLQMtO1ctjWABOFQEBa mwi0wqaKh3GuZUhRsuJuOdbPhDJePkRezQa9arek5a1JF99WicxGTf+aNNAGLxa9/dMx cyiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=HDyw64ihkgdjF4ebKze3p0/WXlBjg+UPCfDd7oxCVkQ=; b=h6rEpPVipfPiBHlC4JC6qRB6XotKGRzuBdHZ3JnyEiW8T369shSSXWoEXeFUdN7uDN 1nqGjUbt30s2+HLrnulueRv/d0dAKnZYD5joLxmowbnabeUHP2qZ09FEI7lzfVC7WIKH BW2QknNwBY0cTJP+n8TpJGT/1iyTnh9pnsUgDcQnX5QY624DFYhi9eMZDPuWSNzulrKr Nj6QhAmar3cIpnIemM9n4056eHFtEner2VeG2xMlYJqfhJNAA/uLfPR+TAByJ7+5KdSq 6TQDbrUw4kQnm4lu9FJXq3sIybtePCbCZdqz+GTtVlAx5ZP8s8OCMdU3slzqXjUXBukj KM3A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq36si3336288ejc.520.2021.08.19.06.12.45; Thu, 19 Aug 2021 06:13:22 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238292AbhHSNMj (ORCPT + 99 others); Thu, 19 Aug 2021 09:12:39 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:8047 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233713AbhHSNMj (ORCPT ); Thu, 19 Aug 2021 09:12:39 -0400 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Gr4sf4jG6zYrSp; Thu, 19 Aug 2021 21:11:34 +0800 (CST) Received: from [10.174.178.134] (10.174.178.134) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 19 Aug 2021 21:11:59 +0800 Subject: Re: [PATCH v2 3/4] ext4: don't return error if huge_file feature mismatch To: Jan Kara CC: , , , References: <20210819065704.1248402-1-yi.zhang@huawei.com> <20210819065704.1248402-4-yi.zhang@huawei.com> <20210819102614.GA32435@quack2.suse.cz> From: Zhang Yi Message-ID: <3bccf3af-8408-4a57-74a0-5d9fca85cf1e@huawei.com> Date: Thu, 19 Aug 2021 21:11:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20210819102614.GA32435@quack2.suse.cz> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.134] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeme752-chm.china.huawei.com (10.3.19.98) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2021/8/19 18:26, Jan Kara wrote: > 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. > Yes, make sense, ext4_error_inode() is more reasonable. Thanks, Yi.