From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH v2 6/8] btrfs-progs: Implement helper to remove received information of RW subvol
Date: Tue, 14 Sep 2021 12:05:56 +0300 [thread overview]
Message-ID: <20210914090558.79411-7-nborisov@suse.com> (raw)
In-Reply-To: <20210914090558.79411-1-nborisov@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
check/mode-common.c | 40 ++++++++++++++++++++++++++++++++++++++++
check/mode-common.h | 1 +
2 files changed, 41 insertions(+)
diff --git a/check/mode-common.c b/check/mode-common.c
index 0059672c6402..7a5313280f3f 100644
--- a/check/mode-common.c
+++ b/check/mode-common.c
@@ -1301,3 +1301,43 @@ int repair_dev_item_bytes_used(struct btrfs_fs_info *fs_info,
btrfs_abort_transaction(trans, ret);
return ret;
}
+
+int repair_received_subvol(struct btrfs_root *root)
+{
+ struct btrfs_root_item *root_item = &root->root_item;
+ struct btrfs_trans_handle *trans;
+ int ret;
+
+ trans = btrfs_start_transaction(root, 2);
+ if (IS_ERR(trans))
+ return PTR_ERR(trans);
+
+ ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid,
+ BTRFS_UUID_KEY_RECEIVED_SUBVOL, root->root_key.objectid);
+
+ if (ret && ret != -ENOENT) {
+ btrfs_abort_transaction(trans, ret);
+ return ret;
+ }
+
+ memset(root_item->received_uuid, 0, BTRFS_UUID_SIZE);
+ btrfs_set_root_stransid(root_item, 0);
+ btrfs_set_root_rtransid(root_item, 0);
+ btrfs_set_stack_timespec_sec(&root_item->stime, 0);
+ btrfs_set_stack_timespec_nsec(&root_item->stime, 0);
+ btrfs_set_stack_timespec_sec(&root_item->rtime, 0);
+ btrfs_set_stack_timespec_nsec(&root_item->rtime, 0);
+
+ ret = btrfs_update_root(trans, gfs_info->tree_root, &root->root_key,
+ root_item);
+ if (ret < 0) {
+ btrfs_abort_transaction(trans, ret);
+ return ret;
+ }
+
+ ret = btrfs_commit_transaction(trans, gfs_info->tree_root);
+ if (!ret)
+ printf("Cleared received information for subvol: %llu\n",
+ root->root_key.objectid);
+ return ret;
+}
diff --git a/check/mode-common.h b/check/mode-common.h
index cdfb10d58cde..f1ec5dca0199 100644
--- a/check/mode-common.h
+++ b/check/mode-common.h
@@ -130,6 +130,7 @@ int reset_imode(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_path *path, u64 ino, u32 mode);
int repair_imode_common(struct btrfs_root *root, struct btrfs_path *path);
int check_repair_free_space_inode(struct btrfs_path *path);
+int repair_received_subvol(struct btrfs_root *root);
/*
* Check if the inode mode @imode is valid
--
2.17.1
next prev parent reply other threads:[~2021-09-14 9:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 9:05 [PATCH v2 0/8] Implement progs support for removing received uuid on RW vols Nikolay Borisov
2021-09-14 9:05 ` [PATCH v2 1/8] btrfs-progs: Add btrfs_is_empty_uuid Nikolay Borisov
2021-09-16 7:26 ` Anand Jain
2021-09-20 11:41 ` David Sterba
2021-09-14 9:05 ` [PATCH v2 2/8] btrfs-progs: Remove root argument from btrfs_fixup_low_keys Nikolay Borisov
2021-09-14 9:05 ` [PATCH v2 3/8] btrfs-progs: Remove fs_info argument from leaf_data_end Nikolay Borisov
2021-09-14 9:05 ` [PATCH v2 4/8] btrfs-progs: Remove root argument from btrfs_truncate_item Nikolay Borisov
2021-09-14 9:05 ` [PATCH v2 5/8] btrfs-progs: Add btrfs_uuid_tree_remove Nikolay Borisov
2021-09-14 9:22 ` Qu Wenruo
2021-09-14 9:05 ` Nikolay Borisov [this message]
2021-09-14 9:23 ` [PATCH v2 6/8] btrfs-progs: Implement helper to remove received information of RW subvol Qu Wenruo
2021-09-14 9:05 ` [PATCH v2 7/8] btrfs-progs: check: Implement removing received data for RW subvols Nikolay Borisov
2021-09-14 9:25 ` Qu Wenruo
2021-09-14 9:55 ` Nikolay Borisov
2021-09-14 9:05 ` [PATCH v2 8/8] btrfs-progs: tests: Add test for received information removal Nikolay Borisov
2021-09-14 9:30 ` [PATCH v2 0/8] Implement progs support for removing received uuid on RW vols Qu Wenruo
2021-09-14 9:30 ` Qu Wenruo
2021-09-14 9:31 ` Nikolay Borisov
2021-09-21 18:51 ` David Sterba
2021-09-21 22:08 ` Graham Cobb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210914090558.79411-7-nborisov@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox