linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PULL] [PATCH 0/6] B-tree key space extensions
@ 2016-02-11 17:23 David Sterba
  2016-02-11 17:23 ` [PATCH 1/6] btrfs: introduce key type for persistent temporary items David Sterba
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, clm

Hi,

this patchset renames some existing key types and gives them a more generalized
meaning (backward compatible). This is motivated by requirements of b-tree
extensions by various patchsets, eg. the deduplication.

The new key type added there BTRFS_DEDUP_STATUS_ITEM_KEY does not use the
objectid or offset members and maps to a single structure. This is very similar
to the balance status item.

The idea is to allow for extensions without key type exhaustion. Obviously we have
to use new values when the offset and objectid are used.

This patchset introduces two types of persistent items to store status data:

* temporary - eg. exists to store state of a running operation like balance
* permanent - eg. exists if a feature is used

The increased variability of the key type will require more parsing, but will
give more flexibility to developers of new features.

The changes are just renames, there's only one user of each type, so no
backward compatibility concerns.

Please consider for 4.6.

----------------------------------------------------------------
The following changes since commit 388f7b1d6e8ca06762e2454d28d6c3c55ad0fe95:

  Linux 4.5-rc3 (2016-02-07 15:38:30 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git dev/rename-keys

for you to fetch changes up to 9f07e1d76eaeeddedcf9651395b4a8f870df31f0:

  btrfs: teach print_leaf about temporary item subtypes (2016-02-11 16:15:43 +0100)

----------------------------------------------------------------
David Sterba (6):
  btrfs: introduce key type for persistent temporary items
  btrfs: switch balance item to the temporary item key
  btrfs: introduce key type for persistent permanent items
  btrfs: switch dev stats item to the permanent item key
  btrfs: teach print_leaf about permanent item subtypes
  btrfs: teach print_leaf about temporary item subtypes

 fs/btrfs/ctree.h      | 39 ++++++++++++++++++++++++++++++++++++---
 fs/btrfs/print-tree.c | 23 +++++++++++++++++++++--
 fs/btrfs/volumes.c    | 14 +++++++-------
 3 files changed, 64 insertions(+), 12 deletions(-)

-- 
2.7.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] btrfs: introduce key type for persistent temporary items
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
@ 2016-02-11 17:23 ` David Sterba
  2016-02-11 17:23 ` [PATCH 2/6] btrfs: switch balance item to the temporary item key David Sterba
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The number of distinct key types is not that big that we could waste one
for something new we want to store in the tree. We'll introduce a new
name for an existing key value and use the objectid for further
extension.  The victim is the BTRFS_BALANCE_ITEM_KEY (248).

The nature of the balance status item is a good example of the temporary
item. It exists from beginning of the balance, keeps the status until it
finishes.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index bfe4a337fb4d..e20f40649917 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2185,9 +2185,25 @@ struct btrfs_ioctl_defrag_range_args {
  */
 #define BTRFS_QGROUP_RELATION_KEY       246
 
+/*
+ * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY.
+ */
 #define BTRFS_BALANCE_ITEM_KEY	248
 
 /*
+ * The key type for tree items that are stored persistently, but do not need to
+ * exist for extended period of time. The items can exist in any tree.
+ *
+ * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data]
+ *
+ * Existing items:
+ *
+ * - balance status item
+ *   (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0)
+ */
+#define BTRFS_TEMPORARY_ITEM_KEY	248
+
+/*
  * Persistantly stores the io stats in the device tree.
  * One key for all stats, (0, BTRFS_DEV_STATS_KEY, devid).
  */
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] btrfs: switch balance item to the temporary item key
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
  2016-02-11 17:23 ` [PATCH 1/6] btrfs: introduce key type for persistent temporary items David Sterba
@ 2016-02-11 17:23 ` David Sterba
  2016-02-11 17:23 ` [PATCH 3/6] btrfs: introduce key type for persistent permanent items David Sterba
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

No visible change.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/volumes.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 366b335946fa..b306a205504b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2966,7 +2966,7 @@ static int insert_balance_item(struct btrfs_root *root,
 	}
 
 	key.objectid = BTRFS_BALANCE_OBJECTID;
-	key.type = BTRFS_BALANCE_ITEM_KEY;
+	key.type = BTRFS_TEMPORARY_ITEM_KEY;
 	key.offset = 0;
 
 	ret = btrfs_insert_empty_item(trans, root, path, &key,
@@ -3015,7 +3015,7 @@ static int del_balance_item(struct btrfs_root *root)
 	}
 
 	key.objectid = BTRFS_BALANCE_OBJECTID;
-	key.type = BTRFS_BALANCE_ITEM_KEY;
+	key.type = BTRFS_TEMPORARY_ITEM_KEY;
 	key.offset = 0;
 
 	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
@@ -3867,7 +3867,7 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
 		return -ENOMEM;
 
 	key.objectid = BTRFS_BALANCE_OBJECTID;
-	key.type = BTRFS_BALANCE_ITEM_KEY;
+	key.type = BTRFS_TEMPORARY_ITEM_KEY;
 	key.offset = 0;
 
 	ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] btrfs: introduce key type for persistent permanent items
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
  2016-02-11 17:23 ` [PATCH 1/6] btrfs: introduce key type for persistent temporary items David Sterba
  2016-02-11 17:23 ` [PATCH 2/6] btrfs: switch balance item to the temporary item key David Sterba
@ 2016-02-11 17:23 ` David Sterba
  2016-02-11 17:23 ` [PATCH 4/6] btrfs: switch dev stats item to the permanent item key David Sterba
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The number of distinct key types is not that big that we could waste one
for something new we want to store in the tree.

Similar to the temporary items, we'll introduce a new name for an
existing key value and use the objectid for further extension.  The
victim is the BTRFS_DEV_STATS_KEY (248).

The device stats are an example of a permanent item.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.h | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e20f40649917..ffc081e11277 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2204,10 +2204,24 @@ struct btrfs_ioctl_defrag_range_args {
 #define BTRFS_TEMPORARY_ITEM_KEY	248
 
 /*
- * Persistantly stores the io stats in the device tree.
- * One key for all stats, (0, BTRFS_DEV_STATS_KEY, devid).
+ * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY
  */
-#define BTRFS_DEV_STATS_KEY	249
+#define BTRFS_DEV_STATS_KEY		249
+
+/*
+ * The key type for tree items that are stored persistently and usually exist
+ * for a long period, eg. filesystem lifetime. The item kinds can be status
+ * information, stats or preference values. The item can exist in any tree.
+ *
+ * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data]
+ *
+ * Existing items:
+ *
+ * - device statistics, store IO stats in the device tree, one key for all
+ *   stats
+ *   (0, BTRFS_DEV_STATS_KEY, 0)
+ */
+#define BTRFS_PERSISTENT_ITEM_KEY	249
 
 /*
  * Persistantly stores the device replace state in the device tree.
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] btrfs: switch dev stats item to the permanent item key
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
                   ` (2 preceding siblings ...)
  2016-02-11 17:23 ` [PATCH 3/6] btrfs: introduce key type for persistent permanent items David Sterba
@ 2016-02-11 17:23 ` David Sterba
  2016-02-11 17:23 ` [PATCH 5/6] btrfs: teach print_leaf about permanent item subtypes David Sterba
  2016-02-11 17:23 ` [PATCH 6/6] btrfs: teach print_leaf about temporary " David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.h   | 5 ++++-
 fs/btrfs/volumes.c | 8 ++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index ffc081e11277..70054ed2bd7b 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -100,6 +100,9 @@ struct btrfs_ordered_sum;
 /* tracks free space in block groups. */
 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
 
+/* device stats in the device tree */
+#define BTRFS_DEV_STATS_OBJECTID 0ULL
+
 /* for storing balance parameters in the root tree */
 #define BTRFS_BALANCE_OBJECTID -4ULL
 
@@ -2219,7 +2222,7 @@ struct btrfs_ioctl_defrag_range_args {
  *
  * - device statistics, store IO stats in the device tree, one key for all
  *   stats
- *   (0, BTRFS_DEV_STATS_KEY, 0)
+ *   (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0)
  */
 #define BTRFS_PERSISTENT_ITEM_KEY	249
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b306a205504b..177a0a8dfd31 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6705,8 +6705,8 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
 		int item_size;
 		struct btrfs_dev_stats_item *ptr;
 
-		key.objectid = 0;
-		key.type = BTRFS_DEV_STATS_KEY;
+		key.objectid = BTRFS_DEV_STATS_OBJECTID;
+		key.type = BTRFS_PERSISTENT_ITEM_KEY;
 		key.offset = device->devid;
 		ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0);
 		if (ret) {
@@ -6753,8 +6753,8 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
 	int ret;
 	int i;
 
-	key.objectid = 0;
-	key.type = BTRFS_DEV_STATS_KEY;
+	key.objectid = BTRFS_DEV_STATS_OBJECTID;
+	key.type = BTRFS_PERSISTENT_ITEM_KEY;
 	key.offset = device->devid;
 
 	path = btrfs_alloc_path();
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] btrfs: teach print_leaf about permanent item subtypes
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
                   ` (3 preceding siblings ...)
  2016-02-11 17:23 ` [PATCH 4/6] btrfs: switch dev stats item to the permanent item key David Sterba
@ 2016-02-11 17:23 ` David Sterba
  2016-02-11 17:23 ` [PATCH 6/6] btrfs: teach print_leaf about temporary " David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/print-tree.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 647ab12fdf5d..7bd0bdfc9812 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -295,8 +295,16 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
 			       btrfs_dev_extent_chunk_offset(l, dev_extent),
 			       btrfs_dev_extent_length(l, dev_extent));
 			break;
-		case BTRFS_DEV_STATS_KEY:
-			printk(KERN_INFO "\t\tdevice stats\n");
+		case BTRFS_PERSISTENT_ITEM_KEY:
+			printk(KERN_INFO "\t\tpersistent item objectid %llu offset %llu\n",
+					key.objectid, key.offset);
+			switch (key.objectid) {
+			case BTRFS_DEV_STATS_OBJECTID:
+				printk(KERN_INFO "\t\tdevice stats\n");
+				break;
+			default:
+				printk(KERN_INFO "\t\tunknown persistent item\n");
+			}
 			break;
 		case BTRFS_DEV_REPLACE_KEY:
 			printk(KERN_INFO "\t\tdev replace\n");
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] btrfs: teach print_leaf about temporary item subtypes
  2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
                   ` (4 preceding siblings ...)
  2016-02-11 17:23 ` [PATCH 5/6] btrfs: teach print_leaf about permanent item subtypes David Sterba
@ 2016-02-11 17:23 ` David Sterba
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2016-02-11 17:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/print-tree.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 7bd0bdfc9812..147dc6ca5de1 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -306,6 +306,17 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
 				printk(KERN_INFO "\t\tunknown persistent item\n");
 			}
 			break;
+		case BTRFS_TEMPORARY_ITEM_KEY:
+			printk(KERN_INFO "\t\ttemporary item objectid %llu offset %llu\n",
+					key.objectid, key.offset);
+			switch (key.objectid) {
+			case BTRFS_BALANCE_OBJECTID:
+				printk(KERN_INFO "\t\tbalance status\n");
+				break;
+			default:
+				printk(KERN_INFO "\t\tunknown temporary item\n");
+			}
+			break;
 		case BTRFS_DEV_REPLACE_KEY:
 			printk(KERN_INFO "\t\tdev replace\n");
 			break;
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-02-11 17:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-11 17:23 [PULL] [PATCH 0/6] B-tree key space extensions David Sterba
2016-02-11 17:23 ` [PATCH 1/6] btrfs: introduce key type for persistent temporary items David Sterba
2016-02-11 17:23 ` [PATCH 2/6] btrfs: switch balance item to the temporary item key David Sterba
2016-02-11 17:23 ` [PATCH 3/6] btrfs: introduce key type for persistent permanent items David Sterba
2016-02-11 17:23 ` [PATCH 4/6] btrfs: switch dev stats item to the permanent item key David Sterba
2016-02-11 17:23 ` [PATCH 5/6] btrfs: teach print_leaf about permanent item subtypes David Sterba
2016-02-11 17:23 ` [PATCH 6/6] btrfs: teach print_leaf about temporary " David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).