All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: more statics & removals
@ 2013-08-07  1:01 Eric Sandeen
  2013-08-07  1:03 ` [PATCH 1/2] btrfs-progs: mark static & remove unused from shared kernel code Eric Sandeen
  2013-08-07  1:05 ` [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code Eric Sandeen
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Sandeen @ 2013-08-07  1:01 UTC (permalink / raw)
  To: linux-btrfs

2 patches, one for shared kernel files, one for pure userspace.

In kernelspace, lots of unused functions purged.  Some functions
which could be static are left alone if they aren't marked static
in kernelspace.

userspace only has a couple removals, mostly just marking static
& removing prototypes in headers as appropriate.

Thanks,
-Eric

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

* [PATCH 1/2] btrfs-progs: mark static & remove unused from shared kernel code
  2013-08-07  1:01 [PATCH 0/2] btrfs-progs: more statics & removals Eric Sandeen
@ 2013-08-07  1:03 ` Eric Sandeen
  2013-08-07  1:05 ` [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code Eric Sandeen
  1 sibling, 0 replies; 12+ messages in thread
From: Eric Sandeen @ 2013-08-07  1:03 UTC (permalink / raw)
  To: linux-btrfs

In files copied from the kernel, mark many functions as static,
and remove any resulting dead code.

Some functions are left unmarked if they aren't static in the
kernel tree.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

 ctree.c            |    2 
 ctree.h            |   43 -------------------
 dir-item.c         |   97 ++------------------------------------------
 disk-io.c          |   14 +++---
 disk-io.h          |    4 -
 extent-tree.c      |  115 +++--------------------------------------------------
 extent_io.c        |   10 ----
 extent_io.h        |    2 
 file-item.c        |   32 ++------------
 free-space-cache.c |    2 
 inode-item.c       |   73 ---------------------------------
 inode-map.c        |   32 --------------
 qgroup.c           |    4 -
 qgroup.h           |    2 
 root-tree.c        |   27 ------------
 volumes.c          |   69 ++-----------------------------
 volumes.h          |    7 ---
 17 files changed, 38 insertions(+), 497 deletions(-)

diff --git a/ctree.c b/ctree.c
index 66b146b..a79ed13 100644
--- a/ctree.c
+++ b/ctree.c
@@ -371,7 +371,7 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
 /*
  * compare two keys in a memcmp fashion
  */
-int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2)
+static int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2)
 {
 	struct btrfs_key k1;
 
diff --git a/ctree.h b/ctree.h
index 257396d..16914a4 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2097,23 +2097,17 @@ static inline int btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
 /* extent-tree.c */
 int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
 				 struct btrfs_root *root);
-int btrfs_check_block_accounting(struct btrfs_root *root);
 void btrfs_pin_extent(struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes);
 void btrfs_unpin_extent(struct btrfs_fs_info *fs_info,
 			u64 bytenr, u64 num_bytes);
 int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root);
-int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy);
 struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
 							 btrfs_fs_info *info,
 							 u64 bytenr);
 struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct
 						       btrfs_fs_info *info,
 						       u64 bytenr);
-struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
-						 struct btrfs_block_group_cache
-						 *hint, u64 search_start,
-						 int data, int owner);
 struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
 					struct btrfs_root *root,
 					u32 blocksize, u64 root_objectid,
@@ -2184,7 +2178,6 @@ struct extent_buffer *read_node_slot(struct btrfs_root *root,
 int btrfs_previous_item(struct btrfs_root *root,
 			struct btrfs_path *path, u64 min_objectid,
 			int type);
-int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2);
 int btrfs_cow_block(struct btrfs_trans_handle *trans,
 		    struct btrfs_root *root, struct extent_buffer *buf,
 		    struct extent_buffer *parent, int parent_slot,
@@ -2257,8 +2250,6 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
 		       u64 root_id, u8 type, u64 ref_id,
 		       u64 dirid, u64 sequence,
 		       const char *name, int name_len);
-int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-		   struct btrfs_key *key);
 int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
 		      *root, struct btrfs_key *key, struct btrfs_root_item
 		      *item);
@@ -2276,46 +2267,20 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
 					     struct btrfs_path *path, u64 dir,
 					     const char *name, int name_len,
 					     int mod);
-struct btrfs_dir_item *
-btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
-			    struct btrfs_root *root,
-			    struct btrfs_path *path, u64 dir,
-			    u64 objectid, const char *name, int name_len,
-			    int mod);
-struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
-			      struct btrfs_path *path,
-			      const char *name, int name_len);
-int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
-			      struct btrfs_root *root,
-			      struct btrfs_path *path,
-			      struct btrfs_dir_item *di);
 int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
 			    struct btrfs_root *root, const char *name,
 			    u16 name_len, const void *data, u16 data_len,
 			    u64 dir);
-struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
-					  struct btrfs_root *root,
-					  struct btrfs_path *path, u64 dir,
-					  const char *name, u16 name_len,
-					  int mod);
 /* inode-map.c */
 int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
 			     struct btrfs_root *fs_root,
 			     u64 dirid, u64 *objectid);
-int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid);
 
 /* inode-item.c */
 int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
 			   struct btrfs_root *root,
 			   const char *name, int name_len,
 			   u64 inode_objectid, u64 ref_objectid, u64 index);
-int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
-			   struct btrfs_root *root,
-			   const char *name, int name_len,
-			   u64 inode_objectid, u64 ref_objectid);
-int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root,
-			     struct btrfs_path *path, u64 objectid);
 int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
 		       *root, u64 objectid, struct btrfs_inode_item
 		       *inode_item);
@@ -2334,17 +2299,9 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
 int btrfs_insert_inline_extent(struct btrfs_trans_handle *trans,
 				struct btrfs_root *root, u64 objectid,
 				u64 offset, char *buffer, size_t size);
-int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root,
-			     struct btrfs_path *path, u64 objectid,
-			     u64 bytenr, int mod);
 int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
 			  struct btrfs_root *root, u64 alloc_end,
 			  u64 bytenr, char *data, size_t len);
-struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
-					  struct btrfs_root *root,
-					  struct btrfs_path *path,
-					  u64 bytenr, int cow);
 int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
 			struct btrfs_root *root, struct btrfs_path *path,
 			u64 isize);
diff --git a/dir-item.c b/dir-item.c
index 6558320..edb290a 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -21,6 +21,10 @@
 #include "hash.h"
 #include "transaction.h"
 
+static struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
+			      struct btrfs_path *path,
+			      const char *name, int name_len);
+
 static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle
 						   *trans,
 						   struct btrfs_root *root,
@@ -213,67 +217,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
 	return btrfs_match_dir_item_name(root, path, name, name_len);
 }
 
-struct btrfs_dir_item *
-btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
-			    struct btrfs_root *root,
-			    struct btrfs_path *path, u64 dir,
-			    u64 objectid, const char *name, int name_len,
-			    int mod)
-{
-	int ret;
-	struct btrfs_key key;
-	int ins_len = mod < 0 ? -1 : 0;
-	int cow = mod != 0;
-
-	key.objectid = dir;
-	btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
-	key.offset = objectid;
-
-	ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
-	if (ret < 0)
-		return ERR_PTR(ret);
-	if (ret > 0)
-		return ERR_PTR(-ENOENT);
-	return btrfs_match_dir_item_name(root, path, name, name_len);
-}
-
-struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
-					  struct btrfs_root *root,
-					  struct btrfs_path *path, u64 dir,
-					  const char *name, u16 name_len,
-					  int mod)
-{
-	int ret;
-	struct btrfs_key key;
-	int ins_len = mod < 0 ? -1 : 0;
-	int cow = mod != 0;
-	struct btrfs_key found_key;
-	struct extent_buffer *leaf;
-
-	key.objectid = dir;
-	btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
-	key.offset = btrfs_name_hash(name, name_len);
-	ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
-	if (ret < 0)
-		return ERR_PTR(ret);
-	if (ret > 0) {
-		if (path->slots[0] == 0)
-			return NULL;
-		path->slots[0]--;
-	}
-
-	leaf = path->nodes[0];
-	btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
-
-	if (found_key.objectid != dir ||
-	    btrfs_key_type(&found_key) != BTRFS_XATTR_ITEM_KEY ||
-	    found_key.offset != key.offset)
-		return NULL;
-
-	return btrfs_match_dir_item_name(root, path, name, name_len);
-}
-
-struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
+static struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
 			      struct btrfs_path *path,
 			      const char *name, int name_len)
 {
@@ -303,34 +247,3 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
 	}
 	return NULL;
 }
-
-int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
-			      struct btrfs_root *root,
-			      struct btrfs_path *path,
-			      struct btrfs_dir_item *di)
-{
-
-	struct extent_buffer *leaf;
-	u32 sub_item_len;
-	u32 item_len;
-	int ret = 0;
-
-	leaf = path->nodes[0];
-	sub_item_len = sizeof(*di) + btrfs_dir_name_len(leaf, di) +
-		btrfs_dir_data_len(leaf, di);
-	item_len = btrfs_item_size_nr(leaf, path->slots[0]);
-	if (sub_item_len == item_len) {
-		ret = btrfs_del_item(trans, root, path);
-	} else {
-		/* MARKER */
-		unsigned long ptr = (unsigned long)di;
-		unsigned long start;
-
-		start = btrfs_item_ptr_offset(leaf, path->slots[0]);
-		memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
-			item_len - (ptr + sub_item_len - start));
-		ret = btrfs_truncate_item(trans, root, path,
-					  item_len - sub_item_len, 1);
-	}
-	return ret;
-}
diff --git a/disk-io.c b/disk-io.c
index 473f7c1..6fb57be 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -112,8 +112,8 @@ int verify_tree_block_csum_silent(struct extent_buffer *buf, u16 csum_size)
 	return __csum_tree_block_size(buf, csum_size, 1, 1);
 }
 
-int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
-		    int verify)
+static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
+			   int verify)
 {
 	u16 csum_size =
 		btrfs_super_csum_size(root->fs_info->super_copy);
@@ -305,8 +305,9 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
 	return NULL;
 }
 
-int write_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-		     struct extent_buffer *eb)
+static int write_tree_block(struct btrfs_trans_handle *trans,
+			    struct btrfs_root *root,
+			    struct extent_buffer *eb)
 {
 	int ret;
 	int dev_nr;
@@ -1179,8 +1180,9 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr)
 	return transid > 0 ? 0 : -1;
 }
 
-int write_dev_supers(struct btrfs_root *root, struct btrfs_super_block *sb,
-		     struct btrfs_device *device)
+static int write_dev_supers(struct btrfs_root *root,
+			    struct btrfs_super_block *sb,
+			    struct btrfs_device *device)
 {
 	u64 bytenr;
 	u32 crc;
diff --git a/disk-io.h b/disk-io.h
index effaa9f..7ebb188 100644
--- a/disk-io.h
+++ b/disk-io.h
@@ -40,8 +40,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
 				      u32 blocksize, u64 parent_transid);
 int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
 			 u64 parent_transid);
-int write_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-		     struct extent_buffer *eb);
 struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
 						   u64 bytenr, u32 blocksize);
 
@@ -99,8 +97,6 @@ int btrfs_open_device(struct btrfs_device *dev);
 int csum_tree_block_size(struct extent_buffer *buf, u16 csum_sectorsize,
 			 int verify);
 int verify_tree_block_csum_silent(struct extent_buffer *buf, u16 csum_size);
-int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
-		    int verify);
 int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid);
 #endif
 
diff --git a/extent-tree.c b/extent-tree.c
index 828f7e3..9fa596b 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -57,6 +57,9 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
 				 btrfs_root *extent_root);
 static int del_pending_extents(struct btrfs_trans_handle *trans, struct
 			       btrfs_root *extent_root);
+static struct btrfs_block_group_cache *
+btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache
+		       *hint, u64 search_start, int data, int owner);
 
 static int remove_sb_from_cache(struct btrfs_root *root,
 				struct btrfs_block_group_cache *cache)
@@ -314,10 +317,9 @@ static int block_group_state_bits(u64 flags)
 	return bits;
 }
 
-struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
-						 struct btrfs_block_group_cache
-						 *hint, u64 search_start,
-						 int data, int owner)
+static struct btrfs_block_group_cache *
+btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache
+		       *hint, u64 search_start, int data, int owner)
 {
 	struct btrfs_block_group_cache *cache;
 	struct extent_io_tree *block_group_cache;
@@ -2012,25 +2014,6 @@ next:
 	return 0;
 }
 
-int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy)
-{
-	u64 last = 0;
-	u64 start;
-	u64 end;
-	struct extent_io_tree *pinned_extents = &root->fs_info->pinned_extents;
-	int ret;
-
-	while(1) {
-		ret = find_first_extent_bit(pinned_extents, last,
-					    &start, &end, EXTENT_DIRTY);
-		if (ret)
-			break;
-		set_extent_dirty(copy, start, end, GFP_NOFS);
-		last = end + 1;
-	}
-	return 0;
-}
-
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
 			       struct btrfs_root *root,
 			       struct extent_io_tree *unpin)
@@ -3135,8 +3118,8 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
 	return 0;
 }
 
-int find_first_block_group(struct btrfs_root *root, struct btrfs_path *path,
-			   struct btrfs_key *key)
+static int find_first_block_group(struct btrfs_root *root,
+		struct btrfs_path *path, struct btrfs_key *key)
 {
 	int ret;
 	struct btrfs_key found_key;
@@ -3422,88 +3405,6 @@ int btrfs_update_block_group(struct btrfs_trans_handle *trans,
 				  alloc, mark_free);
 }
 
-static int btrfs_count_extents_in_block_group(struct btrfs_root *root,
-					      struct btrfs_path *path, u64 start,
-					      u64 len,
-					      u64 *total)
-{
-	struct btrfs_key key;
-	struct extent_buffer *leaf;
-	u64 bytes_used = 0;
-	int ret;
-	int slot;
-
-	key.offset = 0;
-	key.objectid = start;
-	btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
-	ret = btrfs_search_slot(NULL, root->fs_info->extent_root,
-				&key, path, 0, 0);
-	if (ret < 0)
-		return ret;
-	while(1) {
-		leaf = path->nodes[0];
-		slot = path->slots[0];
-		if (slot >= btrfs_header_nritems(leaf)) {
-			ret = btrfs_next_leaf(root, path);
-			if (ret < 0)
-				return ret;
-			if (ret > 0)
-				break;
-			leaf = path->nodes[0];
-			slot = path->slots[0];
-		}
-		btrfs_item_key_to_cpu(leaf, &key, slot);
-		if (key.objectid > start + len)
-			break;
-		if (key.type == BTRFS_EXTENT_ITEM_KEY)
-			bytes_used += key.offset;
-		if (key.type == BTRFS_METADATA_ITEM_KEY)
-			bytes_used += root->leafsize;
-		path->slots[0]++;
-	}
-	*total = bytes_used;
-	btrfs_release_path(path);
-	return 0;
-}
-
-int btrfs_check_block_accounting(struct btrfs_root *root)
-{
-	int ret;
-	u64 start = 0;
-	u64 bytes_used = 0;
-	struct btrfs_path path;
-	struct btrfs_block_group_cache *cache;
-	struct btrfs_fs_info *fs_info = root->fs_info;
-
-	btrfs_init_path(&path);
-
-	while(1) {
-		cache = btrfs_lookup_block_group(fs_info, start);
-		if (!cache)
-			break;
-
-		ret = btrfs_count_extents_in_block_group(root, &path,
-							 cache->key.objectid,
-							 cache->key.offset,
-							 &bytes_used);
-
-		if (ret == 0) {
-			u64 on_disk = btrfs_block_group_used(&cache->item);
-			if (on_disk != bytes_used) {
-				fprintf(stderr, "bad block group accounting found %llu "
-					"expected %llu block group %llu\n",
-					(unsigned long long)bytes_used,
-					(unsigned long long)on_disk,
-					(unsigned long long)cache->key.objectid);
-			}
-		}
-		start = cache->key.objectid + cache->key.offset;
-
-		cache->space_info->bytes_used = 0;
-	}
-	return 0;
-}
-
 /*
  * Fixup block accounting. The initial block accounting created by
  * make_block_groups isn't accuracy in this case.
diff --git a/extent_io.c b/extent_io.c
index 62c05fe..acc4702 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -30,8 +30,8 @@
 #include "ctree.h"
 #include "volumes.h"
 
-u64 cache_soft_max = 1024 * 1024 * 256;
-u64 cache_hard_max = 1 * 1024 * 1024 * 1024;
+static u64 cache_soft_max = 1024 * 1024 * 256;
+static u64 cache_hard_max = 1 * 1024 * 1024 * 1024;
 
 void extent_io_tree_init(struct extent_io_tree *tree)
 {
@@ -906,12 +906,6 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
 	memcpy(dst->data + dst_offset, src->data + src_offset, len);
 }
 
-void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
-			  unsigned long src_offset, unsigned long len)
-{
-	memcpy(dst->data + dst_offset, dst->data + src_offset, len);
-}
-
 void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
 			   unsigned long src_offset, unsigned long len)
 {
diff --git a/extent_io.h b/extent_io.h
index 2604dce..ad283cd 100644
--- a/extent_io.h
+++ b/extent_io.h
@@ -122,8 +122,6 @@ void write_extent_buffer(struct extent_buffer *eb, const void *src,
 void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
 			unsigned long dst_offset, unsigned long src_offset,
 			unsigned long len);
-void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
-			  unsigned long src_offset, unsigned long len);
 void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
 			   unsigned long src_offset, unsigned long len);
 void memset_extent_buffer(struct extent_buffer *eb, char c,
diff --git a/file-item.c b/file-item.c
index c2909dc..515df32 100644
--- a/file-item.c
+++ b/file-item.c
@@ -29,12 +29,6 @@
 #define MAX_CSUM_ITEMS(r,size) ((((BTRFS_LEAF_DATA_SIZE(r) - \
 			       sizeof(struct btrfs_item) * 2) / \
 			       size) - 1))
-int btrfs_create_file(struct btrfs_trans_handle *trans,
-		      struct btrfs_root *root, u64 dirid, u64 *objectid)
-{
-	return 0;
-}
-
 int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
 			     struct btrfs_root *root,
 			     u64 objectid, u64 pos, u64 offset,
@@ -122,10 +116,11 @@ fail:
 	return err;
 }
 
-struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
-					  struct btrfs_root *root,
-					  struct btrfs_path *path,
-					  u64 bytenr, int cow)
+static struct btrfs_csum_item *
+btrfs_lookup_csum(struct btrfs_trans_handle *trans,
+		  struct btrfs_root *root,
+		  struct btrfs_path *path,
+		  u64 bytenr, int cow)
 {
 	int ret;
 	struct btrfs_key file_key;
@@ -172,23 +167,6 @@ fail:
 	return ERR_PTR(ret);
 }
 
-int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root,
-			     struct btrfs_path *path, u64 objectid,
-			     u64 offset, int mod)
-{
-	int ret;
-	struct btrfs_key file_key;
-	int ins_len = mod < 0 ? -1 : 0;
-	int cow = mod != 0;
-
-	file_key.objectid = objectid;
-	file_key.offset = offset;
-	btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
-	ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow);
-	return ret;
-}
-
 int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
 			  struct btrfs_root *root, u64 alloc_end,
 			  u64 bytenr, char *data, size_t len)
diff --git a/free-space-cache.c b/free-space-cache.c
index 6c2e189..35edac2 100644
--- a/free-space-cache.c
+++ b/free-space-cache.c
@@ -257,7 +257,7 @@ static int io_ctl_read_bitmap(struct io_ctl *io_ctl,
 }
 
 
-int __load_free_space_cache(struct btrfs_root *root,
+static int __load_free_space_cache(struct btrfs_root *root,
 			    struct btrfs_free_space_ctl *ctl,
 			    struct btrfs_path *path, u64 offset)
 {
diff --git a/inode-item.c b/inode-item.c
index 28865f7..8cc98c6 100644
--- a/inode-item.c
+++ b/inode-item.c
@@ -20,7 +20,7 @@
 #include "disk-io.h"
 #include "transaction.h"
 
-int find_name_in_backref(struct btrfs_path *path, const char * name,
+static int find_name_in_backref(struct btrfs_path *path, const char * name,
 			 int name_len, struct btrfs_inode_ref **ref_ret)
 {
 	struct extent_buffer *leaf;
@@ -49,60 +49,6 @@ int find_name_in_backref(struct btrfs_path *path, const char * name,
 	return 0;
 }
 
-int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
-			   struct btrfs_root *root,
-			   const char *name, int name_len,
-			   u64 inode_objectid, u64 ref_objectid)
-{
-	struct btrfs_path *path;
-	struct btrfs_key key;
-	struct btrfs_inode_ref *ref;
-	struct extent_buffer *leaf;
-	unsigned long ptr;
-	unsigned long item_start;
-	u32 item_size;
-	u32 sub_item_len;
-	int ret;
-	int del_len = name_len + sizeof(*ref);
-
-	key.objectid = inode_objectid;
-	key.offset = ref_objectid;
-	btrfs_set_key_type(&key, BTRFS_INODE_REF_KEY);
-
-	path = btrfs_alloc_path();
-	if (!path)
-		return -ENOMEM;
-
-	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-	if (ret > 0) {
-		ret = -ENOENT;
-		goto out;
-	} else if (ret < 0) {
-		goto out;
-	}
-	if (!find_name_in_backref(path, name, name_len, &ref)) {
-		ret = -ENOENT;
-		goto out;
-	}
-	leaf = path->nodes[0];
-	item_size = btrfs_item_size_nr(leaf, path->slots[0]);
-	if (del_len == item_size) {
-		ret = btrfs_del_item(trans, root, path);
-		goto out;
-	}
-	ptr = (unsigned long)ref;
-	sub_item_len = name_len + sizeof(*ref);
-	item_start = btrfs_item_ptr_offset(leaf, path->slots[0]);
-	memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
-			      item_size - (ptr + sub_item_len - item_start));
-	ret = btrfs_truncate_item(trans, root, path,
-				  item_size - sub_item_len, 1);
-	BUG_ON(ret);
-out:
-	btrfs_free_path(path);
-	return ret;
-}
-
 int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
 			   struct btrfs_root *root,
 			   const char *name, int name_len,
@@ -158,23 +104,6 @@ out:
 	return ret;
 }
 
-int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
-			     struct btrfs_root *root,
-			     struct btrfs_path *path, u64 objectid)
-{
-	struct btrfs_key key;
-	int ret;
-	key.objectid = objectid;
-	btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
-	key.offset = 0;
-
-	ret = btrfs_insert_empty_item(trans, root, path, &key,
-				      sizeof(struct btrfs_inode_item));
-	if (ret == 0 && objectid > root->highest_inode)
-		root->highest_inode = objectid;
-	return ret;
-}
-
 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
 		       *root, struct btrfs_path *path,
 		       struct btrfs_key *location, int mod)
diff --git a/inode-map.c b/inode-map.c
index f901109..3e138b5 100644
--- a/inode-map.c
+++ b/inode-map.c
@@ -20,38 +20,6 @@
 #include "disk-io.h"
 #include "transaction.h"
 
-int btrfs_find_highest_inode(struct btrfs_root *root, u64 *objectid)
-{
-	struct btrfs_path *path;
-	int ret;
-	struct extent_buffer *l;
-	struct btrfs_key search_key;
-	struct btrfs_key found_key;
-	int slot;
-
-	path = btrfs_alloc_path();
-	BUG_ON(!path);
-
-	search_key.objectid = (u64)-1;
-	search_key.offset = (u64)-1;
-	ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
-	if (ret < 0)
-		goto error;
-	BUG_ON(ret == 0);
-	if (path->slots[0] > 0) {
-		slot = path->slots[0] - 1;
-		l = path->nodes[0];
-		btrfs_item_key_to_cpu(l, &found_key, slot);
-		*objectid = found_key.objectid;
-	} else {
-		*objectid = BTRFS_FIRST_FREE_OBJECTID;
-	}
-	ret = 0;
-error:
-	btrfs_free_path(path);
-	return ret;
-}
-
 /*
  * walks the btree of allocated inodes and find a hole.
  */
diff --git a/qgroup.c b/qgroup.c
index dafde12..038c4dc 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -54,8 +54,8 @@ int qgroup_inherit_size(struct btrfs_qgroup_inherit *p)
 			     2 * p->num_excl_copies);
 }
 
-int qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit, int n,
-			   int pos)
+static int
+qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit, int n, int pos)
 {
 	struct btrfs_qgroup_inherit *out;
 	int nitems = 0;
diff --git a/qgroup.h b/qgroup.h
index ad14c88..da6d113 100644
--- a/qgroup.h
+++ b/qgroup.h
@@ -24,8 +24,6 @@
 
 u64 parse_qgroupid(char *p);
 int qgroup_inherit_size(struct btrfs_qgroup_inherit *p);
-int qgroup_inherit_realloc(struct btrfs_qgroup_inherit **inherit,
-			   int incgroups, int inccopies);
 int qgroup_inherit_add_group(struct btrfs_qgroup_inherit **inherit, char *arg);
 int qgroup_inherit_add_copy(struct btrfs_qgroup_inherit **inherit, char *arg,
 			    int type);
diff --git a/root-tree.c b/root-tree.c
index 9e5f35f..f8ae8e0 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -138,33 +138,6 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
 	return ret;
 }
 
-int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-		   struct btrfs_key *key)
-{
-	struct btrfs_path *path;
-	int ret;
-	u32 refs;
-	struct btrfs_root_item *ri;
-	struct extent_buffer *leaf;
-
-	path = btrfs_alloc_path();
-	BUG_ON(!path);
-	ret = btrfs_search_slot(trans, root, key, path, -1, 1);
-	if (ret < 0)
-		goto out;
-	BUG_ON(ret != 0);
-	leaf = path->nodes[0];
-	ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);
-
-	refs = btrfs_disk_root_refs(leaf, ri);
-	BUG_ON(refs != 0);
-	ret = btrfs_del_item(trans, root, path);
-out:
-	btrfs_release_path(path);
-	btrfs_free_path(path);
-	return ret;
-}
-
 /*
  * add a btrfs_root_ref item.  type is either BTRFS_ROOT_REF_KEY
  * or BTRFS_ROOT_BACKREF_KEY.
diff --git a/volumes.c b/volumes.c
index afc0abc..48f5f71 100644
--- a/volumes.c
+++ b/volumes.c
@@ -379,11 +379,11 @@ error:
 	return ret;
 }
 
-int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
-			   struct btrfs_device *device,
-			   u64 chunk_tree, u64 chunk_objectid,
-			   u64 chunk_offset,
-			   u64 num_bytes, u64 *start)
+static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
+				  struct btrfs_device *device,
+				  u64 chunk_tree, u64 chunk_objectid,
+				  u64 chunk_offset,
+				  u64 num_bytes, u64 *start)
 {
 	int ret;
 	struct btrfs_path *path;
@@ -1000,11 +1000,6 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
 	return ret;
 }
 
-void btrfs_mapping_init(struct btrfs_mapping_tree *tree)
-{
-	cache_tree_init(&tree->cache_tree);
-}
-
 int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
 {
 	struct cache_extent *ce;
@@ -1401,60 +1396,6 @@ btrfs_find_device_by_devid(struct btrfs_fs_devices *fs_devices,
 	return NULL;
 }
 
-int btrfs_bootstrap_super_map(struct btrfs_mapping_tree *map_tree,
-			      struct btrfs_fs_devices *fs_devices)
-{
-	struct map_lookup *map;
-	u64 logical = BTRFS_SUPER_INFO_OFFSET;
-	u64 length = BTRFS_SUPER_INFO_SIZE;
-	int num_stripes = 0;
-	int sub_stripes = 0;
-	int ret;
-	int i;
-	struct list_head *cur;
-
-	list_for_each(cur, &fs_devices->devices) {
-		num_stripes++;
-	}
-	map = kmalloc(btrfs_map_lookup_size(num_stripes), GFP_NOFS);
-	if (!map)
-		return -ENOMEM;
-
-	map->ce.start = logical;
-	map->ce.size = length;
-	map->num_stripes = num_stripes;
-	map->sub_stripes = sub_stripes;
-	map->io_width = length;
-	map->io_align = length;
-	map->sector_size = length;
-	map->stripe_len = length;
-	map->type = BTRFS_BLOCK_GROUP_RAID1;
-
-	i = 0;
-	list_for_each(cur, &fs_devices->devices) {
-		struct btrfs_device *device = list_entry(cur,
-							 struct btrfs_device,
-							 dev_list);
-		map->stripes[i].physical = logical;
-		map->stripes[i].dev = device;
-		i++;
-	}
-	ret = insert_cache_extent(&map_tree->cache_tree, &map->ce);
-	if (ret == -EEXIST) {
-		struct cache_extent *old;
-		struct map_lookup *old_map;
-		old = lookup_cache_extent(&map_tree->cache_tree,
-					  logical, length);
-		old_map = container_of(old, struct map_lookup, ce);
-		remove_cache_extent(&map_tree->cache_tree, old);
-		kfree(old_map);
-		ret = insert_cache_extent(&map_tree->cache_tree,
-						   &map->ce);
-	}
-	BUG_ON(ret);
-	return 0;
-}
-
 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset)
 {
 	struct cache_extent *ce;
diff --git a/volumes.h b/volumes.h
index e36f2f5..2802cb0 100644
--- a/volumes.h
+++ b/volumes.h
@@ -141,11 +141,6 @@ struct map_lookup {
 #define BTRFS_RAID6_Q_STRIPE ((u64)-1)
 
 
-int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
-			   struct btrfs_device *device,
-			   u64 chunk_tree, u64 chunk_objectid,
-			   u64 chunk_offset,
-			   u64 num_bytes, u64 *start);
 int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
 		      u64 logical, u64 *length, u64 *type,
 		      struct btrfs_multi_bio **multi_ret, int mirror_num,
@@ -183,8 +178,6 @@ int btrfs_scan_one_device(int fd, const char *path,
 			  struct btrfs_fs_devices **fs_devices_ret,
 			  u64 *total_devs, u64 super_offset);
 int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len);
-int btrfs_bootstrap_super_map(struct btrfs_mapping_tree *map_tree,
-			      struct btrfs_fs_devices *fs_devices);
 struct list_head *btrfs_scanned_uuids(void);
 int btrfs_add_system_chunk(struct btrfs_trans_handle *trans,
 			   struct btrfs_root *root, struct btrfs_key *key,


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

* [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07  1:01 [PATCH 0/2] btrfs-progs: more statics & removals Eric Sandeen
  2013-08-07  1:03 ` [PATCH 1/2] btrfs-progs: mark static & remove unused from shared kernel code Eric Sandeen
@ 2013-08-07  1:05 ` Eric Sandeen
  2013-08-07  3:49   ` Eric Sandeen
  2013-08-09 20:20   ` [PATCH 2/2 V2] " Eric Sandeen
  1 sibling, 2 replies; 12+ messages in thread
From: Eric Sandeen @ 2013-08-07  1:05 UTC (permalink / raw)
  To: linux-btrfs

Mark many functions as static, and remove any resulting dead code.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

 btrfs-convert.c     |    8 ++++----
 btrfs-find-root.c   |    2 +-
 btrfs-list.c        |   10 +++++-----
 btrfs-list.h        |    3 ---
 btrfs-map-logical.c |    4 ++--
 btrfs.c             |    5 +++--
 btrfstune.c         |    6 +++---
 cmds-chunk.c        |    5 +++--
 cmds-qgroup.c       |    4 ++--
 cmds-quota.c        |    2 +-
 cmds-receive.c      |    4 ++--
 cmds-restore.c      |    2 +-
 cmds-scrub.c        |    2 +-
 ioctl-test.c        |    2 +-
 quick-test.c        |    2 +-
 send-test.c         |    2 +-
 send-utils.c        |    9 ---------
 send-utils.h        |    2 --
 utils.c             |   18 ++++++++++--------
 utils.h             |    3 ---
 20 files changed, 41 insertions(+), 54 deletions(-)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index a9ac9a5..7eaa478 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -1418,8 +1418,8 @@ fail:
 	return ret;
 }
 
-struct btrfs_root *link_subvol(struct btrfs_root *root, const char *base,
-			       u64 root_objectid)
+static struct btrfs_root *
+link_subvol(struct btrfs_root *root, const char *base, u64 root_objectid)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_fs_info *fs_info = root->fs_info;
@@ -2277,7 +2277,7 @@ err:
 	return ret;
 }
 
-int do_convert(const char *devname, int datacsum, int packing, int noxattr)
+static int do_convert(const char *devname, int datacsum, int packing, int noxattr)
 {
 	int i, ret;
 	int fd = -1;
@@ -2456,7 +2456,7 @@ fail:
 	return -1;
 }
 
-int do_rollback(const char *devname, int force)
+static int do_rollback(const char *devname, int force)
 {
 	int fd = -1;
 	int ret;
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 989535f..1912f9d 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -46,7 +46,7 @@ static void usage()
 		"[ -g search_generation ] [ -l search_level ] <device>\n");
 }
 
-int csum_block(void *buf, u32 len)
+static int csum_block(void *buf, u32 len)
 {
 	char *result;
 	u32 crc = ~(u32)0;
diff --git a/btrfs-list.c b/btrfs-list.c
index a6902c3..0a9c52c 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -46,7 +46,7 @@ struct root_lookup {
 	struct rb_root root;
 };
 
-struct {
+static struct {
 	char	*name;
 	char	*column_name;
 	int	need_print;
@@ -240,7 +240,7 @@ void btrfs_list_free_comparer_set(struct btrfs_list_comparer_set *comp_set)
 	free(comp_set);
 }
 
-int btrfs_list_setup_comparer(struct btrfs_list_comparer_set  **comp_set,
+static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set  **comp_set,
 			      enum btrfs_list_comp_enum comparer,
 			      int is_descending)
 {
@@ -820,7 +820,7 @@ static char *__ino_resolve(int fd, u64 dirid)
  * simple string builder, returning a new string with both
  * dirid and name
  */
-char *build_name(char *dirid, char *name)
+static char *build_name(char *dirid, char *name)
 {
 	char *full;
 	if (!dirid)
@@ -1477,7 +1477,7 @@ static void print_all_volume_info(struct root_lookup *sorted_tree,
 	}
 }
 
-int btrfs_list_subvols(int fd, struct root_lookup *root_lookup)
+static int btrfs_list_subvols(int fd, struct root_lookup *root_lookup)
 {
 	int ret;
 
@@ -1522,7 +1522,7 @@ int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 	return 0;
 }
 
-char *strdup_or_null(const char *s)
+static char *strdup_or_null(const char *s)
 {
 	if (!s)
 		return NULL;
diff --git a/btrfs-list.h b/btrfs-list.h
index d3fd9e2..5164467 100644
--- a/btrfs-list.h
+++ b/btrfs-list.h
@@ -150,9 +150,6 @@ int btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set,
 			    enum btrfs_list_filter_enum filter, u64 data);
 struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void);
 void btrfs_list_free_comparer_set(struct btrfs_list_comparer_set *comp_set);
-int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set,
-			      enum btrfs_list_comp_enum comparer,
-			      int is_descending);
 
 int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 		       struct btrfs_list_comparer_set *comp_set,
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index b9635f7..f17d2a0 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -37,8 +37,8 @@
  * */
 static FILE *info_file;
 
-struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
-				     u32 blocksize, int copy)
+static struct extent_buffer *
+debug_read_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, int copy)
 {
 	int ret;
 	struct extent_buffer *eb;
diff --git a/btrfs.c b/btrfs.c
index 4e93e13..9e212ce 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -106,8 +106,9 @@ parse_command_token(const char *arg, const struct cmd_group *grp)
 	return cmd;
 }
 
-void handle_help_options_next_level(const struct cmd_struct *cmd,
-				    int argc, char **argv)
+static void
+handle_help_options_next_level(const struct cmd_struct *cmd,
+			       int argc, char **argv)
 {
 	if (argc < 2)
 		return;
diff --git a/btrfstune.c b/btrfstune.c
index 4db1767..1cf6a68 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -34,7 +34,7 @@
 
 static char *device;
 
-int update_seeding_flag(struct btrfs_root *root, int set_flag)
+static int update_seeding_flag(struct btrfs_root *root, int set_flag)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
@@ -65,7 +65,7 @@ int update_seeding_flag(struct btrfs_root *root, int set_flag)
 	return 0;
 }
 
-int enable_extrefs_flag(struct btrfs_root *root)
+static int enable_extrefs_flag(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
@@ -81,7 +81,7 @@ int enable_extrefs_flag(struct btrfs_root *root)
 	return 0;
 }
 
-int enable_skinny_metadata(struct btrfs_root *root)
+static int enable_skinny_metadata(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
diff --git a/cmds-chunk.c b/cmds-chunk.c
index c20234b..c8234d5 100644
--- a/cmds-chunk.c
+++ b/cmds-chunk.c
@@ -188,7 +188,8 @@ static struct btrfs_chunk *create_chunk_item(struct chunk_record *record)
 	return ret;
 }
 
-void init_recover_control(struct recover_control *rc, int verbose, int yes)
+static void
+init_recover_control(struct recover_control *rc, int verbose, int yes)
 {
 	memset(rc, 0, sizeof(struct recover_control));
 	cache_tree_init(&rc->chunk);
@@ -204,7 +205,7 @@ void init_recover_control(struct recover_control *rc, int verbose, int yes)
 	rc->yes = yes;
 }
 
-void free_recover_control(struct recover_control *rc)
+static void free_recover_control(struct recover_control *rc)
 {
 	free_block_group_tree(&rc->bg);
 	free_chunk_cache_tree(&rc->chunk);
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 95aca9b..bf659ab 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -104,7 +104,7 @@ static int qgroup_create(int create, int argc, char **argv)
 	return 0;
 }
 
-void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
+static void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
 {
 	printf("%llu/%llu %lld %lld\n", objectid >> 48,
 		objectid & ((1ll << 48) - 1),
@@ -112,7 +112,7 @@ void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
 		btrfs_stack_qgroup_info_exclusive(info));
 }
 
-int list_qgroups(int fd)
+static int list_qgroups(int fd)
 {
 	int ret;
 	struct btrfs_ioctl_search_args args;
diff --git a/cmds-quota.c b/cmds-quota.c
index 2e2971a..3357780 100644
--- a/cmds-quota.c
+++ b/cmds-quota.c
@@ -30,7 +30,7 @@ static const char * const quota_cmd_group_usage[] = {
 	NULL
 };
 
-int quota_ctl(int cmd, int argc, char **argv)
+static int quota_ctl(int cmd, int argc, char **argv)
 {
 	int ret = 0;
 	int fd;
diff --git a/cmds-receive.c b/cmds-receive.c
index 7abce76..1630f64 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -787,7 +787,7 @@ out:
 }
 
 
-struct btrfs_send_ops send_ops = {
+static struct btrfs_send_ops send_ops = {
 	.subvol = process_subvol,
 	.snapshot = process_snapshot,
 	.mkfile = process_mkfile,
@@ -810,7 +810,7 @@ struct btrfs_send_ops send_ops = {
 	.utimes = process_utimes,
 };
 
-int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd)
+static int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd)
 {
 	int ret;
 	char *dest_dir_full_path;
diff --git a/cmds-restore.c b/cmds-restore.c
index 0871366..38dfcc9 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -154,7 +154,7 @@ static int decompress(char *inbuf, char *outbuf, u64 compress_len,
 	return -1;
 }
 
-int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
+static int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
 {
 	int slot;
 	int level = 1;
diff --git a/cmds-scrub.c b/cmds-scrub.c
index bf50650..97b93ce 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -1007,7 +1007,7 @@ static struct scrub_file_record *last_dev_scrub(
 	return NULL;
 }
 
-int mkdir_p(char *path)
+static int mkdir_p(char *path)
 {
 	int i;
 	int ret;
diff --git a/ioctl-test.c b/ioctl-test.c
index 1c27d61..54fc013 100644
--- a/ioctl-test.c
+++ b/ioctl-test.c
@@ -3,7 +3,7 @@
 #include "kerncompat.h"
 #include "ioctl.h"
 
-unsigned long ioctls[] = {
+static unsigned long ioctls[] = {
 	BTRFS_IOC_SNAP_CREATE,
 	BTRFS_IOC_DEFRAG,
 	BTRFS_IOC_RESIZE,
diff --git a/quick-test.c b/quick-test.c
index aaedd19..b12b9ef 100644
--- a/quick-test.c
+++ b/quick-test.c
@@ -27,7 +27,7 @@
 #include "transaction.h"
 
 /* for testing only */
-int next_key(int i, int max_key) {
+static int next_key(int i, int max_key) {
 	return rand() % max_key;
 	// return i;
 }
diff --git a/send-test.c b/send-test.c
index 4a53ae2..cb1f57d 100644
--- a/send-test.c
+++ b/send-test.c
@@ -325,7 +325,7 @@ static int print_update_extent(const char *path, u64 offset, u64 len,
 	return 0;
 }
 
-struct btrfs_send_ops send_ops_print = {
+static struct btrfs_send_ops send_ops_print = {
 	.subvol = print_subvol,
 	.snapshot = print_snapshot,
 	.mkfile = print_mkfile,
diff --git a/send-utils.c b/send-utils.c
index 874f8a5..3d562a4 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -255,15 +255,6 @@ static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len,
 	return 0;
 }
 
-void subvol_uuid_search_add(struct subvol_uuid_search *s,
-			    struct subvol_info *si)
-{
-	if (si) {
-		free(si->path);
-		free(si);
-	}
-}
-
 struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
 				       u64 root_id, const u8 *uuid, u64 transid,
 				       const char *path,
diff --git a/send-utils.h b/send-utils.h
index ed1a40e..2607647 100644
--- a/send-utils.h
+++ b/send-utils.h
@@ -60,8 +60,6 @@ struct subvol_info *subvol_uuid_search(struct subvol_uuid_search *s,
 				       u64 root_id, const u8 *uuid, u64 transid,
 				       const char *path,
 				       enum subvol_search_type type);
-void subvol_uuid_search_add(struct subvol_uuid_search *s,
-			    struct subvol_info *si);
 
 int btrfs_subvolid_resolve(int fd, char *path, size_t path_len, u64 subvol_id);
 
diff --git a/utils.c b/utils.c
index e522361..71bb73e 100644
--- a/utils.c
+++ b/utils.c
@@ -751,7 +751,7 @@ int open_path_or_dev_mnt(const char *path)
 }
 
 /* checks if a device is a loop device */
-int is_loop_device (const char* device) {
+static int is_loop_device (const char* device) {
 	struct stat statbuf;
 
 	if(stat(device, &statbuf) < 0)
@@ -764,7 +764,8 @@ int is_loop_device (const char* device) {
 
 /* Takes a loop device path (e.g. /dev/loop0) and returns
  * the associated file (e.g. /images/my_btrfs.img) */
-int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
+static int
+resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
 {
 	int ret;
 	FILE *f;
@@ -790,7 +791,7 @@ int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
 /* Checks whether a and b are identical or device
  * files associated with the same block device
  */
-int is_same_blk_file(const char* a, const char* b)
+static int is_same_blk_file(const char* a, const char* b)
 {
 	struct stat st_buf_a, st_buf_b;
 	char real_a[PATH_MAX];
@@ -837,7 +838,7 @@ int is_same_blk_file(const char* a, const char* b)
  * if one file is a loop device that uses the other
  * file.
  */
-int is_same_loop_file(const char* a, const char* b)
+static int is_same_loop_file(const char* a, const char* b)
 {
 	char res_a[PATH_MAX];
 	char res_b[PATH_MAX];
@@ -877,7 +878,7 @@ int is_same_loop_file(const char* a, const char* b)
 }
 
 /* Checks if a file exists and is a block or regular file*/
-int is_existing_blk_or_reg_file(const char* filename)
+static int is_existing_blk_or_reg_file(const char* filename)
 {
 	struct stat st_buf;
 
@@ -894,7 +895,8 @@ int is_existing_blk_or_reg_file(const char* filename)
 /* Checks if a file is used (directly or indirectly via a loop device)
  * by a device in fs_devices
  */
-int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices, const char* file)
+static int
+blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices, const char* file)
 {
 	int ret;
 	struct list_head *head;
@@ -1524,7 +1526,7 @@ int open_file_or_dir(const char *fname)
 	return fd;
 }
 
-int get_device_info(int fd, u64 devid,
+static int get_device_info(int fd, u64 devid,
 		    struct btrfs_ioctl_dev_info_args *di_args)
 {
 	int ret;
@@ -1648,7 +1650,7 @@ static inline void translate(char *f, char *t)
  * Checks if the swap device.
  * Returns 1 if swap device, < 0 on error or 0 if not swap device.
  */
-int is_swap_device(const char *file)
+static int is_swap_device(const char *file)
 {
 	FILE	*f;
 	struct stat	st_buf;
diff --git a/utils.h b/utils.h
index d20f97f..693c5ad 100644
--- a/utils.h
+++ b/utils.h
@@ -57,8 +57,6 @@ int get_mountpt(char *dev, char *mntpt, size_t size);
 int btrfs_scan_block_devices(int run_ioctl);
 u64 parse_size(char *s);
 int open_file_or_dir(const char *fname);
-int get_device_info(int fd, u64 devid,
-		    struct btrfs_ioctl_dev_info_args *di_args);
 int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
 		struct btrfs_ioctl_dev_info_args **di_ret);
 int get_label(const char *btrfs_dev);
@@ -67,7 +65,6 @@ int set_label(const char *btrfs_dev, const char *label);
 char *__strncpy__null(char *dest, const char *src, size_t n);
 int is_block_device(const char *file);
 int open_path_or_dev_mnt(const char *path);
-int is_swap_device(const char *file);
 u64 btrfs_device_size(int fd, struct stat *st);
 /* Helper to always get proper size of the destination string */
 #define strncpy_null(dest, src) __strncpy__null(dest, src, sizeof(dest))



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

* Re: [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07  1:05 ` [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code Eric Sandeen
@ 2013-08-07  3:49   ` Eric Sandeen
  2013-08-07  7:54     ` Stefan Behrens
  2013-08-09 20:20   ` [PATCH 2/2 V2] " Eric Sandeen
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Sandeen @ 2013-08-07  3:49 UTC (permalink / raw)
  To: linux-btrfs, Stefan Behrens

On 8/6/13 8:05 PM, Eric Sandeen wrote:
> Mark many functions as static, and remove any resulting dead code.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
...

Actually, what the heck was this (note, this patch was against kdave's integration tree):

> diff --git a/send-utils.c b/send-utils.c
> index 874f8a5..3d562a4 100644
> --- a/send-utils.c
> +++ b/send-utils.c
> @@ -255,15 +255,6 @@ static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len,
>  	return 0;
>  }
>  
> -void subvol_uuid_search_add(struct subvol_uuid_search *s,
> -			    struct subvol_info *si)
> -{
> -	if (si) {
> -		free(si->path);
> -		free(si);
> -	}
> -}
> -

That code above came into being with "[PATCH v4 3/5] Btrfs-progs: use UUID tree for send/receive" -

 void subvol_uuid_search_add(struct subvol_uuid_search *s,
 			    struct subvol_info *si)
 {
-	int cnt;
-
-	tree_insert(&s->root_id_subvols, si, subvol_search_by_root_id);
-	tree_insert(&s->path_subvols, si, subvol_search_by_path);
-
-	cnt = count_bytes(si->uuid, BTRFS_UUID_SIZE, 0);
-	if (cnt != BTRFS_UUID_SIZE)
-		tree_insert(&s->local_subvols, si, subvol_search_by_uuid);
-	cnt = count_bytes(si->received_uuid, BTRFS_UUID_SIZE, 0);
-	if (cnt != BTRFS_UUID_SIZE)
-		tree_insert(&s->received_subvols, si,
-				subvol_search_by_received_uuid);
+	if (si) {
+		free(si->path);
+		free(si);
+	}
 }

is that, um, really as intended, or did something get misapplied somewhere?

-Eric

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

* Re: [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07  3:49   ` Eric Sandeen
@ 2013-08-07  7:54     ` Stefan Behrens
  2013-08-07 15:17       ` Eric Sandeen
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Behrens @ 2013-08-07  7:54 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-btrfs

On Tue, 06 Aug 2013 22:49:32 -0500, Eric Sandeen wrote:
> On 8/6/13 8:05 PM, Eric Sandeen wrote:
>> Mark many functions as static, and remove any resulting dead code.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
> ...
> 
> Actually, what the heck was this (note, this patch was against kdave's integration tree):
> 
>> diff --git a/send-utils.c b/send-utils.c
>> index 874f8a5..3d562a4 100644
>> --- a/send-utils.c
>> +++ b/send-utils.c
>> @@ -255,15 +255,6 @@ static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len,
>>  	return 0;
>>  }
>>  
>> -void subvol_uuid_search_add(struct subvol_uuid_search *s,
>> -			    struct subvol_info *si)
>> -{
>> -	if (si) {
>> -		free(si->path);
>> -		free(si);
>> -	}
>> -}
>> -
> 
> That code above came into being with "[PATCH v4 3/5] Btrfs-progs: use UUID tree for send/receive" -
> 
>  void subvol_uuid_search_add(struct subvol_uuid_search *s,
>  			    struct subvol_info *si)
>  {
> -	int cnt;
> -
> -	tree_insert(&s->root_id_subvols, si, subvol_search_by_root_id);
> -	tree_insert(&s->path_subvols, si, subvol_search_by_path);
> -
> -	cnt = count_bytes(si->uuid, BTRFS_UUID_SIZE, 0);
> -	if (cnt != BTRFS_UUID_SIZE)
> -		tree_insert(&s->local_subvols, si, subvol_search_by_uuid);
> -	cnt = count_bytes(si->received_uuid, BTRFS_UUID_SIZE, 0);
> -	if (cnt != BTRFS_UUID_SIZE)
> -		tree_insert(&s->received_subvols, si,
> -				subvol_search_by_received_uuid);
> +	if (si) {
> +		free(si->path);
> +		free(si);
> +	}
>  }
> 
> is that, um, really as intended, or did something get misapplied somewhere?

That was as intended. subvol_uuid_search_add() was not needed anymore
after the UUID tree patch. But it's part of the btrfs library interface
which I didn't want to break.

Before the UUID tree patch, the send/receive code was creating a
database (on the heap) of UUIDs, subvols and paths on each invocation.
The ..._add() function was part of that code. This database building
code was completely removed and replaced by code that uses the
tree-search ioctl (this was possible after the addition of the UUID tree
to the on-disk filesystem).

But subvol_uuid_search_add() is one of the exported btrfslib functions,
therefore I tried to stay compatible and to not break the interface.

To add a BTRFSLIB_VERSION define was proposed some time ago which is
updated with every interface change. I support this idea.

First thing I would like to change in the interface would be to add a
"btrfs_" prefix to all exported symbols. Unfortunately this is a 30k+
lines patch, I wrote a tiny sed script for it some time ago and this
huge patch was the result which I then throw away afterwards.


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

* Re: [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07  7:54     ` Stefan Behrens
@ 2013-08-07 15:17       ` Eric Sandeen
  2013-08-09 14:10         ` David Sterba
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Sandeen @ 2013-08-07 15:17 UTC (permalink / raw)
  To: Stefan Behrens; +Cc: linux-btrfs

On 8/7/13 2:54 AM, Stefan Behrens wrote:
> On Tue, 06 Aug 2013 22:49:32 -0500, Eric Sandeen wrote:
>> On 8/6/13 8:05 PM, Eric Sandeen wrote:
>>> Mark many functions as static, and remove any resulting dead code.
>>>
>>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>>> ---
>> ...
>>
>> Actually, what the heck was this (note, this patch was against kdave's integration tree):
>>
>>> diff --git a/send-utils.c b/send-utils.c
>>> index 874f8a5..3d562a4 100644
>>> --- a/send-utils.c
>>> +++ b/send-utils.c
>>> @@ -255,15 +255,6 @@ static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len,
>>>  	return 0;
>>>  }
>>>  
>>> -void subvol_uuid_search_add(struct subvol_uuid_search *s,
>>> -			    struct subvol_info *si)
>>> -{
>>> -	if (si) {
>>> -		free(si->path);
>>> -		free(si);
>>> -	}
>>> -}
>>> -
>>
>> That code above came into being with "[PATCH v4 3/5] Btrfs-progs: use UUID tree for send/receive" -
>>
>>  void subvol_uuid_search_add(struct subvol_uuid_search *s,
>>  			    struct subvol_info *si)
>>  {
>> -	int cnt;
>> -
>> -	tree_insert(&s->root_id_subvols, si, subvol_search_by_root_id);
>> -	tree_insert(&s->path_subvols, si, subvol_search_by_path);
>> -
>> -	cnt = count_bytes(si->uuid, BTRFS_UUID_SIZE, 0);
>> -	if (cnt != BTRFS_UUID_SIZE)
>> -		tree_insert(&s->local_subvols, si, subvol_search_by_uuid);
>> -	cnt = count_bytes(si->received_uuid, BTRFS_UUID_SIZE, 0);
>> -	if (cnt != BTRFS_UUID_SIZE)
>> -		tree_insert(&s->received_subvols, si,
>> -				subvol_search_by_received_uuid);
>> +	if (si) {
>> +		free(si->path);
>> +		free(si);
>> +	}
>>  }
>>
>> is that, um, really as intended, or did something get misapplied somewhere?
> 
> That was as intended. subvol_uuid_search_add() was not needed anymore
> after the UUID tree patch. But it's part of the btrfs library interface
> which I didn't want to break.

so you have a subvol_uuid_search_add() which . .  . frees things?

That's what was so confusing to me.  Ok, so it's an almost-no-op function
to maintain a symmetric interface, and the only remnant is to free
the things passed to it...

A comment to that effect would have been useful, I guess.  To a casual
code-reader, it just looked like a mistake.

And isn't it still a mistake?  I think it used to be that subvol_uuid_search_init()
would allocate the memory which must be freed, but that's no longer the case,
right?  So under what circumstances is it correct to call
subvol_uuid_search_add() which frees those pointers?

I'm probably missing something.

> Before the UUID tree patch, the send/receive code was creating a
> database (on the heap) of UUIDs, subvols and paths on each invocation.
> The ..._add() function was part of that code. This database building
> code was completely removed and replaced by code that uses the
> tree-search ioctl (this was possible after the addition of the UUID tree
> to the on-disk filesystem).
> 
> But subvol_uuid_search_add() is one of the exported btrfslib functions,
> therefore I tried to stay compatible and to not break the interface.

Oh, hohum.

> To add a BTRFSLIB_VERSION define was proposed some time ago which is
> updated with every interface change. I support this idea.

*nod*

Getting things organized in the tree, with a libbtrfs/ might help,
too.

thanks,
-Eric

> First thing I would like to change in the interface would be to add a
> "btrfs_" prefix to all exported symbols. Unfortunately this is a 30k+
> lines patch, I wrote a tiny sed script for it some time ago and this
> huge patch was the result which I then throw away afterwards.
> 


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

* Re: [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07 15:17       ` Eric Sandeen
@ 2013-08-09 14:10         ` David Sterba
  2013-08-09 14:39           ` Stefan Behrens
  0 siblings, 1 reply; 12+ messages in thread
From: David Sterba @ 2013-08-09 14:10 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Stefan Behrens, linux-btrfs

On Wed, Aug 07, 2013 at 10:17:57AM -0500, Eric Sandeen wrote:
> And isn't it still a mistake?  I think it used to be that subvol_uuid_search_init()
> would allocate the memory which must be freed, but that's no longer the case,
> right?  So under what circumstances is it correct to call
> subvol_uuid_search_add() which frees those pointers?

Looks like the memory management is internal to the subvol_uuid*
functions, now _init does not allocate and I don't see why _add should
call free. All users of subvol_uuid_search() free the memory themselves
(in current code).

Seems that subvol_uuid_search_add was exported without any concern that
it could be part of the library interface.

We don't have library ABI versioning in place, so I suggest to keep the
function there for compatibility with current code (though I'm not aware
of any external users of the _add function), but drop th free() calls
and put a "don't use" comment.

david

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

* Re: [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-09 14:10         ` David Sterba
@ 2013-08-09 14:39           ` Stefan Behrens
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Behrens @ 2013-08-09 14:39 UTC (permalink / raw)
  To: dsterba, Eric Sandeen, linux-btrfs

On Fri, 9 Aug 2013 16:10:39 +0200, David Sterba wrote:
> On Wed, Aug 07, 2013 at 10:17:57AM -0500, Eric Sandeen wrote:
>> And isn't it still a mistake?  I think it used to be that subvol_uuid_search_init()
>> would allocate the memory which must be freed, but that's no longer the case,
>> right?  So under what circumstances is it correct to call
>> subvol_uuid_search_add() which frees those pointers?
> 
> Looks like the memory management is internal to the subvol_uuid*
> functions, now _init does not allocate and I don't see why _add should
> call free. All users of subvol_uuid_search() free the memory themselves
> (in current code).
> 
> Seems that subvol_uuid_search_add was exported without any concern that
> it could be part of the library interface.
> 
> We don't have library ABI versioning in place, so I suggest to keep the
> function there for compatibility with current code (though I'm not aware
> of any external users of the _add function), but drop th free() calls
> and put a "don't use" comment.
> 

Callers of the subvol_uuid interface (like Btrfs receive) allocate the
memory for newly created items (this is the case after receiving a
subvolume) and add them to the database with the _add function. _add()
stores the pointer and the caller mustn't free() the item. This was/is
the interface.

We don't have this database anymore, we don't keep the items that are
added. Since it was not allowed to call free() for items that have been
added, _add() must call free() now.

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

* [PATCH 2/2 V2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-07  1:05 ` [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code Eric Sandeen
  2013-08-07  3:49   ` Eric Sandeen
@ 2013-08-09 20:20   ` Eric Sandeen
  2013-08-09 22:48     ` David Sterba
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Sandeen @ 2013-08-09 20:20 UTC (permalink / raw)
  To: linux-btrfs

Mark many functions as static, and remove any resulting dead code.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: Keep the "special" subvol_uuid_search_add()-which-only-frees-pointers
because I'm picking my battles :)

 btrfs-convert.c     |    8 ++++----
 btrfs-find-root.c   |    2 +-
 btrfs-list.c        |   10 +++++-----
 btrfs-list.h        |    3 ---
 btrfs-map-logical.c |    4 ++--
 btrfs.c             |    5 +++--
 btrfstune.c         |    6 +++---
 cmds-chunk.c        |    5 +++--
 cmds-qgroup.c       |    4 ++--
 cmds-quota.c        |    2 +-
 cmds-receive.c      |    4 ++--
 cmds-restore.c      |    2 +-
 cmds-scrub.c        |    2 +-
 ioctl-test.c        |    2 +-
 quick-test.c        |    2 +-
 send-test.c         |    2 +-
 utils.c             |   18 ++++++++++--------
 utils.h             |    3 ---
 20 files changed, 41 insertions(+), 54 deletions(-)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index a9ac9a5..7eaa478 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -1418,8 +1418,8 @@ fail:
 	return ret;
 }
 
-struct btrfs_root *link_subvol(struct btrfs_root *root, const char *base,
-			       u64 root_objectid)
+static struct btrfs_root *
+link_subvol(struct btrfs_root *root, const char *base, u64 root_objectid)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_fs_info *fs_info = root->fs_info;
@@ -2277,7 +2277,7 @@ err:
 	return ret;
 }
 
-int do_convert(const char *devname, int datacsum, int packing, int noxattr)
+static int do_convert(const char *devname, int datacsum, int packing, int noxattr)
 {
 	int i, ret;
 	int fd = -1;
@@ -2456,7 +2456,7 @@ fail:
 	return -1;
 }
 
-int do_rollback(const char *devname, int force)
+static int do_rollback(const char *devname, int force)
 {
 	int fd = -1;
 	int ret;
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 989535f..1912f9d 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -46,7 +46,7 @@ static void usage()
 		"[ -g search_generation ] [ -l search_level ] <device>\n");
 }
 
-int csum_block(void *buf, u32 len)
+static int csum_block(void *buf, u32 len)
 {
 	char *result;
 	u32 crc = ~(u32)0;
diff --git a/btrfs-list.c b/btrfs-list.c
index a6902c3..0a9c52c 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -46,7 +46,7 @@ struct root_lookup {
 	struct rb_root root;
 };
 
-struct {
+static struct {
 	char	*name;
 	char	*column_name;
 	int	need_print;
@@ -240,7 +240,7 @@ void btrfs_list_free_comparer_set(struct btrfs_list_comparer_set *comp_set)
 	free(comp_set);
 }
 
-int btrfs_list_setup_comparer(struct btrfs_list_comparer_set  **comp_set,
+static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set  **comp_set,
 			      enum btrfs_list_comp_enum comparer,
 			      int is_descending)
 {
@@ -820,7 +820,7 @@ static char *__ino_resolve(int fd, u64 dirid)
  * simple string builder, returning a new string with both
  * dirid and name
  */
-char *build_name(char *dirid, char *name)
+static char *build_name(char *dirid, char *name)
 {
 	char *full;
 	if (!dirid)
@@ -1477,7 +1477,7 @@ static void print_all_volume_info(struct root_lookup *sorted_tree,
 	}
 }
 
-int btrfs_list_subvols(int fd, struct root_lookup *root_lookup)
+static int btrfs_list_subvols(int fd, struct root_lookup *root_lookup)
 {
 	int ret;
 
@@ -1522,7 +1522,7 @@ int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 	return 0;
 }
 
-char *strdup_or_null(const char *s)
+static char *strdup_or_null(const char *s)
 {
 	if (!s)
 		return NULL;
diff --git a/btrfs-list.h b/btrfs-list.h
index d3fd9e2..5164467 100644
--- a/btrfs-list.h
+++ b/btrfs-list.h
@@ -150,9 +150,6 @@ int btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set,
 			    enum btrfs_list_filter_enum filter, u64 data);
 struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void);
 void btrfs_list_free_comparer_set(struct btrfs_list_comparer_set *comp_set);
-int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set,
-			      enum btrfs_list_comp_enum comparer,
-			      int is_descending);
 
 int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
 		       struct btrfs_list_comparer_set *comp_set,
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index b9635f7..f17d2a0 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -37,8 +37,8 @@
  * */
 static FILE *info_file;
 
-struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
-				     u32 blocksize, int copy)
+static struct extent_buffer *
+debug_read_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, int copy)
 {
 	int ret;
 	struct extent_buffer *eb;
diff --git a/btrfs.c b/btrfs.c
index 4e93e13..9e212ce 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -106,8 +106,9 @@ parse_command_token(const char *arg, const struct cmd_group *grp)
 	return cmd;
 }
 
-void handle_help_options_next_level(const struct cmd_struct *cmd,
-				    int argc, char **argv)
+static void
+handle_help_options_next_level(const struct cmd_struct *cmd,
+			       int argc, char **argv)
 {
 	if (argc < 2)
 		return;
diff --git a/btrfstune.c b/btrfstune.c
index 4db1767..1cf6a68 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -34,7 +34,7 @@
 
 static char *device;
 
-int update_seeding_flag(struct btrfs_root *root, int set_flag)
+static int update_seeding_flag(struct btrfs_root *root, int set_flag)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
@@ -65,7 +65,7 @@ int update_seeding_flag(struct btrfs_root *root, int set_flag)
 	return 0;
 }
 
-int enable_extrefs_flag(struct btrfs_root *root)
+static int enable_extrefs_flag(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
@@ -81,7 +81,7 @@ int enable_extrefs_flag(struct btrfs_root *root)
 	return 0;
 }
 
-int enable_skinny_metadata(struct btrfs_root *root)
+static int enable_skinny_metadata(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
 	struct btrfs_super_block *disk_super;
diff --git a/cmds-chunk.c b/cmds-chunk.c
index c20234b..c8234d5 100644
--- a/cmds-chunk.c
+++ b/cmds-chunk.c
@@ -188,7 +188,8 @@ static struct btrfs_chunk *create_chunk_item(struct chunk_record *record)
 	return ret;
 }
 
-void init_recover_control(struct recover_control *rc, int verbose, int yes)
+static void
+init_recover_control(struct recover_control *rc, int verbose, int yes)
 {
 	memset(rc, 0, sizeof(struct recover_control));
 	cache_tree_init(&rc->chunk);
@@ -204,7 +205,7 @@ void init_recover_control(struct recover_control *rc, int verbose, int yes)
 	rc->yes = yes;
 }
 
-void free_recover_control(struct recover_control *rc)
+static void free_recover_control(struct recover_control *rc)
 {
 	free_block_group_tree(&rc->bg);
 	free_chunk_cache_tree(&rc->chunk);
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 95aca9b..bf659ab 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -104,7 +104,7 @@ static int qgroup_create(int create, int argc, char **argv)
 	return 0;
 }
 
-void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
+static void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
 {
 	printf("%llu/%llu %lld %lld\n", objectid >> 48,
 		objectid & ((1ll << 48) - 1),
@@ -112,7 +112,7 @@ void print_qgroup_info(u64 objectid, struct btrfs_qgroup_info_item *info)
 		btrfs_stack_qgroup_info_exclusive(info));
 }
 
-int list_qgroups(int fd)
+static int list_qgroups(int fd)
 {
 	int ret;
 	struct btrfs_ioctl_search_args args;
diff --git a/cmds-quota.c b/cmds-quota.c
index 2e2971a..3357780 100644
--- a/cmds-quota.c
+++ b/cmds-quota.c
@@ -30,7 +30,7 @@ static const char * const quota_cmd_group_usage[] = {
 	NULL
 };
 
-int quota_ctl(int cmd, int argc, char **argv)
+static int quota_ctl(int cmd, int argc, char **argv)
 {
 	int ret = 0;
 	int fd;
diff --git a/cmds-receive.c b/cmds-receive.c
index 7abce76..1630f64 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -787,7 +787,7 @@ out:
 }
 
 
-struct btrfs_send_ops send_ops = {
+static struct btrfs_send_ops send_ops = {
 	.subvol = process_subvol,
 	.snapshot = process_snapshot,
 	.mkfile = process_mkfile,
@@ -810,7 +810,7 @@ struct btrfs_send_ops send_ops = {
 	.utimes = process_utimes,
 };
 
-int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd)
+static int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd)
 {
 	int ret;
 	char *dest_dir_full_path;
diff --git a/cmds-restore.c b/cmds-restore.c
index 0871366..38dfcc9 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -154,7 +154,7 @@ static int decompress(char *inbuf, char *outbuf, u64 compress_len,
 	return -1;
 }
 
-int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
+static int next_leaf(struct btrfs_root *root, struct btrfs_path *path)
 {
 	int slot;
 	int level = 1;
diff --git a/cmds-scrub.c b/cmds-scrub.c
index bf50650..97b93ce 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -1007,7 +1007,7 @@ static struct scrub_file_record *last_dev_scrub(
 	return NULL;
 }
 
-int mkdir_p(char *path)
+static int mkdir_p(char *path)
 {
 	int i;
 	int ret;
diff --git a/ioctl-test.c b/ioctl-test.c
index 1c27d61..54fc013 100644
--- a/ioctl-test.c
+++ b/ioctl-test.c
@@ -3,7 +3,7 @@
 #include "kerncompat.h"
 #include "ioctl.h"
 
-unsigned long ioctls[] = {
+static unsigned long ioctls[] = {
 	BTRFS_IOC_SNAP_CREATE,
 	BTRFS_IOC_DEFRAG,
 	BTRFS_IOC_RESIZE,
diff --git a/quick-test.c b/quick-test.c
index aaedd19..b12b9ef 100644
--- a/quick-test.c
+++ b/quick-test.c
@@ -27,7 +27,7 @@
 #include "transaction.h"
 
 /* for testing only */
-int next_key(int i, int max_key) {
+static int next_key(int i, int max_key) {
 	return rand() % max_key;
 	// return i;
 }
diff --git a/send-test.c b/send-test.c
index 4a53ae2..cb1f57d 100644
--- a/send-test.c
+++ b/send-test.c
@@ -325,7 +325,7 @@ static int print_update_extent(const char *path, u64 offset, u64 len,
 	return 0;
 }
 
-struct btrfs_send_ops send_ops_print = {
+static struct btrfs_send_ops send_ops_print = {
 	.subvol = print_subvol,
 	.snapshot = print_snapshot,
 	.mkfile = print_mkfile,
diff --git a/utils.c b/utils.c
index e522361..71bb73e 100644
--- a/utils.c
+++ b/utils.c
@@ -751,7 +751,7 @@ int open_path_or_dev_mnt(const char *path)
 }
 
 /* checks if a device is a loop device */
-int is_loop_device (const char* device) {
+static int is_loop_device (const char* device) {
 	struct stat statbuf;
 
 	if(stat(device, &statbuf) < 0)
@@ -764,7 +764,8 @@ int is_loop_device (const char* device) {
 
 /* Takes a loop device path (e.g. /dev/loop0) and returns
  * the associated file (e.g. /images/my_btrfs.img) */
-int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
+static int
+resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
 {
 	int ret;
 	FILE *f;
@@ -790,7 +791,7 @@ int resolve_loop_device(const char* loop_dev, char* loop_file, int max_len)
 /* Checks whether a and b are identical or device
  * files associated with the same block device
  */
-int is_same_blk_file(const char* a, const char* b)
+static int is_same_blk_file(const char* a, const char* b)
 {
 	struct stat st_buf_a, st_buf_b;
 	char real_a[PATH_MAX];
@@ -837,7 +838,7 @@ int is_same_blk_file(const char* a, const char* b)
  * if one file is a loop device that uses the other
  * file.
  */
-int is_same_loop_file(const char* a, const char* b)
+static int is_same_loop_file(const char* a, const char* b)
 {
 	char res_a[PATH_MAX];
 	char res_b[PATH_MAX];
@@ -877,7 +878,7 @@ int is_same_loop_file(const char* a, const char* b)
 }
 
 /* Checks if a file exists and is a block or regular file*/
-int is_existing_blk_or_reg_file(const char* filename)
+static int is_existing_blk_or_reg_file(const char* filename)
 {
 	struct stat st_buf;
 
@@ -894,7 +895,8 @@ int is_existing_blk_or_reg_file(const char* filename)
 /* Checks if a file is used (directly or indirectly via a loop device)
  * by a device in fs_devices
  */
-int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices, const char* file)
+static int
+blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices, const char* file)
 {
 	int ret;
 	struct list_head *head;
@@ -1524,7 +1526,7 @@ int open_file_or_dir(const char *fname)
 	return fd;
 }
 
-int get_device_info(int fd, u64 devid,
+static int get_device_info(int fd, u64 devid,
 		    struct btrfs_ioctl_dev_info_args *di_args)
 {
 	int ret;
@@ -1648,7 +1650,7 @@ static inline void translate(char *f, char *t)
  * Checks if the swap device.
  * Returns 1 if swap device, < 0 on error or 0 if not swap device.
  */
-int is_swap_device(const char *file)
+static int is_swap_device(const char *file)
 {
 	FILE	*f;
 	struct stat	st_buf;
diff --git a/utils.h b/utils.h
index d20f97f..693c5ad 100644
--- a/utils.h
+++ b/utils.h
@@ -57,8 +57,6 @@ int get_mountpt(char *dev, char *mntpt, size_t size);
 int btrfs_scan_block_devices(int run_ioctl);
 u64 parse_size(char *s);
 int open_file_or_dir(const char *fname);
-int get_device_info(int fd, u64 devid,
-		    struct btrfs_ioctl_dev_info_args *di_args);
 int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
 		struct btrfs_ioctl_dev_info_args **di_ret);
 int get_label(const char *btrfs_dev);
@@ -67,7 +65,6 @@ int set_label(const char *btrfs_dev, const char *label);
 char *__strncpy__null(char *dest, const char *src, size_t n);
 int is_block_device(const char *file);
 int open_path_or_dev_mnt(const char *path);
-int is_swap_device(const char *file);
 u64 btrfs_device_size(int fd, struct stat *st);
 /* Helper to always get proper size of the destination string */
 #define strncpy_null(dest, src) __strncpy__null(dest, src, sizeof(dest))




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

* Re: [PATCH 2/2 V2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-09 20:20   ` [PATCH 2/2 V2] " Eric Sandeen
@ 2013-08-09 22:48     ` David Sterba
  2013-08-09 23:16       ` Eric Sandeen
  0 siblings, 1 reply; 12+ messages in thread
From: David Sterba @ 2013-08-09 22:48 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-btrfs

On Fri, Aug 09, 2013 at 03:20:47PM -0500, Eric Sandeen wrote:
> Mark many functions as static, and remove any resulting dead code.

Thanks.

> -struct btrfs_root *link_subvol(struct btrfs_root *root, const char *base,
> -			       u64 root_objectid)
> +static struct btrfs_root *
> +link_subvol(struct btrfs_root *root, const char *base, u64 root_objectid)

Please keep the function defintion style if possible. I've fixed that at
commit time, no need to resend.

david

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

* Re: [PATCH 2/2 V2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-09 22:48     ` David Sterba
@ 2013-08-09 23:16       ` Eric Sandeen
  2013-08-09 23:25         ` David Sterba
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Sandeen @ 2013-08-09 23:16 UTC (permalink / raw)
  To: dsterba, linux-btrfs

On 8/9/13 5:48 PM, David Sterba wrote:
> On Fri, Aug 09, 2013 at 03:20:47PM -0500, Eric Sandeen wrote:
>> Mark many functions as static, and remove any resulting dead code.
> 
> Thanks.
> 
>> -struct btrfs_root *link_subvol(struct btrfs_root *root, const char *base,
>> -			       u64 root_objectid)
>> +static struct btrfs_root *
>> +link_subvol(struct btrfs_root *root, const char *base, u64 root_objectid)
> 
> Please keep the function defintion style if possible. I've fixed that at
> commit time, no need to resend.

Ok, fair enough - so preferred is

<lots of type stuff> function(some args . . ,
                              . . .  more args . . .,
                              . . . last args)

?  sorry, old xfs habits die hard. ;)

-Eric

> david
> 


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

* Re: [PATCH 2/2 V2] btrfs-progs: mark static & remove unused from non-kernel code
  2013-08-09 23:16       ` Eric Sandeen
@ 2013-08-09 23:25         ` David Sterba
  0 siblings, 0 replies; 12+ messages in thread
From: David Sterba @ 2013-08-09 23:25 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: dsterba, linux-btrfs

On Fri, Aug 09, 2013 at 06:16:30PM -0500, Eric Sandeen wrote:
> Ok, fair enough - so preferred is
> 
> <lots of type stuff> function(some args . . ,
>                               . . .  more args . . .,
>                               . . . last args)

Yeah something like that, bonus points if variable type and name are on
the same line.

> ?  sorry, old xfs habits die hard. ;)

sure, np ;)

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

end of thread, other threads:[~2013-08-09 23:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07  1:01 [PATCH 0/2] btrfs-progs: more statics & removals Eric Sandeen
2013-08-07  1:03 ` [PATCH 1/2] btrfs-progs: mark static & remove unused from shared kernel code Eric Sandeen
2013-08-07  1:05 ` [PATCH 2/2] btrfs-progs: mark static & remove unused from non-kernel code Eric Sandeen
2013-08-07  3:49   ` Eric Sandeen
2013-08-07  7:54     ` Stefan Behrens
2013-08-07 15:17       ` Eric Sandeen
2013-08-09 14:10         ` David Sterba
2013-08-09 14:39           ` Stefan Behrens
2013-08-09 20:20   ` [PATCH 2/2 V2] " Eric Sandeen
2013-08-09 22:48     ` David Sterba
2013-08-09 23:16       ` Eric Sandeen
2013-08-09 23:25         ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.