Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13854310pxu; Mon, 4 Jan 2021 06:21:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAaMx0em+Capnd358tYBREuzUuv703uD5WwsLPHs/S8LDVYQ/UVpttoes4BVWHbbDiRjl9 X-Received: by 2002:a50:f1c7:: with SMTP id y7mr71492775edl.184.1609770107306; Mon, 04 Jan 2021 06:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609770107; cv=none; d=google.com; s=arc-20160816; b=UTDdey0HDXyRxFfURkOP/46ZeZLCWNht45DRr+k3G4ixajCP/3zoyT4jV3LvYPElCL v1Me95UQ5Pi43NRf7A0SrPDmBvkysyZtPLdZyR4KDHWMwo0XbCToaoMZwgqC/CCXoLSM 73Nfyq1IgdZR5CeHo6cAH4DvA0yKVEpo1tQKUMS8Fl00wT4Zllg2fjjpBNyiB7j39k/2 FXYowZj0wDI26ix/4xlpVztB3Qa1lXB+a67lA3CivmeuHQ0w8e4vgweF2eYIpEdsbl8I ny3VEfpZUJCLNrAWcBszmWPQtlHBix4OQF+DnH/yuL55/FfPJKbUwh3mSt2pQnL0pBsG m/6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=hy13tS8Q4n9q8Dp0EZzID73WL7F7A7qIHDtCwldR/T4=; b=ulKrkguk4RG1+DaRLVRjUjlbbF6aKOUfo/HPgvJCwwXxBOcE/HHd7I6QcaNqscMkgW I4G44ZIoPD+yL21jvD88/ihvTNGMbfVh4hOkTi3eJFNloS1AoGQpQCtRn8xWVDzfU/BS Hw1DDw9DvCQ0atPrAxEKZ011YoKY9iuySeuGTOdAGhp6YAYc8UDM9m+9oPnI9+5gQ46R nkdKN14u7oyw81t9JhGi5eK9bM+dUtNrHjFggzS9KQkRaJ6Rperlavv1uampQV9wuGTH wm67/p0ym3icU4QTCDRgF2N4cPodAgKciSmFKYphu8wW7PyFKC9jKx71tDEvhmhAh/IP iTlQ== 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 kt11si29212082ejb.445.2021.01.04.06.21.22; Mon, 04 Jan 2021 06:21:47 -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 S1726779AbhADOUf (ORCPT + 99 others); Mon, 4 Jan 2021 09:20:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:42808 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727126AbhADOUf (ORCPT ); Mon, 4 Jan 2021 09:20:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id F1E05ACAF; Mon, 4 Jan 2021 14:19:53 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A63521E07FD; Mon, 4 Jan 2021 15:19:53 +0100 (CET) Date: Mon, 4 Jan 2021 15:19:53 +0100 From: Jan Kara To: yangerkun Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, lihaotian9@huawei.com, lutianxiong@huawei.com, linfeilong@huawei.com Subject: Re: [PATCH v2] ext4: fix bug for rename with RENAME_WHITEOUT Message-ID: <20210104141953.GF4018@quack2.suse.cz> References: <20201229090208.1113218-1-yangerkun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201229090208.1113218-1-yangerkun@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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... 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 > -- Jan Kara SUSE Labs, CR