linux v3.1 with btrfs-work: oops when deleting files

2011-10-24 Thread Kai Krakow
Hello list!

I'm trying to rm some files, this is what I get in dmesg:

[30975.249519] [ cut here ]
[30975.249529] WARNING: at fs/btrfs/extent-tree.c:4588 
__btrfs_free_extent+0x3b7/0x7ed()
[30975.249532] Hardware name:  
[30975.249535] Modules linked in: af_packet lm90 it87 hwmon_vid hwmon fuse 
snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss 
snd_mixer_oss reiserfs zram(C) mperf loop emu10k1_gp sidewinder joydev nfs 
lockd auth_rpcgss nfs_acl tcp_cubic sunrpc ipv6 snd_usb_audio 
snd_usbmidi_lib gspca_sonixj gspca_main videodev usbhid 8250_pnp 
i82875p_edac edac_core sr_mod sg analog cdrom firewire_ohci firewire_core 
evdev pcspkr parport_pc floppy parport ns558 gameport i2c_i801 ne2k_pci 8390 
8250 serial_core snd_mpu401 snd_mpu401_uart intel_agp e1000 crc_itu_t fan 
button intel_gtt agpgart processor thermal unix usb_storage hid [last 
unloaded: microcode]
[30975.249604] Pid: 12291, comm: rm Tainted: G   A C  3.1.0-00057-
gc82b96b-dirty #6
[30975.249607] Call Trace:
[30975.249615]  [] ? warn_slowpath_common+0x7c/0x8f
[30975.249620]  [] ? __btrfs_free_extent+0x3b7/0x7ed
[30975.249624]  [] ? __btrfs_free_extent+0x3b7/0x7ed
[30975.249628]  [] ? warn_slowpath_null+0x1b/0x1e
[30975.249632]  [] ? __btrfs_free_extent+0x3b7/0x7ed
[30975.249638]  [] ? rb_erase+0x1ce/0x1f0
[30975.249643]  [] ? run_clustered_refs+0x838/0x87e
[30975.249648]  [] ? btrfs_find_ref_cluster+0xfc/0x13c
[30975.249653]  [] ? btrfs_run_delayed_refs+0xbc/0x13c
[30975.249658]  [] ? __btrfs_end_transaction+0x7e/0x1ac
[30975.249663]  [] ? btrfs_end_transaction+0x11/0x13
[30975.249667]  [] ? btrfs_evict_inode+0x288/0x29f
[30975.249672]  [] ? evict+0x82/0x11d
[30975.249677]  [] ? do_unlinkat+0xc9/0x110
[30975.249683]  [] ? fsnotify_find_inode_mark+0x17/0x1d
[30975.249688]  [] ? filp_close+0x58/0x5f
[30975.249693]  [] ? sysenter_do_call+0x12/0x22
[30975.249697] ---[ end trace 568719abda29cd87 ]---
[30975.249701] btrfs unable to find ref byte nr 1271613026304 parent 0 root 
256  owner 445125 offset 2097152
[30975.249713] BUG: unable to handle kernel NULL pointer dereference at   
(null)
[30975.249992] IP: [] map_private_extent_buffer+0x7/0xbc
[30975.250249] *pde =  
[30975.250446] Oops:  [#1] SMP 
[30975.250652] Modules linked in: af_packet lm90 it87 hwmon_vid hwmon fuse 
snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss 
snd_mixer_oss reiserfs zram(C) mperf loop emu10k1_gp sidewinder joydev nfs 
lockd auth_rpcgss nfs_acl tcp_cubic sunrpc ipv6 snd_usb_audio 
snd_usbmidi_lib gspca_sonixj gspca_main videodev usbhid 8250_pnp 
i82875p_edac edac_core sr_mod sg analog cdrom firewire_ohci firewire_core 
evdev pcspkr parport_pc floppy parport ns558 gameport i2c_i801 ne2k_pci 8390 
8250 serial_core snd_mpu401 snd_mpu401_uart intel_agp e1000 crc_itu_t fan 
button intel_gtt agpgart processor thermal unix usb_storage hid [last 
unloaded: microcode]
[30975.252788] 
[30975.252788] Pid: 12291, comm: rm Tainted: G   AWC  3.1.0-00057-
gc82b96b-dirty #6/8KNXP
[30975.252788] EIP: 0060:[] EFLAGS: 00210282 CPU: 1
[30975.252788] EIP is at map_private_extent_buffer+0x7/0xbc
[30975.252788] EAX:  EBX:  ECX: 0004 EDX: 007a
[30975.252788] ESI: 0065 EDI: 007a EBP: fffb ESP: ec80bcf4
[30975.252788]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[30975.252788] Process rm (pid: 12291, ti=ec80a000 task=f1512370 
task.ti=ec80a000)
[30975.252788] Stack:
[30975.252788]  335b0009 35373930 3934322e 5d313037 c1020020 c13eac01 
 0065
[30975.252788]  007a fffb c1161fe2 ec80bd38 ec80bd34 ec80bd30 
 0006cac5
[30975.252788]  f1f5a7e0 fffb  0006cac5 f1f5a7e0 c1142f61 
c13fc992 120af000
[30975.252788] Call Trace:
[30975.252788]  [] ? sched_move_task+0x70/0x8e
[30975.252788]  [] ? btrfs_item_size+0x32/0x63
[30975.252788]  [] ? __btrfs_free_extent+0x446/0x7ed
[30975.252788]  [] ? rb_erase+0x1ce/0x1f0
[30975.252788]  [] ? run_clustered_refs+0x838/0x87e
[30975.252788]  [] ? btrfs_find_ref_cluster+0xfc/0x13c
[30975.252788]  [] ? btrfs_run_delayed_refs+0xbc/0x13c
[30975.252788]  [] ? __btrfs_end_transaction+0x7e/0x1ac
[30975.252788]  [] ? btrfs_end_transaction+0x11/0x13
[30975.252788]  [] ? btrfs_evict_inode+0x288/0x29f
[30975.252788]  [] ? evict+0x82/0x11d
[30975.252788]  [] ? do_unlinkat+0xc9/0x110
[30975.252788]  [] ? fsnotify_find_inode_mark+0x17/0x1d
[30975.252788]  [] ? filp_close+0x58/0x5f
[30975.252788]  [] ? sysenter_do_call+0x12/0x22
[30975.252788] Code: c7 8b 74 24 04 89 e9 f3 a4 89 74 24 04 29 6c 24 1c ff 
04 24 31 ff 83 7c 24 1c 00 75 a6 5b 5e 5b 5e 5f 5d c3 55 57 56 53 83 ec 18 
<8b> 18 81 e3 ff 0f 00 00 8d 3c 1a 89 fe c1 ee 0c 8d 6c 0f ff c1 
[30975.252788] EIP: [] map_private_extent_buffer+0x7/0xbc SS:ESP 
0068:ec80bcf4
[30975.252788] CR2: 
[30975.252788] [ cut here ]
[30975.252788] WARNING: at kernel/softirq.c:159 
_local_bh_enable_ip+0x2f/0x67()
[30975.252788] Hardware name:  
[30975

[patch 01/66] btrfs: Add btrfs_panic()

2011-10-24 Thread Jeff Mahoney
 As part of the effort to eliminate BUG_ON as an error handling
 technique, we need to determine which errors are actual logic errors,
 which are on-disk corruption, and which are normal runtime errors
 e.g. -ENOMEM.

 Annotating these error cases is helpful to understand and report them.

 This patch adds a btrfs_panic() routine that will either panic
 or BUG depending on the new -ofatal_errors={panic,bug} mount option.
 Since there are still so many BUG_ONs, it defaults to BUG for now but I
 expect that to change once the error handling effort has made
 significant progress.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h |   11 +++
 fs/btrfs/super.c |   50 +-
 2 files changed, 60 insertions(+), 1 deletion(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1357,6 +1357,7 @@ struct btrfs_ioctl_defrag_range_args {
 #define BTRFS_MOUNT_ENOSPC_DEBUG(1 << 15)
 #define BTRFS_MOUNT_AUTO_DEFRAG(1 << 16)
 #define BTRFS_MOUNT_INODE_MAP_CACHE(1 << 17)
+#define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR   (1 << 18)
 
 #define btrfs_clear_opt(o, opt)((o) &= ~BTRFS_MOUNT_##opt)
 #define btrfs_set_opt(o, opt)  ((o) |= BTRFS_MOUNT_##opt)
@@ -2644,6 +2645,16 @@ do { 
\
__btrfs_std_error((fs_info), __func__, __LINE__, (errno));\
 } while (0)
 
+void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
+  unsigned int line, int errno, const char *fmt, ...);
+
+#define btrfs_panic(fs_info, errno, fmt, args...)  \
+do {   \
+   struct btrfs_fs_info *_i = (fs_info);   \
+   __btrfs_panic(_i, __func__, __LINE__, errno, fmt, ##args);  \
+   BUG_ON(!(_i->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR));\
+} while (0)
+
 /* acl.c */
 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
 struct posix_acl *btrfs_get_acl(struct inode *inode, int type);
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -76,6 +76,9 @@ static const char *btrfs_decode_error(st
case -EROFS:
errstr = "Readonly filesystem";
break;
+   case -EEXIST:
+   errstr = "Object already exists";
+   break;
default:
if (nbuf) {
if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
@@ -145,6 +148,36 @@ void __btrfs_std_error(struct btrfs_fs_i
btrfs_handle_error(fs_info);
 }
 
+/*
+ * __btrfs_panic decodes unexpected, fatal errors from the caller,
+ * issues an alert, and either panics or BUGs, depending on mount options.
+ */
+void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
+  unsigned int line, int errno, const char *fmt, ...)
+{
+   char nbuf[16];
+   char *s_id = "";
+   const char *errstr;
+   struct va_format vaf = { .fmt = fmt };
+   va_list args;
+
+   if (fs_info)
+   s_id = fs_info->sb->s_id;
+
+   va_start(args, fmt);
+   vaf.va = &args;
+
+   errstr = btrfs_decode_error(fs_info, errno, nbuf);
+   if (fs_info->mount_opt & BTRFS_MOUNT_PANIC_ON_FATAL_ERROR)
+   panic(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n",
+   s_id, function, line, &vaf, errstr);
+
+   printk(KERN_CRIT "BTRFS panic (device %s) in %s:%d: %pV (%s)\n",
+  s_id, function, line, &vaf, errstr);
+   va_end(args);
+   /* Caller calls BUG() */
+}
+
 static void btrfs_put_super(struct super_block *sb)
 {
struct btrfs_root *root = btrfs_sb(sb);
@@ -164,7 +197,7 @@ enum {
Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
-   Opt_inode_cache, Opt_no_space_cache, Opt_err,
+   Opt_inode_cache, Opt_no_space_cache, Opt_fatal_errors, Opt_err,
 };
 
 static match_table_t tokens = {
@@ -198,6 +231,7 @@ static match_table_t tokens = {
{Opt_defrag, "autodefrag"},
{Opt_inode_cache, "inode_cache"},
{Opt_no_space_cache, "no_space_cache"},
+   {Opt_fatal_errors, "fatal_errors=%s"},
{Opt_err, NULL},
 };
 
@@ -392,6 +426,18 @@ int btrfs_parse_options(struct btrfs_roo
printk(KERN_INFO "btrfs: enabling auto defrag");
btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
break;
+   case Opt_fatal_errors:
+   if (strcmp(args[0].from, "panic") == 0)
+   btrfs_set_opt(info->mount_opt,
+ PANIC_ON_FATAL_ERROR);
+   else if (strcmp(args[0].from, "bug") == 0)
+   btrfs_clear_opt(info->mount_opt,
+

[patch 03/66] btrfs: Panic on bad rbtree operations

2011-10-24 Thread Jeff Mahoney
 The ordered data and relocation trees have BUG_ONs to protect against
 bad tree operations.

 This patch replaces them with a panic that will report the problem.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ordered-data.c |   12 ++--
 fs/btrfs/relocation.c   |   36 +---
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index a1c9404..5a53d94 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -59,6 +59,14 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 
file_offset,
return NULL;
 }
 
+NORET_TYPE static void ordered_data_tree_panic(struct inode *inode, int errno,
+  u64 offset)
+{
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb)->fs_info;
+   btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at offset "
+   "%llu\n", offset);
+}
+
 /*
  * look for a given offset in the tree, and if it can't be found return the
  * first lesser offset
@@ -207,7 +215,8 @@ static int __btrfs_add_ordered_extent(struct inode *inode, 
u64 file_offset,
spin_lock(&tree->lock);
node = tree_insert(&tree->tree, file_offset,
   &entry->rb_node);
-   BUG_ON(node);
+   if (node)
+   ordered_data_tree_panic(inode, -EEXIST, file_offset);
spin_unlock(&tree->lock);
 
spin_lock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock);
@@ -215,7 +224,6 @@ static int __btrfs_add_ordered_extent(struct inode *inode, 
u64 file_offset,
  &BTRFS_I(inode)->root->fs_info->ordered_extents);
spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock);
 
-   BUG_ON(node);
return 0;
 }
 
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 7fa090f..a222957 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -326,6 +326,19 @@ static struct rb_node *tree_search(struct rb_root *root, 
u64 bytenr)
return NULL;
 }
 
+NORET_TYPE static void backref_tree_panic(struct rb_node *rb_node, int errno,
+ u64 bytenr)
+{
+
+   struct btrfs_fs_info *fs_info = NULL;
+   struct backref_node *bnode = rb_entry(rb_node, struct backref_node,
+ rb_node);
+   if (bnode->root)
+   fs_info = bnode->root->fs_info;
+   btrfs_panic(fs_info, errno, "Inconsistency in backref cache "
+   "found at offset %llu\n", bytenr);
+}
+
 /*
  * walk up backref nodes until reach node presents tree root
  */
@@ -452,7 +465,8 @@ static void update_backref_node(struct backref_cache *cache,
rb_erase(&node->rb_node, &cache->rb_root);
node->bytenr = bytenr;
rb_node = tree_insert(&cache->rb_root, node->bytenr, &node->rb_node);
-   BUG_ON(rb_node);
+   if (rb_node)
+   backref_tree_panic(rb_node, -EEXIST, bytenr);
 }
 
 /*
@@ -999,7 +1013,8 @@ next:
if (!cowonly) {
rb_node = tree_insert(&cache->rb_root, node->bytenr,
  &node->rb_node);
-   BUG_ON(rb_node);
+   if (rb_node)
+   backref_tree_panic(rb_node, -EEXIST, node->bytenr);
list_add_tail(&node->lower, &cache->leaves);
}
 
@@ -1034,7 +1049,9 @@ next:
if (!cowonly) {
rb_node = tree_insert(&cache->rb_root, upper->bytenr,
  &upper->rb_node);
-   BUG_ON(rb_node);
+   if (rb_node)
+   backref_tree_panic(rb_node, -EEXIST,
+  upper->bytenr);
}
 
list_add_tail(&edge->list[UPPER], &upper->lower);
@@ -1178,7 +1195,8 @@ static int clone_backref_node(struct btrfs_trans_handle 
*trans,
 
rb_node = tree_insert(&cache->rb_root, new_node->bytenr,
  &new_node->rb_node);
-   BUG_ON(rb_node);
+   if (rb_node)
+   backref_tree_panic(rb_node, -EEXIST, new_node->bytenr);
 
if (!new_node->lowest) {
list_for_each_entry(new_edge, &new_node->lower, list[UPPER]) {
@@ -1250,7 +1268,8 @@ static int __update_reloc_root(struct btrfs_root *root, 
int del)
rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
  node->bytenr, &node->rb_node);
spin_unlock(&rc->reloc_root_tree.lock);
-   BUG_ON(rb_node);
+   if (rb_node)
+   backref_tree_panic(rb_node, -EEXIST, node->bytenr);
} else {
list_del_init(&root->root_list);
kfree(node);
@@ -3151,7 +3170,8 @@ static int add_tree_block(struct reloc_control *rc,
block->key_ready = 0;
 
rb_node = tree_insert(b

[patch 10/66] btrfs: pin_down_extent should return void

2011-10-24 Thread Jeff Mahoney
 pin_down_extent performs some operations which can't fail and then calls
 set_extent_dirty, which has two failure cases via set_extent_bit:
 1) Return -EEXIST if exclusive bits are set
- Since it doesn't use any exclusive bits, this failure case can't
   occur.
 2) Return -ENOMEM if memory can't be allocated
- Since it's called with gfp_flags & __GFP_NOFAIL, this failure case
  can't occur.

 With no failure cases, it should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent-tree.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4290,9 +4290,9 @@ static u64 first_logical_byte(struct btr
return bytenr;
 }
 
-static int pin_down_extent(struct btrfs_root *root,
-  struct btrfs_block_group_cache *cache,
-  u64 bytenr, u64 num_bytes, int reserved)
+static void pin_down_extent(struct btrfs_root *root,
+   struct btrfs_block_group_cache *cache,
+   u64 bytenr, u64 num_bytes, int reserved)
 {
int ret;
 
@@ -4311,8 +4311,6 @@ static int pin_down_extent(struct btrfs_
   bytenr + num_bytes - 1,
   GFP_NOFS | __GFP_NOFAIL);
BUG_ON(ret < 0); /* __GFP_NOFAIL means it can't return -ENOMEM */
-
-   return 0;
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 08/66] btrfs: convert_extent_bit error push-up

2011-10-24 Thread Jeff Mahoney
 convert_extent_bit can fail with -ENOMEM but nothing actually catches the
 errors.

 This patch catches the error with BUG_ON in the caller.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.h   |2 +-
 fs/btrfs/transaction.c |5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -220,7 +220,7 @@ int set_extent_dirty(struct extent_io_tr
 int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
   gfp_t mask) __must_check;
 int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
-  int bits, int clear_bits, gfp_t mask);
+  int bits, int clear_bits, gfp_t mask) __must_check;
 int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end,
struct extent_state **cached_state, gfp_t mask);
 int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -580,8 +580,9 @@ int btrfs_write_marked_extents(struct bt
 
while (!find_first_extent_bit(dirty_pages, start, &start, &end,
  mark)) {
-   convert_extent_bit(dirty_pages, start, end, EXTENT_NEED_WAIT, 
mark,
-  GFP_NOFS);
+   err = convert_extent_bit(dirty_pages, start, end,
+EXTENT_NEED_WAIT, mark, GFP_NOFS);
+   BUG_ON(err < 0);
err = filemap_fdatawrite_range(mapping, start, end);
if (err)
werr = err;


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 09/66] btrfs: unlock_extent error push-up

2011-10-24 Thread Jeff Mahoney
 The previous patch pushed the clear_extent_bit error handling up a level,
 which included unlock_extent and unlock_extent_cache.

 This patch pushes the BUG_ON up into the callers of those functions.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/compression.c  |6 +-
 fs/btrfs/disk-io.c  |7 +--
 fs/btrfs/extent_io.c|   52 +--
 fs/btrfs/extent_io.h|6 +-
 fs/btrfs/file.c |   35 ---
 fs/btrfs/free-space-cache.c |9 ++--
 fs/btrfs/inode.c|   98 ++--
 fs/btrfs/ioctl.c|   26 +++
 fs/btrfs/relocation.c   |   24 +++---
 9 files changed, 159 insertions(+), 104 deletions(-)

--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -507,7 +507,8 @@ static noinline int add_ra_bio_pages(str
(last_offset + PAGE_CACHE_SIZE > extent_map_end(em)) ||
(em->block_start >> 9) != cb->orig_bio->bi_sector) {
free_extent_map(em);
-   unlock_extent(tree, last_offset, end, GFP_NOFS);
+   ret = unlock_extent(tree, last_offset, end, GFP_NOFS);
+   BUG_ON(ret < 0);
unlock_page(page);
page_cache_release(page);
break;
@@ -535,7 +536,8 @@ static noinline int add_ra_bio_pages(str
nr_pages++;
page_cache_release(page);
} else {
-   unlock_extent(tree, last_offset, end, GFP_NOFS);
+   ret = unlock_extent(tree, last_offset, end, GFP_NOFS);
+   BUG_ON(ret < 0);
unlock_page(page);
page_cache_release(page);
break;
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -326,7 +326,7 @@ static int verify_parent_transid(struct
 struct extent_buffer *eb, u64 parent_transid)
 {
struct extent_state *cached_state = NULL;
-   int ret;
+   int ret, err;
 
if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
return 0;
@@ -347,8 +347,9 @@ static int verify_parent_transid(struct
ret = 1;
clear_extent_buffer_uptodate(io_tree, eb, &cached_state);
 out:
-   unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1,
-&cached_state, GFP_NOFS);
+   err = unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1,
+  &cached_state, GFP_NOFS);
+   BUG_ON(err < 0);
return ret;
 }
 
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1242,18 +1242,14 @@ int try_lock_extent(struct extent_io_tre
 int unlock_extent_cached(struct extent_io_tree *tree, u64 start, u64 end,
 struct extent_state **cached, gfp_t mask)
 {
-   int ret = clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0,
-  cached, mask);
-   BUG_ON(ret < 0);
-   return ret;
+   return clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, cached,
+   mask);
 }
 
 int unlock_extent(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask)
 {
-   int ret =  clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL,
-   mask);
-   BUG_ON(ret < 0);
-   return ret;
+   return clear_extent_bit(tree, start, end, EXTENT_LOCKED, 1, 0, NULL,
+   mask);
 }
 
 /*
@@ -1558,8 +1554,9 @@ again:
ret = test_range_bit(tree, delalloc_start, delalloc_end,
 EXTENT_DELALLOC, 1, cached_state);
if (!ret) {
-   unlock_extent_cached(tree, delalloc_start, delalloc_end,
-&cached_state, GFP_NOFS);
+   ret = unlock_extent_cached(tree, delalloc_start, delalloc_end,
+  &cached_state, GFP_NOFS);
+   BUG_ON(ret < 0);
__unlock_for_delalloc(inode, locked_page,
  delalloc_start, delalloc_end);
cond_resched();
@@ -1996,7 +1993,9 @@ static void end_bio_extent_readpage(stru
  GFP_ATOMIC);
BUG_ON(ret < 0);
}
-   unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC);
+   ret = unlock_extent_cached(tree, start, end,
+  &cached, GFP_ATOMIC);
+   BUG_ON(ret < 0);
 
if (whole_page) {
if (uptodate) {
@@ -2190,7 +2189,8 @@ static int __extent_read_full_page(struc
ordered = btrfs_lookup_ordered_extent(inode, start);
if (!ordered)
break;
-   un

[patch 02/66] btrfs: Catch locking failures in {set,clear,convert}_extent_bit

2011-10-24 Thread Jeff Mahoney
 The *_state functions can only return 0 or -EEXIST. This patch addresses
 the cases where those functions return -EEXIST, representing a locking
 failure. It handles them by panicking with an appropriate error message.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |   58 +--
 1 file changed, 38 insertions(+), 20 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -51,6 +51,12 @@ struct extent_page_data {
unsigned int sync_io:1;
 };
 
+static inline struct btrfs_fs_info *
+tree_fs_info(struct extent_io_tree *tree)
+{
+   return btrfs_sb(tree->mapping->host->i_sb)->fs_info;
+}
+
 int __init extent_io_init(void)
 {
extent_state_cache = kmem_cache_create("extent_state",
@@ -437,6 +443,13 @@ alloc_extent_state_atomic(struct extent_
return prealloc;
 }
 
+NORET_TYPE void extent_io_tree_panic(struct extent_io_tree *tree, int err)
+{
+   btrfs_panic(tree_fs_info(tree), err, "Locking error: "
+   "Extent tree was modified by another "
+   "thread while locked.");
+}
+
 /*
  * clear some bits on a range in the tree.  This may require splitting
  * or inserting elements in the tree, so the gfp mask is used to
@@ -531,7 +544,9 @@ hit_next:
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, start);
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
+
prealloc = NULL;
if (err)
goto out;
@@ -553,7 +568,9 @@ hit_next:
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, end + 1);
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
+
if (wake)
wake_up(&state->wq);
 
@@ -736,8 +753,10 @@ again:
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = insert_state(tree, prealloc, start, end, &bits);
+   if (err)
+   extent_io_tree_panic(tree, err);
+
prealloc = NULL;
-   BUG_ON(err == -EEXIST);
goto out;
}
state = rb_entry(node, struct extent_state, rb_node);
@@ -803,7 +822,9 @@ hit_next:
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, start);
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
+
prealloc = NULL;
if (err)
goto out;
@@ -840,12 +861,9 @@ hit_next:
 */
err = insert_state(tree, prealloc, start, this_end,
   &bits);
-   BUG_ON(err == -EEXIST);
-   if (err) {
-   free_extent_state(prealloc);
-   prealloc = NULL;
-   goto out;
-   }
+   if (err)
+   extent_io_tree_panic(tree, err);
+
cache_state(prealloc, cached_state);
prealloc = NULL;
start = this_end + 1;
@@ -867,7 +885,8 @@ hit_next:
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, end + 1);
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
 
set_state_bits(tree, prealloc, &bits);
cache_state(prealloc, cached_state);
@@ -938,7 +957,8 @@ again:
return -ENOMEM;
err = insert_state(tree, prealloc, start, end, &bits);
prealloc = NULL;
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
goto out;
}
state = rb_entry(node, struct extent_state, rb_node);
@@ -994,7 +1014,8 @@ hit_next:
if (!prealloc)
return -ENOMEM;
err = split_state(tree, state, prealloc, start);
-   BUG_ON(err == -EEXIST);
+   if (err)
+   extent_io_tree_panic(tree, err);
prealloc = NULL;
if (err)
goto out;
@@ -1032,12 +1053,8 @@ hit_next:
 */
err = insert_state(tree, prealloc, start, this_end,
   &bits);
-   BUG_ON(err == -EEXIST);
-   if (err) {
-   free_extent_state(prealloc);
-   

[patch 18/66] btrfs: wait_extent_bit should return void

2011-10-24 Thread Jeff Mahoney
 wait_extent_bit has no error conditions and should return void. Its
 callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |3 +--
 fs/btrfs/extent_io.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -639,7 +639,7 @@ static void wait_on_state(struct extent_
  * The range [start, end] is inclusive.
  * The tree lock is taken by this function
  */
-int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits)
+void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits)
 {
struct extent_state *state;
struct rb_node *node;
@@ -676,7 +676,6 @@ again:
}
 out:
spin_unlock(&tree->lock);
-   return 0;
 }
 
 static void set_state_bits(struct extent_io_tree *tree,
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -277,7 +277,7 @@ void memmove_extent_buffer(struct extent
   unsigned long src_offset, unsigned long len);
 void memset_extent_buffer(struct extent_buffer *eb, char c,
  unsigned long start, unsigned long len);
-int wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits);
+void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int 
bits);
 int clear_extent_buffer_dirty(struct extent_io_tree *tree,
  struct extent_buffer *eb);
 int set_extent_buffer_dirty(struct extent_io_tree *tree,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 12/66] btrfs: btrfs_drop_snapshot should return int

2011-10-24 Thread Jeff Mahoney
Commit cb1b69f4 (Btrfs: forced readonly when btrfs_drop_snapshot() fails)
made btrfs_drop_snapshot return void because there were no callers checking
the return value. That is the wrong order to handle error propogation since
the caller will have no idea that an error has occured and continue on
as if nothing went wrong.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |5 +++--
 fs/btrfs/extent-tree.c |6 +++---
 fs/btrfs/relocation.c  |3 ++-
 fs/btrfs/transaction.c |7 +--
 4 files changed, 13 insertions(+), 8 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2367,8 +2367,9 @@ static inline int btrfs_insert_empty_ite
 int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
 int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
 int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
-void btrfs_drop_snapshot(struct btrfs_root *root,
-struct btrfs_block_rsv *block_rsv, int update_ref);
+int btrfs_drop_snapshot(struct btrfs_root *root,
+   struct btrfs_block_rsv *block_rsv, int update_ref)
+   __must_check;
 int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_buffer *node,
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6347,8 +6347,8 @@ static noinline int walk_up_tree(struct
  * also make sure backrefs for the shared block and all lower level
  * blocks are properly updated.
  */
-void btrfs_drop_snapshot(struct btrfs_root *root,
-struct btrfs_block_rsv *block_rsv, int update_ref)
+int btrfs_drop_snapshot(struct btrfs_root *root,
+   struct btrfs_block_rsv *block_rsv, int update_ref)
 {
struct btrfs_path *path;
struct btrfs_trans_handle *trans;
@@ -6513,7 +6513,7 @@ out_free:
 out:
if (err)
btrfs_std_error(root->fs_info, err);
-   return;
+   return err;
 }
 
 /*
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2269,7 +2269,8 @@ again:
} else {
list_del_init(&reloc_root->root_list);
}
-   btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0);
+   ret = btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0);
+   BUG_ON(ret < 0);
}
 
if (found) {
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1375,6 +1375,8 @@ int btrfs_clean_old_snapshots(struct btr
spin_unlock(&fs_info->trans_lock);
 
while (!list_empty(&list)) {
+   int ret;
+
root = list_entry(list.next, struct btrfs_root, root_list);
list_del(&root->root_list);
 
@@ -1382,9 +1384,10 @@ int btrfs_clean_old_snapshots(struct btr
 
if (btrfs_header_backref_rev(root->node) <
BTRFS_MIXED_BACKREF_REV)
-   btrfs_drop_snapshot(root, NULL, 0);
+   ret = btrfs_drop_snapshot(root, NULL, 0);
else
-   btrfs_drop_snapshot(root, NULL, 1);
+   ret = btrfs_drop_snapshot(root, NULL, 1);
+   BUG_ON(ret < 0);
}
return 0;
 }


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 11/66] btrfs: btrfs_pin_extent error push-up

2011-10-24 Thread Jeff Mahoney
 btrfs_pin_extent looks up a block group and then calls pin_down_extent
 with it. If the lookup fails, it should return -ENOENT to allow callers
 to handle the error condition. For the three existing callers, it is
 a logic error if the lookup fails and a panic will occur.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |2 +-
 fs/btrfs/extent-tree.c |   20 +++-
 fs/btrfs/tree-log.c|   10 +++---
 3 files changed, 23 insertions(+), 9 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2156,7 +2156,7 @@ int btrfs_lookup_extent_info(struct btrf
 struct btrfs_root *root, u64 bytenr,
 u64 num_bytes, u64 *refs, u64 *flags);
 int btrfs_pin_extent(struct btrfs_root *root,
-u64 bytenr, u64 num, int reserved);
+u64 bytenr, u64 num, int reserved) __must_check;
 int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans,
  struct btrfs_root *root,
  u64 objectid, u64 offset, u64 bytenr);
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2100,8 +2100,14 @@ static int run_one_delayed_ref(struct bt
BUG_ON(extent_op);
head = btrfs_delayed_node_to_head(node);
if (insert_reserved) {
-   btrfs_pin_extent(root, node->bytenr,
-node->num_bytes, 1);
+   ret = btrfs_pin_extent(root, node->bytenr,
+  node->num_bytes, 1);
+   if (ret)
+   btrfs_panic(root->fs_info, ret,
+   "Cannot pin extent in range "
+   "%llu(%llu)\n",
+   node->bytenr, node->num_bytes);
+
if (head->is_data) {
ret = btrfs_del_csums(trans, root,
  node->bytenr,
@@ -4322,7 +4328,8 @@ int btrfs_pin_extent(struct btrfs_root *
struct btrfs_block_group_cache *cache;
 
cache = btrfs_lookup_block_group(root->fs_info, bytenr);
-   BUG_ON(!cache);
+   if (cache == NULL)
+   return -ENOENT;
 
pin_down_extent(root, cache, bytenr, num_bytes, reserved);
 
@@ -4818,8 +4825,11 @@ int btrfs_free_extent(struct btrfs_trans
if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);
/* unlocks the pinned mutex */
-   btrfs_pin_extent(root, bytenr, num_bytes, 1);
-   ret = 0;
+   ret = btrfs_pin_extent(root, bytenr, num_bytes, 1);
+   if (ret)
+   btrfs_panic(root->fs_info, ret, "Cannot pin "
+   "extent in range %llu(%llu)\n",
+   bytenr, num_bytes);
} else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
ret = btrfs_add_delayed_tree_ref(trans, bytenr, num_bytes,
parent, root_objectid, (int)owner,
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -275,9 +275,13 @@ static int process_one_buffer(struct btr
  struct extent_buffer *eb,
  struct walk_control *wc, u64 gen)
 {
-   if (wc->pin)
-   btrfs_pin_extent(log->fs_info->extent_root,
-eb->start, eb->len, 0);
+   if (wc->pin) {
+   int ret = btrfs_pin_extent(log->fs_info->extent_root,
+  eb->start, eb->len, 0);
+   if (ret)
+   btrfs_panic(log->fs_info, ret, "Cannot pin extent in "
+   "range %llu(%llu)\n", eb->start, eb->len);
+   }
 
if (btrfs_buffer_uptodate(eb, gen)) {
if (wc->write)


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 14/66] btrfs: find_and_setup_root error push-up

2011-10-24 Thread Jeff Mahoney
 find_and_setup_root BUGs when it encounters an error from
 btrfs_find_last_root, which can occur if a path can't be allocated.

 This patch pushes it up to its callers where it is already handled.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1117,10 +1117,10 @@ static int __setup_root(u32 nodesize, u3
return 0;
 }
 
-static int find_and_setup_root(struct btrfs_root *tree_root,
-  struct btrfs_fs_info *fs_info,
-  u64 objectid,
-  struct btrfs_root *root)
+static int __must_check find_and_setup_root(struct btrfs_root *tree_root,
+   struct btrfs_fs_info *fs_info,
+   u64 objectid,
+   struct btrfs_root *root)
 {
int ret;
u32 blocksize;
@@ -1133,7 +1133,8 @@ static int find_and_setup_root(struct bt
   &root->root_item, &root->root_key);
if (ret > 0)
return -ENOENT;
-   BUG_ON(ret);
+   else if (ret < 0)
+   return ret;
 
generation = btrfs_root_generation(&root->root_item);
blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 15/66] btrfs: btrfs_update_root error push-up

2011-10-24 Thread Jeff Mahoney
 btrfs_update_root BUG's when it can't alloc a path, yet it can recover
 from a search error. This patch returns -ENOMEM instead.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h |6 +++---
 fs/btrfs/root-tree.c |4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2400,9 +2400,9 @@ int btrfs_del_root(struct btrfs_trans_ha
 int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
  *root, struct btrfs_key *key, struct btrfs_root_item
  *item);
-int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
- *root, struct btrfs_key *key, struct btrfs_root_item
- *item);
+int btrfs_update_root(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, struct btrfs_key *key,
+ struct btrfs_root_item *item) __must_check;
 int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
 btrfs_root_item *item, struct btrfs_key *key);
 int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid);
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -93,7 +93,9 @@ int btrfs_update_root(struct btrfs_trans
unsigned long ptr;
 
path = btrfs_alloc_path();
-   BUG_ON(!path);
+   if (!path)
+   return -ENOMEM;
+
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
if (ret < 0)
goto out;


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 16/66] btrfs: set_range_writeback should return void

2011-10-24 Thread Jeff Mahoney
 set_range_writeback has no error conditions and should return void.
 Its callers already ignore the error code anyway.

 There are internal error conditions but they are fatal and will cause
 a panic.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1253,7 +1253,7 @@ int unlock_extent(struct extent_io_tree
 /*
  * helper function to set both pages and extents in the tree writeback
  */
-static int set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end)
+static void set_range_writeback(struct extent_io_tree *tree, u64 start, u64 
end)
 {
unsigned long index = start >> PAGE_CACHE_SHIFT;
unsigned long end_index = end >> PAGE_CACHE_SHIFT;
@@ -1261,12 +1261,14 @@ static int set_range_writeback(struct ex
 
while (index <= end_index) {
page = find_get_page(tree->mapping, index);
-   BUG_ON(!page);
+   if (!page)
+   btrfs_panic(tree_fs_info(tree), -ENOENT,
+   "Page not found in extent io tree at "
+   "offset %llu", index << PAGE_CACHE_SHIFT);
set_page_writeback(page);
page_cache_release(page);
index++;
}
-   return 0;
 }
 
 /* find the first state struct with 'bits' set after 'start', and


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 17/66] btrfs: wait_on_state should return void

2011-10-24 Thread Jeff Mahoney
 wait_on_state has no error conditions and should return void. Its callers
 already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -621,8 +621,8 @@ search_again:
goto again;
 }
 
-static int wait_on_state(struct extent_io_tree *tree,
-struct extent_state *state)
+static void wait_on_state(struct extent_io_tree *tree,
+ struct extent_state *state)
__releases(tree->lock)
__acquires(tree->lock)
 {
@@ -632,7 +632,6 @@ static int wait_on_state(struct extent_i
schedule();
spin_lock(&tree->lock);
finish_wait(&state->wq, &wait);
-   return 0;
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 19/66] btrfs: __unlock_for_delalloc should return void

2011-10-24 Thread Jeff Mahoney
 __unlock_for_delalloc has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1384,9 +1384,9 @@ out:
return found;
 }
 
-static noinline int __unlock_for_delalloc(struct inode *inode,
- struct page *locked_page,
- u64 start, u64 end)
+static noinline void __unlock_for_delalloc(struct inode *inode,
+  struct page *locked_page,
+  u64 start, u64 end)
 {
int ret;
struct page *pages[16];
@@ -1396,7 +1396,7 @@ static noinline int __unlock_for_delallo
int i;
 
if (index == locked_page->index && end_index == index)
-   return 0;
+   return;
 
while (nr_pages > 0) {
ret = find_get_pages_contig(inode->i_mapping, index,
@@ -1411,7 +1411,6 @@ static noinline int __unlock_for_delallo
index += ret;
cond_resched();
}
-   return 0;
 }
 
 static noinline int lock_delalloc_pages(struct inode *inode,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 22/66] btrfs: check_page_writeback should return void

2011-10-24 Thread Jeff Mahoney
 check_page_writeback has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1829,11 +1829,10 @@ static void check_page_locked(struct ext
  * helper function to end page writeback if all the extents
  * in the tree for that page are done with writeback
  */
-static int check_page_writeback(struct extent_io_tree *tree,
-struct page *page)
+static void check_page_writeback(struct extent_io_tree *tree,
+struct page *page)
 {
end_page_writeback(page);
-   return 0;
 }
 
 /* lots and lots of room for performance fixes in the end_bio funcs */


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 20/66] btrfs: check_page_uptodate should return void

2011-10-24 Thread Jeff Mahoney
 check_page_uptodate has no error conditions and should return void. Its
 callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1805,14 +1805,12 @@ int test_range_bit(struct extent_io_tree
  * helper function to set a given page up to date if all the
  * extents in the tree for that page are up to date
  */
-static int check_page_uptodate(struct extent_io_tree *tree,
-  struct page *page)
+static void check_page_uptodate(struct extent_io_tree *tree, struct page *page)
 {
u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
u64 end = start + PAGE_CACHE_SIZE - 1;
if (test_range_bit(tree, start, end, EXTENT_UPTODATE, 1, NULL))
SetPageUptodate(page);
-   return 0;
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 21/66] btrfs: check_page_locked should return void

2011-10-24 Thread Jeff Mahoney
 check_page_locked has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1817,14 +1817,12 @@ static void check_page_uptodate(struct e
  * helper function to unlock a page if all the extents in the tree
  * for that page are unlocked
  */
-static int check_page_locked(struct extent_io_tree *tree,
-struct page *page)
+static void check_page_locked(struct extent_io_tree *tree, struct page *page)
 {
u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
u64 end = start + PAGE_CACHE_SIZE - 1;
if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL))
unlock_page(page);
-   return 0;
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 24/66] btrfs: btrfs_cleanup_fs_uuids should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_cleanup_fs_uuids has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/volumes.c |3 +--
 fs/btrfs/volumes.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -65,7 +65,7 @@ static void free_fs_devices(struct btrfs
kfree(fs_devices);
 }
 
-int btrfs_cleanup_fs_uuids(void)
+void btrfs_cleanup_fs_uuids(void)
 {
struct btrfs_fs_devices *fs_devices;
 
@@ -75,7 +75,6 @@ int btrfs_cleanup_fs_uuids(void)
list_del(&fs_devices->list);
free_fs_devices(fs_devices);
}
-   return 0;
 }
 
 static noinline struct btrfs_device *__find_device(struct list_head *head,
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -202,7 +202,7 @@ int btrfs_add_device(struct btrfs_trans_
 struct btrfs_root *root,
 struct btrfs_device *device);
 int btrfs_rm_device(struct btrfs_root *root, char *device_path);
-int btrfs_cleanup_fs_uuids(void);
+void btrfs_cleanup_fs_uuids(void);
 int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 
len);
 int btrfs_grow_device(struct btrfs_trans_handle *trans,
  struct btrfs_device *device, u64 new_size);


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 26/66] btrfs: btrfs_close_extra_devices should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_close_extra_devices has no error conditions and should return
 void. Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/volumes.c |3 +--
 fs/btrfs/volumes.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -437,7 +437,7 @@ error:
return ERR_PTR(-ENOMEM);
 }
 
-int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
+void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
 {
struct btrfs_device *device, *next;
 
@@ -470,7 +470,6 @@ again:
}
 
mutex_unlock(&uuid_mutex);
-   return 0;
 }
 
 static void __free_device(struct work_struct *work)
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -197,7 +197,7 @@ int btrfs_open_devices(struct btrfs_fs_d
 int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
  struct btrfs_fs_devices **fs_devices_ret);
 int btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
-int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices);
+void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices);
 int btrfs_add_device(struct btrfs_trans_handle *trans,
 struct btrfs_root *root,
 struct btrfs_device *device);


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 23/66] btrfs: clear_extent_buffer_dirty should return void

2011-10-24 Thread Jeff Mahoney
 clear_extent_buffer_dirty has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |3 +--
 fs/btrfs/extent_io.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3436,7 +3436,7 @@ void free_extent_buffer(struct extent_bu
WARN_ON(1);
 }
 
-int clear_extent_buffer_dirty(struct extent_io_tree *tree,
+void clear_extent_buffer_dirty(struct extent_io_tree *tree,
  struct extent_buffer *eb)
 {
unsigned long i;
@@ -3467,7 +3467,6 @@ int clear_extent_buffer_dirty(struct ext
spin_unlock_irq(&page->mapping->tree_lock);
unlock_page(page);
}
-   return 0;
 }
 
 int set_extent_buffer_dirty(struct extent_io_tree *tree,
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -278,7 +278,7 @@ void memmove_extent_buffer(struct extent
 void memset_extent_buffer(struct extent_buffer *eb, char c,
  unsigned long start, unsigned long len);
 void wait_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int 
bits);
-int clear_extent_buffer_dirty(struct extent_io_tree *tree,
+void clear_extent_buffer_dirty(struct extent_io_tree *tree,
  struct extent_buffer *eb);
 int set_extent_buffer_dirty(struct extent_io_tree *tree,
 struct extent_buffer *eb);


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 25/66] btrfs: run_scheduled_bios should return void

2011-10-24 Thread Jeff Mahoney
 run_scheduled_bios has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/volumes.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -127,7 +127,7 @@ static void requeue_list(struct btrfs_pe
  * the list if the block device is congested.  This way, multiple devices
  * can make progress from a single worker thread.
  */
-static noinline int run_scheduled_bios(struct btrfs_device *device)
+static noinline void run_scheduled_bios(struct btrfs_device *device)
 {
struct bio *pending;
struct backing_dev_info *bdi;
@@ -307,7 +307,6 @@ loop_lock:
 
 done:
blk_finish_plug(&plug);
-   return 0;
 }
 
 static void pending_bios_fn(struct btrfs_work *work)


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 27/66] btrfs: schedule_bio should return void

2011-10-24 Thread Jeff Mahoney
 schedule_bio has no error conditions and should return void. Its callers
 already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/volumes.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3268,7 +3268,7 @@ struct async_sched {
  * This will add one bio to the pending list for a device and make sure
  * the work struct is scheduled.
  */
-static noinline int schedule_bio(struct btrfs_root *root,
+static noinline void schedule_bio(struct btrfs_root *root,
 struct btrfs_device *device,
 int rw, struct bio *bio)
 {
@@ -3280,7 +3280,6 @@ static noinline int schedule_bio(struct
bio_get(bio);
submit_bio(rw, bio);
bio_put(bio);
-   return 0;
}
 
/*
@@ -3314,7 +3313,6 @@ static noinline int schedule_bio(struct
if (should_queue)
btrfs_queue_worker(&root->fs_info->submit_workers,
   &device->work);
-   return 0;
 }
 
 int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 28/66] btrfs: fill_device_from_item should return void

2011-10-24 Thread Jeff Mahoney
 fill_device_from_item has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/volumes.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3513,7 +3513,7 @@ static int read_one_chunk(struct btrfs_r
return 0;
 }
 
-static int fill_device_from_item(struct extent_buffer *leaf,
+static void fill_device_from_item(struct extent_buffer *leaf,
 struct btrfs_dev_item *dev_item,
 struct btrfs_device *device)
 {
@@ -3530,8 +3530,6 @@ static int fill_device_from_item(struct
 
ptr = (unsigned long)btrfs_device_uuid(dev_item);
read_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE);
-
-   return 0;
 }
 
 static int open_seed_devices(struct btrfs_root *root, u8 *fsid)


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 30/66] btrfs: run_ordered_completions should return void

2011-10-24 Thread Jeff Mahoney
 run_ordered_completions has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/async-thread.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -174,11 +174,11 @@ out:
spin_unlock_irqrestore(&workers->lock, flags);
 }
 
-static noinline int run_ordered_completions(struct btrfs_workers *workers,
+static noinline void run_ordered_completions(struct btrfs_workers *workers,
struct btrfs_work *work)
 {
if (!workers->ordered)
-   return 0;
+   return;
 
set_bit(WORK_DONE_BIT, &work->flags);
 
@@ -216,7 +216,6 @@ static noinline int run_ordered_completi
}
 
spin_unlock(&workers->order_lock);
-   return 0;
 }
 
 static void put_worker(struct btrfs_worker_thread *worker)


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 29/66] btrfs: btrfs_queue_worker should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_queue_worker has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/async-thread.c |   14 --
 fs/btrfs/async-thread.h |2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -95,7 +95,6 @@ static void start_new_worker_func(struct
 static int start_new_worker(struct btrfs_workers *queue)
 {
struct worker_start *start;
-   int ret;
 
start = kzalloc(sizeof(*start), GFP_NOFS);
if (!start)
@@ -103,10 +102,8 @@ static int start_new_worker(struct btrfs
 
start->work.func = start_new_worker_func;
start->queue = queue;
-   ret = btrfs_queue_worker(queue->atomic_worker_start, &start->work);
-   if (ret)
-   kfree(start);
-   return ret;
+   btrfs_queue_worker(queue->atomic_worker_start, &start->work);
+   return 0;
 }
 
 /*
@@ -665,7 +662,7 @@ void btrfs_set_work_high_prio(struct btr
 /*
  * places a struct btrfs_work into the pending queue of one of the kthreads
  */
-int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
+void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
 {
struct btrfs_worker_thread *worker;
unsigned long flags;
@@ -673,7 +670,7 @@ int btrfs_queue_worker(struct btrfs_work
 
/* don't requeue something already on a list */
if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags))
-   goto out;
+   return;
 
worker = find_worker(workers);
if (workers->ordered) {
@@ -712,7 +709,4 @@ int btrfs_queue_worker(struct btrfs_work
if (wake)
wake_up_process(worker->task);
spin_unlock_irqrestore(&worker->lock, flags);
-
-out:
-   return 0;
 }
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -109,7 +109,7 @@ struct btrfs_workers {
char *name;
 };
 
-int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work);
+void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work 
*work);
 int btrfs_start_workers(struct btrfs_workers *workers, int num_workers);
 int btrfs_stop_workers(struct btrfs_workers *workers);
 void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 32/66] btrfs: btrfs_requeue_work should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_requeue_work has no error conditions and should return void.
 Its callers ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/async-thread.c |7 ++-
 fs/btrfs/async-thread.h |2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)

--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -613,14 +613,14 @@ found:
  * it was taken from.  It is intended for use with long running work functions
  * that make some progress and want to give the cpu up for others.
  */
-int btrfs_requeue_work(struct btrfs_work *work)
+void btrfs_requeue_work(struct btrfs_work *work)
 {
struct btrfs_worker_thread *worker = work->worker;
unsigned long flags;
int wake = 0;
 
if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags))
-   goto out;
+   return;
 
spin_lock_irqsave(&worker->lock, flags);
if (test_bit(WORK_HIGH_PRIO_BIT, &work->flags))
@@ -647,9 +647,6 @@ int btrfs_requeue_work(struct btrfs_work
if (wake)
wake_up_process(worker->task);
spin_unlock_irqrestore(&worker->lock, flags);
-out:
-
-   return 0;
 }
 
 void btrfs_set_work_high_prio(struct btrfs_work *work)
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -114,6 +114,6 @@ int btrfs_start_workers(struct btrfs_wor
 void btrfs_stop_workers(struct btrfs_workers *workers);
 void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max,
struct btrfs_workers *async_starter);
-int btrfs_requeue_work(struct btrfs_work *work);
+void btrfs_requeue_work(struct btrfs_work *work);
 void btrfs_set_work_high_prio(struct btrfs_work *work);
 #endif


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 05/66] btrfs: set_extent_bit error push-up

2011-10-24 Thread Jeff Mahoney
 In the locking case, set_extent_bit can return -EEXIST but callers
 already handle that.

 In the non-locking case, it can't fail. Memory allocation failures are
 handled by BUG_ON.

 This patch pushes up the BUG_ONs from set_extent_bit to callers, except
 where -ENOMEM can't occur (e.g. __GFP_WAIT && __GFP_NOFAIL).

 Update v2: Changed cases of BUG_ON(ret) to BUG_ON(ret < 0)

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |2 -
 fs/btrfs/extent-tree.c |   48 +++--
 fs/btrfs/extent_io.c   |   52 -
 fs/btrfs/extent_io.h   |   12 ++-
 fs/btrfs/file-item.c   |3 +-
 fs/btrfs/inode.c   |   25 ---
 fs/btrfs/ioctl.c   |5 ++--
 fs/btrfs/relocation.c  |   23 +
 8 files changed, 116 insertions(+), 54 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2551,7 +2551,7 @@ int btrfs_truncate_inode_items(struct bt
 
 int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput);
 int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
- struct extent_state **cached_state);
+ struct extent_state **cached_state) __must_check;
 int btrfs_writepages(struct address_space *mapping,
 struct writeback_control *wbc);
 int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -208,11 +208,14 @@ block_group_cache_tree_search(struct btr
 static int add_excluded_extent(struct btrfs_root *root,
   u64 start, u64 num_bytes)
 {
+   int ret;
u64 end = start + num_bytes - 1;
-   set_extent_bits(&root->fs_info->freed_extents[0],
-   start, end, EXTENT_UPTODATE, GFP_NOFS);
-   set_extent_bits(&root->fs_info->freed_extents[1],
-   start, end, EXTENT_UPTODATE, GFP_NOFS);
+   ret = set_extent_bits(&root->fs_info->freed_extents[0],
+ start, end, EXTENT_UPTODATE, GFP_NOFS);
+   BUG_ON(ret < 0);
+   ret = set_extent_bits(&root->fs_info->freed_extents[1],
+ start, end, EXTENT_UPTODATE, GFP_NOFS);
+   BUG_ON(ret < 0);
return 0;
 }
 
@@ -4194,6 +4197,7 @@ static int update_block_group(struct btr
u64 old_val;
u64 byte_in_group;
int factor;
+   int ret;
 
/* block accounting for super block */
spin_lock(&info->delalloc_lock);
@@ -4256,9 +4260,10 @@ static int update_block_group(struct btr
spin_unlock(&cache->lock);
spin_unlock(&cache->space_info->lock);
 
-   set_extent_dirty(info->pinned_extents,
-bytenr, bytenr + num_bytes - 1,
-GFP_NOFS | __GFP_NOFAIL);
+   ret = set_extent_dirty(info->pinned_extents, bytenr,
+  bytenr + num_bytes - 1,
+  GFP_NOFS | __GFP_NOFAIL);
+   BUG_ON(ret < 0); /* Can't return -ENOMEM */
}
btrfs_put_block_group(cache);
total -= num_bytes;
@@ -4286,6 +4291,8 @@ static int pin_down_extent(struct btrfs_
   struct btrfs_block_group_cache *cache,
   u64 bytenr, u64 num_bytes, int reserved)
 {
+   int ret;
+
spin_lock(&cache->space_info->lock);
spin_lock(&cache->lock);
cache->pinned += num_bytes;
@@ -4297,8 +4304,11 @@ static int pin_down_extent(struct btrfs_
spin_unlock(&cache->lock);
spin_unlock(&cache->space_info->lock);
 
-   set_extent_dirty(root->fs_info->pinned_extents, bytenr,
-bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
+   ret = set_extent_dirty(root->fs_info->pinned_extents, bytenr,
+  bytenr + num_bytes - 1,
+  GFP_NOFS | __GFP_NOFAIL);
+   BUG_ON(ret < 0); /* __GFP_NOFAIL means it can't return -ENOMEM */
+
return 0;
 }
 
@@ -5689,6 +5699,7 @@ struct extent_buffer *btrfs_init_new_buf
int level)
 {
struct extent_buffer *buf;
+   int ret;
 
buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
if (!buf)
@@ -5707,14 +5718,21 @@ struct extent_buffer *btrfs_init_new_buf
 * EXENT bit to differentiate dirty pages.
 */
if (root->log_transid % 2 == 0)
-   set_extent_dirty(&root->dirty_log_pages, buf->start,
-   buf->start + buf->len - 1, GFP_NOFS);
+   ret = set_extent_dirty(&root->dirty_log_pages,
+  buf->start,
+

[patch 06/66] btrfs: lock_extent error push-up

2011-10-24 Thread Jeff Mahoney
 lock_extent, try_lock_extent, and lock_extent_bits can't currently fail
 because errors are caught via BUG_ON.

 This patch pushes the error handling up to callers, which currently
 only handle them via BUG_ON themselves.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/compression.c  |3 +-
 fs/btrfs/disk-io.c  |5 ++-
 fs/btrfs/extent_io.c|   20 -
 fs/btrfs/extent_io.h|8 +++--
 fs/btrfs/file.c |   17 ++-
 fs/btrfs/free-space-cache.c |6 ++--
 fs/btrfs/inode.c|   66 ++--
 fs/btrfs/ioctl.c|   16 ++
 fs/btrfs/relocation.c   |   18 
 9 files changed, 99 insertions(+), 60 deletions(-)

--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -496,7 +496,8 @@ static noinline int add_ra_bio_pages(str
 * sure they map to this compressed extent on disk.
 */
set_page_extent_mapped(page);
-   lock_extent(tree, last_offset, end, GFP_NOFS);
+   ret = lock_extent(tree, last_offset, end, GFP_NOFS);
+   BUG_ON(ret < 0);
read_lock(&em_tree->lock);
em = lookup_extent_mapping(em_tree, last_offset,
   PAGE_CACHE_SIZE);
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -331,8 +331,9 @@ static int verify_parent_transid(struct
if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
return 0;
 
-   lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1,
-0, &cached_state, GFP_NOFS);
+   ret = lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1,
+  0, &cached_state, GFP_NOFS);
+   BUG_ON(ret < 0);
if (extent_buffer_uptodate(io_tree, eb, cached_state) &&
btrfs_header_generation(eb) == parent_transid) {
ret = 0;
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1200,7 +1200,6 @@ int lock_extent_bits(struct extent_io_tr
}
WARN_ON(start > end);
}
-   BUG_ON(err < 0);
return err;
 }
 
@@ -1222,8 +1221,8 @@ int try_lock_extent(struct extent_io_tre
clear_extent_bit(tree, start, failed_start - 1,
 EXTENT_LOCKED, 1, 0, NULL, mask);
return 0;
-   }
-   BUG_ON(err < 0);
+   } else if (err < 0)
+   return err;
return 1;
 }
 
@@ -1534,8 +1533,9 @@ again:
BUG_ON(ret);
 
/* step three, lock the state bits for the whole range */
-   lock_extent_bits(tree, delalloc_start, delalloc_end,
-0, &cached_state, GFP_NOFS);
+   ret = lock_extent_bits(tree, delalloc_start, delalloc_end,
+  0, &cached_state, GFP_NOFS);
+   BUG_ON(ret < 0);
 
/* then test to make sure it is all still delalloc */
ret = test_range_bit(tree, delalloc_start, delalloc_end,
@@ -2164,7 +2164,8 @@ static int __extent_read_full_page(struc
 
end = page_end;
while (1) {
-   lock_extent(tree, start, end, GFP_NOFS);
+   ret = lock_extent(tree, start, end, GFP_NOFS);
+   BUG_ON(ret < 0);
ordered = btrfs_lookup_ordered_extent(inode, start);
if (!ordered)
break;
@@ -2854,12 +2855,14 @@ int extent_invalidatepage(struct extent_
u64 start = ((u64)page->index << PAGE_CACHE_SHIFT);
u64 end = start + PAGE_CACHE_SIZE - 1;
size_t blocksize = page->mapping->host->i_sb->s_blocksize;
+   int ret;
 
start += (offset + blocksize - 1) & ~(blocksize - 1);
if (start > end)
return 0;
 
-   lock_extent_bits(tree, start, end, 0, &cached_state, GFP_NOFS);
+   ret = lock_extent_bits(tree, start, end, 0, &cached_state, GFP_NOFS);
+   BUG_ON(ret < 0);
wait_on_page_writeback(page);
clear_extent_bit(tree, start, end,
 EXTENT_LOCKED | EXTENT_DIRTY | EXTENT_DELALLOC |
@@ -3069,8 +3072,9 @@ int extent_fiemap(struct inode *inode, s
last_for_get_extent = isize;
}
 
-   lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0,
+   ret = lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0,
 &cached_state, GFP_NOFS);
+   BUG_ON(ret < 0);
 
em = get_extent_skip_holes(inode, off, last_for_get_extent,
   get_extent);
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -177,14 +177,16 @@ int try_release_extent_buffer(struct ext
 int try_release_extent_state(struct extent_map_tree *map,
 struct extent_io_tree *tree, struct page *page,
 gfp_t mask);
-int lock_extent(struct extent_io_tree *tree, u64 start, u

[patch 33/66] btrfs: tree-log: btrfs_end_log_trans should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_end_log_trans has no error conditions and should return void.
 Its callers ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/tree-log.c |3 +--
 fs/btrfs/tree-log.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 483e280..2c45b3d 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -212,14 +212,13 @@ int btrfs_pin_log_trans(struct btrfs_root *root)
  * indicate we're done making changes to the log tree
  * and wake up anyone waiting to do a sync
  */
-int btrfs_end_log_trans(struct btrfs_root *root)
+void btrfs_end_log_trans(struct btrfs_root *root)
 {
if (atomic_dec_and_test(&root->log_writers)) {
smp_mb();
if (waitqueue_active(&root->log_writer_wait))
wake_up(&root->log_writer_wait);
}
-   return 0;
 }
 
 
diff --git a/fs/btrfs/tree-log.h b/fs/btrfs/tree-log.h
index 2270ac5..862ac81 100644
--- a/fs/btrfs/tree-log.h
+++ b/fs/btrfs/tree-log.h
@@ -38,7 +38,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle 
*trans,
   struct btrfs_root *root,
   const char *name, int name_len,
   struct inode *inode, u64 dirid);
-int btrfs_end_log_trans(struct btrfs_root *root);
+void btrfs_end_log_trans(struct btrfs_root *root);
 int btrfs_pin_log_trans(struct btrfs_root *root);
 int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode,



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 38/66] btrfs: btrfs_destroy_delalloc_inodes should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_destroy_delalloc_inodes has no error conditions and should return
 void. Its callers already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -54,7 +54,7 @@ static int btrfs_destroy_ordered_extents
 static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
  struct btrfs_root *root);
 static int btrfs_destroy_pending_snapshots(struct btrfs_transaction *t);
-static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root);
+static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root);
 static int btrfs_destroy_marked_extents(struct btrfs_root *root,
struct extent_io_tree *dirty_pages,
int mark);
@@ -2939,7 +2939,7 @@ static int btrfs_destroy_pending_snapsho
return 0;
 }
 
-static int btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
+static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root)
 {
struct btrfs_inode *btrfs_inode;
struct list_head splice;
@@ -2959,8 +2959,6 @@ static int btrfs_destroy_delalloc_inodes
}
 
spin_unlock(&root->fs_info->delalloc_lock);
-
-   return 0;
 }
 
 static int btrfs_destroy_marked_extents(struct btrfs_root *root,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 34/66] btrfs: tree-log: wait_for_writer should return void

2011-10-24 Thread Jeff Mahoney
 wait_for_writer has no error conditions and should return void. Its
 callers already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/tree-log.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 2c45b3d..aac743b 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1964,8 +1964,8 @@ static int wait_log_commit(struct btrfs_trans_handle 
*trans,
return 0;
 }
 
-static int wait_for_writer(struct btrfs_trans_handle *trans,
-  struct btrfs_root *root)
+static void wait_for_writer(struct btrfs_trans_handle *trans,
+   struct btrfs_root *root)
 {
DEFINE_WAIT(wait);
while (atomic_read(&root->log_writers)) {
@@ -1978,7 +1978,6 @@ static int wait_for_writer(struct btrfs_trans_handle 
*trans,
mutex_lock(&root->log_mutex);
finish_wait(&root->log_writer_wait, &wait);
}
-   return 0;
 }
 
 /*



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 35/66] btrfs: btrfs_init_compress should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_init_compress doesn't have any failure conditions, so return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/compression.c |3 +--
 fs/btrfs/compression.h |2 +-
 fs/btrfs/super.c   |5 +
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index cca501b..0c0e842 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -734,7 +734,7 @@ struct btrfs_compress_op *btrfs_compress_op[] = {
&btrfs_lzo_compress,
 };
 
-int __init btrfs_init_compress(void)
+void __init btrfs_init_compress(void)
 {
int i;
 
@@ -744,7 +744,6 @@ int __init btrfs_init_compress(void)
atomic_set(&comp_alloc_workspace[i], 0);
init_waitqueue_head(&comp_workspace_wait[i]);
}
-   return 0;
 }
 
 /*
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index a12059f..9afb0a6 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -19,7 +19,7 @@
 #ifndef __BTRFS_COMPRESSION_
 #define __BTRFS_COMPRESSION_
 
-int btrfs_init_compress(void);
+void btrfs_init_compress(void);
 void btrfs_exit_compress(void);
 
 int btrfs_compress_pages(int type, struct address_space *mapping,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 0152207..26e1dcf 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1347,9 +1347,7 @@ static int __init init_btrfs_fs(void)
if (err)
return err;
 
-   err = btrfs_init_compress();
-   if (err)
-   goto free_sysfs;
+   btrfs_init_compress();
 
err = btrfs_init_cachep();
if (err)
@@ -1390,7 +1388,6 @@ free_cachep:
btrfs_destroy_cachep();
 free_compress:
btrfs_exit_compress();
-free_sysfs:
btrfs_exit_sysfs();
return err;
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 36/66] btrfs: btrfs_invalidate_inodes should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_invalidate_inodes has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h |2 +-
 fs/btrfs/inode.c |3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 7d90a9c..e8f0689 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2584,7 +2584,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root);
 void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
  struct btrfs_root *root);
 int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size);
-int btrfs_invalidate_inodes(struct btrfs_root *root);
+void btrfs_invalidate_inodes(struct btrfs_root *root);
 void btrfs_add_delayed_iput(struct inode *inode);
 void btrfs_run_delayed_iputs(struct btrfs_root *root);
 int btrfs_prealloc_file_range(struct inode *inode, int mode,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 321c9cf..59c681b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3861,7 +3861,7 @@ static void inode_tree_del(struct inode *inode)
}
 }
 
-int btrfs_invalidate_inodes(struct btrfs_root *root)
+void btrfs_invalidate_inodes(struct btrfs_root *root)
 {
struct rb_node *node;
struct rb_node *prev;
@@ -3921,7 +3921,6 @@ again:
node = rb_next(node);
}
spin_unlock(&root->inode_lock);
-   return 0;
 }
 
 static int btrfs_init_locked_inode(struct inode *inode, void *p)



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 31/66] btrfs: btrfs_stop_workers should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_stop_workers has no error conditions and should return void.
 Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/async-thread.c |3 +--
 fs/btrfs/async-thread.h |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -401,7 +401,7 @@ again:
 /*
  * this will wait for all the worker threads to shutdown
  */
-int btrfs_stop_workers(struct btrfs_workers *workers)
+void btrfs_stop_workers(struct btrfs_workers *workers)
 {
struct list_head *cur;
struct btrfs_worker_thread *worker;
@@ -429,7 +429,6 @@ int btrfs_stop_workers(struct btrfs_work
put_worker(worker);
}
spin_unlock_irq(&workers->lock);
-   return 0;
 }
 
 /*
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -111,7 +111,7 @@ struct btrfs_workers {
 
 void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work 
*work);
 int btrfs_start_workers(struct btrfs_workers *workers, int num_workers);
-int btrfs_stop_workers(struct btrfs_workers *workers);
+void btrfs_stop_workers(struct btrfs_workers *workers);
 void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max,
struct btrfs_workers *async_starter);
 int btrfs_requeue_work(struct btrfs_work *work);


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 37/66] btrfs: __setup_root should return void

2011-10-24 Thread Jeff Mahoney
 __setup_root has no error conditions and should return void. Its callers
 already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1058,10 +1058,10 @@ int clean_tree_block(struct btrfs_trans_
return 0;
 }
 
-static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
-   u32 stripesize, struct btrfs_root *root,
-   struct btrfs_fs_info *fs_info,
-   u64 objectid)
+static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
+u32 stripesize, struct btrfs_root *root,
+struct btrfs_fs_info *fs_info,
+u64 objectid)
 {
root->node = NULL;
root->commit_root = NULL;
@@ -1114,7 +1114,6 @@ static int __setup_root(u32 nodesize, u3
root->defrag_running = 0;
root->root_key.objectid = objectid;
root->anon_dev = 0;
-   return 0;
 }
 
 static int __must_check find_and_setup_root(struct btrfs_root *tree_root,


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 39/66] btrfs: btrfs_prepare_extent_commit should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_prepare_extent_commit has no error conditions and should return
 void. Its callers already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |4 ++--
 fs/btrfs/extent-tree.c |3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2207,8 +2207,8 @@ int btrfs_free_extent(struct btrfs_trans
  u64 root_objectid, u64 owner, u64 offset);
 
 int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len);
-int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
-   struct btrfs_root *root);
+void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
+struct btrfs_root *root);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
   struct btrfs_root *root);
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4385,7 +4385,7 @@ static int btrfs_update_reserved_bytes(s
return ret;
 }
 
-int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
+void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
 {
struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4415,7 +4415,6 @@ int btrfs_prepare_extent_commit(struct b
up_write(&fs_info->extent_commit_sem);
 
update_global_block_rsv(fs_info);
-   return 0;
 }
 
 static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end)


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 41/66] btrfs: setup_inline_extent_backref should return void

2011-10-24 Thread Jeff Mahoney
 setup_inline_extent_backref has no error conditions and should return
 void. We set ret = 0 explicitly in insert_inline_extent_backref since
 it would have been set using the return value, which would have been 0.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent-tree.c |   23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1556,13 +1556,13 @@ out:
  * helper to add new inline back ref
  */
 static noinline_for_stack
-int setup_inline_extent_backref(struct btrfs_trans_handle *trans,
-   struct btrfs_root *root,
-   struct btrfs_path *path,
-   struct btrfs_extent_inline_ref *iref,
-   u64 parent, u64 root_objectid,
-   u64 owner, u64 offset, int refs_to_add,
-   struct btrfs_delayed_extent_op *extent_op)
+void setup_inline_extent_backref(struct btrfs_trans_handle *trans,
+struct btrfs_root *root,
+struct btrfs_path *path,
+struct btrfs_extent_inline_ref *iref,
+u64 parent, u64 root_objectid,
+u64 owner, u64 offset, int refs_to_add,
+struct btrfs_delayed_extent_op *extent_op)
 {
struct extent_buffer *leaf;
struct btrfs_extent_item *ei;
@@ -1616,7 +1616,6 @@ int setup_inline_extent_backref(struct b
btrfs_set_extent_inline_ref_offset(leaf, iref, root_objectid);
}
btrfs_mark_buffer_dirty(leaf);
-   return 0;
 }
 
 static int lookup_extent_backref(struct btrfs_trans_handle *trans,
@@ -1735,10 +1734,10 @@ int insert_inline_extent_backref(struct
ret = update_inline_extent_backref(trans, root, path, iref,
   refs_to_add, extent_op);
} else if (ret == -ENOENT) {
-   ret = setup_inline_extent_backref(trans, root, path, iref,
- parent, root_objectid,
- owner, offset, refs_to_add,
- extent_op);
+   setup_inline_extent_backref(trans, root, path, iref, parent,
+   root_objectid, owner, offset,
+   refs_to_add, extent_op);
+   ret = 0;
}
return ret;
 }


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 40/66] btrfs: btrfs_set_block_group_rw should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_set_block_group_rw has no error conditions and should return
 void. Its callers already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |4 ++--
 fs/btrfs/extent-tree.c |3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2263,8 +2263,8 @@ void btrfs_block_rsv_release(struct btrf
 u64 num_bytes);
 int btrfs_set_block_group_ro(struct btrfs_root *root,
 struct btrfs_block_group_cache *cache);
-int btrfs_set_block_group_rw(struct btrfs_root *root,
-struct btrfs_block_group_cache *cache);
+void btrfs_set_block_group_rw(struct btrfs_root *root,
+ struct btrfs_block_group_cache *cache);
 void btrfs_put_block_group_cache(struct btrfs_fs_info *info);
 u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo);
 int btrfs_error_unpin_extent_range(struct btrfs_root *root,
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6769,7 +6769,7 @@ u64 btrfs_account_ro_block_groups_free_s
return free_bytes;
 }
 
-int btrfs_set_block_group_rw(struct btrfs_root *root,
+void btrfs_set_block_group_rw(struct btrfs_root *root,
  struct btrfs_block_group_cache *cache)
 {
struct btrfs_space_info *sinfo = cache->space_info;
@@ -6785,7 +6785,6 @@ int btrfs_set_block_group_rw(struct btrf
cache->ro = 0;
spin_unlock(&cache->lock);
spin_unlock(&sinfo->lock);
-   return 0;
 }
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 42/66] btrfs: btrfs_run_defrag_inodes should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_run_defrag_inodes has no error conditions and should return
 void. Its callers already ignore the error codes anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h |2 +-
 fs/btrfs/file.c  |3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2606,7 +2606,7 @@ int btrfs_defrag_file(struct inode *inod
 /* file.c */
 int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
   struct inode *inode);
-int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
+void btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
 int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
 int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
int skip_pinned);
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -193,7 +193,7 @@ struct inode_defrag *btrfs_find_defrag_i
  * run through the list of inodes in the FS that need
  * defragging
  */
-int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info)
+void btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info)
 {
struct inode_defrag *defrag;
struct btrfs_root *inode_root;
@@ -296,7 +296,6 @@ next_free:
 * wait for the defragger to stop
 */
wake_up(&fs_info->transaction_wait);
-   return 0;
 }
 
 /* simple helper to fault in pages and copy.  This should go away


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 44/66] btrfs: Factor out tree->ops->merge_bio_hook call

2011-10-24 Thread Jeff Mahoney
 In submit_extent_page, there's a visually noisy if statement that, in
 the midst of other conditions, does the tree dependency for tree->ops
 and tree->ops->merge_bio_hook before calling it, and then another
 condition afterwards. If an error is returned from merge_bio_hook,
 there's no way to catch it. It's considered a routine "1" return
 value instead of a failure.

 This patch factors out the dependency check into a new local merge_bio
 routine and BUG's on an error. The if statement is less noisy as a side-
 effect.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent_io.c |   17 ++---
 fs/btrfs/inode.c |5 +++--
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 0575792..09095b8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2058,6 +2058,19 @@ static int submit_one_bio(int rw, struct bio *bio, int 
mirror_num,
return ret;
 }
 
+static int merge_bio(struct extent_io_tree *tree, struct page *page,
+unsigned long offset, size_t size, struct bio *bio,
+unsigned long bio_flags)
+{
+   int ret = 0;
+   if (tree->ops && tree->ops->merge_bio_hook)
+   ret = tree->ops->merge_bio_hook(page, offset, size, bio,
+   bio_flags);
+   BUG_ON(ret < 0);
+   return ret;
+
+}
+
 static int submit_extent_page(int rw, struct extent_io_tree *tree,
  struct page *page, sector_t sector,
  size_t size, unsigned long offset,
@@ -2086,9 +2099,7 @@ static int submit_extent_page(int rw, struct 
extent_io_tree *tree,
sector;
 
if (prev_bio_flags != bio_flags || !contig ||
-   (tree->ops && tree->ops->merge_bio_hook &&
-tree->ops->merge_bio_hook(page, offset, page_size, bio,
-  bio_flags)) ||
+   merge_bio(tree, page, offset, page_size, bio, bio_flags) ||
bio_add_page(bio, page, page_size, offset) < page_size) {
ret = submit_one_bio(rw, bio, mirror_num,
 prev_bio_flags);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c0dc599..a06cb64 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1425,10 +1425,11 @@ int btrfs_merge_bio_hook(struct page *page, unsigned 
long offset,
map_length = length;
ret = btrfs_map_block(map_tree, READ, logical,
  &map_length, NULL, 0);
-
+   /* Will always return 0 or 1 with map_multi == NULL */
+   BUG_ON(ret < 0);
if (map_length < length + size)
return 1;
-   return ret;
+   return 0;
 }
 
 /*



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 43/66] btrfs: Simplify btrfs_submit_bio_hook

2011-10-24 Thread Jeff Mahoney
 btrfs_submit_bio_hook currently calls btrfs_bio_wq_end_io in either case
 of an if statement that determines one of the arguments.

 This patch moves the function call outside of the if statement and uses it
 to only determine the different argument. This allows us to catch an
 error in one place in a more visually obvious way.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/inode.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 59c681b..c0dc599 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1479,13 +1479,14 @@ static int btrfs_submit_bio_hook(struct inode *inode, 
int rw, struct bio *bio,
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0;
int skip_sum;
+   int metadata = 0;
 
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
 
if (btrfs_is_free_space_inode(root, inode))
-   ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2);
-   else
-   ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
+   metadata = 2;
+
+   ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata);
BUG_ON(ret);
 
if (!(rw & REQ_WRITE)) {



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 46/66] btrfs: __add_reloc_root error push-up

2011-10-24 Thread Jeff Mahoney
 This patch pushes kmalloc errors up to the caller and BUGs in the caller.

 The BUG_ON for duplicate reloc tree root insertion is replaced with a
 panic explaining the issue.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/relocation.c |   22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1219,14 +1219,15 @@ fail:
 /*
  * helper to add 'address of tree root -> reloc tree' mapping
  */
-static int __add_reloc_root(struct btrfs_root *root)
+static int __must_check __add_reloc_root(struct btrfs_root *root)
 {
struct rb_node *rb_node;
struct mapping_node *node;
struct reloc_control *rc = root->fs_info->reloc_ctl;
 
node = kmalloc(sizeof(*node), GFP_NOFS);
-   BUG_ON(!node);
+   if (!node)
+   return -ENOMEM;
 
node->bytenr = root->node->start;
node->data = root;
@@ -1235,7 +1236,12 @@ static int __add_reloc_root(struct btrfs
rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
  node->bytenr, &node->rb_node);
spin_unlock(&rc->reloc_root_tree.lock);
-   BUG_ON(rb_node);
+   if (rb_node) {
+   kfree(node);
+   btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
+   "for start=%llu while inserting into relocation "
+   "tree\n");
+   }
 
list_add_tail(&root->root_list, &rc->reloc_roots);
return 0;
@@ -1351,6 +1357,7 @@ int btrfs_init_reloc_root(struct btrfs_t
struct btrfs_root *reloc_root;
struct reloc_control *rc = root->fs_info->reloc_ctl;
int clear_rsv = 0;
+   int ret;
 
if (root->reloc_root) {
reloc_root = root->reloc_root;
@@ -1370,7 +1377,8 @@ int btrfs_init_reloc_root(struct btrfs_t
if (clear_rsv)
trans->block_rsv = NULL;
 
-   __add_reloc_root(reloc_root);
+   ret = __add_reloc_root(reloc_root);
+   BUG_ON(ret < 0);
root->reloc_root = reloc_root;
return 0;
 }
@@ -4248,7 +4256,8 @@ int btrfs_recover_relocation(struct btrf
   reloc_root->root_key.offset);
BUG_ON(IS_ERR(fs_root));
 
-   __add_reloc_root(reloc_root);
+   err = __add_reloc_root(reloc_root);
+   BUG_ON(err < 0);
fs_root->reloc_root = reloc_root;
}
 
@@ -4450,7 +4459,8 @@ void btrfs_reloc_post_snapshot(struct bt
reloc_root = create_reloc_root(trans, root->reloc_root,
   new_root->root_key.objectid);
 
-   __add_reloc_root(reloc_root);
+   ret = __add_reloc_root(reloc_root);
+   BUG_ON(ret < 0);
new_root->reloc_root = reloc_root;
 
if (rc->create_reloc_tree) {


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 45/66] btrfs: ->submit_bio_hook error push-up

2011-10-24 Thread Jeff Mahoney
 This pushes failures from the submit_bio_hook callbacks,
 btrfs_submit_bio_hook and btree_submit_bio_hook into the callers, including
 callers of submit_one_bio where it catches the failures with BUG_ON.

 It also pushes up through the ->readpage_io_failed_hook to
 end_bio_extent_writepage where the error is already caught with BUG_ON.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c   |6 +++---
 fs/btrfs/extent_io.c |   33 +++--
 fs/btrfs/inode.c |3 ++-
 3 files changed, 28 insertions(+), 14 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -811,9 +811,9 @@ static int btree_submit_bio_hook(struct
 {
int ret;
 
-   ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info,
- bio, 1);
-   BUG_ON(ret);
+   ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, bio, 1);
+   if (ret)
+   return ret;
 
if (!(rw & REQ_WRITE)) {
/*
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1888,6 +1888,7 @@ static void end_bio_extent_writepage(str
uptodate = (err == 0);
continue;
}
+   BUG_ON(ret < 0);
}
 
if (!uptodate) {
@@ -1980,6 +1981,7 @@ static void end_bio_extent_readpage(stru
uncache_state(&cached);
continue;
}
+   BUG_ON(ret < 0);
}
 
if (uptodate) {
@@ -2034,8 +2036,8 @@ btrfs_bio_alloc(struct block_device *bde
return bio;
 }
 
-static int submit_one_bio(int rw, struct bio *bio, int mirror_num,
- unsigned long bio_flags)
+static int __must_check submit_one_bio(int rw, struct bio *bio,
+  int mirror_num, unsigned long bio_flags)
 {
int ret = 0;
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
@@ -2105,6 +2107,7 @@ static int submit_extent_page(int rw, st
bio_add_page(bio, page, page_size, offset) < page_size) {
ret = submit_one_bio(rw, bio, mirror_num,
 prev_bio_flags);
+   BUG_ON(ret < 0);
bio = NULL;
} else {
return 0;
@@ -2125,8 +2128,10 @@ static int submit_extent_page(int rw, st
 
if (bio_ret)
*bio_ret = bio;
-   else
+   else {
ret = submit_one_bio(rw, bio, mirror_num, bio_flags);
+   BUG_ON(ret < 0);
+   }
 
return ret;
 }
@@ -2349,8 +2354,10 @@ int extent_read_full_page(struct extent_
 
ret = __extent_read_full_page(tree, page, get_extent, &bio, 0,
  &bio_flags);
-   if (bio)
+   if (bio) {
ret = submit_one_bio(READ, bio, 0, bio_flags);
+   BUG_ON(ret < 0);
+   }
return ret;
 }
 
@@ -2752,10 +2759,12 @@ retry:
 static void flush_epd_write_bio(struct extent_page_data *epd)
 {
if (epd->bio) {
+   int ret;
if (epd->sync_io)
-   submit_one_bio(WRITE_SYNC, epd->bio, 0, 0);
+   ret = submit_one_bio(WRITE_SYNC, epd->bio, 0, 0);
else
-   submit_one_bio(WRITE, epd->bio, 0, 0);
+   ret = submit_one_bio(WRITE, epd->bio, 0, 0);
+   BUG_ON(ret < 0);
epd->bio = NULL;
}
 }
@@ -2871,8 +2880,10 @@ int extent_readpages(struct extent_io_tr
page_cache_release(page);
}
BUG_ON(!list_empty(pages));
-   if (bio)
-   submit_one_bio(READ, bio, 0, bio_flags);
+   if (bio) {
+   int ret = submit_one_bio(READ, bio, 0, bio_flags);
+   BUG_ON(ret < 0);
+   }
return 0;
 }
 
@@ -3704,8 +3715,10 @@ int read_extent_buffer_pages(struct exte
}
}
 
-   if (bio)
-   submit_one_bio(READ, bio, mirror_num, bio_flags);
+   if (bio) {
+   err = submit_one_bio(READ, bio, mirror_num, bio_flags);
+   BUG_ON(err < 0);
+   }
 
if (ret || !wait)
return ret;
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1488,7 +1488,8 @@ static int btrfs_submit_bio_hook(struct
metadata = 2;
 
ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata);
-   BUG_ON(ret);
+   if (ret)
+   return ret;
 
if (!(rw & REQ_WRITE)) {
if (bio_flags & EXTENT_BIO_COMPRESSED) {


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 47/66] btrfs: fixup_low_keys should return void

2011-10-24 Thread Jeff Mahoney
 fixup_low_keys has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c |   39 +++
 1 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 011cab3..dedd3a1 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1864,15 +1864,12 @@ done:
  * fixing up pointers when a given leaf/node is not in slot 0 of the
  * higher levels
  *
- * If this fails to write a tree block, it returns -1, but continues
- * fixing up the blocks in ram so the tree is consistent.
  */
-static int fixup_low_keys(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, struct btrfs_path *path,
- struct btrfs_disk_key *key, int level)
+static void fixup_low_keys(struct btrfs_trans_handle *trans,
+  struct btrfs_root *root, struct btrfs_path *path,
+  struct btrfs_disk_key *key, int level)
 {
int i;
-   int ret = 0;
struct extent_buffer *t;
 
for (i = level; i < BTRFS_MAX_LEVEL; i++) {
@@ -1885,7 +1882,6 @@ static int fixup_low_keys(struct btrfs_trans_handle 
*trans,
if (tslot != 0)
break;
}
-   return ret;
 }
 
 /*
@@ -2626,9 +2622,7 @@ static noinline int __push_leaf_left(struct 
btrfs_trans_handle *trans,
clean_tree_block(trans, root, right);
 
btrfs_item_key(right, &disk_key, 0);
-   wret = fixup_low_keys(trans, root, path, &disk_key, 1);
-   if (wret)
-   ret = wret;
+   fixup_low_keys(trans, root, path, &disk_key, 1);
 
/* then fixup the leaf pointer in the path */
if (path->slots[0] < push_items) {
@@ -2999,12 +2993,9 @@ again:
free_extent_buffer(path->nodes[0]);
path->nodes[0] = right;
path->slots[0] = 0;
-   if (path->slots[1] == 0) {
-   wret = fixup_low_keys(trans, root,
-   path, &disk_key, 1);
-   if (wret)
-   ret = wret;
-   }
+   if (path->slots[1] == 0)
+   fixup_low_keys(trans, root, path,
+  &disk_key, 1);
}
btrfs_mark_buffer_dirty(right);
return ret;
@@ -3527,7 +3518,7 @@ int btrfs_insert_some_items(struct btrfs_trans_handle 
*trans,
ret = 0;
if (slot == 0) {
btrfs_cpu_key_to_disk(&disk_key, cpu_key);
-   ret = fixup_low_keys(trans, root, path, &disk_key, 1);
+   fixup_low_keys(trans, root, path, &disk_key, 1);
}
 
if (btrfs_leaf_free_space(root, leaf) < 0) {
@@ -3555,7 +3546,6 @@ int setup_items_for_insert(struct btrfs_trans_handle 
*trans,
u32 nritems;
unsigned int data_end;
struct btrfs_disk_key disk_key;
-   int ret;
struct extent_buffer *leaf;
int slot;
 
@@ -3616,10 +3606,9 @@ int setup_items_for_insert(struct btrfs_trans_handle 
*trans,
 
btrfs_set_header_nritems(leaf, nritems + nr);
 
-   ret = 0;
if (slot == 0) {
btrfs_cpu_key_to_disk(&disk_key, cpu_key);
-   ret = fixup_low_keys(trans, root, path, &disk_key, 1);
+   fixup_low_keys(trans, root, path, &disk_key, 1);
}
btrfs_unlock_up_safe(path, 1);
btrfs_mark_buffer_dirty(leaf);
@@ -3706,7 +3695,6 @@ static int del_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
struct extent_buffer *parent = path->nodes[level];
u32 nritems;
int ret = 0;
-   int wret;
 
nritems = btrfs_header_nritems(parent);
if (slot != nritems - 1) {
@@ -3726,9 +3714,7 @@ static int del_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
struct btrfs_disk_key disk_key;
 
btrfs_node_key(parent, &disk_key, 0);
-   wret = fixup_low_keys(trans, root, path, &disk_key, level + 1);
-   if (wret)
-   ret = wret;
+   fixup_low_keys(trans, root, path, &disk_key, level + 1);
}
btrfs_mark_buffer_dirty(parent);
return ret;
@@ -3831,10 +3817,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
struct btrfs_disk_key disk_key;
 
btrfs_item_key(leaf, &disk_key, 0);
-   wret = fixup_low_keys(trans, root, path,
- &disk_key, 1);
-   if (wret)
-   ret = wret;
+   fixup_low_keys(trans, root, path, &disk_key, 1);
}
 
/* delete the leaf if it is m

[patch 50/66] btrfs: insert_ptr should return void

2011-10-24 Thread Jeff Mahoney
 insert_ptr has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c |   46 +-
 1 files changed, 13 insertions(+), 33 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c605fb3..2604ec4 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2114,12 +2114,11 @@ static noinline int insert_new_root(struct 
btrfs_trans_handle *trans,
  *
  * slot and level indicate where you want the key to go, and
  * blocknr is the block the key points to.
- *
- * returns zero on success and < 0 on any error
  */
-static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root
- *root, struct btrfs_path *path, struct btrfs_disk_key
- *key, u64 bytenr, int slot, int level)
+static void insert_ptr(struct btrfs_trans_handle *trans,
+  struct btrfs_root *root, struct btrfs_path *path,
+  struct btrfs_disk_key *key, u64 bytenr,
+  int slot, int level)
 {
struct extent_buffer *lower;
int nritems;
@@ -2129,8 +2128,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root
lower = path->nodes[level];
nritems = btrfs_header_nritems(lower);
BUG_ON(slot > nritems);
-   if (nritems == BTRFS_NODEPTRS_PER_BLOCK(root))
-   BUG();
+   BUG_ON(nritems == BTRFS_NODEPTRS_PER_BLOCK(root));
if (slot != nritems) {
memmove_extent_buffer(lower,
  btrfs_node_key_ptr_offset(slot + 1),
@@ -2143,7 +2141,6 @@ static int insert_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root
btrfs_set_node_ptr_generation(lower, slot, trans->transid);
btrfs_set_header_nritems(lower, nritems + 1);
btrfs_mark_buffer_dirty(lower);
-   return 0;
 }
 
 /*
@@ -2164,7 +2161,6 @@ static noinline int split_node(struct btrfs_trans_handle 
*trans,
struct btrfs_disk_key disk_key;
int mid;
int ret;
-   int wret;
u32 c_nritems;
 
c = path->nodes[level];
@@ -2221,11 +2217,8 @@ static noinline int split_node(struct btrfs_trans_handle 
*trans,
btrfs_mark_buffer_dirty(c);
btrfs_mark_buffer_dirty(split);
 
-   wret = insert_ptr(trans, root, path, &disk_key, split->start,
- path->slots[level + 1] + 1,
- level + 1);
-   if (wret)
-   ret = wret;
+   insert_ptr(trans, root, path, &disk_key, split->start,
+  path->slots[level + 1] + 1, level + 1);
 
if (path->slots[level] >= mid) {
path->slots[level] -= mid;
@@ -2722,8 +2715,6 @@ static noinline int copy_for_split(struct 
btrfs_trans_handle *trans,
int data_copy_size;
int rt_data_off;
int i;
-   int ret = 0;
-   int wret;
struct btrfs_disk_key disk_key;
 
nritems = nritems - mid;
@@ -2751,12 +2742,9 @@ static noinline int copy_for_split(struct 
btrfs_trans_handle *trans,
}
 
btrfs_set_header_nritems(l, mid);
-   ret = 0;
btrfs_item_key(right, &disk_key, 0);
-   wret = insert_ptr(trans, root, path, &disk_key, right->start,
- path->slots[1] + 1, 1);
-   if (wret)
-   ret = wret;
+   insert_ptr(trans, root, path, &disk_key, right->start,
+  path->slots[1] + 1, 1);
 
btrfs_mark_buffer_dirty(right);
btrfs_mark_buffer_dirty(l);
@@ -2775,7 +2763,7 @@ static noinline int copy_for_split(struct 
btrfs_trans_handle *trans,
 
BUG_ON(path->slots[0] < 0);
 
-   return ret;
+   return 0;
 }
 
 /*
@@ -2964,12 +2952,8 @@ again:
if (split == 0) {
if (mid <= slot) {
btrfs_set_header_nritems(right, 0);
-   wret = insert_ptr(trans, root, path,
- &disk_key, right->start,
- path->slots[1] + 1, 1);
-   if (wret)
-   ret = wret;
-
+   insert_ptr(trans, root, path, &disk_key, right->start,
+  path->slots[1] + 1, 1);
btrfs_tree_unlock(path->nodes[0]);
free_extent_buffer(path->nodes[0]);
path->nodes[0] = right;
@@ -2977,12 +2961,8 @@ again:
path->slots[1] += 1;
} else {
btrfs_set_header_nritems(right, 0);
-   wret = insert_ptr(trans, root, path,
- &disk_key,
- right->start,
+   insert_ptr(trans, root, path, &disk_key, right->start,
  path->slots[1], 1);
-   if (wret)
-   ret 

[patch 49/66] btrfs: del_ptr should return void

2011-10-24 Thread Jeff Mahoney
 With fixup_low_keys now returning void, there are no error conditions
 for del_ptr to report so it should return void. We set ret = 0 explicitly
 in btrfs_del_items but I'm not convinced that the error handling code
 already there is correct.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c |   39 +--
 1 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index fdaddcc..c605fb3 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -36,7 +36,7 @@ static int balance_node_right(struct btrfs_trans_handle 
*trans,
  struct btrfs_root *root,
  struct extent_buffer *dst_buf,
  struct extent_buffer *src_buf);
-static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
   struct btrfs_path *path, int level, int slot);
 
 struct btrfs_path *btrfs_alloc_path(void)
@@ -994,10 +994,7 @@ static noinline int balance_level(struct 
btrfs_trans_handle *trans,
if (btrfs_header_nritems(right) == 0) {
clean_tree_block(trans, root, right);
btrfs_tree_unlock(right);
-   wret = del_ptr(trans, root, path, level + 1, pslot +
-  1);
-   if (wret)
-   ret = wret;
+   del_ptr(trans, root, path, level + 1, pslot + 1);
root_sub_used(root, right->len);
btrfs_free_tree_block(trans, root, right, 0, 1);
free_extent_buffer(right);
@@ -1035,9 +1032,7 @@ static noinline int balance_level(struct 
btrfs_trans_handle *trans,
if (btrfs_header_nritems(mid) == 0) {
clean_tree_block(trans, root, mid);
btrfs_tree_unlock(mid);
-   wret = del_ptr(trans, root, path, level + 1, pslot);
-   if (wret)
-   ret = wret;
+   del_ptr(trans, root, path, level + 1, pslot);
root_sub_used(root, mid->len);
btrfs_free_tree_block(trans, root, mid, 0, 1);
free_extent_buffer(mid);
@@ -3683,12 +3678,11 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, 
struct btrfs_root
  * the tree should have been previously balanced so the deletion does not
  * empty a node.
  */
-static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-  struct btrfs_path *path, int level, int slot)
+static void del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+   struct btrfs_path *path, int level, int slot)
 {
struct extent_buffer *parent = path->nodes[level];
u32 nritems;
-   int ret = 0;
 
nritems = btrfs_header_nritems(parent);
if (slot != nritems - 1) {
@@ -3711,7 +3705,6 @@ static int del_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
fixup_low_keys(trans, root, path, &disk_key, level + 1);
}
btrfs_mark_buffer_dirty(parent);
-   return ret;
 }
 
 /*
@@ -3724,17 +3717,13 @@ static int del_ptr(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
  * The path must have already been setup for deleting the leaf, including
  * all the proper balancing.  path->nodes[1] must be locked.
  */
-static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans,
-  struct btrfs_root *root,
-  struct btrfs_path *path,
-  struct extent_buffer *leaf)
+static noinline void btrfs_del_leaf(struct btrfs_trans_handle *trans,
+   struct btrfs_root *root,
+   struct btrfs_path *path,
+   struct extent_buffer *leaf)
 {
-   int ret;
-
WARN_ON(btrfs_header_generation(leaf) != trans->transid);
-   ret = del_ptr(trans, root, path, 1, path->slots[1]);
-   if (ret)
-   return ret;
+   del_ptr(trans, root, path, 1, path->slots[1]);
 
/*
 * btrfs_free_extent is expensive, we want to make sure we
@@ -3745,7 +3734,6 @@ static noinline int btrfs_del_leaf(struct 
btrfs_trans_handle *trans,
root_sub_used(root, leaf->len);
 
btrfs_free_tree_block(trans, root, leaf, 0, 1);
-   return 0;
 }
 /*
  * delete the item at the leaf level in path.  If that empties
@@ -3802,8 +3790,7 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
} else {
btrfs_set_path_blocking(path);
clean_tree_block(trans, root, leaf);
-   ret = btrfs_del_leaf(trans, root, path, leaf);
-   BUG_ON(ret);
+  

[patch 54/66] btrfs: Fix kfree of member instead of structure

2011-10-24 Thread Jeff Mahoney
 Correctness fix: The kfree calls in the add_delayed_* functions free
 the node that's passed into it, but the node is a member of another
 structure. It works because it's always the first member of the
 containing structure, but it should really be using the containing
 structure itself.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/delayed-ref.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index b004960..e388ca3 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -455,7 +455,7 @@ static noinline void add_delayed_ref_head(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(ref);
+   kfree(head_ref);
} else {
delayed_refs->num_heads++;
delayed_refs->num_heads_ready++;
@@ -510,7 +510,7 @@ static noinline void add_delayed_tree_ref(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(ref);
+   kfree(full_ref);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
@@ -565,7 +565,7 @@ static noinline void add_delayed_data_ref(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(ref);
+   kfree(full_ref);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 58/66] btrfs: btrfs_free_extent void return prep

2011-10-24 Thread Jeff Mahoney
 btrfs_free_extent has no error conditions, but is used via process_func
 in __btrfs_mod_ref which requires it to return an int.

 This patch cleans up the callers to eliminate error handling that will
 never be used. The next patch makes both btrfs_free_extent and the other
 function used via process_func, btrfs_inc_extent_ref, return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent-tree.c |8 +++-
 fs/btrfs/file.c|   23 +--
 fs/btrfs/inode.c   |9 -
 fs/btrfs/relocation.c  |   23 +--
 4 files changed, 25 insertions(+), 38 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fe95f37..dc91e4d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4805,13 +4805,12 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
  u64 bytenr, u64 num_bytes, u64 parent,
  u64 root_objectid, u64 owner, u64 offset)
 {
-   int ret;
-
/*
 * tree log blocks never actually go into the extent allocation
 * tree, just update pinning info and exit early.
 */
if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
+   int ret;
WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);
/* unlocks the pinned mutex */
ret = btrfs_pin_extent(root, bytenr, num_bytes, 1);
@@ -6142,9 +6141,8 @@ skip:
parent = 0;
}
 
-   ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent,
-   root->root_key.objectid, level - 1, 0);
-   BUG_ON(ret);
+   btrfs_free_extent(trans, root, bytenr, blocksize, parent,
+ root->root_key.objectid, level - 1, 0);
}
btrfs_tree_unlock(next);
free_extent_buffer(next);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 314c08e..fa8f83e 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -747,12 +747,11 @@ next_slot:
extent_end = ALIGN(extent_end,
   root->sectorsize);
} else if (disk_bytenr > 0) {
-   ret = btrfs_free_extent(trans, root,
-   disk_bytenr, num_bytes, 0,
-   root->root_key.objectid,
-   key.objectid, key.offset -
-   extent_offset);
-   BUG_ON(ret);
+   btrfs_free_extent(trans, root,
+ disk_bytenr, num_bytes, 0,
+ root->root_key.objectid,
+ key.objectid, key.offset -
+ extent_offset);
inode_sub_bytes(inode,
extent_end - key.offset);
*hint_byte = disk_bytenr;
@@ -984,10 +983,8 @@ again:
extent_end = other_end;
del_slot = path->slots[0] + 1;
del_nr++;
-   ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
-   0, root->root_key.objectid,
-   ino, orig_offset);
-   BUG_ON(ret);
+   btrfs_free_extent(trans, root, bytenr, num_bytes, 0,
+ root->root_key.objectid, ino, orig_offset);
}
other_start = 0;
other_end = start;
@@ -1001,10 +998,8 @@ again:
key.offset = other_start;
del_slot = path->slots[0];
del_nr++;
-   ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
-   0, root->root_key.objectid,
-   ino, orig_offset);
-   BUG_ON(ret);
+   btrfs_free_extent(trans, root, bytenr, num_bytes, 0,
+ root->root_key.objectid, ino, orig_offset);
}
if (del_nr == 0) {
fi = btrfs_item_ptr(leaf, path->slots[0],
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 46f3d4a..d8bb54e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3270,11 +3270,10 @@ delete:
if (found_extent && (root->ref_cows ||
 root == root->fs_info->tree_root)) {
btrfs_set_path_blocking(path);
-   ret = btrfs_free_extent(trans, root, extent_start,
-   extent_num_bytes, 0,
-   btrfs_header_owner(leaf),
-   ino, extent

[patch 55/66] btrfs: Use mempools for delayed refs

2011-10-24 Thread Jeff Mahoney
 This patch converts the delayed ref code to use slab cache-backed mempools
 for allocating its nodes.

 The allocations happen deep in the call path where error recovery is
 impossible.

 By using mempools, we ensure that the allocations can't fail. Each
 mempool keeps a page of structures available for each type.

 This also has an advantage of eliminating the error path from a big
 chunk of code, simplifying the error handling.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/delayed-ref.c |  119 ++--
 fs/btrfs/delayed-ref.h |6 ++-
 fs/btrfs/super.c   |9 +++-
 3 files changed, 107 insertions(+), 27 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index e388ca3..a70c40d 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -18,11 +18,20 @@
 
 #include 
 #include 
+#include 
 #include 
 #include "ctree.h"
 #include "delayed-ref.h"
 #include "transaction.h"
 
+static struct kmem_cache *ref_head_cache;
+static struct kmem_cache *tree_ref_cache;
+static struct kmem_cache *data_ref_cache;
+
+static mempool_t *ref_head_pool;
+static mempool_t *tree_ref_pool;
+static mempool_t *data_ref_pool;
+
 /*
  * delayed back reference update tracking.  For subvolume trees
  * we queue up extent allocations and backref maintenance for
@@ -455,7 +464,7 @@ static noinline void add_delayed_ref_head(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(head_ref);
+   mempool_free(head_ref, ref_head_pool);
} else {
delayed_refs->num_heads++;
delayed_refs->num_heads_ready++;
@@ -510,7 +519,7 @@ static noinline void add_delayed_tree_ref(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(full_ref);
+   mempool_free(full_ref, tree_ref_pool);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
@@ -565,7 +574,7 @@ static noinline void add_delayed_data_ref(struct 
btrfs_trans_handle *trans,
 * we've updated the existing ref, free the newly
 * allocated ref
 */
-   kfree(full_ref);
+   mempool_free(full_ref, data_ref_pool);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
@@ -587,15 +596,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
struct btrfs_delayed_ref_root *delayed_refs;
 
BUG_ON(extent_op && extent_op->is_data);
-   ref = kmalloc(sizeof(*ref), GFP_NOFS);
-   if (!ref)
-   return -ENOMEM;
-
-   head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS);
-   if (!head_ref) {
-   kfree(ref);
-   return -ENOMEM;
-   }
+   ref = mempool_alloc(tree_ref_pool, GFP_NOFS);
+   head_ref = mempool_alloc(ref_head_pool, GFP_NOFS);
 
head_ref->extent_op = extent_op;
 
@@ -628,15 +630,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle 
*trans,
struct btrfs_delayed_ref_root *delayed_refs;
 
BUG_ON(extent_op && !extent_op->is_data);
-   ref = kmalloc(sizeof(*ref), GFP_NOFS);
-   if (!ref)
-   return -ENOMEM;
-
-   head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS);
-   if (!head_ref) {
-   kfree(ref);
-   return -ENOMEM;
-   }
+   ref = mempool_alloc(data_ref_pool, GFP_NOFS);
+   head_ref = mempool_alloc(ref_head_pool, GFP_NOFS);
 
head_ref->extent_op = extent_op;
 
@@ -662,10 +657,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle 
*trans,
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
 
-   head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS);
-   if (!head_ref)
-   return -ENOMEM;
-
+   head_ref = mempool_alloc(ref_head_pool, GFP_NOFS);
head_ref->extent_op = extent_op;
 
delayed_refs = &trans->transaction->delayed_refs;
@@ -694,3 +686,80 @@ btrfs_find_delayed_ref_head(struct btrfs_trans_handle 
*trans, u64 bytenr)
return btrfs_delayed_node_to_head(ref);
return NULL;
 }
+
+void btrfs_free_delayed_ref(struct btrfs_delayed_ref_node *ref)
+{
+   if (!ref->type)
+   mempool_free(ref, ref_head_pool);
+   else if (ref->type == BTRFS_SHARED_BLOCK_REF_KEY ||
+ref->type == BTRFS_TREE_BLOCK_REF_KEY)
+   mempool_free(ref, tree_ref_pool);
+   else if (ref->type == BTRFS_SHARED_DATA_REF_KEY ||
+ref->type == BTRFS_EXTENT_DATA_REF_KEY)
+   mempool_free(ref, data_ref_pool);
+   else
+   BUG();
+}
+
+void
+btrfs_destroy_delayed_ref_caches(void)
+{
+   if (data_ref_po

[patch 56/66] btrfs: Delayed ref mempool functions should return void

2011-10-24 Thread Jeff Mahoney
 Now that the delayed ref code uses mempools, allocations can't fail,
 and there are no more error conditions to report.

 This patch makes the following functions return void:
 - btrfs_alloc_reserved_file_extent
 - btrfs_add_delayed_tree_ref
 - btrfs_add_delayed_data_ref
 - btrfs_add_delayed_extent_op

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |8 ++--
 fs/btrfs/delayed-ref.c |   27 +++-
 fs/btrfs/delayed-ref.h |   24 +++---
 fs/btrfs/extent-tree.c |   78 ---
 fs/btrfs/inode.c   |6 +--
 5 files changed, 63 insertions(+), 80 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index ea47c73..f704253 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2179,10 +2179,10 @@ struct extent_buffer *btrfs_init_new_buffer(struct 
btrfs_trans_handle *trans,
struct btrfs_root *root,
u64 bytenr, u32 blocksize,
int level);
-int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
-struct btrfs_root *root,
-u64 root_objectid, u64 owner,
-u64 offset, struct btrfs_key *ins);
+void btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 root_objectid, u64 owner,
+ u64 offset, struct btrfs_key *ins);
 int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
   struct btrfs_root *root,
   u64 root_objectid, u64 owner, u64 offset,
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index a70c40d..16aea4e 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -586,10 +586,10 @@ static noinline void add_delayed_data_ref(struct 
btrfs_trans_handle *trans,
  * to make sure the delayed ref is eventually processed before this
  * transaction commits.
  */
-int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
-  u64 bytenr, u64 num_bytes, u64 parent,
-  u64 ref_root,  int level, int action,
-  struct btrfs_delayed_extent_op *extent_op)
+void btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
+   u64 bytenr, u64 num_bytes, u64 parent,
+   u64 ref_root,  int level, int action,
+   struct btrfs_delayed_extent_op *extent_op)
 {
struct btrfs_delayed_tree_ref *ref;
struct btrfs_delayed_ref_head *head_ref;
@@ -613,17 +613,16 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, parent,
 ref_root, level, action);
spin_unlock(&delayed_refs->lock);
-   return 0;
 }
 
 /*
  * add a delayed data ref. it's similar to btrfs_add_delayed_tree_ref.
  */
-int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
-  u64 bytenr, u64 num_bytes,
-  u64 parent, u64 ref_root,
-  u64 owner, u64 offset, int action,
-  struct btrfs_delayed_extent_op *extent_op)
+void btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
+   u64 bytenr, u64 num_bytes,
+   u64 parent, u64 ref_root,
+   u64 owner, u64 offset, int action,
+   struct btrfs_delayed_extent_op *extent_op)
 {
struct btrfs_delayed_data_ref *ref;
struct btrfs_delayed_ref_head *head_ref;
@@ -647,12 +646,11 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle 
*trans,
add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, parent,
 ref_root, owner, offset, action);
spin_unlock(&delayed_refs->lock);
-   return 0;
 }
 
-int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,
-   u64 bytenr, u64 num_bytes,
-   struct btrfs_delayed_extent_op *extent_op)
+void btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,
+u64 bytenr, u64 num_bytes,
+struct btrfs_delayed_extent_op *extent_op)
 {
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
@@ -666,7 +664,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle 
*trans,
add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
 BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data);
spin_unlock(&delayed_ref

[patch 57/66] btrfs: btrfs_inc_extent_ref void return prep

2011-10-24 Thread Jeff Mahoney
 btrfs_inc_extent_ref has no error conditions, but is used via
 process_func in __btrfs_mod_ref which requires it to return an int.

 This patch cleans up the callers to eliminate error handling that will
 never be used. A later patch in this series makes both
 btrfs_inc_extent_ref and the other function used via process_func,
 btrfs_inc_extent_ref, return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/file.c   |   18 --
 fs/btrfs/ioctl.c  |3 +--
 fs/btrfs/relocation.c |   34 ++
 fs/btrfs/tree-log.c   |9 -
 4 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 74f50ba..314c08e 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -673,12 +673,11 @@ next_slot:
btrfs_mark_buffer_dirty(leaf);
 
if (disk_bytenr > 0) {
-   ret = btrfs_inc_extent_ref(trans, root,
-   disk_bytenr, num_bytes, 0,
-   root->root_key.objectid,
-   new_key.objectid,
-   start - extent_offset);
-   BUG_ON(ret);
+   btrfs_inc_extent_ref(trans, root,
+disk_bytenr, num_bytes, 0,
+root->root_key.objectid,
+new_key.objectid,
+start - extent_offset);
*hint_byte = disk_bytenr;
}
key.offset = start;
@@ -959,10 +958,9 @@ again:
extent_end - split);
btrfs_mark_buffer_dirty(leaf);
 
-   ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
-  root->root_key.objectid,
-  ino, orig_offset);
-   BUG_ON(ret);
+   btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
+root->root_key.objectid,
+ino, orig_offset);
 
if (split == start) {
key.offset = start;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a7450b3..4cef4f1 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2402,12 +2402,11 @@ static noinline long btrfs_ioctl_clone(struct file 
*file, unsigned long srcfd,
datal);
if (disko) {
inode_add_bytes(inode, datal);
-   ret = btrfs_inc_extent_ref(trans, root,
+   btrfs_inc_extent_ref(trans, root,
disko, diskl, 0,
root->root_key.objectid,
btrfs_ino(inode),
new_key.offset - datao);
-   BUG_ON(ret);
}
} else if (type == BTRFS_FILE_EXTENT_INLINE) {
u64 skip = 0;
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index f2ff530..4c65c4e 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1628,11 +1628,10 @@ int replace_file_extents(struct btrfs_trans_handle 
*trans,
dirty = 1;
 
key.offset -= btrfs_file_extent_offset(leaf, fi);
-   ret = btrfs_inc_extent_ref(trans, root, new_bytenr,
-  num_bytes, parent,
-  btrfs_header_owner(leaf),
-  key.objectid, key.offset);
-   BUG_ON(ret);
+   btrfs_inc_extent_ref(trans, root, new_bytenr,
+num_bytes, parent,
+btrfs_header_owner(leaf),
+key.objectid, key.offset);
 
ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
parent, btrfs_header_owner(leaf),
@@ -1803,15 +1802,11 @@ again:
  path->slots[level], old_ptr_gen);
btrfs_mark_buffer_dirty(path->nodes[level]);
 
-   ret = btrfs_inc_extent_ref(trans, src, old_bytenr, blocksize,
-   path->nodes[level]->start,
-   src->root_key.objectid, level - 1, 0);
-   BUG_ON(ret);
-  

[patch 64/66] btrfs: end_compressed_writeback should return void

2011-10-24 Thread Jeff Mahoney
 end_compressed_writeback has no error conditions and should return
 void. Its callers already ignore the error code anyway.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/compression.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 0c0e842..6c4d228 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -225,8 +225,8 @@ out:
  * Clear the writeback bits on all of the file
  * pages for a compressed write
  */
-static noinline int end_compressed_writeback(struct inode *inode, u64 start,
-unsigned long ram_size)
+static noinline void end_compressed_writeback(struct inode *inode, u64 start,
+ unsigned long ram_size)
 {
unsigned long index = start >> PAGE_CACHE_SHIFT;
unsigned long end_index = (start + ram_size - 1) >> PAGE_CACHE_SHIFT;
@@ -252,7 +252,6 @@ static noinline int end_compressed_writeback(struct inode 
*inode, u64 start,
index += ret;
}
/* the inode may be gone now */
-   return 0;
 }
 
 /*



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 62/66] btrfs: btrfs_truncate_item should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_truncate_item has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c   |   11 +--
 fs/btrfs/ctree.h   |8 
 fs/btrfs/dir-item.c|4 ++--
 fs/btrfs/extent-tree.c |3 +--
 fs/btrfs/file-item.c   |4 ++--
 fs/btrfs/inode-item.c  |3 +--
 fs/btrfs/inode.c   |4 ++--
 7 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index bdaf3ad..12c66ea 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3193,10 +3193,10 @@ int btrfs_duplicate_item(struct btrfs_trans_handle 
*trans,
  * off the end of the item or if we shift the item to chop bytes off
  * the front.
  */
-int btrfs_truncate_item(struct btrfs_trans_handle *trans,
-   struct btrfs_root *root,
-   struct btrfs_path *path,
-   u32 new_size, int from_end)
+void btrfs_truncate_item(struct btrfs_trans_handle *trans,
+struct btrfs_root *root,
+struct btrfs_path *path,
+u32 new_size, int from_end)
 {
int slot;
struct extent_buffer *leaf;
@@ -3213,7 +3213,7 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
 
old_size = btrfs_item_size_nr(leaf, slot);
if (old_size == new_size)
-   return 0;
+   return;
 
nritems = btrfs_header_nritems(leaf);
data_end = leaf_data_end(root, leaf);
@@ -3286,7 +3286,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
btrfs_print_leaf(root, leaf);
BUG();
}
-   return 0;
 }
 
 /*
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 51f2840..5d1e06c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2307,10 +2307,10 @@ int btrfs_block_can_be_shared(struct btrfs_root *root,
  struct extent_buffer *buf);
 int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
  *root, struct btrfs_path *path, u32 data_size);
-int btrfs_truncate_item(struct btrfs_trans_handle *trans,
-   struct btrfs_root *root,
-   struct btrfs_path *path,
-   u32 new_size, int from_end);
+void btrfs_truncate_item(struct btrfs_trans_handle *trans,
+struct btrfs_root *root,
+struct btrfs_path *path,
+u32 new_size, int from_end);
 int btrfs_split_item(struct btrfs_trans_handle *trans,
 struct btrfs_root *root,
 struct btrfs_path *path,
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 31d84e7..c95fc70 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -383,8 +383,8 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle 
*trans,
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);
+   btrfs_truncate_item(trans, root, path,
+   item_len - sub_item_len, 1);
}
return ret;
 }
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fac996d..4ab965d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1666,7 +1666,6 @@ int update_inline_extent_backref(struct 
btrfs_trans_handle *trans,
u32 item_size;
int size;
int type;
-   int ret;
u64 refs;
 
leaf = path->nodes[0];
@@ -1708,7 +1707,7 @@ int update_inline_extent_backref(struct 
btrfs_trans_handle *trans,
memmove_extent_buffer(leaf, ptr, ptr + size,
  end - ptr - size);
item_size -= size;
-   ret = btrfs_truncate_item(trans, root, path, item_size, 1);
+   btrfs_truncate_item(trans, root, path, item_size, 1);
}
btrfs_mark_buffer_dirty(leaf);
return 0;
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 8d5272d..319129e 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -514,7 +514,7 @@ static noinline int truncate_one_csum(struct 
btrfs_trans_handle *trans,
 */
u32 new_size = (bytenr - key->offset) >> blocksize_bits;
new_size *= csum_size;
-   ret = btrfs_truncate_item(trans, root, path, new_size, 1);
+   btrfs_truncate_item(trans, root, path, new_size, 1);
} else if (key->offset >= bytenr && csum_end > end_byte &&
   end_byte > key->offset) {
/*
@@ -526,7 +526,7 @@ static noinline int truncate_one_csum(struct 
btrfs_trans_handle *trans,
u32 new_size = (csum_end - en

[patch 65/66] btrfs: copy_for_split should return void

2011-10-24 Thread Jeff Mahoney
 copy_for_split has no error conditions and should return void. We
 return 0 from split_leaf instead of ret since ret would have been
 set using the return value from copy_for_split which would have been 0.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 4c9dc73..263abce 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2695,12 +2695,12 @@ out:
  *
  * returns 0 if all went well and < 0 on failure.
  */
-static noinline int copy_for_split(struct btrfs_trans_handle *trans,
-  struct btrfs_root *root,
-  struct btrfs_path *path,
-  struct extent_buffer *l,
-  struct extent_buffer *right,
-  int slot, int mid, int nritems)
+static noinline void copy_for_split(struct btrfs_trans_handle *trans,
+   struct btrfs_root *root,
+   struct btrfs_path *path,
+   struct extent_buffer *l,
+   struct extent_buffer *right,
+   int slot, int mid, int nritems)
 {
int data_copy_size;
int rt_data_off;
@@ -2752,8 +2752,6 @@ static noinline int copy_for_split(struct 
btrfs_trans_handle *trans,
}
 
BUG_ON(path->slots[0] < 0);
-
-   return 0;
 }
 
 /*
@@ -2965,8 +2963,7 @@ again:
return ret;
}
 
-   ret = copy_for_split(trans, root, path, l, right, slot, mid, nritems);
-   BUG_ON(ret);
+   copy_for_split(trans, root, path, l, right, slot, mid, nritems);
 
if (split == 2) {
BUG_ON(num_doubles != 0);
@@ -2974,7 +2971,7 @@ again:
goto again;
}
 
-   return ret;
+   return 0;
 
 push_for_double:
push_for_double_split(trans, root, path, data_size);



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 60/66] btrfs: __btrfs_mod_ref should return void

2011-10-24 Thread Jeff Mahoney
 Now that process_func can't return an error, __btrfs_mod_ref has no more
 error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c   |   30 ++
 fs/btrfs/ctree.h   |8 
 fs/btrfs/extent-tree.c |   34 +++---
 3 files changed, 29 insertions(+), 43 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 2604ec4..bdaf3ad 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -224,7 +224,6 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
  struct extent_buffer **cow_ret, u64 new_root_objectid)
 {
struct extent_buffer *cow;
-   int ret = 0;
int level;
struct btrfs_disk_key disk_key;
 
@@ -261,12 +260,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
 
WARN_ON(btrfs_header_generation(buf) > trans->transid);
if (new_root_objectid == BTRFS_TREE_RELOC_OBJECTID)
-   ret = btrfs_inc_ref(trans, root, cow, 1);
+   btrfs_inc_ref(trans, root, cow, 1);
else
-   ret = btrfs_inc_ref(trans, root, cow, 0);
-
-   if (ret)
-   return ret;
+   btrfs_inc_ref(trans, root, cow, 0);
 
btrfs_mark_buffer_dirty(cow);
*cow_ret = cow;
@@ -350,25 +346,21 @@ static noinline int update_ref_for_cow(struct 
btrfs_trans_handle *trans,
if ((owner == root->root_key.objectid ||
 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) &&
!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) {
-   ret = btrfs_inc_ref(trans, root, buf, 1);
-   BUG_ON(ret);
+   btrfs_inc_ref(trans, root, buf, 1);
 
if (root->root_key.objectid ==
BTRFS_TREE_RELOC_OBJECTID) {
-   ret = btrfs_dec_ref(trans, root, buf, 0);
-   BUG_ON(ret);
-   ret = btrfs_inc_ref(trans, root, cow, 1);
-   BUG_ON(ret);
+   btrfs_dec_ref(trans, root, buf, 0);
+   btrfs_inc_ref(trans, root, cow, 1);
}
new_flags |= BTRFS_BLOCK_FLAG_FULL_BACKREF;
} else {
 
if (root->root_key.objectid ==
BTRFS_TREE_RELOC_OBJECTID)
-   ret = btrfs_inc_ref(trans, root, cow, 1);
+   btrfs_inc_ref(trans, root, cow, 1);
else
-   ret = btrfs_inc_ref(trans, root, cow, 0);
-   BUG_ON(ret);
+   btrfs_inc_ref(trans, root, cow, 0);
}
if (new_flags != 0) {
ret = btrfs_set_disk_extent_flags(trans, root,
@@ -381,12 +373,10 @@ static noinline int update_ref_for_cow(struct 
btrfs_trans_handle *trans,
if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
if (root->root_key.objectid ==
BTRFS_TREE_RELOC_OBJECTID)
-   ret = btrfs_inc_ref(trans, root, cow, 1);
+   btrfs_inc_ref(trans, root, cow, 1);
else
-   ret = btrfs_inc_ref(trans, root, cow, 0);
-   BUG_ON(ret);
-   ret = btrfs_dec_ref(trans, root, buf, 1);
-   BUG_ON(ret);
+   btrfs_inc_ref(trans, root, cow, 0);
+   btrfs_dec_ref(trans, root, buf, 1);
}
clean_tree_block(trans, root, buf);
*last_ref = 1;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b791b8f..51f2840 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2193,10 +2193,10 @@ int btrfs_reserve_extent(struct btrfs_trans_handle 
*trans,
  u64 empty_size, u64 hint_byte,
  u64 search_end, struct btrfs_key *ins,
  u64 data);
-int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
- struct extent_buffer *buf, int full_backref);
-int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
- struct extent_buffer *buf, int full_backref);
+void btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+  struct extent_buffer *buf, int full_backref);
+void btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+  struct extent_buffer *buf, int full_backref);
 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64 bytenr, u64 num_bytes, u64 f

[patch 59/66] btrfs: __btrfs_mod_refs process_func should return void

2011-10-24 Thread Jeff Mahoney
 __btrfs_mod_ref's process_func function pointer calls btrfs_free_extent
 and btrfs_inc_extent_ref, which now both return only 0. This patches
 makes them return void and eliminates the error condition in
 __btrfs_mod_ref.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.h   |   16 
 fs/btrfs/extent-tree.c |   39 ++-
 2 files changed, 22 insertions(+), 33 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2201,20 +2201,20 @@ int btrfs_set_disk_extent_flags(struct b
struct btrfs_root *root,
u64 bytenr, u64 num_bytes, u64 flags,
int is_data);
-int btrfs_free_extent(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
- u64 bytenr, u64 num_bytes, u64 parent,
- u64 root_objectid, u64 owner, u64 offset);
+void btrfs_free_extent(struct btrfs_trans_handle *trans,
+  struct btrfs_root *root,
+  u64 bytenr, u64 num_bytes, u64 parent,
+  u64 root_objectid, u64 owner, u64 offset);
 
 int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len);
 void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
 struct btrfs_root *root);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
   struct btrfs_root *root);
-int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-struct btrfs_root *root,
-u64 bytenr, u64 num_bytes, u64 parent,
-u64 root_objectid, u64 owner, u64 offset);
+void btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 bytenr, u64 num_bytes, u64 parent,
+ u64 root_objectid, u64 owner, u64 offset);
 
 int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1832,10 +1832,10 @@ static int btrfs_discard_extent(struct b
return ret;
 }
 
-int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-struct btrfs_root *root,
-u64 bytenr, u64 num_bytes, u64 parent,
-u64 root_objectid, u64 owner, u64 offset)
+void btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 bytenr, u64 num_bytes, u64 parent,
+ u64 root_objectid, u64 owner, u64 offset)
 {
BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID &&
   root_objectid == BTRFS_TREE_LOG_OBJECTID);
@@ -1849,7 +1849,6 @@ int btrfs_inc_extent_ref(struct btrfs_tr
   root_objectid, owner, offset,
   BTRFS_ADD_DELAYED_REF, NULL);
}
-   return 0;
 }
 
 static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
@@ -2566,9 +2565,8 @@ static int __btrfs_mod_ref(struct btrfs_
struct btrfs_file_extent_item *fi;
int i;
int level;
-   int ret = 0;
-   int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
-   u64, u64, u64, u64, u64, u64);
+   void (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
+u64, u64, u64, u64, u64, u64);
 
ref_root = btrfs_header_owner(buf);
nritems = btrfs_header_nritems(buf);
@@ -2603,24 +2601,16 @@ static int __btrfs_mod_ref(struct btrfs_
 
num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
key.offset -= btrfs_file_extent_offset(buf, fi);
-   ret = process_func(trans, root, bytenr, num_bytes,
-  parent, ref_root, key.objectid,
-  key.offset);
-   if (ret)
-   goto fail;
+   process_func(trans, root, bytenr, num_bytes, parent,
+ref_root, key.objectid, key.offset);
} else {
bytenr = btrfs_node_blockptr(buf, i);
num_bytes = btrfs_level_size(root, level - 1);
-   ret = process_func(trans, root, bytenr, num_bytes,
-  parent, ref_root, level - 1, 0);
-   if (ret)
-   goto fail;
+   process_func(trans, root, bytenr, num_bytes, parent,
+ref_root, level - 1, 0);
}
}
return 0;
-fail:
-   BUG();
-   return ret;
 }
 
 int btrfs_inc_

[patch 61/66] btrfs: clean_tree_block should return void

2011-10-24 Thread Jeff Mahoney
 clean_tree_block has no error conditions and should return void. Its
 callers already ignore the error codes.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c |5 ++---
 fs/btrfs/disk-io.h |4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index fcb0f7f..e16a3e9 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1033,8 +1033,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root 
*root, u64 bytenr,
 
 }
 
-int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-struct extent_buffer *buf)
+void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root 
*root,
+ struct extent_buffer *buf)
 {
struct inode *btree_inode = root->fs_info->btree_inode;
if (btrfs_header_generation(buf) ==
@@ -1055,7 +1055,6 @@ int clean_tree_block(struct btrfs_trans_handle *trans, 
struct btrfs_root *root,
clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree,
  buf);
}
-   return 0;
 }
 
 static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index bec3ea4..5a2604a 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -42,8 +42,8 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, 
u32 blocksize,
 u64 parent_transid);
 struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
   u64 bytenr, u32 blocksize);
-int clean_tree_block(struct btrfs_trans_handle *trans,
-struct btrfs_root *root, struct extent_buffer *buf);
+void clean_tree_block(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, struct extent_buffer *buf);
 struct btrfs_root *open_ctree(struct super_block *sb,
  struct btrfs_fs_devices *fs_devices,
  char *options);



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 63/66] btrfs: btrfs_extend_item should return void

2011-10-24 Thread Jeff Mahoney
 btrfs_extend_item has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c   |7 +++
 fs/btrfs/ctree.h   |5 +++--
 fs/btrfs/dir-item.c|5 ++---
 fs/btrfs/extent-tree.c |5 ++---
 fs/btrfs/file-item.c   |2 +-
 fs/btrfs/inode-item.c  |2 +-
 fs/btrfs/tree-log.c|9 -
 7 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 12c66ea..4c9dc73 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3291,9 +3291,9 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans,
 /*
  * make the item pointed to by the path bigger, data_size is the new size.
  */
-int btrfs_extend_item(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, struct btrfs_path *path,
- u32 data_size)
+void btrfs_extend_item(struct btrfs_trans_handle *trans,
+  struct btrfs_root *root, struct btrfs_path *path,
+  u32 data_size)
 {
int slot;
struct extent_buffer *leaf;
@@ -3351,7 +3351,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
btrfs_print_leaf(root, leaf);
BUG();
}
-   return 0;
 }
 
 /*
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 5d1e06c..5dee97f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2305,8 +2305,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
  struct extent_buffer **cow_ret, u64 new_root_objectid);
 int btrfs_block_can_be_shared(struct btrfs_root *root,
  struct extent_buffer *buf);
-int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
- *root, struct btrfs_path *path, u32 data_size);
+void btrfs_extend_item(struct btrfs_trans_handle *trans,
+  struct btrfs_root *root, struct btrfs_path *path,
+  u32 data_size);
 void btrfs_truncate_item(struct btrfs_trans_handle *trans,
 struct btrfs_root *root,
 struct btrfs_path *path,
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index c95fc70..7674330 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -49,9 +49,8 @@ static struct btrfs_dir_item *insert_with_overflow(struct 
btrfs_trans_handle
di = btrfs_match_dir_item_name(root, path, name, name_len);
if (di)
return ERR_PTR(-EEXIST);
-   ret = btrfs_extend_item(trans, root, path, data_size);
-   }
-   if (ret < 0)
+   btrfs_extend_item(trans, root, path, data_size);
+   } else if (ret < 0)
return ERR_PTR(ret);
WARN_ON(ret > 0);
leaf = path->nodes[0];
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 4ab965d..201822d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -974,7 +974,7 @@ static int convert_extent_item_v0(struct btrfs_trans_handle 
*trans,
return ret;
BUG_ON(ret);
 
-   ret = btrfs_extend_item(trans, root, path, new_size);
+   btrfs_extend_item(trans, root, path, new_size);
 
leaf = path->nodes[0];
item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1572,7 +1572,6 @@ void setup_inline_extent_backref(struct 
btrfs_trans_handle *trans,
u64 refs;
int size;
int type;
-   int ret;
 
leaf = path->nodes[0];
ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
@@ -1581,7 +1580,7 @@ void setup_inline_extent_backref(struct 
btrfs_trans_handle *trans,
type = extent_ref_type(parent, owner);
size = btrfs_extent_inline_ref_size(type);
 
-   ret = btrfs_extend_item(trans, root, path, size);
+   btrfs_extend_item(trans, root, path, size);
 
ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
refs = btrfs_extent_refs(leaf, ei);
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 319129e..4a73745 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -778,7 +778,7 @@ again:
if (diff != csum_size)
goto insert;
 
-   ret = btrfs_extend_item(trans, root, path, diff);
+   btrfs_extend_item(trans, root, path, diff);
goto csum;
}
 
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
index c04018c..9f0d038 100644
--- a/fs/btrfs/inode-item.c
+++ b/fs/btrfs/inode-item.c
@@ -164,7 +164,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
goto out;
 
old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
-   ret = btrfs_extend_item(trans, root, path, ins_len);
+   btrfs_extend_item(trans, root, path, ins_len);
ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
  

[patch 66/66] btrfs: update_inline_extent_backref should return void

2011-10-24 Thread Jeff Mahoney
 Now that btrfs_truncate_item returns void, there are no more error
 conditions in update_inline_extent_backref and it should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent-tree.c |   23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1649,12 +1649,12 @@ static int lookup_extent_backref(struct
  * helper to update/remove inline back ref
  */
 static noinline_for_stack
-int update_inline_extent_backref(struct btrfs_trans_handle *trans,
-struct btrfs_root *root,
-struct btrfs_path *path,
-struct btrfs_extent_inline_ref *iref,
-int refs_to_mod,
-struct btrfs_delayed_extent_op *extent_op)
+void update_inline_extent_backref(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_path *path,
+ struct btrfs_extent_inline_ref *iref,
+ int refs_to_mod,
+ struct btrfs_delayed_extent_op *extent_op)
 {
struct extent_buffer *leaf;
struct btrfs_extent_item *ei;
@@ -1709,7 +1709,6 @@ int update_inline_extent_backref(struct
btrfs_truncate_item(trans, root, path, item_size, 1);
}
btrfs_mark_buffer_dirty(leaf);
-   return 0;
 }
 
 static noinline_for_stack
@@ -1729,8 +1728,8 @@ int insert_inline_extent_backref(struct
   root_objectid, owner, offset, 1);
if (ret == 0) {
BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID);
-   ret = update_inline_extent_backref(trans, root, path, iref,
-  refs_to_add, extent_op);
+   update_inline_extent_backref(trans, root, path, iref,
+refs_to_add, extent_op);
} else if (ret == -ENOENT) {
setup_inline_extent_backref(trans, root, path, iref, parent,
root_objectid, owner, offset,
@@ -1765,12 +1764,12 @@ static int remove_extent_backref(struct
 struct btrfs_extent_inline_ref *iref,
 int refs_to_drop, int is_data)
 {
-   int ret;
+   int ret = 0;
 
BUG_ON(!is_data && refs_to_drop != 1);
if (iref) {
-   ret = update_inline_extent_backref(trans, root, path, iref,
-  -refs_to_drop, NULL);
+   update_inline_extent_backref(trans, root, path, iref,
+-refs_to_drop, NULL);
} else if (is_data) {
ret = remove_extent_data_ref(trans, root, path, refs_to_drop);
} else {


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 51/66] btrfs: add_delayed_ref_head should return void

2011-10-24 Thread Jeff Mahoney
 add_delayed_ref_head has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/delayed-ref.c |   29 ++---
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 125cf76..caa9ade 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -390,10 +390,10 @@ update_existing_head_ref(struct btrfs_delayed_ref_node 
*existing,
  * this does all the dirty work in terms of maintaining the correct
  * overall modification count.
  */
-static noinline int add_delayed_ref_head(struct btrfs_trans_handle *trans,
-   struct btrfs_delayed_ref_node *ref,
-   u64 bytenr, u64 num_bytes,
-   int action, int is_data)
+static noinline void add_delayed_ref_head(struct btrfs_trans_handle *trans,
+struct btrfs_delayed_ref_node *ref,
+u64 bytenr, u64 num_bytes,
+int action, int is_data)
 {
struct btrfs_delayed_ref_node *existing;
struct btrfs_delayed_ref_head *head_ref = NULL;
@@ -462,7 +462,6 @@ static noinline int add_delayed_ref_head(struct 
btrfs_trans_handle *trans,
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
}
-   return 0;
 }
 
 /*
@@ -610,10 +609,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
 * insert both the head node and the new ref without dropping
 * the spin lock
 */
-   ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
-  action, 0);
-   BUG_ON(ret);
-
+   add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
+action, 0);
ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes,
   parent, ref_root, level, action);
BUG_ON(ret);
@@ -655,10 +652,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle 
*trans,
 * insert both the head node and the new ref without dropping
 * the spin lock
 */
-   ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
-  action, 1);
-   BUG_ON(ret);
-
+   add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
+action, 1);
ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes,
   parent, ref_root, owner, offset, action);
BUG_ON(ret);
@@ -672,7 +667,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle 
*trans,
 {
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
-   int ret;
 
head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS);
if (!head_ref)
@@ -683,11 +677,8 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle 
*trans,
delayed_refs = &trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
 
-   ret = add_delayed_ref_head(trans, &head_ref->node, bytenr,
-  num_bytes, BTRFS_UPDATE_DELAYED_HEAD,
-  extent_op->is_data);
-   BUG_ON(ret);
-
+   add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
+BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data);
spin_unlock(&delayed_refs->lock);
return 0;
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 48/66] btrfs: setup_items_for_insert should return void

2011-10-24 Thread Jeff Mahoney
 setup_items_for_insert now has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/ctree.c |   26 ++
 fs/btrfs/ctree.h |8 
 fs/btrfs/delayed-inode.c |6 ++
 3 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index dedd3a1..fdaddcc 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2516,7 +2516,6 @@ static noinline int __push_leaf_left(struct 
btrfs_trans_handle *trans,
u32 old_left_nritems;
u32 nr;
int ret = 0;
-   int wret;
u32 this_item_size;
u32 old_left_item_size;
 
@@ -3212,11 +3211,9 @@ int btrfs_duplicate_item(struct btrfs_trans_handle 
*trans,
return ret;
 
path->slots[0]++;
-   ret = setup_items_for_insert(trans, root, path, new_key, &item_size,
-item_size, item_size +
-sizeof(struct btrfs_item), 1);
-   BUG_ON(ret);
-
+   setup_items_for_insert(trans, root, path, new_key, &item_size,
+  item_size, item_size +
+  sizeof(struct btrfs_item), 1);
leaf = path->nodes[0];
memcpy_extent_buffer(leaf,
 btrfs_item_ptr_offset(leaf, path->slots[0]),
@@ -3536,10 +3533,10 @@ out:
  * to save stack depth by doing the bulk of the work in a function
  * that doesn't call btrfs_search_slot
  */
-int setup_items_for_insert(struct btrfs_trans_handle *trans,
-  struct btrfs_root *root, struct btrfs_path *path,
-  struct btrfs_key *cpu_key, u32 *data_size,
-  u32 total_data, u32 total_size, int nr)
+void setup_items_for_insert(struct btrfs_trans_handle *trans,
+   struct btrfs_root *root, struct btrfs_path *path,
+   struct btrfs_key *cpu_key, u32 *data_size,
+   u32 total_data, u32 total_size, int nr)
 {
struct btrfs_item *item;
int i;
@@ -3617,7 +3614,6 @@ int setup_items_for_insert(struct btrfs_trans_handle 
*trans,
btrfs_print_leaf(root, leaf);
BUG();
}
-   return ret;
 }
 
 /*
@@ -3644,16 +3640,14 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle 
*trans,
if (ret == 0)
return -EEXIST;
if (ret < 0)
-   goto out;
+   return ret;
 
slot = path->slots[0];
BUG_ON(slot < 0);
 
-   ret = setup_items_for_insert(trans, root, path, cpu_key, data_size,
+   setup_items_for_insert(trans, root, path, cpu_key, data_size,
   total_data, total_size, nr);
-
-out:
-   return ret;
+   return 0;
 }
 
 /*
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c866167..ea47c73 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2344,10 +2344,10 @@ static inline int btrfs_del_item(struct 
btrfs_trans_handle *trans,
return btrfs_del_items(trans, root, path, path->slots[0], 1);
 }
 
-int setup_items_for_insert(struct btrfs_trans_handle *trans,
-  struct btrfs_root *root, struct btrfs_path *path,
-  struct btrfs_key *cpu_key, u32 *data_size,
-  u32 total_data, u32 total_size, int nr);
+void setup_items_for_insert(struct btrfs_trans_handle *trans,
+   struct btrfs_root *root, struct btrfs_path *path,
+   struct btrfs_key *cpu_key, u32 *data_size,
+   u32 total_data, u32 total_size, int nr);
 int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root
  *root, struct btrfs_key *key, void *data, u32 data_size);
 int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index b52c672..6211997 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -738,10 +738,8 @@ static int btrfs_batch_insert_items(struct 
btrfs_trans_handle *trans,
btrfs_clear_path_blocking(path, NULL, 0);
 
/* insert the keys of the items */
-   ret = setup_items_for_insert(trans, root, path, keys, data_size,
-total_data_size, total_size, nitems);
-   if (ret)
-   goto error;
+   setup_items_for_insert(trans, root, path, keys, data_size,
+  total_data_size, total_size, nitems);
 
/* insert the dir index items */
slot = path->slots[0];



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 52/66] btrfs: add_delayed_tree_ref should return void

2011-10-24 Thread Jeff Mahoney
 add_delayed_tree_ref has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/delayed-ref.c |   15 ++-
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index caa9ade..3ae2401 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -467,10 +467,10 @@ static noinline void add_delayed_ref_head(struct 
btrfs_trans_handle *trans,
 /*
  * helper to insert a delayed tree ref into the rbtree.
  */
-static noinline int add_delayed_tree_ref(struct btrfs_trans_handle *trans,
-struct btrfs_delayed_ref_node *ref,
-u64 bytenr, u64 num_bytes, u64 parent,
-u64 ref_root, int level, int action)
+static noinline void add_delayed_tree_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_node *ref,
+ u64 bytenr, u64 num_bytes, u64 parent,
+ u64 ref_root, int level, int action)
 {
struct btrfs_delayed_ref_node *existing;
struct btrfs_delayed_tree_ref *full_ref;
@@ -515,7 +515,6 @@ static noinline int add_delayed_tree_ref(struct 
btrfs_trans_handle *trans,
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
}
-   return 0;
 }
 
 /*
@@ -587,7 +586,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
struct btrfs_delayed_tree_ref *ref;
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
-   int ret;
 
BUG_ON(extent_op && extent_op->is_data);
ref = kmalloc(sizeof(*ref), GFP_NOFS);
@@ -611,9 +609,8 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle 
*trans,
 */
add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
 action, 0);
-   ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes,
-  parent, ref_root, level, action);
-   BUG_ON(ret);
+   add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, parent,
+ref_root, level, action);
spin_unlock(&delayed_refs->lock);
return 0;
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 53/66] btrfs: add_delayed_data_ref should return void

2011-10-24 Thread Jeff Mahoney
 add_delayed_data_ref has no error conditions and should return void.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/delayed-ref.c |   17 +++--
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 3ae2401..b004960 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -520,11 +520,11 @@ static noinline void add_delayed_tree_ref(struct 
btrfs_trans_handle *trans,
 /*
  * helper to insert a delayed data ref into the rbtree.
  */
-static noinline int add_delayed_data_ref(struct btrfs_trans_handle *trans,
-struct btrfs_delayed_ref_node *ref,
-u64 bytenr, u64 num_bytes, u64 parent,
-u64 ref_root, u64 owner, u64 offset,
-int action)
+static noinline void add_delayed_data_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_node *ref,
+ u64 bytenr, u64 num_bytes, u64 parent,
+ u64 ref_root, u64 owner, u64 offset,
+ int action)
 {
struct btrfs_delayed_ref_node *existing;
struct btrfs_delayed_data_ref *full_ref;
@@ -570,7 +570,6 @@ static noinline int add_delayed_data_ref(struct 
btrfs_trans_handle *trans,
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
}
-   return 0;
 }
 
 /*
@@ -627,7 +626,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle 
*trans,
struct btrfs_delayed_data_ref *ref;
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
-   int ret;
 
BUG_ON(extent_op && !extent_op->is_data);
ref = kmalloc(sizeof(*ref), GFP_NOFS);
@@ -651,9 +649,8 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle 
*trans,
 */
add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes,
 action, 1);
-   ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes,
-  parent, ref_root, owner, offset, action);
-   BUG_ON(ret);
+   add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, parent,
+ref_root, owner, offset, action);
spin_unlock(&delayed_refs->lock);
return 0;
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 13/66] btrfs: btrfs_start_transaction non-looped error push-up

2011-10-24 Thread Jeff Mahoney
 This patch handles btrfs_start_transaction failures that don't occur
 in a loop and are obvious to simply push up. In all cases except the
 mark_garbage_root case, the error is already handled by BUG_ON in the
 caller.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/extent-tree.c |6 +-
 fs/btrfs/relocation.c  |6 --
 fs/btrfs/tree-log.c|5 -
 fs/btrfs/volumes.c |3 ++-
 4 files changed, 15 insertions(+), 5 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6374,7 +6374,11 @@ int btrfs_drop_snapshot(struct btrfs_roo
}
 
trans = btrfs_start_transaction(tree_root, 0);
-   BUG_ON(IS_ERR(trans));
+   if (IS_ERR(trans)) {
+   kfree(wc);
+   btrfs_free_path(path);
+   return PTR_ERR(trans);
+   }
 
if (block_rsv)
trans->block_rsv = block_rsv;
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4118,7 +4118,8 @@ static noinline_for_stack int mark_garba
int ret;
 
trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
-   BUG_ON(IS_ERR(trans));
+   if (IS_ERR(trans))
+   return PTR_ERR(trans);
 
memset(&root->root_item.drop_progress, 0,
sizeof(root->root_item.drop_progress));
@@ -4198,7 +4199,8 @@ int btrfs_recover_relocation(struct btrf
err = ret;
goto out;
}
-   mark_garbage_root(reloc_root);
+   ret = mark_garbage_root(reloc_root);
+   BUG_ON(ret);
}
}
 
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3171,7 +3171,10 @@ int btrfs_recover_log_trees(struct btrfs
fs_info->log_root_recovering = 1;
 
trans = btrfs_start_transaction(fs_info->tree_root, 0);
-   BUG_ON(IS_ERR(trans));
+   if (IS_ERR(trans)) {
+   btrfs_free_path(path);
+   return PTR_ERR(trans);
+   }
 
wc.trans = trans;
wc.pin = 1;
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1932,7 +1932,8 @@ static int btrfs_relocate_chunk(struct b
return ret;
 
trans = btrfs_start_transaction(root, 0);
-   BUG_ON(IS_ERR(trans));
+   if (IS_ERR(trans))
+   return PTR_ERR(trans);
 
lock_chunks(root);
 


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 07/66] btrfs: clear_extent_bit error push-up

2011-10-24 Thread Jeff Mahoney
 clear_extent_bit can fail with -ENOMEM for a specific case but will BUG
 on other memory allocation failures.

 This patch returns -ENOMEM for memory allocation failures and handles them
 with BUG_ON in callers which don't handle it already.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/disk-io.c  |8 ++-
 fs/btrfs/extent-tree.c  |   14 --
 fs/btrfs/extent_io.c|   61 
 fs/btrfs/extent_io.h|8 +--
 fs/btrfs/file.c |   10 ++--
 fs/btrfs/free-space-cache.c |7 ++-
 fs/btrfs/inode.c|   94 +++-
 fs/btrfs/ioctl.c|9 ++--
 fs/btrfs/relocation.c   |5 +-
 fs/btrfs/transaction.c  |4 +
 fs/btrfs/tree-log.c |5 +-
 11 files changed, 146 insertions(+), 79 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2981,7 +2981,10 @@ static int btrfs_destroy_marked_extents(
if (ret)
break;
 
-   clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS);
+   ret = clear_extent_bits(dirty_pages, start, end, mark,
+   GFP_NOFS);
+   BUG_ON(ret < 0);
+   ret = 0;
while (start <= end) {
index = start >> PAGE_CACHE_SHIFT;
start = (u64)(index + 1) << PAGE_CACHE_SHIFT;
@@ -3042,7 +3045,8 @@ static int btrfs_destroy_pinned_extent(s
 end + 1 - start,
 NULL);
 
-   clear_extent_dirty(unpin, start, end, GFP_NOFS);
+   ret = clear_extent_dirty(unpin, start, end, GFP_NOFS);
+   BUG_ON(ret < 0);
btrfs_error_unpin_extent_range(root, start, end);
cond_resched();
}
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -223,14 +223,17 @@ static void free_excluded_extents(struct
  struct btrfs_block_group_cache *cache)
 {
u64 start, end;
+   int ret;
 
start = cache->key.objectid;
end = start + cache->key.offset - 1;
 
-   clear_extent_bits(&root->fs_info->freed_extents[0],
- start, end, EXTENT_UPTODATE, GFP_NOFS);
-   clear_extent_bits(&root->fs_info->freed_extents[1],
- start, end, EXTENT_UPTODATE, GFP_NOFS);
+   ret = clear_extent_bits(&root->fs_info->freed_extents[0],
+   start, end, EXTENT_UPTODATE, GFP_NOFS);
+   BUG_ON(ret < 0);
+   ret = clear_extent_bits(&root->fs_info->freed_extents[1],
+   start, end, EXTENT_UPTODATE, GFP_NOFS);
+   BUG_ON(ret < 0);
 }
 
 static int exclude_super_stripes(struct btrfs_root *root,
@@ -4478,7 +4481,8 @@ int btrfs_finish_extent_commit(struct bt
ret = btrfs_discard_extent(root, start,
   end + 1 - start, NULL);
 
-   clear_extent_dirty(unpin, start, end, GFP_NOFS);
+   ret = clear_extent_dirty(unpin, start, end, GFP_NOFS);
+   BUG_ON(ret < 0);
unpin_extent_range(root, start, end);
cond_resched();
}
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -542,7 +542,11 @@ hit_next:
 
if (state->start < start) {
prealloc = alloc_extent_state_atomic(prealloc);
-   BUG_ON(!prealloc);
+   if (!prealloc) {
+   err = -ENOMEM;
+   goto out;
+   }
+
err = split_state(tree, state, prealloc, start);
if (err)
extent_io_tree_panic(tree, err);
@@ -566,7 +570,11 @@ hit_next:
 */
if (state->start <= end && state->end > end) {
prealloc = alloc_extent_state_atomic(prealloc);
-   BUG_ON(!prealloc);
+   if (!prealloc) {
+   err = -ENOMEM;
+   goto out;
+   }
+
err = split_state(tree, state, prealloc, end + 1);
if (err)
extent_io_tree_panic(tree, err);
@@ -1172,7 +1180,10 @@ int set_extent_uptodate(struct extent_io
 
 static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
 u64 end, struct extent_state **cached_state,
-gfp_t mask)
+gfp_t mask) __must_check;
+static int __must_check
+clear_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
+ struct extent_state **cached_state, gfp_t mask)
 {
return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0,
cached_state, mask);
@@ -1216,9 +1227,12 @@ int try_lock_extent(struct extent_io_tre

[patch 00/66] [pull] Error handling patchset v5

2011-10-24 Thread Jeff Mahoney
Hi all -

Here's my current error handling patchset, against David's integration
branch. Almost all of this patchset is preparing for actual error
handling.  Before we start in on that work, I'm trying to reduce the
surface we need to worry about. It turns out that there is a ton of code
that returns an error code but never actually reports an error.

The patchset has grown to 66 patches. 46 of them change functions that
currently return int to return void. Many of them didn't even have the
error codes checked in the caller to begin with. 11 of the patches push
error codes up into the caller.

The remaining 9 patches do:
- Add a btrfs_panic facility, with a mount option to select BUG or panic
- Catch tree operation failures
- Simplify/add some wrapper functions

The biggest change, which will probably merit some discussion, is the
introduction of slab-backed mempools in the delayed ref code. I expect
to use this technique in other areas of the code to deal with deep
failures that are impossible to recover gracefully from. Rather than
returning -ENOMEM, we keep a page's worth of objects around for each
node type. That allows the callers to be drastically simplified. There's
no reason in particular to start with the delayed ref code, it's just
where I happened to do it.

Changes since v3 in order of impact:
- Fixed an issue in ("btrfs: clear_extent_bit error push-up") where a
  positive error code returned by clear_extent_bit was being passed to
  callers of btrfs_direct_IO. The callers intepreted it as an error and
  xfstests reported corruption in test 130.
- Push-up patches have added __must_check to their prototypes so that
  new callers are forced to properly handle the error conditions, even if
  it's also with BUG_ON. Some callers weren't checking error codes at
  all and this will prevent those types of issues from being
  re-introduced.
- Added error push-up and tree locking check for convert_extent_bit.
- Moved btrfs_drop_snapshot checks into the patch that changed it to
  return int.

This is also available in my git repository at:
git://git.jeffreymahoney.com/linux/btrfs-unstable for-david-v5

It depends on git://repo.or.cz/linux-2.6/btrfs-unstable.git, starting
with commit f2ab07c6 ("Btrfs: fix the amount of space reserved for unlink").

I can rebase if necessary.

-Jeff

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 04/66] btrfs: Simplify btrfs_insert_root

2011-10-24 Thread Jeff Mahoney
 btrfs_insert_root is just a wrapper for btrfs_insert_item. Just return
 the error directly.

Signed-off-by: Jeff Mahoney 
---
 fs/btrfs/root-tree.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index f409990..1fd93d6 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -116,13 +116,10 @@ out:
return ret;
 }
 
-int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
- *root, struct btrfs_key *key, struct btrfs_root_item
- *item)
+int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root 
*root,
+ struct btrfs_key *key, struct btrfs_root_item *item)
 {
-   int ret;
-   ret = btrfs_insert_item(trans, root, key, item, sizeof(*item));
-   return ret;
+   return btrfs_insert_item(trans, root, key, item, sizeof(*item));
 }
 
 /*



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Snapshot rollback

2011-10-24 Thread Arand Nash

On 25/10/11 02:45, Phillip Susi wrote:
> (...)


On 10/24/2011 01:45 AM, dima wrote:

Hello Phillip,
It is hard to judge without seeing your fstab and bootloader config. Maybe your
/ was directly in subvolid=0 without creating a separate subvolume for it (like
__active in Goffredo's reply)? In my very humble opinion, if you have your @home
subvolume under subvolid=0 and then change the default subvolume, it just cannot
access your @home any more.


Why can't it?

It appears that Ubuntu sets up two subvols, one named @ and one named
@home, and mounts them at / and /home respectively.  The boot loader was
set to pass rootflags=subvol=@.  After changing the default volume, the
system would not boot until I removed that rootflags argument, then it
mounted the snapshot correctly as the root, but refused to mount /home,
giving this nonsense error that /dev/sda1 is not a valid block device.

>
> (...)

Btrfs is unfortunately unable to look for snapshots by name above the 
currently set default root (I do not know why exectly), it can however 
find them by id anywhere.


In the case of (Debian?) Ubuntu, you should pretty much stay away from 
set-default.


What happens is Ubuntu mounts the _default_ subvolume, which in the 
normal case refers to the top of the btrfs tree (alias subvolid=5), then 
it looks below this for the subvolumes ("directories") named "@/" (given 
by the boot option) and "@home/" (given in fstab).


Now, when you use set-default here, it will instead mount that subvolume 
as the default, and then look _below_ that for "@/" and "@home/", 
obviously, this won't work, since these exist higher up in the tree.


When you disable the rootflags argument, btrfs assumes the default 
subvolume is the root, which works, as noted.


In order to find "@home/", you could rewrite the fstab to instead of 
"subvol=@home" read "subvolid=###", since by specifying id instead of 
name, it can find it anywhere in the tree, the subvolid can be found via

~# btrfs subvolume list /


HOWEVER, this is not the way btrfs is intended to be used on Ubuntu.
As mentioned earlier, you likely will not want to touch set-default, 
instead, when you want to muck around with your mounting sobvolumes, you 
just use mv:


To backup
~# mount /dev/sda1 /mnt
~# ls /mnt
@ @home
~@ btrfs sub snap /mnt/@ /mnt/@rootsnap
~# ls /mnt
@ @home @rootsnap

And to rollback:
~# mv /mnt/@ /mnt/@rootmessy
~# mv /mnt/@rootsnap /mnt/@
And just reboot, since it just mounts whatever is named "@/".


Now in your case, if you want to go back to the Ubuntu default btrfs 
setup, you would:

~# btrfs subvolume set-default 5 /
(since id 5 is always the top of the tree)
And reinstate the rootflags boot option.


Hope that explains some of it.

--
Martin Werner ("arand")
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Snapshot rollback

2011-10-24 Thread dima
Fajar A. Nugraha  fajar.net> writes:

> AFAIK you have three possible ways to use /boot on btrfs:
> 
> (1) put /boot on subvolid=0, don't change the default subvolume. That
> works, but all your snapshot/subvols will be visible under /boot. Some
> people might not want that for estetic reason.

Hi Fajar,
I think I am doing just this, but my subvolumes are not visible under /boot. I
have all my subvolumes set up like this:
/path/to/subvolid_0/boot   < a simple directory bind-mounted to /
/path/to/subvolid_0/__active   < my / subvolume
/path/to/subvolid_0/__home < my /home subvolume


> (3) put /boot on a subvolume, do not change the default subvolume, and
> manage grub.cfg manually. This is what I currently do.

Could you elaborate about this option pls., and if possible post your grub.cfg?
I don't quite understand how it works. Though I am doing syslinux at the moment,
I think the process is the same.

thanks
~dima

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Snapshot rollback

2011-10-24 Thread Phillip Susi
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/24/2011 01:45 AM, dima wrote:
> Hello Phillip,
> It is hard to judge without seeing your fstab and bootloader config. Maybe 
> your
> / was directly in subvolid=0 without creating a separate subvolume for it 
> (like
> __active in Goffredo's reply)? In my very humble opinion, if you have your 
> @home
> subvolume under subvolid=0 and then change the default subvolume, it just 
> cannot
> access your @home any more.

Why can't it?

It appears that Ubuntu sets up two subvols, one named @ and one named
@home, and mounts them at / and /home respectively.  The boot loader was
set to pass rootflags=subvol=@.  After changing the default volume, the
system would not boot until I removed that rootflags argument, then it
mounted the snapshot correctly as the root, but refused to mount /home,
giving this nonsense error that /dev/sda1 is not a valid block device.

> Here is a very good article that explains the working of subvolumes. I used it
> as reference a lot.
> http://www.funtoo.org/wiki/BTRFS_Fun#Using_snapshots_for_system_recovery_.28aka_Back_to_the_Future.29

This advice seems completely goofy.  It tells you to change the default
subvol and boot from the snapshot, but then to have rsync copy all of
the files back to the default volume, then switch back to using that.
This seems to defeat the entire purpose.  If you are already booting
from the snapshot, why would you want to waste time copying the files
back to the original subvol instead of just deleting it, and using the
snapshot volume from now on?

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6mBo4ACgkQJ4UciIs+XuK+wgCeOD0km3GpdseQ0h4y0FKSI7JS
xC0An2JqA4aOHCkZ7+g+TORunVnpmQj7
=6KKf
-END PGP SIGNATURE-
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs error handling v4

2011-10-24 Thread Jeff Mahoney
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/24/2011 05:51 PM, Jeff Mahoney wrote:
> Hi David -
> 
> Please pull from git://git.jeffreymahoney.com/linux/btrfs-unstable 
> for-david.
> 
> It contains the previously integrated v3 error handling patch with
> an updated ("btrfs: clear_extent_bit error push-up") commit that
> resets the return value in btrfs_direct_IO.
> 
> This branch is built on the base of the integration branch you sent
> me previously. If it needs updating, let me know.

Actually, scratch that. The next thing I wanted to do was add
__must_check and that should be integrated into the set, not an
afterthought.

- -Jeff

- -- 
Jeff Mahoney
SUSE Labs
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6l+sEACgkQLPWxlyuTD7LP/QCfT5A4lSX4ensbX5DCyeFkoMR5
+qEAn26h1Nl7YVlpXtu4EAjuuM2Vt9lG
=8K4x
-END PGP SIGNATURE-
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL] Btrfs error handling v4

2011-10-24 Thread Jeff Mahoney
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi David -

Please pull from git://git.jeffreymahoney.com/linux/btrfs-unstable
for-david.

It contains the previously integrated v3 error handling patch with an
updated ("btrfs: clear_extent_bit error push-up") commit that resets
the return value in btrfs_direct_IO.

This branch is built on the base of the integration branch you sent me
previously. If it needs updating, let me know.

- -Jeff

- -- 
Jeff Mahoney
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6l3eUACgkQLPWxlyuTD7L/aQCcC7lo+p5lv8Grfb1GcIPL9GlA
hsoAoIFKFr3+gn8SfGOdnWd00fREmYcO
=ekcX
-END PGP SIGNATURE-
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: ceph on btrfs [was Re: ceph on non-btrfs file systems]

2011-10-24 Thread Arne Jansen

On 24.10.2011 23:34, Christian Brunner wrote:

2011/10/24 Chris Mason:

On Mon, Oct 24, 2011 at 03:51:47PM -0400, Josef Bacik wrote:

On Mon, Oct 24, 2011 at 10:06:49AM -0700, Sage Weil wrote:

[adding linux-btrfs to cc]

Josef, Chris, any ideas on the below issues?

On Mon, 24 Oct 2011, Christian Brunner wrote:

Thanks for explaining this. I don't have any objections against btrfs
as a osd filesystem. Even the fact that there is no btrfs-fsck doesn't
scare me, since I can use the ceph replication to recover a lost
btrfs-filesystem. The only problem I have is, that btrfs is not stable
on our side and I wonder what you are doing to make it work. (Maybe
it's related to the load pattern of using ceph as a backend store for
qemu).

Here is a list of the btrfs problems I'm having:

- When I run ceph with the default configuration (btrfs snaps enabled)
I can see a rapid increase in Disk-I/O after a few hours of uptime.
Btrfs-cleaner is using more and more time in
btrfs_clean_old_snapshots().


In theory, there shouldn't be any significant difference between taking a
snapshot and removing it a few commits later, and the prior root refs that
btrfs holds on to internally until the new commit is complete.  That's
clearly not quite the case, though.

In any case, we're going to try to reproduce this issue in our
environment.



I've noticed this problem too, clean_old_snapshots is taking quite a while in
cases where it really shouldn't.  I will see if I can come up with a reproducer
that doesn't require setting up ceph ;).


This sounds familiar though, I thought we had fixed a similar
regression.  Either way, Arne's readahead code should really help.

Which kernel version were you running?

[ ack on the rest of Josef's comments ]


This was with a 3.0 kernel, including all btrfs-patches from josefs
git repo plus the "use the global reserve when truncating the free
space cache inode" patch.

I'll try the readahead code.


The current readahead code is only used for scrub. I plan to extend it
to snapshot deletion in a next step, but currently I'm afraid it can't
help.

-Arne



Thanks,
Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: ceph on btrfs [was Re: ceph on non-btrfs file systems]

2011-10-24 Thread Christian Brunner
2011/10/24 Chris Mason :
> On Mon, Oct 24, 2011 at 03:51:47PM -0400, Josef Bacik wrote:
>> On Mon, Oct 24, 2011 at 10:06:49AM -0700, Sage Weil wrote:
>> > [adding linux-btrfs to cc]
>> >
>> > Josef, Chris, any ideas on the below issues?
>> >
>> > On Mon, 24 Oct 2011, Christian Brunner wrote:
>> > > Thanks for explaining this. I don't have any objections against btrfs
>> > > as a osd filesystem. Even the fact that there is no btrfs-fsck doesn't
>> > > scare me, since I can use the ceph replication to recover a lost
>> > > btrfs-filesystem. The only problem I have is, that btrfs is not stable
>> > > on our side and I wonder what you are doing to make it work. (Maybe
>> > > it's related to the load pattern of using ceph as a backend store for
>> > > qemu).
>> > >
>> > > Here is a list of the btrfs problems I'm having:
>> > >
>> > > - When I run ceph with the default configuration (btrfs snaps enabled)
>> > > I can see a rapid increase in Disk-I/O after a few hours of uptime.
>> > > Btrfs-cleaner is using more and more time in
>> > > btrfs_clean_old_snapshots().
>> >
>> > In theory, there shouldn't be any significant difference between taking a
>> > snapshot and removing it a few commits later, and the prior root refs that
>> > btrfs holds on to internally until the new commit is complete.  That's
>> > clearly not quite the case, though.
>> >
>> > In any case, we're going to try to reproduce this issue in our
>> > environment.
>> >
>>
>> I've noticed this problem too, clean_old_snapshots is taking quite a while in
>> cases where it really shouldn't.  I will see if I can come up with a 
>> reproducer
>> that doesn't require setting up ceph ;).
>
> This sounds familiar though, I thought we had fixed a similar
> regression.  Either way, Arne's readahead code should really help.
>
> Which kernel version were you running?
>
> [ ack on the rest of Josef's comments ]

This was with a 3.0 kernel, including all btrfs-patches from josefs
git repo plus the "use the global reserve when truncating the free
space cache inode" patch.

I'll try the readahead code.

Thanks,
Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


subvolume delete freezes

2011-10-24 Thread Jim

Good afternoon Btrfs list.
I was working with snapshots and created one of a small filetree as 
/btrfs/snaps/.101411.  Several days late, not having written to the 
snapshot, but having written to the original files, I tried to delete 
the snapshot.  btrfs subvolume delete /snaps/.101411 hung the 
machine.  I had to open a new terminal, ssh in, and use echo b > 
/proc/sysrq-trigger (all else had failed) to reboot the machine.  Here 
are the log entries I recovered.  I hope this means something to you 
guys because I am at a loss to explain what happened.


Oct 24 12:32:54 btrfs kernel: ame:4>Mon: nnfsdacl ss efs4vint ipmsi 
indleunrpq ga llcdemaacpiufreq frle mperfpt_Rnf_cack_nf_d_ipv ip_es 
nack_6t_REJECT nfconnk_ip6 nffragpv6 te nack ble_ter les  lzo_comd se sg 
pcspkr serio_raw i2dor_suppo mbcache jbdrc_t10dif [last unloaded: ash 
Tainted: GW   3.1fff81049b [
Oct 24 12:32:54 btrfs kernel: [Oct 24 12:32:54 btrfs kernel: <0x210/0rfs_lookup_denf8113cb2b>] ? 
1146425106>] 
btfff8113ae718113cdc68113f380fff8[] 
?] vfs_fstatat+0x4c/0x90

Oct 24 12:32:54 btrfs kernel: [stemtpat16/0end ace af9a4ae678 ]---
Oct 24 12:32:54 btrfs kernel: -cut 4>WAING:btrf btrlean3c0 ]()
Oct 24 12:32:54 btrfs kernel: ame:4>Mon: nnfsdacl ss efs4 vint ipmsi 
indleunrpq ga llcdemaacpiufreq frle mperfpt_Rnf_cack_nf_d_ipv ip_es 
nack_6t_REJECT nfconnk_ip6 nffragpv6 te nack ble_ter les  lzo_comd se sg 
pcspkr serio_raw idor_supp mbcache jbd2 sr_mod cdrom rc_t10dif [last 
unloadeash Tainted: GW   3fff81049b [Oct 24 12:32:54 btrfs kernel: [[btr0x210/0x4rfs_lookupf8113cb2b>] ? d1146425>106>] 
btfff8113ae78113cdc68113f380fff[] ? 
cu] vfs_fstatat+0x4c/0x90

Oct 24 12:32:54 btrfs kernel: [at+0fff8_syscallry+01bf/0
Oct 24 12:32:54 btrfs kernel: <49ab>stemtpat16/0end ace af9a4ae679 ]---
Oct 24 12:32:54 btrfs kernel: -cut 4>WAING:btrf btrlean3c0 ]()

I am running on kernel 3.1-rc4.  Thanks for any info.
Jim Maloney
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: ceph on btrfs [was Re: ceph on non-btrfs file systems]

2011-10-24 Thread Chris Mason
On Mon, Oct 24, 2011 at 03:51:47PM -0400, Josef Bacik wrote:
> On Mon, Oct 24, 2011 at 10:06:49AM -0700, Sage Weil wrote:
> > [adding linux-btrfs to cc]
> > 
> > Josef, Chris, any ideas on the below issues?
> > 
> > On Mon, 24 Oct 2011, Christian Brunner wrote:
> > > Thanks for explaining this. I don't have any objections against btrfs
> > > as a osd filesystem. Even the fact that there is no btrfs-fsck doesn't
> > > scare me, since I can use the ceph replication to recover a lost
> > > btrfs-filesystem. The only problem I have is, that btrfs is not stable
> > > on our side and I wonder what you are doing to make it work. (Maybe
> > > it's related to the load pattern of using ceph as a backend store for
> > > qemu).
> > > 
> > > Here is a list of the btrfs problems I'm having:
> > > 
> > > - When I run ceph with the default configuration (btrfs snaps enabled)
> > > I can see a rapid increase in Disk-I/O after a few hours of uptime.
> > > Btrfs-cleaner is using more and more time in
> > > btrfs_clean_old_snapshots().
> > 
> > In theory, there shouldn't be any significant difference between taking a 
> > snapshot and removing it a few commits later, and the prior root refs that 
> > btrfs holds on to internally until the new commit is complete.  That's 
> > clearly not quite the case, though.
> > 
> > In any case, we're going to try to reproduce this issue in our 
> > environment.
> > 
> 
> I've noticed this problem too, clean_old_snapshots is taking quite a while in
> cases where it really shouldn't.  I will see if I can come up with a 
> reproducer
> that doesn't require setting up ceph ;).

This sounds familiar though, I thought we had fixed a similar
regression.  Either way, Arne's readahead code should really help.

Which kernel version were you running?

[ ack on the rest of Josef's comments ]

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: ceph on btrfs [was Re: ceph on non-btrfs file systems]

2011-10-24 Thread Josef Bacik
On Mon, Oct 24, 2011 at 10:06:49AM -0700, Sage Weil wrote:
> [adding linux-btrfs to cc]
> 
> Josef, Chris, any ideas on the below issues?
> 
> On Mon, 24 Oct 2011, Christian Brunner wrote:
> > Thanks for explaining this. I don't have any objections against btrfs
> > as a osd filesystem. Even the fact that there is no btrfs-fsck doesn't
> > scare me, since I can use the ceph replication to recover a lost
> > btrfs-filesystem. The only problem I have is, that btrfs is not stable
> > on our side and I wonder what you are doing to make it work. (Maybe
> > it's related to the load pattern of using ceph as a backend store for
> > qemu).
> > 
> > Here is a list of the btrfs problems I'm having:
> > 
> > - When I run ceph with the default configuration (btrfs snaps enabled)
> > I can see a rapid increase in Disk-I/O after a few hours of uptime.
> > Btrfs-cleaner is using more and more time in
> > btrfs_clean_old_snapshots().
> 
> In theory, there shouldn't be any significant difference between taking a 
> snapshot and removing it a few commits later, and the prior root refs that 
> btrfs holds on to internally until the new commit is complete.  That's 
> clearly not quite the case, though.
> 
> In any case, we're going to try to reproduce this issue in our 
> environment.
> 

I've noticed this problem too, clean_old_snapshots is taking quite a while in
cases where it really shouldn't.  I will see if I can come up with a reproducer
that doesn't require setting up ceph ;).

> > - When I run ceph with btrfs snaps disabled, the situation is getting
> > slightly better. I can run an OSD for about 3 days without problems,
> > but then again the load increases. This time, I can see that the
> > ceph-osd (blkdev_issue_flush) and btrfs-endio-wri are doing more work
> > than usual.
> 
> FYI in this scenario you're exposed to the same journal replay issues that 
> ext4 and XFS are.  The btrfs workload that ceph is generating will also 
> not be all that special, though, so this problem shouldn't be unique to 
> ceph.
> 

Can you get sysrq+w when this happens?  I'd like to see what btrfs-endio-write
is up to.

> > Another thing is that I'm seeing a WARNING: at fs/btrfs/inode.c:2114
> > from time to time. Maybe it's related to the performance issues, but
> > seems to be able to verify this.
> 
> I haven't seen this yet with the latest stuff from Josef, but others have.  
> Josef, is there any information we can provide to help track it down?
>

Actually this would show up in 2 cases, I fixed the one most people hit with my
earlier stuff and then fixed the other one more recently, hopefully it will be
fixed in 3.2.  A full backtrace would be nice so I can figure out which one it
is you are hitting.
 
> > It's really sad to see, that ceph performance and stability is
> > suffering that much from the underlying filesystems and that this
> > hasn't changed over the last months.
> 
> We don't have anyone internally working on btrfs at the moment, and are 
> still struggling to hire experienced kernel/fs people.  Josef has been 
> very helpful with tracking these issues down, but he hass responsibilities 
> beyond just the Ceph related issues.  Progress is slow, but we are 
> working on it!

I'm open to offers ;).  These things are being hit by people all over the place,
but it's hard for me to reproduce, especially since most of the reports are "run
X server for Y days and wait for it to start sucking."  I will try and get a box
setup that I can let stress.sh run on for a few days to see if I can make some
of this stuff come out to play with me, but unfortunately I end up having to
debug these kind of things over email, which means they get a whole lot of
nowhere.  Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ceph on btrfs [was Re: ceph on non-btrfs file systems]

2011-10-24 Thread Sage Weil
[adding linux-btrfs to cc]

Josef, Chris, any ideas on the below issues?

On Mon, 24 Oct 2011, Christian Brunner wrote:
> Thanks for explaining this. I don't have any objections against btrfs
> as a osd filesystem. Even the fact that there is no btrfs-fsck doesn't
> scare me, since I can use the ceph replication to recover a lost
> btrfs-filesystem. The only problem I have is, that btrfs is not stable
> on our side and I wonder what you are doing to make it work. (Maybe
> it's related to the load pattern of using ceph as a backend store for
> qemu).
> 
> Here is a list of the btrfs problems I'm having:
> 
> - When I run ceph with the default configuration (btrfs snaps enabled)
> I can see a rapid increase in Disk-I/O after a few hours of uptime.
> Btrfs-cleaner is using more and more time in
> btrfs_clean_old_snapshots().

In theory, there shouldn't be any significant difference between taking a 
snapshot and removing it a few commits later, and the prior root refs that 
btrfs holds on to internally until the new commit is complete.  That's 
clearly not quite the case, though.

In any case, we're going to try to reproduce this issue in our 
environment.

> - When I run ceph with btrfs snaps disabled, the situation is getting
> slightly better. I can run an OSD for about 3 days without problems,
> but then again the load increases. This time, I can see that the
> ceph-osd (blkdev_issue_flush) and btrfs-endio-wri are doing more work
> than usual.

FYI in this scenario you're exposed to the same journal replay issues that 
ext4 and XFS are.  The btrfs workload that ceph is generating will also 
not be all that special, though, so this problem shouldn't be unique to 
ceph.

> Another thing is that I'm seeing a WARNING: at fs/btrfs/inode.c:2114
> from time to time. Maybe it's related to the performance issues, but
> seems to be able to verify this.

I haven't seen this yet with the latest stuff from Josef, but others have.  
Josef, is there any information we can provide to help track it down?

> It's really sad to see, that ceph performance and stability is
> suffering that much from the underlying filesystems and that this
> hasn't changed over the last months.

We don't have anyone internally working on btrfs at the moment, and are 
still struggling to hire experienced kernel/fs people.  Josef has been 
very helpful with tracking these issues down, but he hass responsibilities 
beyond just the Ceph related issues.  Progress is slow, but we are 
working on it!

sage


> 
> Kind regards,
> Christian
> 
> 2011/10/24 Sage Weil :
> > Although running on ext4, xfs, or whatever other non-btrfs you want mostly
> > works, there are a few important remaining issues:
> >
> > 1- ext4 limits total xattrs for 4KB.  This can cause problems in some
> > cases, as Ceph uses xattrs extensively.  Most of the time we don't hit
> > this.  We do hit the limit with radosgw pretty easily, though, and may
> > also hit it in exceptional cases where the OSD cluster is very unhealthy.
> >
> > There is a large xattr patch for ext4 from the Lustre folks that has been
> > floating around for (I think) years.  Maybe as interest grows in running
> > Ceph on ext4 this can move upstream.
> >
> > Previously we were being forgiving about large setxattr failures on ext3,
> > but we found that was leading to corruption in certain cases (because we
> > couldn't set our internal metadata), so the next release will assert/crash
> > in that case (fail-stop instead of fail-maybe-eventually-corrupt).
> >
> > XFS does not have an xattr size limit and thus does have this problem.
> >
> > 2- The other problem is with OSD journal replay of non-idempotent
> > transactions.  On non-btrfs backends, the Ceph OSDs use a write-ahead
> > journal.  After restart, the OSD does not know exactly which transactions
> > in the journal may have already been committed to disk, and may reapply a
> > transaction again during replay.  For most operations (write, delete,
> > truncate) this is fine.
> >
> > Some operations, though, are non-idempotent.  The simplest example is
> > CLONE, which copies (efficiently, on btrfs) data from one object to
> > another.  If the source object is modified, the osd restarts, and then
> > the clone is replayed, the target will get incorrect (newer) data.  For
> > example,
> >
> > 1- clone A -> B
> > 2- modify A
> >   
> >
> > B will get new instead of old contents.
> >
> > (This doesn't happen on btrfs because the snapshots allow us to replay
> > from a known consistent point in time.)
> >
> > For things like clone, skipping the operation of the target exists almost
> > works, except for cases like
> >
> > 1- clone A -> B
> > 2- modify A
> > ...
> > 3- delete B
> >   
> >
> > (Although in that example who cares if B had bad data; it was removed
> > anyway.)  The larger problem, though, is that that doesn't always work;
> > CLONERANGE copies a range of a file from A to B, where B may already
> > exist.
> >
> > In practice, the higher level in

Re: Chrome brings whole system down

2011-10-24 Thread Chester
Just yesterday I can reproduce this reliably. There was no way to turn
the system off other than to use the 'ol REISUB sysrq tricks. I
decided to give it a try today, and it works somehow..
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: how stable are snapshots at the block level?

2011-10-24 Thread Stephane CHAZELAS
2011-10-24, 09:59(-04), Edward Ned Harvey:
[...]
> If you are reading the raw device underneath btrfs, you are
> not getting the benefit of the filesystem checksumming.  If
> you encounter an undetected read/write error, it will silently
> pass.  Your data will be corrupted, you'll never know about it
> until you see the side-effects (whatever they may be).
[...]

I don't follow you here. If you're cloning a device holding a
btrfs FS, you'll clone the checksums as well. If there were
errors, they will be detected on the cloned FS as well?

> There is never a situation where block level copies have any
> advantage over something like btrfs send.  Except perhaps
> forensics or espionage.  But in terms of fast efficient
> reliable backups, btrfs send has every advantage and no
> disadvantage compared to block level copy.

$ btrfs send
ERROR: unknown command 'send'
Usage:
[...]

(from 2011-10-12 integration branch). Am I missing something?

> There are many situations where btrfs send has an advantage
> over both block level and file level copies.  It instantly
> knows all the relevant disk blocks to send, it preserves every
> property, it's agnostic about filesystem size or layout on
> either sending or receiving end, you have the option to create
> different configurations on each side, including compression
> etc.  And so on.
[...]

That sounds like "zfs send", I didn't know btrfs had it yet.

My understanding was that to clone/backup a btrfs FS, you could
only clone the block devices or use the "device add" + "device
del" trick with some extra copy-on-write (LVM, nbd) layer.

-- 
Stephane

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: system hangs after deleting bad file

2011-10-24 Thread Helmut Hullen
Hallo, dima,

Du meintest am 24.10.11:

[system hangs]

> I had a similar problem.

> Some files (2-3) got corrupted in my /home subvolume for no apparent
> reason. Trying to access the files gives kernel oops. Sometimes it
> freezes the machine, sometimes I am back to my console without any
> problems.

> Then I switched to the latest 3.1rc and freezes were gone (though I
> still had the kernel oops).

I'll try in some hours ... I've just seen kernel 3.1 has been released.

Viele Gruesse!
Helmut
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: how stable are snapshots at the block level?

2011-10-24 Thread Edward Ned Harvey
> From: Mathijs Kwik [mailto:math...@bluescreen303.nl]
> Sent: Sunday, October 23, 2011 11:20 AM
> 
> > Also if you're rsyncing the block level device, you're running underneath
> btrfs and losing any checksumming benefit that btrfs was giving you, so
> you're possibly introducing risk for silent data corruption.  (Or more
> accurately, failing to allow btrfs to detect/correct it.)
> 
> Not sure... I'm sure that's the case for in-use subvolumes, but
> shouldn't snapshots (and their metadata/checksums) just be safe?

Nope.  The whole point of checksumming is like this:  All devices are 
imperfect.  They have built-in error detection and correction.  Whenever an 
error occurs (which is often) the drive tries to silently correct it (reread) 
without telling the OS.  But the checksumming in hardware is rather weak.  
Sometimes you'll get corrupt data that passes the hardware test and reaches the 
OS without any clue that it's wrong.  I find that a typical small business 
fileserver (10 sata disks) hits these approx once a year.

Filesystem checksumming is much stronger (lower probability to silently allow 
an error).  Like randomly selecting a single molecule twice consecutively 
amongst all the molecules in the solar system.  Like much less likely to occur 
than the end of the human race, etc.  So when the silent errors occur, 
filesystem checksumming definitely detects it, and if possible, corrects it.   

If you are reading the raw device underneath btrfs, you are not getting the 
benefit of the filesystem checksumming.  If you encounter an undetected 
read/write error, it will silently pass.  Your data will be corrupted, you'll 
never know about it until you see the side-effects (whatever they may be).

While people with computers have accepted this level of unreliability for years 
(fat32, ntfs, ext3/4, etc) people are now beginning to recognize the importance 
on a greater scale.  Once corrupted, always corrupted.  People want to keep 
their data indefinitely.  


> Thanks for your advice,
> Like I said, for me, right now, sticking to tried-and-tested
> file-based rsync is just ok. But I hope to get some insights into
> other possibilities. btrfs send sounds cool, but I sure hope this is
> not the only solution, as I described a few scenarios where
> block-level copies have advantages.

There is never a situation where block level copies have any advantage over 
something like btrfs send.  Except perhaps forensics or espionage.  But in 
terms of fast efficient reliable backups, btrfs send has every advantage and no 
disadvantage compared to block level copy.

There are many situations where btrfs send has an advantage over both block 
level and file level copies.  It instantly knows all the relevant disk blocks 
to send, it preserves every property, it's agnostic about filesystem size or 
layout on either sending or receiving end, you have the option to create 
different configurations on each side, including compression etc.  And so on.

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: how stable are snapshots at the block level?

2011-10-24 Thread Stephane CHAZELAS
2011-10-23, 17:19(+02), Mathijs Kwik:
[...]
> For this case (my laptop) I can stick to file-based rsync, but I think
> some guarantees should exist at the block level. Many virtual machines
> and cloud hosting services (like ec2) provide block-level snapshots.
> With xfs, I can freeze the filesystem for a short amount of time
> (<100ms), snapshot, unfreeze. I don't think such a lock/freeze feature
> exists for btrfs
[...]

That FS-freeze feature has been moved to the vfs layer so is
available to any filesystem now.

You can either use xfs_io (see -F option to "freeze" for foreign
FS) like for xfs FS or use fsfreeze from util-linux.

Note that you can thaw file systems with a sysrq combination
now. (for instance with xen using "xm sysrq vm j").

For block level snapshots, see also ddsnap (device mapper target
unfortunately no longer maintained) and lvm of course (but
doesn't scale well with several snapshots).

-- 
Stephane

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Snapshot rollback

2011-10-24 Thread Fajar A. Nugraha
On Mon, Oct 24, 2011 at 3:24 PM, dima  wrote:
> Fajar A. Nugraha  fajar.net> writes:
>
>> A problem with that, though, if you decide to put /boot on btrfs as
>> well. Grub uses the default subvolume to determine paths (for kernel,
>> initrd, etc). A workaround is to manually create and manage your
>> grub.cfg (or create and use a manual-managed include file, like
>> custom-top.cfg, that gets parsed before the automatically created
>> entries).
>
> Oops, sorry, I was incorrect of course. Thanks Fajar.
> I do have /boot in my subvolid=0 because bootloaders can't read inside
> subvolumes (other than the default) as far as I understand.
> And I just bind /boot through fstab.

AFAIK you have three possible ways to use /boot on btrfs:

(1) put /boot on subvolid=0, don't change the default subvolume. That
works, but all your snapshot/subvols will be visible under /boot. Some
people might not want that for estetic reason.

(2) put /boot (or /, when /boot is part of / ) on a subvolume, then
change the default subvolume. This works cleanly, but there were some
problems in the past when changing the default subvolume (at least I
had problem). Current kernel version might not have this problem
anymore (I haven't tried again)

(3) put /boot on a subvolume, do not change the default subvolume, and
manage grub.cfg manually. This is what I currently do.

I wish grub's btrfs support is more like zfs support, where both the
bootloader and tools (e.g. update-grub, grub-probe, etc) can
intellegently recognize what dataset /boot is on, and create the
correct entry. For example, if you have this

# df -h /boot
FilesystemSize  Used Avail Use% Mounted on
rpool/ROOT/ubuntu-1   384G  1.2G  383G   1% /
rpool/ROOT/ubuntu-1/boot
  383G   71M  383G   1% /boot

... then grub.cfg will have an entry like this

zfs-bootfs ($root) bootfs
linux   /ROOT/ubuntu-1/boot/@/vmlinuz-2.6.38-10-generic root=/dev/sda5
ro boot=zfs $bootfs rpool=rpool bootfs=rpool/ROOT/ubuntu-1
initrd  /ROOT/ubuntu-1/boot/@/initrd.img-2.6.38-10-generic

This flexibility allows me (for example) to have multiple version of
kernel, initrd, and root fs in different datasets, all selectable
during boot process (possibly by manually editing grub command line to
suplly the correct path/argument). Good for rescue purposes, just in
case a recent update made the system broken :)

The closest thing we can get to that with btrfs is currently option
(1), as option (2) requires you to boot to an alternate environment
(e.g live cd) to change the default subvol first.

-- 
Fajar
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Kernel BUG unable to handle kernel NULL pointer dereference

2011-10-24 Thread Leonidas Spyropoulos
On Mon, Oct 24, 2011 at 12:51 PM, David Sterba  wrote:
> On Mon, Oct 24, 2011 at 12:33:05PM +0100, Leonidas Spyropoulos wrote:
>> Here is it, it's big and contains usless information..
>>
>> http://paste.pocoo.org/show/497299/
>
> not all that useless ... I saw another BUG earlier than the one you've
> reported:
>
> [31653.267742] [ cut here ]
> [31653.267764] kernel BUG at fs/btrfs/extent-tree.c:5510!
> [31653.267773] invalid opcode:  [#1] PREEMPT SMP
> [31653.267785] CPU 1
> [31653.267790] Modules linked in: vboxdrv ipv6 loop fuse adt7475 hwmon_vid 
> nouveau evdev uvcvideo hid_apple ttm videodev drm_kms_helper media 
> v4l2_compat_ioctl32 drm snd_emu10k1 i2c_algo_bit mxm_wmi wmi pcspkr 
> snd_rawmidi snd_seq_device firewire_ohci emu10k1_gp edac_core psmouse 
> snd_util_mem edac_mce_amd k8temp firewire_core gameport snd_hwdep video 
> serio_raw crc_itu_t sg snd_intel8x0 snd_ac97_codec usbhid ac97_bus snd_pcm 
> snd_timer hid snd floppy i2c_nforce2 thermal processor fan button soundcore 
> i2c_core snd_page_alloc forcedeth btrfs zlib_deflate crc32c libcrc32c ext4 
> jbd2 crc16 ext3 jbd mbcache ohci_hcd ehci_hcd usbcore sr_mod sd_mod cdrom 
> sata_nv pata_amd libata scsi_mod
> [31653.267989]
> [31653.267995] Pid: 726, comm: btrfs-transacti Not tainted 3.0-ARCH #1    /LP 
> UT NF4 Expert
> [31653.268011] RIP: 0010:[]  [] 
> run_clustered_refs+0x813/0x830 [btrfs]
> [31653.268045] RSP: 0018:88013469bc70  EFLAGS: 00010286
> [31653.268286] RAX: ffe4 RBX: 88012e406900 RCX: 
> 8801378a6100
> [31653.268296] RDX: 88011513a0f0 RSI:  RDI: 
> 
> [31653.268306] RBP: 88013469bd50 R08:  R09: 
> 
> [31653.268315] R10: 8801346f9800 R11: 88013735d3f0 R12: 
> 8800a9bc7f00
> [31653.268325] R13: 88007b1d7e40 R14: 88011bd1e4b0 R15: 
> 
> [31653.268341] FS:  7f8dcc527880() GS:88013fd0() 
> knlGS:f67567f0
> [31653.268367] CS:  0010 DS:  ES:  CR0: 8005003b
> [31653.268380] CR2: 7f9059631550 CR3: a499c000 CR4: 
> 06e0
> [31653.268394] DR0:  DR1:  DR2: 
> 
> [31653.268409] DR3:  DR6: 0ff0 DR7: 
> 0400
> [31653.268424] Process btrfs-transacti (pid: 726, threadinfo 
> 88013469a000, task 880136c140b0)
> [31653.268443] Stack:
> [31653.268449]    88010001 
> 
> [31653.268473]  0c2e a01dc529  
> 0002
> [31653.268495]  0b9f 0c04  
> 88013469bd90
> [31653.268515] Call Trace:
> [31653.268531]  [] btrfs_run_delayed_refs+0xc8/0x220 [btrfs]
> [31653.268549]  [] ? btrfs_free_path+0x2a/0x40 [btrfs]
> [31653.268568]  [] btrfs_commit_transaction+0x3c3/0x8a0 
> [btrfs]
> [31653.268581]  [] ? abort_exclusive_wait+0xb0/0xb0
> [31653.268598]  [] transaction_kthread+0x26d/0x290 [btrfs]
> [31653.268617]  [] ? btrfs_congested_fn+0xd0/0xd0 [btrfs]
> [31653.268627]  [] kthread+0x8c/0xa0
> [31653.268638]  [] kernel_thread_helper+0x4/0x10
> [31653.268647]  [] ? kthread_worker_fn+0x190/0x190
> [31653.268657]  [] ? gs_change+0x13/0x13
> [31653.268673] Code: e0 e9 12 f9 ff ff 0f 0b 80 fa b2 0f 84 bc f9 ff ff 0f 0b 
> be 95 00 00 00 48 c7 c7 37 d0 20 a0 e8 54 65 eb e0 e9 04 f9 ff ff 0f 0b <0f> 
> 0b 0f 0b 0f 0b 0f 0b 0f 0b 0f 0b 0f 0b 66 66 66 66 66 66 2e
> [31653.268928] RIP  [] run_clustered_refs+0x813/0x830 
> [btrfs]
> [31653.268956]  RSP 
> [31653.284196] ---[ end trace d5d8ee7634d1c36e ]---
>
> and it looks related to the print_leaf bug later (eg. mentiones same functions
> in the stacktrace and happens during commit).
>
> And judging from the rest of BUG's in the paste, the filesystem is in a bad
> shape. Some BUG_ON's seem to be triggered by ENOSPC (RAX containing 
> 0xfff..e4).
>
>
> david
>

I am doing a backup of my current data as I write this mail (hopefully
it will finish without IO errors).
Will it help if I print the btrfs tree and post it somewhere?

I mean, since the system is funcionable, it could be useful to track
down the bug, no?

Regards
Leonidas



-- 
Caution: breathing may be hazardous to your health.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Kernel BUG unable to handle kernel NULL pointer dereference

2011-10-24 Thread David Sterba
On Mon, Oct 24, 2011 at 12:33:05PM +0100, Leonidas Spyropoulos wrote:
> Here is it, it's big and contains usless information..
> 
> http://paste.pocoo.org/show/497299/

not all that useless ... I saw another BUG earlier than the one you've
reported:

[31653.267742] [ cut here ]
[31653.267764] kernel BUG at fs/btrfs/extent-tree.c:5510!
[31653.267773] invalid opcode:  [#1] PREEMPT SMP 
[31653.267785] CPU 1 
[31653.267790] Modules linked in: vboxdrv ipv6 loop fuse adt7475 hwmon_vid 
nouveau evdev uvcvideo hid_apple ttm videodev drm_kms_helper media 
v4l2_compat_ioctl32 drm snd_emu10k1 i2c_algo_bit mxm_wmi wmi pcspkr snd_rawmidi 
snd_seq_device firewire_ohci emu10k1_gp edac_core psmouse snd_util_mem 
edac_mce_amd k8temp firewire_core gameport snd_hwdep video serio_raw crc_itu_t 
sg snd_intel8x0 snd_ac97_codec usbhid ac97_bus snd_pcm snd_timer hid snd floppy 
i2c_nforce2 thermal processor fan button soundcore i2c_core snd_page_alloc 
forcedeth btrfs zlib_deflate crc32c libcrc32c ext4 jbd2 crc16 ext3 jbd mbcache 
ohci_hcd ehci_hcd usbcore sr_mod sd_mod cdrom sata_nv pata_amd libata scsi_mod
[31653.267989] 
[31653.267995] Pid: 726, comm: btrfs-transacti Not tainted 3.0-ARCH #1/LP 
UT NF4 Expert
[31653.268011] RIP: 0010:[]  [] 
run_clustered_refs+0x813/0x830 [btrfs]
[31653.268045] RSP: 0018:88013469bc70  EFLAGS: 00010286
[31653.268286] RAX: ffe4 RBX: 88012e406900 RCX: 8801378a6100
[31653.268296] RDX: 88011513a0f0 RSI:  RDI: 
[31653.268306] RBP: 88013469bd50 R08:  R09: 
[31653.268315] R10: 8801346f9800 R11: 88013735d3f0 R12: 8800a9bc7f00
[31653.268325] R13: 88007b1d7e40 R14: 88011bd1e4b0 R15: 
[31653.268341] FS:  7f8dcc527880() GS:88013fd0() 
knlGS:f67567f0
[31653.268367] CS:  0010 DS:  ES:  CR0: 8005003b
[31653.268380] CR2: 7f9059631550 CR3: a499c000 CR4: 06e0
[31653.268394] DR0:  DR1:  DR2: 
[31653.268409] DR3:  DR6: 0ff0 DR7: 0400
[31653.268424] Process btrfs-transacti (pid: 726, threadinfo 88013469a000, 
task 880136c140b0)
[31653.268443] Stack:
[31653.268449]    88010001 

[31653.268473]  0c2e a01dc529  
0002
[31653.268495]  0b9f 0c04  
88013469bd90
[31653.268515] Call Trace:
[31653.268531]  [] btrfs_run_delayed_refs+0xc8/0x220 [btrfs]
[31653.268549]  [] ? btrfs_free_path+0x2a/0x40 [btrfs]
[31653.268568]  [] btrfs_commit_transaction+0x3c3/0x8a0 
[btrfs]
[31653.268581]  [] ? abort_exclusive_wait+0xb0/0xb0
[31653.268598]  [] transaction_kthread+0x26d/0x290 [btrfs]
[31653.268617]  [] ? btrfs_congested_fn+0xd0/0xd0 [btrfs]
[31653.268627]  [] kthread+0x8c/0xa0
[31653.268638]  [] kernel_thread_helper+0x4/0x10
[31653.268647]  [] ? kthread_worker_fn+0x190/0x190
[31653.268657]  [] ? gs_change+0x13/0x13
[31653.268673] Code: e0 e9 12 f9 ff ff 0f 0b 80 fa b2 0f 84 bc f9 ff ff 0f 0b 
be 95 00 00 00 48 c7 c7 37 d0 20 a0 e8 54 65 eb e0 e9 04 f9 ff ff 0f 0b <0f> 0b 
0f 0b 0f 0b 0f 0b 0f 0b 0f 0b 0f 0b 66 66 66 66 66 66 2e 
[31653.268928] RIP  [] run_clustered_refs+0x813/0x830 [btrfs]
[31653.268956]  RSP 
[31653.284196] ---[ end trace d5d8ee7634d1c36e ]---

and it looks related to the print_leaf bug later (eg. mentiones same functions
in the stacktrace and happens during commit).

And judging from the rest of BUG's in the paste, the filesystem is in a bad
shape. Some BUG_ON's seem to be triggered by ENOSPC (RAX containing 0xfff..e4).


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: kernel BUG at fs/btrfs/inode.c:1163

2011-10-24 Thread David Sterba
On Wed, Oct 19, 2011 at 02:59:45PM +0200, Martin Mailand wrote:
> Am 19.10.2011 11:49, schrieb David Sterba:
> >It would be interesting what's the value of 'extent_type' at the time of
> >crash, if it's eg -1 that could point to a real bug, some unhandled
> >corner case in truncate, for example.
> >
> 
> How can I do that?

something like that would print the type information during runtime

--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1160,6 +1160,11 @@ next_slot:
btrfs_file_extent_inline_len(leaf, fi);
extent_end = ALIGN(extent_end, root->sectorsize);
} else {
+   printk(KERN_CRIT "btrfs: unhandled extent type %d, 
key=[%llu,%u,%llu]",
+   (unsigned long long)found_key.objecitd,
+   (unsigned)found_key.tyep,
+   (unsigned long long)found_key.offset,
+   extent_type);
BUG_ON(1);
}
 out_check:
---

the key seems to be a relevant iformation to print as well, but the rest
stored in the leaf item could be just garbage.

The btrfs-debug-tree utility prints the whole tree items, but as I saw just now
in the case of extent, it skips an unknown type (the same where kernel
BUGs), which means that other extent data are glued to previous output
and thus cannot be spotted easily. To fix that, apply these changes to
progs' print-tree.c:

--- a/print-tree.c
+++ b/print-tree.c
@@ -138,7 +138,7 @@ static void print_file_extent_item(struct extent_buffer *eb,
  btrfs_file_extent_inline_len(eb, fi),
  btrfs_file_extent_compression(eb, fi));
return;
-   }
+   } else
if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
printf("\t\tprealloc data disk byte %llu nr %llu\n",
  (unsigned long long)btrfs_file_extent_disk_bytenr(eb, fi),
@@ -147,6 +147,8 @@ static void print_file_extent_item(struct extent_buffer *eb,
  (unsigned long long)btrfs_file_extent_offset(eb, fi),
  (unsigned long long)btrfs_file_extent_num_bytes(eb, fi));
return;
+   } else {
+   printf("*** ERROR unknown extent type %d\n", extent_type);
}
printf("\t\textent data disk byte %llu nr %llu\n",
(unsigned long long)btrfs_file_extent_disk_bytenr(eb, fi),
---

and run the utility on your fs.


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Kernel BUG unable to handle kernel NULL pointer dereference

2011-10-24 Thread Leonidas Spyropoulos
On Mon, Oct 24, 2011 at 12:22 PM, David Sterba  wrote:
> On Sun, Oct 23, 2011 at 07:24:42PM +0100, Leonidas Spyropoulos wrote:
>> On Sun, Oct 23, 2011 at 4:37 PM, Mitch Harder
>>  wrote:
>> > A patch was submitted by Sergei Trofimovich to address the issue with
>> > handling a NULL pointer in btrfs_print_leaf.
>> >
>> > http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg12021.html
>
> afaik the patch should be enqueued for 3.2
>
>> How can I track down the real problem? Any suggestions?
>
> The preceding function in the stack was __btrfs_free_extent, there are 3
> instances of btrfs_print_leaf() in that function, 2 of them relevant:
>
> 4470                                 printk(KERN_ERR "umm, got %d back from 
> search"
> 4471                                        ", was looking for %llu\n", ret,
> 4472                                        (unsigned long long)bytenr);
>
>
> 4494 #ifdef BTRFS_COMPAT_EXTENT_TREE_V0
> ...
> 4511                         printk(KERN_ERR "umm, got %d back from search"
> 4512                                ", was looking for %llu\n", ret,
> 4513                                (unsigned long long)bytenr);
> 4514                         btrfs_print_leaf(extent_root, path->nodes[0]);
> ...
>     #endif
>
> and the third one without a pre-message
>
> 4481                 btrfs_print_leaf(extent_root, path->nodes[0]);
> 4482                 WARN_ON(1);
> 4483                 printk(KERN_ERR "btrfs unable to find ref byte nr %llu "
> 4484                        "parent %llu root %llu  owner %llu offset %llu\n",
> 4485                        (unsigned long long)bytenr,
> 4486                        (unsigned long long)parent,
> 4487                        (unsigned long long)root_objectid,
> 4488                        (unsigned long long)owner_objectid,
> 4489                        (unsigned long long)owner_offset);
>
>
> your original report does not contain any messages before the BUG
> listing, so I'm not sure which one it is.

I got the whole log somwehre lying arround, let me find it and give a
pastbin link

Here is it, it's big and contains usless information..

http://paste.pocoo.org/show/497299/

>
> Supposed it's the 3rd, it's resulting from an error returned by
>
> 4429         ret = lookup_extent_backref(trans, extent_root, path, &iref,
> 4430                                     bytenr, num_bytes, parent,
> 4431                                     root_objectid, owner_objectid,
> 4432                                     owner_offset);
>
> ret != 0 -> print leaf etc, a missing backref could be the problem here.
>
> Are you able to trigger the BUG() repeatedly?

No I cannot reproduce it intentionally, it was quite random, while
playing something in the SMPlayer - think it was a movie. The movie
kept playing, and I can start programs (that was on the memory I
assume), couldn't access the FS at all. ls failed for example.
So I just hard-reboot and hoped all was alright.

So far I didn't see any problems after that.



>
>
> david
>


Thanks for checking it

Regards
Leonidas


-- 
Caution: breathing may be hazardous to your health.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Kernel BUG unable to handle kernel NULL pointer dereference

2011-10-24 Thread David Sterba
On Sun, Oct 23, 2011 at 07:24:42PM +0100, Leonidas Spyropoulos wrote:
> On Sun, Oct 23, 2011 at 4:37 PM, Mitch Harder
>  wrote:
> > A patch was submitted by Sergei Trofimovich to address the issue with
> > handling a NULL pointer in btrfs_print_leaf.
> >
> > http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg12021.html

afaik the patch should be enqueued for 3.2

> How can I track down the real problem? Any suggestions?

The preceding function in the stack was __btrfs_free_extent, there are 3
instances of btrfs_print_leaf() in that function, 2 of them relevant:

4470 printk(KERN_ERR "umm, got %d back from 
search"
4471", was looking for %llu\n", ret,
4472(unsigned long long)bytenr);


4494 #ifdef BTRFS_COMPAT_EXTENT_TREE_V0
...
4511 printk(KERN_ERR "umm, got %d back from search"
4512", was looking for %llu\n", ret,
4513(unsigned long long)bytenr);
4514 btrfs_print_leaf(extent_root, path->nodes[0]);
...
 #endif

and the third one without a pre-message

4481 btrfs_print_leaf(extent_root, path->nodes[0]);
4482 WARN_ON(1);
4483 printk(KERN_ERR "btrfs unable to find ref byte nr %llu "
4484"parent %llu root %llu  owner %llu offset %llu\n",
4485(unsigned long long)bytenr,
4486(unsigned long long)parent,
4487(unsigned long long)root_objectid,
4488(unsigned long long)owner_objectid,
4489(unsigned long long)owner_offset);


your original report does not contain any messages before the BUG
listing, so I'm not sure which one it is.

Supposed it's the 3rd, it's resulting from an error returned by

4429 ret = lookup_extent_backref(trans, extent_root, path, &iref,
4430 bytenr, num_bytes, parent,
4431 root_objectid, owner_objectid,
4432 owner_offset);

ret != 0 -> print leaf etc, a missing backref could be the problem here.

Are you able to trigger the BUG() repeatedly?


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Subvolume level allocation policy

2011-10-24 Thread Jan Schmidt
On 23.10.2011 20:50, Phillip Susi wrote:
> Is it ( yet? ) possible to manipulate the allocation policy on a
> subvolume level instead of the fs level?  For example, to make / use
> raid1, and /home use raid0?  Or to have / allocated from an ssd and
> /home allocated from the giant 2tb hd.

At least the latter can be achieved with speed profiles. I worked on
those together with Arne Jansen who sent patches in January 2011,
subject "[PATCH] Btrfs: introducing speed profiles and dedicated log
devices".

I don't assume they apply nowadays without a major rework, though. We
should get those patches merged sometime.

-Jan
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Snapshot rollback

2011-10-24 Thread dima
Fajar A. Nugraha  fajar.net> writes:
 
> A problem with that, though, if you decide to put /boot on btrfs as
> well. Grub uses the default subvolume to determine paths (for kernel,
> initrd, etc). A workaround is to manually create and manage your
> grub.cfg (or create and use a manual-managed include file, like
> custom-top.cfg, that gets parsed before the automatically created
> entries).

Oops, sorry, I was incorrect of course. Thanks Fajar.
I do have /boot in my subvolid=0 because bootloaders can't read inside
subvolumes (other than the default) as far as I understand.
And I just bind /boot through fstab.

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html