On Fri, Nov 7, 2014 at 12:15 PM, Filipe Manana <fdmanana@xxxxxxxx> wrote: > When attempting to insert a new dir_item, we were calling btrfs_extent_item() > without checking if the leaf has enough space to extend the item. This made > btrfs_extent_item() crash through a BUG() call. > Therefore do the check and return ENOSPC if the leaf doesn't have enough space. Please ignore, this isn't needed, because btrfs_insert_empty_item / btrfs_search_slot gives us a leaf with enough space when they return -eexist / 0 and -eoverflow otherwise. > > Signed-off-by: Filipe Manana <fdmanana@xxxxxxxx> > --- > fs/btrfs/dir-item.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c > index fc8df86..65bf60e 100644 > --- a/fs/btrfs/dir-item.c > +++ b/fs/btrfs/dir-item.c > @@ -53,6 +53,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); > + if (btrfs_leaf_free_space(root, path->nodes[0]) < data_size) > + return ERR_PTR(-ENOSPC); > btrfs_extend_item(root, path, data_size); > } else if (ret < 0) > return ERR_PTR(ret); > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Filipe David Manana, "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men." -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
