Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1049914pxb; Thu, 4 Mar 2021 01:45:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJy78rnZArNesyHrDm8eesJxktpWKkjreqV8tyVg+m6tNY3w7R9OsHvgTaVUgPAI4XAFD9C+ X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr3311459ejg.482.1614851158472; Thu, 04 Mar 2021 01:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614851158; cv=none; d=google.com; s=arc-20160816; b=bfKcWYyVHsGOWbnfAMhpxjpGYpIHmnCWnkiG+RCrEXhpY0pUgco7XuQ3vCtfryDFJg NkEucra6uqK3Ywmb6rgafRMkbLlTGpsaRRtD8O8DwxHAGPYj8aYpgMZgpFNr+6v52tjH mvu+rUcJI6XDpPeTq6151A9Co4UoDNw+CMBSYqzz0jfRW6Uc4Uq+xsjJd2yFitEYlmjY b2q2K8O9k29I79JXBRArQhKfla9U5RQNhKvuhZKHdDWtNcJMpkRPlHRlJmbvXrQA8wg/ 16GiaYFZsnjZTiFnU8GqbmzY2suSGKNk7YdRhkd2mWCyUG018zvx5wQ+7rTkhgXbV8hZ Omkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nKC0sSQp3/fLC7eamM4q4GX5ghXR8Xt83z1exW3b1tg=; b=z/EkmceVJ8vue73A0ghpNvn8ZpeR7q6HlY5G8WcHrg69pfBpWbI+V37b7jM66bNLEy moA2laSB6brYIgFVpnKpr+OA+/GZTRjRIpuWwKoPh1jNiEpOH9PgkKofK/Dm6e0CaRyg zM5/Y181BbFUsGg+zY9eM30ed3HBfZPRIeWII+C0YbwrJ20/OQcksr1Hw4y/wKX09LYP KzmKgX/g/edEsuV3DmiZnbuX9Scwv5l7j/+czQvPaPYsF/X/8/3DAYjNqCthshp3vuVT Sgb9HFZmvMwYGrpiTvjaMOyijeQrtGlJOVEiy8k+LnpjSM9mRMSECYgNwvCCdb9XJkDn OxxA== 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 c11si878606ede.102.2021.03.04.01.45.35; Thu, 04 Mar 2021 01:45: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 S1382517AbhCCPbu (ORCPT + 99 others); Wed, 3 Mar 2021 10:31:50 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:13425 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346378AbhCCNKv (ORCPT ); Wed, 3 Mar 2021 08:10:51 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DrDpH5L8nzjTH1; Wed, 3 Mar 2021 21:08:39 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 21:09:55 +0800 From: "zhangyi (F)" To: CC: , , , Subject: [PATCH v1 2/2] ext4: Do not iput inode under running transaction in ext4_rename() Date: Wed, 3 Mar 2021 21:17:03 +0800 Message-ID: <20210303131703.330415-2-yi.zhang@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210303131703.330415-1-yi.zhang@huawei.com> References: <20210303131703.330415-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ext4_rename(), when RENAME_WHITEOUT failed to add new entry into directory, it ends up dropping new created whiteout inode under the running transaction. After commit <9b88f9fb0d2> ("ext4: Do not iput inode under running transaction"), we follow the assumptions that evict() does not get called from a transaction context but in ext4_rename() it breaks this suggestion. Although it's not a real problem, better to obey it, so this patch add inode to orphan list and stop transaction before final iput(). Signed-off-by: zhangyi (F) --- fs/ext4/namei.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 17d9400563fa..defdbf80ebfa 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3786,14 +3786,14 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, */ retval = -ENOENT; if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino) - goto end_rename; + goto release_bh; new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, &new.de, &new.inlined); if (IS_ERR(new.bh)) { retval = PTR_ERR(new.bh); new.bh = NULL; - goto end_rename; + goto release_bh; } if (new.bh) { if (!new.inode) { @@ -3810,15 +3810,13 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits); if (IS_ERR(handle)) { retval = PTR_ERR(handle); - handle = NULL; - goto end_rename; + goto release_bh; } } else { whiteout = ext4_whiteout_for_rename(&old, credits, &handle); if (IS_ERR(whiteout)) { retval = PTR_ERR(whiteout); - whiteout = NULL; - goto end_rename; + goto release_bh; } } @@ -3952,16 +3950,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ext4_resetent(handle, &old, old.inode->i_ino, old_file_type); drop_nlink(whiteout); + ext4_orphan_add(handle, whiteout); } unlock_new_inode(whiteout); + ext4_journal_stop(handle); iput(whiteout); - + } else { + ext4_journal_stop(handle); } +release_bh: brelse(old.dir_bh); brelse(old.bh); brelse(new.bh); - if (handle) - ext4_journal_stop(handle); return retval; } -- 2.25.4