linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] patches from Fedora 18
@ 2013-01-19 14:56 Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch Gene Czarcinski
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gene Czarcinski @ 2013-01-19 14:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gene Czarcinski

These are the patches from the Fedora 18 btrfs-progs package.

I claim no authorship and am simply passing these on to the
btrfs mailing list.  There are only four patches.  The 
btrfs-init-dev-list.patch is new to 18.  The others all date
back to at least Fedora 15 in early 2011.

These patches were applied on top of the 19 patches
assembled by David Sterba.  They all applied cleanly
except the valgrind patch where I had to remove a small part
because it had already been fixed by the "plug a memory leak
reported by cppcheck" patch.

Gene Czarcinski (4):
  Fedora 18 - btrfs-init-dev-list.patch
  Fedora 18 - build-fixes.patch
  Fedora 18 - fix-labels.patch
  Fedora 18 - modified valgrind.patch

 btrfsck.c      |  2 ++
 disk-io.c      | 16 +++++++++++-----
 extent-cache.c | 11 +++++++++++
 extent-cache.h |  1 +
 extent-tree.c  | 10 ++++++++++
 mkfs.c         | 11 ++---------
 utils.c        |  3 ++-
 volumes.c      | 16 +++++++++++++++-
 volumes.h      |  1 +
 9 files changed, 55 insertions(+), 16 deletions(-)

-- 
1.8.1


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

* [PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch
  2013-01-19 14:56 [PATCH 0/4] patches from Fedora 18 Gene Czarcinski
@ 2013-01-19 14:56 ` Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 2/4] Fedora 18 - build-fixes.patch Gene Czarcinski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gene Czarcinski @ 2013-01-19 14:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gene Czarcinski

---
 utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index 938f9a5..51b78d5 100644
--- a/utils.c
+++ b/utils.c
@@ -477,7 +477,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
 	u64 num_devs;
 	int ret;
 
-	device = kmalloc(sizeof(*device), GFP_NOFS);
+	device = kzalloc(sizeof(*device), GFP_NOFS);
 	if (!device)
 		return -ENOMEM;
 	buf = kmalloc(sectorsize, GFP_NOFS);
@@ -503,6 +503,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
 	device->bytes_used = 0;
 	device->total_ios = 0;
 	device->dev_root = root->fs_info->dev_root;
+	INIT_LIST_HEAD(&device->dev_list);
 
 	ret = btrfs_add_device(trans, root, device);
 	BUG_ON(ret);
-- 
1.8.1


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

* [PATCH 2/4] Fedora 18 - build-fixes.patch
  2013-01-19 14:56 [PATCH 0/4] patches from Fedora 18 Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch Gene Czarcinski
@ 2013-01-19 14:56 ` Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 3/4] Fedora 18 - fix-labels.patch Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 4/4] Fedora 18 - modified valgrind.patch Gene Czarcinski
  3 siblings, 0 replies; 5+ messages in thread
From: Gene Czarcinski @ 2013-01-19 14:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gene Czarcinski

---
 btrfsck.c | 2 ++
 mkfs.c    | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/btrfsck.c b/btrfsck.c
index a851008..6274ff7 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -22,7 +22,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <sys/types.h>
 #include <sys/stat.h>
+#include <unistd.h>
 #include <getopt.h>
 #include "kerncompat.h"
 #include "ctree.h"
diff --git a/mkfs.c b/mkfs.c
index fbf8319..d123d5f 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1206,7 +1206,7 @@ int main(int ac, char **av)
 	u64 alloc_start = 0;
 	u64 metadata_profile = 0;
 	u64 data_profile = 0;
-	u32 leafsize = getpagesize();
+	u32 leafsize = sysconf(_SC_PAGESIZE);
 	u32 sectorsize = 4096;
 	u32 nodesize = leafsize;
 	u32 stripesize = 4096;
@@ -1282,7 +1282,7 @@ int main(int ac, char **av)
 				print_usage();
 		}
 	}
-	sectorsize = max(sectorsize, (u32)getpagesize());
+	sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
 	if (check_leaf_or_node_size(leafsize, sectorsize))
 		exit(1);
 	if (check_leaf_or_node_size(nodesize, sectorsize))
-- 
1.8.1


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

* [PATCH 3/4] Fedora 18 - fix-labels.patch
  2013-01-19 14:56 [PATCH 0/4] patches from Fedora 18 Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 2/4] Fedora 18 - build-fixes.patch Gene Czarcinski
@ 2013-01-19 14:56 ` Gene Czarcinski
  2013-01-19 14:56 ` [PATCH 4/4] Fedora 18 - modified valgrind.patch Gene Czarcinski
  3 siblings, 0 replies; 5+ messages in thread
From: Gene Czarcinski @ 2013-01-19 14:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gene Czarcinski

---
 mkfs.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index d123d5f..8c291c9 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -352,7 +352,6 @@ static u64 parse_profile(char *s)
 
 static char *parse_label(char *input)
 {
-	int i;
 	int len = strlen(input);
 
 	if (len >= BTRFS_LABEL_SIZE) {
@@ -360,12 +359,6 @@ static char *parse_label(char *input)
 			BTRFS_LABEL_SIZE - 1);
 		exit(1);
 	}
-	for (i = 0; i < len; i++) {
-		if (input[i] == '/' || input[i] == '\\') {
-			fprintf(stderr, "invalid label %s\n", input);
-			exit(1);
-		}
-	}
 	return strdup(input);
 }
 
-- 
1.8.1


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

* [PATCH 4/4] Fedora 18 - modified valgrind.patch
  2013-01-19 14:56 [PATCH 0/4] patches from Fedora 18 Gene Czarcinski
                   ` (2 preceding siblings ...)
  2013-01-19 14:56 ` [PATCH 3/4] Fedora 18 - fix-labels.patch Gene Czarcinski
@ 2013-01-19 14:56 ` Gene Czarcinski
  3 siblings, 0 replies; 5+ messages in thread
From: Gene Czarcinski @ 2013-01-19 14:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Gene Czarcinski

A small part of this patch proved unnecessary because it was
already corrected by the plug a memory leak reported by cppcheck
patch.
---
 disk-io.c      | 16 +++++++++++-----
 extent-cache.c | 11 +++++++++++
 extent-cache.h |  1 +
 extent-tree.c  | 10 ++++++++++
 volumes.c      | 16 +++++++++++++++-
 volumes.h      |  1 +
 6 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index c4d4631..5b6c6b1 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -631,7 +631,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
 	struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
 	struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
 	struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
-	struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
+	struct btrfs_fs_info *fs_info = malloc(sizeof(struct btrfs_fs_info));
 	int ret;
 	struct btrfs_super_block *disk_super;
 	struct btrfs_fs_devices *fs_devices = NULL;
@@ -655,7 +655,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
 			goto out;
 	}
 
-	memset(fs_info, 0, sizeof(*fs_info));
+	memset(fs_info, 0, sizeof(struct btrfs_fs_info));
 	fs_info->tree_root = tree_root;
 	fs_info->extent_root = extent_root;
 	fs_info->chunk_root = chunk_root;
@@ -1084,15 +1084,19 @@ static int close_all_devices(struct btrfs_fs_info *fs_info)
 {
 	struct list_head *list;
 	struct list_head *next;
+	struct list_head *tmp;
 	struct btrfs_device *device;
 
-	return 0;
-
 	list = &fs_info->fs_devices->devices;
-	list_for_each(next, list) {
+	list_for_each_safe(next, tmp, list) {
 		device = list_entry(next, struct btrfs_device, dev_list);
 		close(device->fd);
+		list_del(&device->dev_list);
+		free(device->name);
+		free(device->label);
+		free(device);
 	}
+	free(fs_info->fs_devices);
 	return 0;
 }
 
@@ -1142,12 +1146,14 @@ int close_ctree(struct btrfs_root *root)
 	extent_io_tree_cleanup(&fs_info->pinned_extents);
 	extent_io_tree_cleanup(&fs_info->pending_del);
 	extent_io_tree_cleanup(&fs_info->extent_ins);
+	btrfs_mapping_tree_free(&fs_info->mapping_tree);
 
 	free(fs_info->tree_root);
 	free(fs_info->extent_root);
 	free(fs_info->chunk_root);
 	free(fs_info->dev_root);
 	free(fs_info->csum_root);
+	free(fs_info->log_root_tree);
 	free(fs_info);
 
 	return 0;
diff --git a/extent-cache.c b/extent-cache.c
index 3dd6434..84d4bbc 100644
--- a/extent-cache.c
+++ b/extent-cache.c
@@ -168,3 +168,14 @@ void remove_cache_extent(struct cache_tree *tree,
 	rb_erase(&pe->rb_node, &tree->root);
 }
 
+void free_cache_tree(struct cache_tree *tree)
+{
+	struct rb_node *node;
+	struct cache_extent *cache;
+
+	while ((node = rb_last(&tree->root)) != NULL) {
+		cache = rb_entry(node, struct cache_extent, rb_node);
+		remove_cache_extent(tree, cache);
+		free(cache);
+	}
+}
diff --git a/extent-cache.h b/extent-cache.h
index 7f2f2a6..1696bc2 100644
--- a/extent-cache.h
+++ b/extent-cache.h
@@ -43,6 +43,7 @@ struct cache_extent *find_cache_extent(struct cache_tree *tree,
 int insert_cache_extent(struct cache_tree *tree, u64 start, u64 size);
 int insert_existing_cache_extent(struct cache_tree *tree,
 				 struct cache_extent *pe);
+void free_cache_tree(struct cache_tree *tree);
 
 static inline int cache_tree_empty(struct cache_tree *tree)
 {
diff --git a/extent-tree.c b/extent-tree.c
index 20cdffa..d644d9a 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2999,6 +2999,7 @@ out:
 
 int btrfs_free_block_groups(struct btrfs_fs_info *info)
 {
+	struct btrfs_space_info *space_info;
 	u64 start;
 	u64 end;
 	u64 ptr;
@@ -3022,6 +3023,15 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
 		clear_extent_dirty(&info->free_space_cache, start,
 				   end, GFP_NOFS);
 	}
+
+	while (!list_empty(&info->space_info)) {
+		space_info = list_entry(info->space_info.next,
+					struct btrfs_space_info,
+					list);
+		list_del(&space_info->list);
+		kfree(space_info);
+	}
+
 	return 0;
 }
 
diff --git a/volumes.c b/volumes.c
index 581c298..37b0074 100644
--- a/volumes.c
+++ b/volumes.c
@@ -959,6 +959,20 @@ void btrfs_mapping_init(struct btrfs_mapping_tree *tree)
 	cache_tree_init(&tree->cache_tree);
 }
 
+void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
+{
+	struct cache_extent *cache;
+	struct rb_node *node;
+	struct map_lookup *map;
+
+	while ((node = rb_last(&tree->cache_tree.root)) != NULL) {
+		cache = rb_entry(node, struct cache_extent, rb_node);
+		map = container_of(cache, struct map_lookup, ce);
+		remove_cache_extent(&tree->cache_tree, cache);
+		free(map);
+	}
+}
+
 int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
 {
 	struct cache_extent *ce;
@@ -1486,7 +1500,7 @@ int btrfs_read_sys_array(struct btrfs_root *root)
 	if (!sb)
 		return -ENOMEM;
 	btrfs_set_buffer_uptodate(sb);
-	write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE);
+	write_extent_buffer(sb, super_copy, 0, sizeof(*super_copy));
 	array_size = btrfs_super_sys_array_size(super_copy);
 
 	/*
diff --git a/volumes.h b/volumes.h
index 9ff6182..ce1e413 100644
--- a/volumes.h
+++ b/volumes.h
@@ -182,4 +182,5 @@ int btrfs_add_system_chunk(struct btrfs_trans_handle *trans,
 			   struct btrfs_root *root, struct btrfs_key *key,
 			   struct btrfs_chunk *chunk, int item_size);
 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset);
+void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree);
 #endif
-- 
1.8.1


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

end of thread, other threads:[~2013-01-19 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-19 14:56 [PATCH 0/4] patches from Fedora 18 Gene Czarcinski
2013-01-19 14:56 ` [PATCH 1/4] Fedora 18 - btrfs-init-dev-list.patch Gene Czarcinski
2013-01-19 14:56 ` [PATCH 2/4] Fedora 18 - build-fixes.patch Gene Czarcinski
2013-01-19 14:56 ` [PATCH 3/4] Fedora 18 - fix-labels.patch Gene Czarcinski
2013-01-19 14:56 ` [PATCH 4/4] Fedora 18 - modified valgrind.patch Gene Czarcinski

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).