Accepting request 233800 from home:mfasheh:branches:filesystems

- add quota group verify patches, sent to list near end of the week starting
  5/4/2014
  - updates btrfsck with the ability to verify quota groups

OBS-URL: https://build.opensuse.org/request/show/233800
OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=158
This commit is contained in:
Mark Fasheh 2014-05-16 16:58:33 +00:00 committed by Git OBS Bridge
parent 6beb01c50d
commit 9d69a3f78d
5 changed files with 1836 additions and 0 deletions

View File

@ -0,0 +1,64 @@
From 8b40b00f23806115c9f03344227b6590cb187a96 Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.de>
Date: Thu, 1 May 2014 22:35:15 -0700
Subject: [PATCH 1/3] btrfs-progs: print qgroup excl as unsigned
References: bnc#865621
It's unsigned in the structure definition.
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
---
print-tree.c | 12 ++++++------
qgroup.c | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/print-tree.c b/print-tree.c
index 7263b09..adef94a 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -884,18 +884,18 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
qg_info = btrfs_item_ptr(l, i,
struct btrfs_qgroup_info_item);
printf("\t\tgeneration %llu\n"
- "\t\treferenced %lld referenced compressed %lld\n"
- "\t\texclusive %lld exclusive compressed %lld\n",
+ "\t\treferenced %llu referenced compressed %llu\n"
+ "\t\texclusive %llu exclusive compressed %llu\n",
(unsigned long long)
btrfs_qgroup_info_generation(l, qg_info),
- (long long)
+ (unsigned long long)
btrfs_qgroup_info_referenced(l, qg_info),
- (long long)
+ (unsigned long long)
btrfs_qgroup_info_referenced_compressed(l,
qg_info),
- (long long)
+ (unsigned long long)
btrfs_qgroup_info_exclusive(l, qg_info),
- (long long)
+ (unsigned long long)
btrfs_qgroup_info_exclusive_compressed(l,
qg_info));
break;
diff --git a/qgroup.c b/qgroup.c
index 94d1feb..368b262 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -203,11 +203,11 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup,
print_qgroup_column_add_blank(BTRFS_QGROUP_QGROUPID, len);
break;
case BTRFS_QGROUP_RFER:
- len = printf("%lld", qgroup->rfer);
+ len = printf("%llu", qgroup->rfer);
print_qgroup_column_add_blank(BTRFS_QGROUP_RFER, len);
break;
case BTRFS_QGROUP_EXCL:
- len = printf("%lld", qgroup->excl);
+ len = printf("%llu", qgroup->excl);
print_qgroup_column_add_blank(BTRFS_QGROUP_EXCL, len);
break;
case BTRFS_QGROUP_PARENT:
--
1.8.4

View File

@ -0,0 +1,373 @@
From e1857c491c61040cd845b5e08f1d996d3e3557a8 Mon Sep 17 00:00:00 2001
From: Mark Fasheh <mfasheh@suse.de>
Date: Thu, 1 May 2014 14:34:30 -0700
Subject: [PATCH 2/3] btrfs-progs: import ulist
References: bnc#865621
qgroup-verify.c wants this for walking root refs.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
Makefile | 3 +-
kerncompat.h | 2 +-
ulist.c | 253 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ulist.h | 66 ++++++++++++++++
4 files changed, 322 insertions(+), 2 deletions(-)
create mode 100644 ulist.c
create mode 100644 ulist.h
Index: btrfs-progs-v3.14.1/Makefile
===================================================================
--- btrfs-progs-v3.14.1.orig/Makefile
+++ btrfs-progs-v3.14.1/Makefile
@@ -10,7 +10,7 @@ objects = ctree.o disk-io.o radix-tree.o
root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
extent-cache.o extent_io.o volumes.o utils.o repair.o \
qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
- utils-lib.o string_table.o
+ utils-lib.o string_table.o ulist.o
cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
Index: btrfs-progs-v3.14.1/kerncompat.h
===================================================================
--- btrfs-progs-v3.14.1.orig/kerncompat.h
+++ btrfs-progs-v3.14.1/kerncompat.h
@@ -235,7 +235,7 @@ static inline long IS_ERR(const void *pt
#define BUG_ON(c) assert(!(c))
#define WARN_ON(c) assert(!(c))
-
+#define ASSERT(c) assert(c)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
Index: btrfs-progs-v3.14.1/ulist.c
===================================================================
--- /dev/null
+++ btrfs-progs-v3.14.1/ulist.c
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2011 STRATO AG
+ * written by Arne Jansen <sensille@gmx.net>
+ * Distributed under the GNU GPL license version 2.
+ */
+
+//#include <linux/slab.h>
+#include <stdlib.h>
+#include "kerncompat.h"
+#include "ulist.h"
+#include "ctree.h"
+
+/*
+ * ulist is a generic data structure to hold a collection of unique u64
+ * values. The only operations it supports is adding to the list and
+ * enumerating it.
+ * It is possible to store an auxiliary value along with the key.
+ *
+ * A sample usage for ulists is the enumeration of directed graphs without
+ * visiting a node twice. The pseudo-code could look like this:
+ *
+ * ulist = ulist_alloc();
+ * ulist_add(ulist, root);
+ * ULIST_ITER_INIT(&uiter);
+ *
+ * while ((elem = ulist_next(ulist, &uiter)) {
+ * for (all child nodes n in elem)
+ * ulist_add(ulist, n);
+ * do something useful with the node;
+ * }
+ * ulist_free(ulist);
+ *
+ * This assumes the graph nodes are adressable by u64. This stems from the
+ * usage for tree enumeration in btrfs, where the logical addresses are
+ * 64 bit.
+ *
+ * It is also useful for tree enumeration which could be done elegantly
+ * recursively, but is not possible due to kernel stack limitations. The
+ * loop would be similar to the above.
+ */
+
+/**
+ * ulist_init - freshly initialize a ulist
+ * @ulist: the ulist to initialize
+ *
+ * Note: don't use this function to init an already used ulist, use
+ * ulist_reinit instead.
+ */
+void ulist_init(struct ulist *ulist)
+{
+ INIT_LIST_HEAD(&ulist->nodes);
+ ulist->root = RB_ROOT;
+ ulist->nnodes = 0;
+}
+
+/**
+ * ulist_fini - free up additionally allocated memory for the ulist
+ * @ulist: the ulist from which to free the additional memory
+ *
+ * This is useful in cases where the base 'struct ulist' has been statically
+ * allocated.
+ */
+static void ulist_fini(struct ulist *ulist)
+{
+ struct ulist_node *node;
+ struct ulist_node *next;
+
+ list_for_each_entry_safe(node, next, &ulist->nodes, list) {
+ kfree(node);
+ }
+ ulist->root = RB_ROOT;
+ INIT_LIST_HEAD(&ulist->nodes);
+}
+
+/**
+ * ulist_reinit - prepare a ulist for reuse
+ * @ulist: ulist to be reused
+ *
+ * Free up all additional memory allocated for the list elements and reinit
+ * the ulist.
+ */
+void ulist_reinit(struct ulist *ulist)
+{
+ ulist_fini(ulist);
+ ulist_init(ulist);
+}
+
+/**
+ * ulist_alloc - dynamically allocate a ulist
+ * @gfp_mask: allocation flags to for base allocation
+ *
+ * The allocated ulist will be returned in an initialized state.
+ */
+struct ulist *ulist_alloc(gfp_t gfp_mask)
+{
+ struct ulist *ulist = kmalloc(sizeof(*ulist), gfp_mask);
+
+ if (!ulist)
+ return NULL;
+
+ ulist_init(ulist);
+
+ return ulist;
+}
+
+/**
+ * ulist_free - free dynamically allocated ulist
+ * @ulist: ulist to free
+ *
+ * It is not necessary to call ulist_fini before.
+ */
+void ulist_free(struct ulist *ulist)
+{
+ if (!ulist)
+ return;
+ ulist_fini(ulist);
+ kfree(ulist);
+}
+
+static struct ulist_node *ulist_rbtree_search(struct ulist *ulist, u64 val)
+{
+ struct rb_node *n = ulist->root.rb_node;
+ struct ulist_node *u = NULL;
+
+ while (n) {
+ u = rb_entry(n, struct ulist_node, rb_node);
+ if (u->val < val)
+ n = n->rb_right;
+ else if (u->val > val)
+ n = n->rb_left;
+ else
+ return u;
+ }
+ return NULL;
+}
+
+static int ulist_rbtree_insert(struct ulist *ulist, struct ulist_node *ins)
+{
+ struct rb_node **p = &ulist->root.rb_node;
+ struct rb_node *parent = NULL;
+ struct ulist_node *cur = NULL;
+
+ while (*p) {
+ parent = *p;
+ cur = rb_entry(parent, struct ulist_node, rb_node);
+
+ if (cur->val < ins->val)
+ p = &(*p)->rb_right;
+ else if (cur->val > ins->val)
+ p = &(*p)->rb_left;
+ else
+ return -EEXIST;
+ }
+ rb_link_node(&ins->rb_node, parent, p);
+ rb_insert_color(&ins->rb_node, &ulist->root);
+ return 0;
+}
+
+/**
+ * ulist_add - add an element to the ulist
+ * @ulist: ulist to add the element to
+ * @val: value to add to ulist
+ * @aux: auxiliary value to store along with val
+ * @gfp_mask: flags to use for allocation
+ *
+ * Note: locking must be provided by the caller. In case of rwlocks write
+ * locking is needed
+ *
+ * Add an element to a ulist. The @val will only be added if it doesn't
+ * already exist. If it is added, the auxiliary value @aux is stored along with
+ * it. In case @val already exists in the ulist, @aux is ignored, even if
+ * it differs from the already stored value.
+ *
+ * ulist_add returns 0 if @val already exists in ulist and 1 if @val has been
+ * inserted.
+ * In case of allocation failure -ENOMEM is returned and the ulist stays
+ * unaltered.
+ */
+int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask)
+{
+ return ulist_add_merge(ulist, val, aux, NULL, gfp_mask);
+}
+
+int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
+ u64 *old_aux, gfp_t gfp_mask)
+{
+ int ret;
+ struct ulist_node *node;
+
+ node = ulist_rbtree_search(ulist, val);
+ if (node) {
+ if (old_aux)
+ *old_aux = node->aux;
+ return 0;
+ }
+ node = kmalloc(sizeof(*node), gfp_mask);
+ if (!node)
+ return -ENOMEM;
+
+ node->val = val;
+ node->aux = aux;
+#ifdef CONFIG_BTRFS_DEBUG
+ node->seqnum = ulist->nnodes;
+#endif
+
+ ret = ulist_rbtree_insert(ulist, node);
+ ASSERT(!ret);
+ list_add_tail(&node->list, &ulist->nodes);
+ ulist->nnodes++;
+
+ return 1;
+}
+
+/**
+ * ulist_next - iterate ulist
+ * @ulist: ulist to iterate
+ * @uiter: iterator variable, initialized with ULIST_ITER_INIT(&iterator)
+ *
+ * Note: locking must be provided by the caller. In case of rwlocks only read
+ * locking is needed
+ *
+ * This function is used to iterate an ulist.
+ * It returns the next element from the ulist or %NULL when the
+ * end is reached. No guarantee is made with respect to the order in which
+ * the elements are returned. They might neither be returned in order of
+ * addition nor in ascending order.
+ * It is allowed to call ulist_add during an enumeration. Newly added items
+ * are guaranteed to show up in the running enumeration.
+ */
+struct ulist_node *ulist_next(struct ulist *ulist, struct ulist_iterator *uiter)
+{
+ struct ulist_node *node;
+
+ if (list_empty(&ulist->nodes))
+ return NULL;
+ if (uiter->cur_list && uiter->cur_list->next == &ulist->nodes)
+ return NULL;
+ if (uiter->cur_list) {
+ uiter->cur_list = uiter->cur_list->next;
+ } else {
+ uiter->cur_list = ulist->nodes.next;
+#ifdef CONFIG_BTRFS_DEBUG
+ uiter->i = 0;
+#endif
+ }
+ node = list_entry(uiter->cur_list, struct ulist_node, list);
+#ifdef CONFIG_BTRFS_DEBUG
+ ASSERT(node->seqnum == uiter->i);
+ ASSERT(uiter->i >= 0 && uiter->i < ulist->nnodes);
+ uiter->i++;
+#endif
+ return node;
+}
Index: btrfs-progs-v3.14.1/ulist.h
===================================================================
--- /dev/null
+++ btrfs-progs-v3.14.1/ulist.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 STRATO AG
+ * written by Arne Jansen <sensille@gmx.net>
+ * Distributed under the GNU GPL license version 2.
+ *
+ */
+
+#ifndef __ULIST__
+#define __ULIST__
+
+#include "kerncompat.h"
+#include "list.h"
+#include "rbtree.h"
+
+/*
+ * ulist is a generic data structure to hold a collection of unique u64
+ * values. The only operations it supports is adding to the list and
+ * enumerating it.
+ * It is possible to store an auxiliary value along with the key.
+ *
+ */
+struct ulist_iterator {
+#ifdef CONFIG_BTRFS_DEBUG
+ int i;
+#endif
+ struct list_head *cur_list; /* hint to start search */
+};
+
+/*
+ * element of the list
+ */
+struct ulist_node {
+ u64 val; /* value to store */
+ u64 aux; /* auxiliary value saved along with the val */
+
+#ifdef CONFIG_BTRFS_DEBUG
+ int seqnum; /* sequence number this node is added */
+#endif
+
+ struct list_head list; /* used to link node */
+ struct rb_node rb_node; /* used to speed up search */
+};
+
+struct ulist {
+ /*
+ * number of elements stored in list
+ */
+ unsigned long nnodes;
+
+ struct list_head nodes;
+ struct rb_root root;
+};
+
+void ulist_init(struct ulist *ulist);
+void ulist_reinit(struct ulist *ulist);
+struct ulist *ulist_alloc(gfp_t gfp_mask);
+void ulist_free(struct ulist *ulist);
+int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask);
+int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
+ u64 *old_aux, gfp_t gfp_mask);
+struct ulist_node *ulist_next(struct ulist *ulist,
+ struct ulist_iterator *uiter);
+
+#define ULIST_ITER_INIT(uiter) ((uiter)->cur_list = NULL)
+
+#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue May 13 20:28:23 UTC 2014 - mfasheh@suse.com
- add quota group verify patches, sent to list near end of the week starting
5/4/2014
- updates btrfsck with the ability to verify quota groups
-------------------------------------------------------------------
Fri May 2 13:37:04 UTC 2014 - dsterba@suse.cz

View File

@ -69,6 +69,11 @@ Patch167: 0167-Btrfs-progs-make-find_and_setup_root-return-an-error.patch
Patch168: 0168-Btrfs-progs-don-t-bug-out-if-we-can-t-find-the-last-.patch
Patch169: 0169-btrfs-progs-Check-metadata-mirrors-in-find-root.patch
Patch170: 0170-btrfs-progs-In-find-root-dump-bytenr-for-every-slot.patch
Patch200: 0200-btrfs-progs-print-qgroup-excl-as-unsigned.patch
Patch201: 0201-btrfs-progs-import-ulist.patch
Patch202: 0202-btrfs-progs-add-quota-group-verify-code.patch
Patch1000: local-version-override.patch
BuildRequires: libacl-devel
BuildRequires: libattr-devel
@ -143,6 +148,9 @@ build applications to interface with btrfs.
%patch168 -p1
%patch169 -p1
%patch170 -p1
%patch200 -p1
%patch201 -p1
%patch202 -p1
%patch1000 -p1
%build