Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp879631pxf; Thu, 11 Mar 2021 18:03:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJy88Ywra+StRizr3a1XEoJfzwEkVD69kzGMRhXSJrv4YJnm0srquaH4lUaGqmGFoCQfniBz X-Received: by 2002:a05:6402:3049:: with SMTP id bu9mr11765056edb.104.1615514618724; Thu, 11 Mar 2021 18:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615514618; cv=none; d=google.com; s=arc-20160816; b=Duw+hmbKIBoTtEclFR9xS8ffrorVRXlFi92RygEWGeh5bIWnESCejhwJ/Yp/lp8FYh 0vJ61aE2TfTXPrISZu7Q/RSPtQUgFwwKOmwvioOqGKuaTb4ZiDtTxqmyN6EwHrmNDCVI shzhEYuNuL06Rrl09VWSEpReBhRT3MIyky8ja5Lf8nfSnZShnBYKQfcRbyF2Ly+UWFVT /T62bHbQnzlcTr7FW0tK3DMjHn7SLOvvYmt73P8GaCYJkqQm3qbx3E853JklGDcBmVFf lJgEmORhiUEsQlwdKk5FEGuw7Z8e3EfhOhOhbPFBq4QbFwy6JJU2ljVL/1IhoWT/h9KS SM+A== 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=b1FL4arNu+uk4VEOGqKbsSd1U5GBzD5GAjILXgdy/T0=; b=LujPPd43QJ7VUZRZPqtTzhlguteCVxV66LATor5wijCgoccYa/3pb9Z0hg12L7OozT y1FRWDeNZ2ZrQutP2Dih/n2Bx43qFY05c9zq8/dCC4/df8NLOqpA4s6yMhfMTbl82M+j s9gOjl6p9IPpop0M53y8LE8ngqUitQmgZrVokzT2jFrG0UlP7pASHtREEe7DzyUwltmx zMz4knvt9fLYOCvCnePqmOqhg5FzVLT76RQl6nqT1+OKa+6waEc9vvmtR/AUSZlPtkR4 t5pryM1yY/xl0+OUsPMGEx5yi9aYu04kBiZdix+TAUQeN2t/p1Av0yAolB+9Yqz2xmTk irkQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o20si2960471eja.515.2021.03.11.18.03.11; Thu, 11 Mar 2021 18:03:38 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbhCLCCf (ORCPT + 99 others); Thu, 11 Mar 2021 21:02:35 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:13909 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhCLCCG (ORCPT ); Thu, 11 Mar 2021 21:02:06 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DxTYB6qrpzkXvk; Fri, 12 Mar 2021 10:00:30 +0800 (CST) Received: from [10.174.176.202] (10.174.176.202) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Fri, 12 Mar 2021 10:01:50 +0800 Subject: Re: [PATCH v1 1/2] ext4: find old entry again if failed to rename whiteout To: Theodore Ts'o CC: , , References: <20210303131703.330415-1-yi.zhang@huawei.com> From: "zhangyi (F)" Message-ID: Date: Fri, 12 Mar 2021 10:01:50 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.202] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2021/3/11 23:43, Theodore Ts'o wrote: > On Wed, Mar 03, 2021 at 09:17:02PM +0800, zhangyi (F) wrote: >> If we failed to add new entry on rename whiteout, we cannot reset the >> old->de entry directly, because the old->de could have moved from under >> us during make indexed dir. So find the old entry again before reset is >> needed, otherwise it may corrupt the filesystem as below. >> >> /dev/sda: Entry '00000001' in ??? (12) has deleted/unused inode 15. CLEARED. >> /dev/sda: Unattached inode 75 >> /dev/sda: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. >> >> .... >> >> + /* >> + * old->de could have moved from under us during make indexed dir, >> + * so the old->de may no longer valid and need to find it again >> + * before reset old inode info. >> + */ >> + old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); >> + if (IS_ERR(old.bh)) >> + retval = PTR_ERR(old.bh); >> + if (!old.bh) >> + retval = -ENOENT; >> + if (retval) { >> + ext4_std_error(old.dir->i_sb, retval); > > > So if the directory entry may have been deleted out from under us, an > ENOENT failure might happen under normal circumstances, shouldn't it? > > In that case, ext4_std_error() will declare that the file system is > inconsistent, potentially resulting in the file system to be remounted > read-only, or causing the system to panic. So calling > ext4_std_error() needs to be done carefully. > > Are we sure that calling ext4_std_error() is the right thing to do in > the case where ext4_find_entry() returns ENOENT? > Hi, Ted In this error path of whiteout rename, we want to restore the old inode number and old name back to the old entry, it's just a rollback operation. The old entry will stay where it was in common cases, but it can be moved from the first block to the leaf block during make indexed dir for one special case, but it cannot be deleted in theory. So if we cannot find it again, there must some bad thing happen and the filesystem may probably inconsistency. So I calling ext4_std_error() here,or am I missing something? Thanks, Yi.