Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp466731pxf; Thu, 11 Mar 2021 07:45:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMgi2Ue/VBBSmf3BWTOax+/R3PQ6BEzUKBRBhJxAgapm3LtfBIzUuKjHc22ff4DMMSxRHa X-Received: by 2002:a17:906:9714:: with SMTP id k20mr3628940ejx.519.1615477501586; Thu, 11 Mar 2021 07:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615477501; cv=none; d=google.com; s=arc-20160816; b=ofZUuILQGv4ZB2Vdj5YiUESXAVKHT/gHzYDcpbtoDveVJ2PuuCIR2BuaVw4H9YsLkv u7gAzoK114+eKIVADnqB2Yuv9akPMfduskFttU0BXKCAMyegs6YRtOqbMlmPjr5d4Mpi GGyWqFmnE67QdMZB/THFU9KECIzWc2bjmF5/1l6h7NLvX/gqIiv+Jt3mha4UbntZnAbO hoXZM+SCXlMHBgqG+ac6E5kuM6FatS/4AtI89NFYBgKd7SKQGX8Cym7l3HPnskYoYxUI J6ZI5BeGt/SqVGHDVtzYps8XmGqdb9HxK7TMKjPX220wwRd4OugY5oWRUg9bCM/IZCKd EOlA== 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; bh=HozHbC7x1CZSamEU/C6TYXd8FWAPQnTQRfIjPdUfGvg=; b=eEa2PSEcdpC/Tdq6CZdp50YG9Xq1QKG8SqZWs7oeWDmIhLMx2j8LWnIMKpnK0iXWKf CiWmgUGoKg0dLF2KaefAxkPL+8oTs7cUF+ucY524SneDpioPY4Lq5BdCfjTEJS0XatZg JZfwGg3DHKdiRn6bCQhK6j1KLNfev5aZTQDxtBzEGN+NZcNC6YW4CElwmR5YZL2mOfIz IZ3tKg8NqQ7cLlILqg6hm5VfZWbFsqyJkbSDGFzN364cFISWfu+epm8L22l6OTBz2z5s qW7QBfV0ZLitpY1E1dFK3ULTST4dNDv22MR5C/cbcpgfv18we4F/bzFaZtpFXM8Ors9O LVQg== 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 m21si1305201edp.392.2021.03.11.07.44.35; Thu, 11 Mar 2021 07:45:01 -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 S234253AbhCKPoC (ORCPT + 99 others); Thu, 11 Mar 2021 10:44:02 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:49485 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234382AbhCKPna (ORCPT ); Thu, 11 Mar 2021 10:43:30 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 12BFhFIM000793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Mar 2021 10:43:17 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 8FB0815C3AA0; Thu, 11 Mar 2021 10:43:15 -0500 (EST) Date: Thu, 11 Mar 2021 10:43:15 -0500 From: "Theodore Ts'o" To: "zhangyi (F)" Cc: linux-ext4@vger.kernel.org, jack@suse.cz, yangerkun@huawei.com Subject: Re: [PATCH v1 1/2] ext4: find old entry again if failed to rename whiteout Message-ID: References: <20210303131703.330415-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210303131703.330415-1-yi.zhang@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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? - Ted