/*
* Copyright (C) 2011 STRATO. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#include "ctree.h"
#include "disk-io.h"
#include "backref.h"
#include "ulist.h"
#include "transaction.h"
#include "delayed-ref.h"
/*
* this structure records all encountered refs on the way up to the root
*/
struct __prelim_ref {
struct list_head list;
u64 root_id;
struct btrfs_key key;
int level;
int count;
u64 parent;
u64 wanted_disk_byte;
};
static int __add_prelim_ref(struct list_head *head, u64 root_id,
struct btrfs_key *key, int level, u64 parent,
u64 wanted_disk_byte, int count)
{
struct __prelim_ref *ref;
/* in case we're adding delayed refs, we're holding the refs spinlock */
ref = kmalloc(sizeof(*ref), GFP_ATOMIC);
if (!ref)
return -ENOMEM;
ref->root_id = root_id;
if (key)
ref->key = *key;
else
memset(&ref->key, 0, sizeof(ref->key));
ref->level = level;
ref->count = count;
ref->parent = parent;
ref->wanted_disk_byte = wanted_disk_byte;
list_add_tail(&ref->list, head);