From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53865C433DB for ; Mon, 4 Jan 2021 14:20:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27FEB20784 for ; Mon, 4 Jan 2021 14:20:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbhADOUf (ORCPT ); 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