Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14349792pxu; Mon, 4 Jan 2021 22:00:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIQbOax7Of3DkwxG4+1ri+wso+qkhOyHAA3+KZKbEzSSVJAg4Pem5OqOvPO9q+M/Dn1dDE X-Received: by 2002:a17:906:a3c7:: with SMTP id ca7mr71408149ejb.523.1609826402708; Mon, 04 Jan 2021 22:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609826402; cv=none; d=google.com; s=arc-20160816; b=yY52VH8cGYAVQRBUJXg3d8GQlUvBtKE7tDFRhGQrfsxYQq3AY8s8pzl8qmHIsO2Nsw mt+6q/U6UmUCSn95pCJfcsnE97z4PicKzEo9KCuxyN2BKhR56HXAa+hSP0pg/ZEA/dDM a1oUvzNw3tXKbpto0u6ga2uTQVPtDmslkb8hvhzqzyxE58UYU7JjIZPI/yEPSeb8iYXh 3/7/vU/85YxbaLP2op392X30rkQUx5fWhGe8wJBkxuh03CcsB6Mnq9rCMouyPZ0JS2RT bhlFXE0ybIvQxZJSkP7vRgeTYV8yVFcYZUO5GoTsjJ2xKzeRjb7mrA3IDtgITeJOQo9r v8wg== 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=Vln9d0MjSHFcYyp0Zt/cce21Apyp+E1kvaW6UcEicgM=; b=e92mIVvIGoMx0MiWKT4fqxxv1XjC90yg2rPCN/oTLNIPfbQ2xkejdr4/l8+ghvhael RrvhBXGy5NOKg4JMuYJmVoUfdXcbTH4cpoQktw3vQVNmykk45678uJwBnfdmJBlkNsZp zlU6g5XHW28J3sydJN+VX7+XtcNgK5PFgYj0ZUCkcmGU3zZlrNiCMYf98PZzN748SqnO osic+8LB2MoQ6wJ5Aif2qch/hEaT4G8oI/kBPZDaubGfNvsOPvhtFYbQC3F/8nbNCTQj 6zSqc2OC7GXqQh9CocEEseWG4/WIMhhMvRfQAWn3HNmRCxhgNxawLUZhpThS5RR+u03d +UZA== 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 b7si33578506edy.561.2021.01.04.21.59.36; Mon, 04 Jan 2021 22:00:02 -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 S1725290AbhAEF6v (ORCPT + 99 others); Tue, 5 Jan 2021 00:58:51 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:10020 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725287AbhAEF6v (ORCPT ); Tue, 5 Jan 2021 00:58:51 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4D91wq0pTVzj3p6; Tue, 5 Jan 2021 13:57:15 +0800 (CST) Received: from [10.174.176.235] (10.174.176.235) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 5 Jan 2021 13:58:00 +0800 Subject: Re: [PATCH v2] ext4: fix bug for rename with RENAME_WHITEOUT To: Jan Kara CC: , , , , , , References: <20201229090208.1113218-1-yangerkun@huawei.com> <20210104141953.GF4018@quack2.suse.cz> From: yangerkun Message-ID: Date: Tue, 5 Jan 2021 13:58:00 +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: <20210104141953.GF4018@quack2.suse.cz> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.235] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ?? 2021/1/4 22:19, Jan Kara ะด??: > On Tue 29-12-20 17:02:08, yangerkun wrote: >> 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 > > Thanks for the patch! It looks mostly good, just one comment below: > >> 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); > > I'm wondering here - how is it correct to reset the 'old' entry whenever > whiteout != NULL? I'd expect this to be guarded by the if (retval) check... Thanks a lot! This is actually a bug and sorry for that. We need check retval to prevent call for ext4_setent for the correct case. I will resend the patch! > > Honza > >> if (retval) >> drop_nlink(whiteout); >> unlock_new_inode(whiteout); >> iput(whiteout); >> } >> + brelse(old.dir_bh); >> + brelse(old.bh); >> + brelse(new.bh); >> if (handle) >> ext4_journal_stop(handle); >> return retval; >> -- >> 2.25.4 >>