memset(p, 0, sizeof(*p));
 }
 
-int btrfs_cow_block(struct btrfs_root *root,
+static int btrfs_cow_block(struct btrfs_root *root,
                    struct btrfs_buffer *buf,
                    struct btrfs_buffer *parent,
                    int parent_slot,
 /*
  * compare two keys in a memcmp fashion
  */
-int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2)
+static int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2)
 {
        struct btrfs_key k1;
 
        return 0;
 }
 
-int check_node(struct btrfs_path *path, int level)
+static int check_node(struct btrfs_path *path, int level)
 {
        int i;
        struct btrfs_node *parent = NULL;
        return 0;
 }
 
-int check_leaf(struct btrfs_path *path, int level)
+static int check_leaf(struct btrfs_path *path, int level)
 {
        int i;
        struct btrfs_leaf *leaf = &path->nodes[level]->leaf;
        return 0;
 }
 
-int check_block(struct btrfs_path *path, int level)
+static int check_block(struct btrfs_path *path, int level)
 {
        if (level == 0)
                return check_leaf(path, level);
  *
  * slot may point to max if the key is bigger than all of the keys
  */
-int generic_bin_search(char *p, int item_size, struct btrfs_key *key,
+static int generic_bin_search(char *p, int item_size, struct btrfs_key *key,
                       int max, int *slot)
 {
        int low = 0;
  * simple bin_search frontend that does the right thing for
  * leaves vs nodes
  */
-int bin_search(struct btrfs_node *c, struct btrfs_key *key, int *slot)
+static int bin_search(struct btrfs_node *c, struct btrfs_key *key, int *slot)
 {
        if (btrfs_is_leaf(c)) {
                struct btrfs_leaf *l = (struct btrfs_leaf *)c;
        return -1;
 }
 
-struct btrfs_buffer *read_node_slot(struct btrfs_root *root,
+static struct btrfs_buffer *read_node_slot(struct btrfs_root *root,
                                   struct btrfs_buffer *parent_buf,
                                   int slot)
 {
 
  *
  * returns 0 if everything worked, non-zero otherwise.
  */
-int alloc_extent(struct btrfs_root *root, u64 num_blocks, u64 search_start,
-                        u64 search_end, u64 owner, struct btrfs_key *ins)
+static int alloc_extent(struct btrfs_root *root, u64 num_blocks,
+                       u64 search_start, u64 search_end, u64 owner,
+                       struct btrfs_key *ins)
 {
        int ret;
        int pending_ret;
        return buf;
 }
 
-int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, int *level)
+/*
+ * helper function for drop_snapshot, this walks down the tree dropping ref
+ * counts as it goes.
+ */
+static int walk_down_tree(struct btrfs_root *root,
+                         struct btrfs_path *path, int *level)
 {
        struct btrfs_buffer *next;
        struct btrfs_buffer *cur;
        BUG_ON(ret);
        if (refs > 1)
                goto out;
+       /*
+        * walk down to the last node level and free all the leaves
+        */
        while(*level > 0) {
                cur = path->nodes[*level];
                if (path->slots[*level] >=
        return 0;
 }
 
-int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path, int *level)
+/*
+ * helper for dropping snapshots.  This walks back up the tree in the path
+ * to find the first node higher up where we haven't yet gone through
+ * all the slots
+ */
+static int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path,
+                       int *level)
 {
        int i;
        int slot;
        return 1;
 }
 
+/*
+ * drop the reference count on the tree rooted at 'snap'.  This traverses
+ * the tree freeing any blocks that have a ref count of zero after being
+ * decremented.
+ */
 int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap)
 {
-       int ret;
+       int ret = 0;;
+       int wret;
        int level;
        struct btrfs_path path;
        int i;
        path.nodes[level] = snap;
        path.slots[level] = 0;
        while(1) {
-               ret = walk_down_tree(root, &path, &level);
-               if (ret > 0)
+               wret = walk_down_tree(root, &path, &level);
+               if (wret > 0)
                        break;
-               ret = walk_up_tree(root, &path, &level);
-               if (ret > 0)
+               if (wret < 0)
+                       ret = wret;
+
+               wret = walk_up_tree(root, &path, &level);
+               if (wret > 0)
                        break;
+               if (wret < 0)
+                       ret = wret;
        }
        for (i = 0; i <= orig_level; i++) {
                if (path.nodes[i]) {
                        btrfs_block_release(root, path.nodes[i]);
                }
        }
-
-       return 0;
+       return ret;
 }