From patchwork Thu Apr 6 19:19:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13203899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5CF2C7618D for ; Thu, 6 Apr 2023 19:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbjDFTTK (ORCPT ); Thu, 6 Apr 2023 15:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240531AbjDFTTJ (ORCPT ); Thu, 6 Apr 2023 15:19:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BE78E78 for ; Thu, 6 Apr 2023 12:19:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0588A63D38 for ; Thu, 6 Apr 2023 19:19:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 632B0C433EF; Thu, 6 Apr 2023 19:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680808747; bh=u4NSqMy17yGRWznyOT8AHPWjOGzvCnWKM+nqdV1r6E4=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=cAHQKXeVh/RkTThT3+Veak8C37dDzjOHnIx+D62qhJxgAIooFVZPSYBia6e3hF8xL ltQ3wqZ+ZEidPGXuq4WYqYOvFJ5h/loqLumM2sCdweEDncpQHpsWhcjqotCwQ8/WA6 ct6Lmljf/dr+ajqdoUqSJ4gQZbzrsnyLKUmI+VvLa7NcCzTQ3qmcvPJ+6TUeHFvM05 hpCud3JhXEySKN9W0o0JMeHSJWZBeOSwOZbqQoICeSvbbYPGfkEkT3NuM+m4LiF2Ww OERXVc+xOTNHAuK/3O+0n1kFZzv9FBciBLj6zVNp+JyvXtiQMI028raDbarTBvP7K8 4oFu44vXJQtVg== Date: Thu, 06 Apr 2023 12:19:07 -0700 Subject: [PATCH 10/12] xfs: log NVLOOKUP xattr removal operations From: "Darrick J. Wong" To: djwong@kernel.org Cc: allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <168080823946.613065.16786327016716587364.stgit@frogsfrogsfrogs> In-Reply-To: <168080823794.613065.2971656278555515103.stgit@frogsfrogsfrogs> References: <168080823794.613065.2971656278555515103.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If high level code wants to do a deferred xattr remove operation with the NVLOOKUP flag set, we need to push this through the log. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 6 +++++- fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_attr_item.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index b0da2e862ef9..1f4dc6e01e68 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -942,9 +942,13 @@ xfs_attr_defer_remove( { struct xfs_attr_intent *new; + int op_flag = XFS_ATTRI_OP_FLAGS_REMOVE; int error; - error = xfs_attr_intent_init(args, XFS_ATTRI_OP_FLAGS_REMOVE, &new); + if (args->op_flags & XFS_DA_OP_NVLOOKUP) + op_flag = XFS_ATTRI_OP_FLAGS_NVREMOVE; + + error = xfs_attr_intent_init(args, op_flag, &new); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index f13e0809dc63..ecf0ac32d752 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -957,6 +957,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */ #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */ #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */ +#define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */ #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */ /* diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index f756bee9fb73..dd73d30f9e8d 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -522,6 +522,7 @@ xfs_attri_validate( case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: case XFS_ATTRI_OP_FLAGS_REMOVE: + case XFS_ATTRI_OP_FLAGS_NVREMOVE: break; default: return false; @@ -611,6 +612,9 @@ xfs_attri_item_recover( else attr->xattri_dela_state = xfs_attr_init_add_state(args); break; + case XFS_ATTRI_OP_FLAGS_NVREMOVE: + args->op_flags |= XFS_DA_OP_NVLOOKUP; + fallthrough; case XFS_ATTRI_OP_FLAGS_REMOVE: if (!xfs_inode_hasattr(args->dp)) goto out; @@ -736,6 +740,16 @@ xlog_recover_attri_commit_pass2( /* Check the number of log iovecs makes sense for the op code. */ op = xfs_attr_log_item_op(attri_formatp); switch (op) { + case XFS_ATTRI_OP_FLAGS_NVREMOVE: + /* Log item, attr name, optional attr value */ + if (item->ri_total != 3 && item->ri_total != 2) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + name_len = attri_formatp->alfi_name_len; + value_len = attri_formatp->alfi_value_len; + break; case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: /* Log item, attr name, attr value */ @@ -810,12 +824,16 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } fallthrough; + case XFS_ATTRI_OP_FLAGS_NVREMOVE: case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: /* * Regular xattr set/remove/replace operations require a name * and do not take a newname. Values are optional for set and * replace. + * + * Name-value remove operations must have a name, do not + * take a newname, and can take a value. */ if (attr_name == NULL || name_len == 0) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,