1) add missing write check for mkfs 2) add kstrdup() return value check 3) remove unused code in btrfs_scan_one_device() Filipe David Borba Manana (3): Btrfs-progs: add missing write check for mkfs Btrfs-progs: add kstrdup() return value check Btrfs-progs: remove unused code in btrfs_scan_one_device() utils.c | 1 + volumes.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jun-30 11:51 UTC
[PATCH 1/3] Btrfs-progs: add missing write check for mkfs
Assert that the write of the device tree root succeeds. This verification is currently done for all other tree roots, however it was missing for the device tree root. Would this tree root write fail, but all others succeed, it would lead to a corrupted/incomplete btrfs filesystem. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utils.c b/utils.c index 7b4cd74..43d93f1 100644 --- a/utils.c +++ b/utils.c @@ -381,6 +381,7 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[4]); + BUG_ON(ret != leafsize); /* create the FS root */ memset(buf->data+sizeof(struct btrfs_header), 0, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jun-30 11:51 UTC
[PATCH 2/3] Btrfs-progs: add kstrdup() return value check
When allocating a btrfs_device structure, device_list_add() in volumes.c was not checking if the call to duplicate the label string succeeded or not. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- volumes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/volumes.c b/volumes.c index d6f81f8..ea1d401 100644 --- a/volumes.c +++ b/volumes.c @@ -125,6 +125,11 @@ static int device_list_add(const char *path, return -ENOMEM; } device->label = kstrdup(disk_super->label, GFP_NOFS); + if (!device->label) { + kfree(device->name); + kfree(device); + return -ENOMEM; + } device->total_devs = btrfs_super_num_devices(disk_super); device->super_bytes_used = btrfs_super_bytes_used(disk_super); device->total_bytes -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jun-30 11:51 UTC
[PATCH 3/3] Btrfs-progs: remove unused code
The uuid_unparse() call in btrfs_scan_one_device() was a no-op. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- volumes.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/volumes.c b/volumes.c index ea1d401..9d5e97e 100644 --- a/volumes.c +++ b/volumes.c @@ -223,7 +223,6 @@ int btrfs_scan_one_device(int fd, const char *path, char *buf; int ret; u64 devid; - char uuidbuf[37]; buf = malloc(4096); if (!buf) { @@ -241,7 +240,6 @@ int btrfs_scan_one_device(int fd, const char *path, *total_devs = 1; else *total_devs = btrfs_super_num_devices(disk_super); - uuid_unparse(disk_super->fsid, uuidbuf); ret = device_list_add(path, disk_super, devid, fs_devices_ret); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
good catch. Reviewed-by: Anand Jain <anand.jain@oracle.com> On 06/30/2013 07:51 PM, Filipe David Borba Manana wrote:> The uuid_unparse() call in btrfs_scan_one_device() was > a no-op. > > > Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> > --- > volumes.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/volumes.c b/volumes.c > index ea1d401..9d5e97e 100644 > --- a/volumes.c > +++ b/volumes.c > @@ -223,7 +223,6 @@ int btrfs_scan_one_device(int fd, const char *path, > char *buf; > int ret; > u64 devid; > - char uuidbuf[37]; > > buf = malloc(4096); > if (!buf) { > @@ -241,7 +240,6 @@ int btrfs_scan_one_device(int fd, const char *path, > *total_devs = 1; > else > *total_devs = btrfs_super_num_devices(disk_super); > - uuid_unparse(disk_super->fsid, uuidbuf); > > ret = device_list_add(path, disk_super, devid, fs_devices_ret); > >-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2013-Jul-03 17:09 UTC
Re: [PATCH 1/3] Btrfs-progs: add missing write check for mkfs
On Sun, Jun 30, 2013 at 12:51:44PM +0100, Filipe David Borba Manana wrote:> Assert that the write of the device tree root succeeds. > This verification is currently done for all other tree > roots, however it was missing for the device tree root. > > Would this tree root write fail, but all others succeed, > it would lead to a corrupted/incomplete btrfs filesystem. > > Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> > --- > utils.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/utils.c b/utils.c > index 7b4cd74..43d93f1 100644 > --- a/utils.c > +++ b/utils.c > @@ -381,6 +381,7 @@ int make_btrfs(int fd, const char *device, const char *label, > btrfs_set_header_nritems(buf, nritems); > csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); > ret = pwrite(fd, buf->data, leafsize, blocks[4]); > + BUG_ON(ret != leafsize);Please fix also the 2nd instance where the return value check is missing 344 btrfs_set_header_bytenr(buf, blocks[3]); 345 btrfs_set_header_owner(buf, BTRFS_CHUNK_TREE_OBJECTID); 346 btrfs_set_header_nritems(buf, nritems); 347 csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); 348 ret = pwrite(fd, buf->data, leafsize, blocks[3]); 349 350 /* create the device tree */ 351 memset(buf->data+sizeof(struct btrfs_header), 0, 352 leafsize-sizeof(struct btrfs_header));> > /* create the FS root */ > memset(buf->data+sizeof(struct btrfs_header), 0,Also, replacing the BUG_ON with something else would be nice of course. thanks, david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Manana
2013-Jul-03 17:25 UTC
Re: [PATCH 1/3] Btrfs-progs: add missing write check for mkfs
On Wed, Jul 3, 2013 at 6:09 PM, David Sterba <dsterba@suse.cz> wrote:> On Sun, Jun 30, 2013 at 12:51:44PM +0100, Filipe David Borba Manana wrote: >> Assert that the write of the device tree root succeeds. >> This verification is currently done for all other tree >> roots, however it was missing for the device tree root. >> >> Would this tree root write fail, but all others succeed, >> it would lead to a corrupted/incomplete btrfs filesystem. >> >> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> >> --- >> utils.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/utils.c b/utils.c >> index 7b4cd74..43d93f1 100644 >> --- a/utils.c >> +++ b/utils.c >> @@ -381,6 +381,7 @@ int make_btrfs(int fd, const char *device, const char *label, >> btrfs_set_header_nritems(buf, nritems); >> csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); >> ret = pwrite(fd, buf->data, leafsize, blocks[4]); >> + BUG_ON(ret != leafsize); > > Please fix also the 2nd instance where the return value check is > missingGood catch, thanks. Adding it now.> > 344 btrfs_set_header_bytenr(buf, blocks[3]); > 345 btrfs_set_header_owner(buf, BTRFS_CHUNK_TREE_OBJECTID); > 346 btrfs_set_header_nritems(buf, nritems); > 347 csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); > 348 ret = pwrite(fd, buf->data, leafsize, blocks[3]); > 349 > 350 /* create the device tree */ > 351 memset(buf->data+sizeof(struct btrfs_header), 0, > 352 leafsize-sizeof(struct btrfs_header)); > >> >> /* create the FS root */ >> memset(buf->data+sizeof(struct btrfs_header), 0, > > Also, replacing the BUG_ON with something else would be nice of course.If you don''t mind, I would prefer to do that as a different patch, since the BUG_ON() use is what is currently done everywhere in this function at least. thanks> > thanks, > david-- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-03 17:30 UTC
[PATCH v2 1/3] Btrfs-progs: add missing write check for mkfs
Assert that the writes of the device and chunk tree roots succeed. This verification is currently done for all other tree roots, however it was missing for those 2 trees. Would these tree root writes fail, but all others succeed, it would lead to a corrupted/incomplete btrfs filesystem, or, more likely some weird failure later on in mkfs.btrfs inside open_ctree(). V2: Added check for the chunk tree root write. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils.c b/utils.c index 7b4cd74..702a0b1 100644 --- a/utils.c +++ b/utils.c @@ -346,6 +346,7 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[3]); + BUG_ON(ret != leafsize); /* create the device tree */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -381,6 +382,7 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[4]); + BUG_ON(ret != leafsize); /* create the FS root */ memset(buf->data+sizeof(struct btrfs_header), 0, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-03 17:32 UTC
[PATCH v2 3/3] Btrfs-progs: remove unused code
V2: removed unused statement in extent-cache.c:tree_insert() too. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- extent-cache.c | 1 - volumes.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/extent-cache.c b/extent-cache.c index 3dd6434..a8bab59 100644 --- a/extent-cache.c +++ b/extent-cache.c @@ -44,7 +44,6 @@ static struct rb_node *tree_insert(struct rb_root *root, u64 offset, return parent; } - entry = rb_entry(parent, struct cache_extent, rb_node); rb_link_node(node, parent, p); rb_insert_color(node, root); return NULL; diff --git a/volumes.c b/volumes.c index ea1d401..9d5e97e 100644 --- a/volumes.c +++ b/volumes.c @@ -223,7 +223,6 @@ int btrfs_scan_one_device(int fd, const char *path, char *buf; int ret; u64 devid; - char uuidbuf[37]; buf = malloc(4096); if (!buf) { @@ -241,7 +240,6 @@ int btrfs_scan_one_device(int fd, const char *path, *total_devs = 1; else *total_devs = btrfs_super_num_devices(disk_super); - uuid_unparse(disk_super->fsid, uuidbuf); ret = device_list_add(path, disk_super, devid, fs_devices_ret); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2013-Jul-03 21:12 UTC
Re: [PATCH 1/3] Btrfs-progs: add missing write check for mkfs
On Wed, Jul 03, 2013 at 06:25:59PM +0100, Filipe David Manana wrote:> > Also, replacing the BUG_ON with something else would be nice of course. > > If you don''t mind, I would prefer to do that as a different patch, > since the BUG_ON() use is what is currently done everywhere in this > function at least.Yes, separate patch. thanks, david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-04 09:48 UTC
[PATCH v2 0/5] Small fixes for btrfs-progs
1) add missing write checks for mkfs 2) add kstrdup() return value check 3) remove unused code 4) make_btrfs() return error code on write failure 5) check for errors in btrfs_add_block_group() V2: added patches 4 and 5. Filipe David Borba Manana (5): Btrfs-progs: add missing write check for mkfs Btrfs-progs: add kstrdup() return value check Btrfs-progs: remove unused code Btrfs-progs: return error on write failure in make_btrfs() Btrfs-progs: don''t ignore errors in btrfs_add_block_group() btrfs-convert.c | 3 ++- extent-cache.c | 1 - extent-tree.c | 12 +++++++----- mkfs.c | 2 +- utils.c | 34 ++++++++++++++++++++++++++++------ volumes.c | 7 +++++-- 6 files changed, 43 insertions(+), 16 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-04 09:48 UTC
[PATCH 4/5] Btrfs-progs: return error on write failure in make_btrfs()
Instead of aborting with a BUG_ON() statement, return a negated errno code. Also updated mkfs and convert tools to print a nicer error message when make_btrfs() returns an error. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- btrfs-convert.c | 3 ++- mkfs.c | 2 +- utils.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/btrfs-convert.c b/btrfs-convert.c index 399856f..0e66eb9 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2323,7 +2323,8 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) blocks, total_bytes, blocksize, blocksize, blocksize, blocksize); if (ret) { - fprintf(stderr, "unable to create initial ctree\n"); + fprintf(stderr, "unable to create initial ctree: %s\n", + strerror(-ret)); goto fail; } /* create a system chunk that maps the whole device */ diff --git a/mkfs.c b/mkfs.c index 7ff60e5..348bcaa 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1446,7 +1446,7 @@ int main(int ac, char **av) nodesize, leafsize, sectorsize, stripesize); if (ret) { - fprintf(stderr, "error during mkfs %d\n", ret); + fprintf(stderr, "error during mkfs: %s\n", strerror(-ret)); exit(1); } diff --git a/utils.c b/utils.c index 702a0b1..f43816b 100644 --- a/utils.c +++ b/utils.c @@ -215,7 +215,10 @@ int make_btrfs(int fd, const char *device, const char *label, csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[1]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* create the items for the extent tree */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -262,7 +265,10 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[2]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* create the chunk tree */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -346,7 +352,10 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[3]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* create the device tree */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -382,7 +391,10 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[4]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* create the FS root */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -392,7 +404,10 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[5]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* finally create the csum root */ memset(buf->data+sizeof(struct btrfs_header), 0, @@ -402,7 +417,10 @@ int make_btrfs(int fd, const char *device, const char *label, btrfs_set_header_nritems(buf, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, leafsize, blocks[6]); - BUG_ON(ret != leafsize); + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; /* and write out the super block */ BUG_ON(sizeof(super) > sectorsize); @@ -411,8 +429,10 @@ int make_btrfs(int fd, const char *device, const char *label, buf->len = sectorsize; csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); ret = pwrite(fd, buf->data, sectorsize, blocks[0]); - BUG_ON(ret != sectorsize); - + if (ret < 0) + return -errno; + else if (ret != leafsize) + return -EIO; free(buf); return 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-04 09:48 UTC
[PATCH 5/5] Btrfs-progs: don''t ignore errors in btrfs_add_block_group()
This function was not checking if the calls to set_extent_bits() and set_state_private() actually succeeded or not. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- extent-tree.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index b0cfe0a..d260c14 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -3355,12 +3355,14 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, BUG_ON(ret); bit = block_group_state_bits(type); - set_extent_bits(block_group_cache, chunk_offset, - chunk_offset + size - 1, - bit | EXTENT_LOCKED, GFP_NOFS); + ret = set_extent_bits(block_group_cache, chunk_offset, + chunk_offset + size - 1, + bit | EXTENT_LOCKED, GFP_NOFS); + BUG_ON(ret); - set_state_private(block_group_cache, chunk_offset, - (unsigned long)cache); + ret = set_state_private(block_group_cache, chunk_offset, + (unsigned long)cache); + BUG_ON(ret); set_avail_alloc_bits(fs_info, type); return cache; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Borba Manana
2013-Jul-08 13:21 UTC
[PATCH v2 5/5] Btrfs-progs: don''t ignore errors in extent-tree.c
Several function return values were being completely ignored. V2: Added more error checking all over extent-tree.c Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- extent-tree.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index 6490d8a..6458ce4 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -2110,6 +2110,7 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, extent_op->flags, &extent_op->key, extent_op->level, &key); + BUG_ON(ret); } else { BUG_ON(1); } @@ -2756,7 +2757,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ret = update_block_group(trans, root, ins->objectid, root->leafsize, 1, 0); - return 0; + return ret; } static int alloc_tree_block(struct btrfs_trans_handle *trans, @@ -3345,12 +3346,14 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, BUG_ON(ret); bit = block_group_state_bits(type); - set_extent_bits(block_group_cache, chunk_offset, - chunk_offset + size - 1, - bit | EXTENT_LOCKED, GFP_NOFS); + ret = set_extent_bits(block_group_cache, chunk_offset, + chunk_offset + size - 1, + bit | EXTENT_LOCKED, GFP_NOFS); + BUG_ON(ret); - set_state_private(block_group_cache, chunk_offset, - (unsigned long)cache); + ret = set_state_private(block_group_cache, chunk_offset, + (unsigned long)cache); + BUG_ON(ret); set_avail_alloc_bits(fs_info, type); return cache; @@ -3372,8 +3375,11 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, sizeof(cache->item)); BUG_ON(ret); - finish_current_insert(trans, extent_root); + ret = finish_current_insert(trans, extent_root); + BUG_ON(ret); ret = del_pending_extents(trans, extent_root); + BUG_ON(ret); + return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Stefan Behrens
2013-Aug-08 10:52 UTC
Re: [PATCH 4/5] Btrfs-progs: return error on write failure in make_btrfs()
On Thu, 4 Jul 2013 10:48:39 +0100, Filipe David Borba Manana wrote:> Instead of aborting with a BUG_ON() statement, return a > negated errno code. Also updated mkfs and convert tools > to print a nicer error message when make_btrfs() returns > an error. > > Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>[...]> ret = pwrite(fd, buf->data, sectorsize, blocks[0]); > - BUG_ON(ret != sectorsize); > - > + if (ret < 0) > + return -errno; > + else if (ret != leafsize) > + return -EIO;mkfs.btrfs with leafsize != sectorsize fails. I''ve sent a patch for it. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Filipe David Manana
2013-Aug-08 10:56 UTC
Re: [PATCH 4/5] Btrfs-progs: return error on write failure in make_btrfs()
On Thu, Aug 8, 2013 at 11:52 AM, Stefan Behrens <sbehrens@giantdisaster.de> wrote:> On Thu, 4 Jul 2013 10:48:39 +0100, Filipe David Borba Manana wrote: >> Instead of aborting with a BUG_ON() statement, return a >> negated errno code. Also updated mkfs and convert tools >> to print a nicer error message when make_btrfs() returns >> an error. >> >> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> > [...] >> ret = pwrite(fd, buf->data, sectorsize, blocks[0]); >> - BUG_ON(ret != sectorsize); >> - >> + if (ret < 0) >> + return -errno; >> + else if (ret != leafsize) >> + return -EIO; > > mkfs.btrfs with leafsize != sectorsize fails. I''ve sent a patch for it.Copy paste error :( Thanks for catching and fixing it.>-- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html