Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9652946pxu; Tue, 29 Dec 2020 00:59:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwiHMPbRPgjaxALpE7zucYDKYXVTb/D9HVhdg74pNdQgA/5TdMWpoMeexW6uzEg39GZe/q X-Received: by 2002:a50:f089:: with SMTP id v9mr46627421edl.353.1609232398438; Tue, 29 Dec 2020 00:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609232398; cv=none; d=google.com; s=arc-20160816; b=o4Gu9oA4QJP7mt8fXXprdEq2XGGjLuOe3hsbYf/Xz6w8+PcXBvtMyQjNiJKihzQsCc WdCZdWbM+Ilshh1jb8vNfuEA5IfWGc297t3MdDvCFTtYsjQIRLK3I/rPxiad2WqclNsu zAez+014QNabE+ncTQj7QnBwpbiA5Ln7E2iVFsJjNrVaVjsDS8MqA2wN/Clq4O6bu2MN n4KI1KNeGdLwOOQ6WhQIZ1NC37uLarDadng+kkV/EP3Pt32RL5zYwEkiDAEEqNLLEY8U EeM3LgbPtsnRKIfiZPe0PeGslZ27nbzUKXGsHv7Sxf3JfbrZWEntEbvwxZGB6mL+A70S wcNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=FjwFknbnzRbW131EK/8HXyg9JWkcN5qqv8WjASWHtB0=; b=d85fZvnNxTxm0MuPYL8s8UOpAdC/O+yP2geRnW1NQzcbQ9n8nHdZqr2taFucHa+WaL l82BWfrwWfE4I7w4jimbXxZYYp8jURhYZWQDL4ztAMpndZqwPEY4llR9w9YHCKno3mxc 6YCWQHQx03ZxIw3MnL8uyRLKcMECGnM4gRtSf+LbeIzLFW11m5g3NBVcUBYcFER/uVPu SgybnWtLYgQPpEs5m51eMRMg0yWyfQdpUHZ209TNsU9A5m0Egjy/rVYDWylXrIZVfQIn d7AOtnqf71QkLXiJIbVHByEMeDm0vp3M+qdOUCLxfWk5QU9/QrYWZAxwNRTWRVJ3QtyZ jlxQ== 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 ca24si20949461edb.492.2020.12.29.00.59.35; Tue, 29 Dec 2020 00:59:58 -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 S1726185AbgL2I6g (ORCPT + 99 others); Tue, 29 Dec 2020 03:58:36 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:10372 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgL2I6g (ORCPT ); Tue, 29 Dec 2020 03:58:36 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D4pFY1sfWz7Lyf; Tue, 29 Dec 2020 16:57:05 +0800 (CST) Received: from [10.174.179.106] (10.174.179.106) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 29 Dec 2020 16:57:46 +0800 Subject: Re: [PATCH] ext4: fix bug for rename with RENAME_WHITEOUT To: , , , CC: , , , References: <20201229085609.1109598-1-yangerkun@huawei.com> From: yangerkun Message-ID: <24f6a6ff-bfa9-f0e6-1ab0-cf56222d0d40@huawei.com> Date: Tue, 29 Dec 2020 16:57:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20201229085609.1109598-1-yangerkun@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.106] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ?? 2020/12/29 16:56, yangerkun ะด??: > ext4_rename will create a special inode for whiteout and use this 'ino' > to replace the source file's dir entry 'ino'. Once error happens > latter(small ext4 img, and consume all space, so the rename with dst > path not exist will fail due to the ENOSPC return from ext4_add_entry in > ext4_rename), the cleanup do drop the nlink for whiteout, but forget to > restore 'ino' with source file. This will lead to "deleted inode > referenced". > > Signed-off-by: yangerkun > --- > fs/ext4/namei.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index b17a082b7db1..0e89e5a0c758 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -3593,9 +3593,6 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent, > return retval2; > } > } > - brelse(ent->bh); > - ent->bh = NULL; > - > return retval; > } > > @@ -3794,6 +3791,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, > } > } > > + old_file_type = old.de->file_type; > if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) > ext4_handle_sync(handle); > > @@ -3821,7 +3819,6 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, > force_reread = (new.dir->i_ino == old.dir->i_ino && > ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA)); > > - old_file_type = old.de->file_type; > if (whiteout) { > /* > * Do this before adding a new entry, so the old entry is sure > @@ -3919,15 +3916,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, > retval = 0; > > end_rename: > - brelse(old.dir_bh); > - brelse(old.bh); > - brelse(new.bh); > if (whiteout) { > + ext4_setent(handle, &old, > + old.inode->i_ino, old_file_type); > if (retval) > drop_nlink(whiteout); > unlock_new_inode(whiteout); > iput(whiteout); > + This is a mistake... Will send v2. > } > + brelse(old.dir_bh); > + brelse(old.bh); > + brelse(new.bh); > if (handle) > ext4_journal_stop(handle); > return retval; >