Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3409189pxf; Mon, 22 Mar 2021 05:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh4IKg5xa8lQflWW/A7kRuKzEzyja8F9YMwODBwwxDYxFpdHdN7VdbZQXwYzFXUFq6u2vV X-Received: by 2002:a17:906:a413:: with SMTP id l19mr19233781ejz.421.1616417798881; Mon, 22 Mar 2021 05:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616417798; cv=none; d=google.com; s=arc-20160816; b=VlDoioNDA3a/2n8QF/t4BvWBygFr0oqdb6Avl+5Nh8yhYoepvQgDchHTLafojAmMGi HOgfaxkby2OeqQhO3nA+yrn+00+1lxDIojwHpbpJwxdEpUmxONxUnO/VBsEYU+RO5cA0 c8/V4JDiZt7awKlyy31y145amLN1AMwArQkfIbhjllaeAKzY4dFGQcLRPEpOI+ezWGSQ EkH+UHA9/FaucVlTcHltv4avvhffYRD9RcP5wm5olGw0lnpWj24EljBjGHDaM7IL2FKj K8RnrVV1wp9Oz35xuP0P8BcZJGz45oBEzV/tVtkYzQ0WNo4E+58V6ETK9ORJtkyuDaZ6 A/aw== 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=hVM5+GLfBWiF2SIKHTSqIzSs6Aj1QNGYrf54i9dQNr0=; b=WVmYmVIzyqyIBXdOgONJ3z2ll78614OFaCdIqk0fDJkt8XsWDf7vNjo5qpjxTvMg6y CFTrp7H58NNYT1UOHeRZLn7byMso8DgBa12oI54Wd5ZAU2TjLWgRVnc2lsSytf4e3YFs Z3AZEaowIHBG7aw9NLeOuVEILRWKT3HMQ+4UPnuuYrIEdqSTIWhTzoXeORlNdEKFz240 9joTHKTK0v6hmO84oTdKxaaXUim/UvhHbGEdZj3F5BOdoPzryiwdnEDSCeygz2riHxpu lwVNgaXbPt3FwDYOaRAP1bCpj3geFVy8lW9IcvolBgpLRqbKzOzukgGvwx8wLGK8Qsfl 5cdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VxaRSRzV; 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 m21si11295085edp.392.2021.03.22.05.56.16; Mon, 22 Mar 2021 05:56:38 -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=VxaRSRzV; 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 S232389AbhCVMyt (ORCPT + 99 others); Mon, 22 Mar 2021 08:54:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbhCVMoJ (ORCPT ); Mon, 22 Mar 2021 08:44:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03E3E619B0; Mon, 22 Mar 2021 12:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416892; bh=K1yVs+ATTGPbdjKYT4WrLa8eLqUZeNITUe3109y6baM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VxaRSRzV4gUb2aWoJuRs8G/4hdN9anEOleD4mCc89shAuYAJncpjujIEvN44h2/dk IZjTQLfXsc+yEzXclnqgYMhEt0wdkGln65LgvPOJeYLkHG48PKScVbpdQsRtO0e49n hcOYC0/F7hU023sQifq6h2QveNaNgJse1ySHkDpA= 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.10 150/157] ext4: fix rename whiteout with fast commit Date: Mon, 22 Mar 2021 13:28:27 +0100 Message-Id: <20210322121938.499373097@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121933.746237845@linuxfoundation.org> References: <20210322121933.746237845@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 @@ -2762,6 +2762,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 @@ -452,10 +452,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; @@ -466,6 +466,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 @@ -3864,6 +3864,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); @@ -3937,6 +3938,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) {