Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3401257pxf; Mon, 22 Mar 2021 05:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOY7A5+lAMbYi5yH22xtt4obI28VI6mdpp0KUFv3/rD8hQvHjXXa97akzKJBagS5a1/Th5 X-Received: by 2002:a17:906:32da:: with SMTP id k26mr18960843ejk.483.1616417030912; Mon, 22 Mar 2021 05:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616417030; cv=none; d=google.com; s=arc-20160816; b=SaBXWyPqCvdo0hrn6hDziyEDvLMlOUChL2gqWvDujiUHGmHATGsCPRvEMOZlcqaP9c COg3UMRLMndZZRNpry9JIlzxc9U9E7AvuU6ZZ6PgQgUmDQ02yVhUs8hlFXgNHrnnkdGl GolYIDVi1PyBtFD2ab3lE/J0GySkC4Mr/Tkx/raYF/tzM1zmy88eq7Ofgnbkzu8krxaC 40u7kdDqRx/kfhQqOVLPJBVFcSSKe7nbav5flh8tcIQxyS+VHcgu/4dSGa3DBFhZq6wz JmWYIAzxU8ycf5/dvdKhYtmHUNoMUyj0WNjQtTrWSw5TiXADfeB2DsHPzgTIfw7nY1f+ FeQw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9e5aD53DRuTlYRC3y40nyPdMBLgzbXli9EHEnmEnHYo=; b=GzFq2eiO8dUVD0QPw0XMH5w7HMorQcmakAy0Ux7+p4eYwbJhQjXmxBoU2MmwC54fhr 58I9IW/TaTNn5jbH14vAmM/G9eFOAp5pHfXVuTtrPBsKdIMpA+6uoYJj8uwydfxb3fwd eOzn/SDbvl3v1qrfhdf6NCMyprtIeg2X5YxYQtMF8XGshxfTJwk5dgOAXA7p6OdMKO+l dW6FZkQVDkKsDx0wZZWGStB0a9sqlBk8PcDh0skWHKDYZn+KqiNvg9xJwX3/wOj40YiR XQjk3MRNsJo2FvvZ2E6U0qN0ari7hwKpEGf1T+lDib42epYxS6G6DrSstCgvKh/wJ3KV Xfng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RN7tgmsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si11428914eda.74.2021.03.22.05.43.27; Mon, 22 Mar 2021 05:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RN7tgmsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbhCVMjw (ORCPT + 99 others); Mon, 22 Mar 2021 08:39:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:55660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbhCVMes (ORCPT ); Mon, 22 Mar 2021 08:34:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21F0E619B4; Mon, 22 Mar 2021 12:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416484; bh=REuqPmLRtSXR6dvTDd8N2Yvy5KppgN6BAlZ6/BUr184=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RN7tgmsg/VVjZS3g2OjKfHN00qBo5SNPYo6HMMZu328XeUN16VuPODMU7U1Eawkxk D2Jr9xpsqik2ya1vdGp2ovFKMGTx8STvDxpCwH5O579/EsnZVIfPqr4Vqm+cIJCe+L DDfogglYd6sQituXPJMRmQntvGYJnDvh58kaNEPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Harshad Shirwadkar , Theodore Tso Subject: [PATCH 5.11 113/120] ext4: fix rename whiteout with fast commit Date: Mon, 22 Mar 2021 13:28:16 +0100 Message-Id: <20210322121933.426194326@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121929.669628946@linuxfoundation.org> References: <20210322121929.669628946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harshad Shirwadkar commit 8210bb29c1b66200cff7b25febcf6e39baf49fbf upstream. This patch adds rename whiteout support in fast commits. Note that the whiteout object that gets created is actually char device. Which imples, the function ext4_inode_journal_mode(struct inode *inode) would return "JOURNAL_DATA" for this inode. This has a consequence in fast commit code that it will make creation of the whiteout object a fast-commit ineligible behavior and thus will fall back to full commits. With this patch, this can be observed by running fast commits with rename whiteout and seeing the stats generated by ext4_fc_stats tracepoint as follows: ext4_fc_stats: dev 254:32 fc ineligible reasons: XATTR:0, CROSS_RENAME:0, JOURNAL_FLAG_CHANGE:0, NO_MEM:0, SWAP_BOOT:0, RESIZE:0, RENAME_DIR:0, FALLOC_RANGE:0, INODE_JOURNAL_DATA:16; num_commits:6, ineligible: 6, numblks: 3 So in short, this patch guarantees that in case of rename whiteout, we fall back to full commits. Amir mentioned that instead of creating a new whiteout object for every rename, we can create a static whiteout object with irrelevant nlink. That will make fast commits to not fall back to full commit. But until this happens, this patch will ensure correctness by falling back to full commits. Fixes: 8016e29f4362 ("ext4: fast commit recovery path") Cc: stable@kernel.org Signed-off-by: Harshad Shirwadkar Link: https://lore.kernel.org/r/20210316221921.1124955-1-harshadshirwadkar@gmail.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/ext4.h | 2 ++ fs/ext4/fast_commit.c | 9 +++++++-- fs/ext4/namei.c | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2792,6 +2792,8 @@ void __ext4_fc_track_link(handle_t *hand struct dentry *dentry); void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry); void ext4_fc_track_link(handle_t *handle, struct dentry *dentry); +void __ext4_fc_track_create(handle_t *handle, struct inode *inode, + struct dentry *dentry); void ext4_fc_track_create(handle_t *handle, struct dentry *dentry); void ext4_fc_track_inode(handle_t *handle, struct inode *inode); void ext4_fc_mark_ineligible(struct super_block *sb, int reason); --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -513,10 +513,10 @@ void ext4_fc_track_link(handle_t *handle __ext4_fc_track_link(handle, d_inode(dentry), dentry); } -void ext4_fc_track_create(handle_t *handle, struct dentry *dentry) +void __ext4_fc_track_create(handle_t *handle, struct inode *inode, + struct dentry *dentry) { struct __track_dentry_update_args args; - struct inode *inode = d_inode(dentry); int ret; args.dentry = dentry; @@ -527,6 +527,11 @@ void ext4_fc_track_create(handle_t *hand trace_ext4_fc_track_create(inode, dentry, ret); } +void ext4_fc_track_create(handle_t *handle, struct dentry *dentry) +{ + __ext4_fc_track_create(handle, d_inode(dentry), dentry); +} + /* __track_fn for inode tracking */ static int __track_inode(struct inode *inode, void *arg, bool update) { --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3861,6 +3861,7 @@ static int ext4_rename(struct inode *old retval = ext4_mark_inode_dirty(handle, whiteout); if (unlikely(retval)) goto end_rename; + } if (!new.bh) { retval = ext4_add_entry(handle, new.dentry, old.inode); @@ -3934,6 +3935,8 @@ static int ext4_rename(struct inode *old ext4_fc_track_unlink(handle, new.dentry); __ext4_fc_track_link(handle, old.inode, new.dentry); __ext4_fc_track_unlink(handle, old.inode, old.dentry); + if (whiteout) + __ext4_fc_track_create(handle, whiteout, old.dentry); } if (new.inode) {