Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1124620pxf; Fri, 2 Apr 2021 01:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3GgR7038UQkH+DgVh/qCFEPB4FQ5O8VM1SJK59/fMCbS6rIwDgW6dodMJPk3CAwlOaENp X-Received: by 2002:a6b:8b0e:: with SMTP id n14mr10405113iod.199.1617353052754; Fri, 02 Apr 2021 01:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617353052; cv=none; d=google.com; s=arc-20160816; b=ObvTOL5sFZG7tBF8cKGokhSmbIXNmiuDqszlhhK6PSe9v/bAN1edRHyQLkXAz/70/P +NG0/YrprJ1M76wJn8x9066Is6pqvHJ9j6AoWODqgewtPhueEcMwQZxrFezxRsIylw2+ hVV3ol1fwWm/Fs83nAopgGOYZys0g3Jv0NUHodMHIazDkVHIxB1vJn6g8C0WvETukF1a bCEuQyJuVVxEW4W6qIA7UPicNvYSs3Rmns1/CF/x5eSdBYFQQXLF6OA7yUi8hTOwtvEb 8xEm8jPWyn53QlGsqoIHeJzfRyB161vYwv81nwBkIo94Qe+aSa1zKcKkA9RI95EXYpqA EmkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:thread-index :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from; bh=IPqcgecqQ6D9TNP0uG3O79A4qXJfu0j2UxfRtK7FVyU=; b=NWrgdjrGVMsUOwObLN2mq8YU5lEt6N4TReza9pCblSSDr1Qen4hUMPEQc60sfFLw8c oZ7BfwPS5i15GDrjrr59QkVwKALyHQjHbFtJjdVEEPIr5+GCW2+Q9qdrCFCeX/Apgpfn k/BXMkYbTtqxJdcCjBXc5skeDr0izvXCy96P+BTWrt44xToqsTZc3RaRDBD4f9u8aG8V oM0YYt/yTnGyP7U8c+KDzwa4zdoqkYorF4u1J+Xud6tMuji52+ZAub9U5A/8EtMD8mtM 7HHdjXEpWTwleqUbR4XF/+xals3RG1Xl8Lk7/mNQk41mRLv0bBgv9eBGagjZmgaRjRdi NsRw== 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=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si7583913ilj.28.2021.04.02.01.43.54; Fri, 02 Apr 2021 01:44:12 -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=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbhDBInx convert rfc822-to-8bit (ORCPT + 99 others); Fri, 2 Apr 2021 04:43:53 -0400 Received: from mail-m17639.qiye.163.com ([59.111.176.39]:33820 "EHLO mail-m17639.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbhDBInw (ORCPT ); Fri, 2 Apr 2021 04:43:52 -0400 Received: from SZ11126892 (unknown [58.251.74.232]) by mail-m17639.qiye.163.com (Hmail) with ESMTPA id C66573804F9; Fri, 2 Apr 2021 16:43:49 +0800 (CST) From: To: "'Andreas Dilger'" Cc: "'Theodore Y. Ts'o'" , "'Ext4 Developers List'" References: <20210329035800.648-1-changfengnan@vivo.com> <000801d72770$d3f4b890$7bde29b0$@vivo.com> In-Reply-To: Subject: =?utf-8?Q?=E7=AD=94=E5=A4=8D:_=5BPATCH=5D_ext4:_fix_error_code?= =?utf-8?Q?_in_ext4=5Fcommit=5Fsuper?= Date: Fri, 2 Apr 2021 16:43:49 +0800 Message-ID: <001801d7279c$4d851df0$e88f59d0$@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKGikBhgiQAULD/1R54Z6dLmieg4wKxp9ylAmuttrIBOyE5Ew== Content-Language: zh-cn X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZSEtJGUsaT0tLSk5MVkpNSkxITkhLSEtLSktVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6K0k6IRw6PD8OTyoZDh4IESxC GkMwCjdVSlVKTUpMSE5IS0hLSUJCVTMWGhIXVRgTGhUcHR4VHBUaFTsNEg0UVRgUFkVZV1kSC1lB WU5DVUlOSlVMT1VJSElZV1kIAVlBT0xCTDcG X-HM-Tid: 0a7891c0b928d994kuwsc66573804f9 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Thanks for your advice, We did found this problem during code review. I will revise it according to your opinion. -----邮件原件----- 发件人: Andreas Dilger 发送时间: 2021年4月2日 15:58 收件人: changfengnan@vivo.com 抄送: Theodore Y. Ts'o ; Ext4 Developers List 主题: Re: [PATCH] ext4: fix error code in ext4_commit_super On Apr 1, 2021, at 9:32 PM, wrote: > > Is there any problem with this patch? I did not see a reply, please > let me know if there is a problem. Thanks It's only been a few days since the patch was first posted, so nobody has had a chance to review it yet. The patch looks "obviously correct" at first glance, but often changing code is not as obvious as first expected. Also, is "-EINVAL" the best code here? For "block_device_ejected()" it might be more clear to return "-ENODEV" so that it prints "No such device" instead of "Invalid argument" in userspace. > 发件人: Fengnan Chang > 发送时间: 2021年3月29日 11:58 > 收件人: tytso@mit.edu; adilger.kernel@dilger.ca; > linux-ext4@vger.kernel.org > > We should set the error code when ext4_commit_super check argument failed. It would be useful if this also described how this problem was hit, or what caused this issue to be seen/fixed. "Found while reviewing code" is OK, if that is the case, or "crashed during mount when ejecting a floppy disk", or whatever. That makes it more clear how important the bug fix is to be landed and backported. It would also be useful to include a "Fixes:" label to show which patch caused the problem, and help decide which stable kernels need this patch. From running "git blame fs/ext4/super.c" appears that commit 2d01ddc86606 ("ext4: save error info to sb through journal if available") introduced the problem, but it seems like that patch only copied it from older code. However, further digging shows commit c4be0c1dc4cdc ("filesystem freeze: add error handling of write_super_lockfs/unlockfs") added this particular code (error = 0; return error). Before that time, no error was returned from this function at all, so the commit message should include: Fixes: c4be0c1dc4cdc ("filesystem freeze: add error handling of write_super_lockfs/unlockfs") Cheers, Andreas > Signed-off-by: Fengnan Chang > --- > fs/ext4/super.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c index > 03373471131c..5440b8ff86a8 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -5501,7 +5501,7 @@ static int ext4_commit_super(struct super_block > *sb, int sync) > int error = 0; > > if (!sbh || block_device_ejected(sb)) > - return error; > + return -EINVAL; > > /* > * If the file system is mounted read-only, don't update the > -- > 2.29.0 > > > Cheers, Andreas