* [PATCH 0/8] Bio allocation and error handling cleanups
@ 2017-06-02 16:58 David Sterba
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
` (7 more replies)
0 siblings, 8 replies; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
The error handling can be simplified as we do bio allocations using a bioset as
was pointed out by Christoph in https://lkml.kernel.org/r/20170516143737.GA24541@infradead.org
David Sterba (8):
btrfs: bioset allocations will never fail, adapt our helpers
btrfs: btrfs_bio_alloc never fails, skip error handling
btrfs: btrfs_bio_clone never fails, skip error handling
btrfs: btrfs_io_bio_alloc never fails, skip error handling
btrfs: sink gfp parameter to btrfs_bio_clone
btrfs: remove redundant parameters from btrfs_bio_alloc
btrfs: opencode trivial compressed_bio_alloc, simplify error handling
btrfs: pass bytes to btrfs_bio_alloc
fs/btrfs/check-integrity.c | 5 ----
fs/btrfs/compression.c | 23 +++------------
fs/btrfs/disk-io.c | 3 --
fs/btrfs/extent_io.c | 71 ++++++++++++++++------------------------------
fs/btrfs/extent_io.h | 6 ++--
fs/btrfs/inode.c | 6 +---
fs/btrfs/raid56.c | 3 --
fs/btrfs/scrub.c | 25 ----------------
fs/btrfs/volumes.c | 3 +-
9 files changed, 32 insertions(+), 113 deletions(-)
--
2.12.0
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-03 5:10 ` Christoph Hellwig
` (2 more replies)
2017-06-02 16:58 ` [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling David Sterba
` (6 subsequent siblings)
7 siblings, 3 replies; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba, Christoph Hellwig, Liu Bo
Christoph pointed out that bio allocations backed by a bioset will never
fail. As we always use a bioset for all bio allocations, we can skip
the error handling. This patch adjusts our low-level helpers, the
cascaded changes to all callers will come next.
CC: Christoph Hellwig <hch@lst.de>
CC: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/extent_io.c | 50 +++++++++++++++++++-------------------------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 5909f8214255..78a787c36a35 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2659,8 +2659,9 @@ static void end_bio_extent_readpage(struct bio *bio)
}
/*
- * this allocates from the btrfs_bioset. We're returning a bio right now
- * but you can call btrfs_io_bio for the appropriate container_of magic
+ * The following helpers allocate a bio. As it's backed by a bioset, it'll
+ * never fail. We're returning a bio right now but you can call btrfs_io_bio
+ * for the appropriate container_of magic
*/
struct bio *
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
@@ -2670,22 +2671,12 @@ btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
struct bio *bio;
bio = bio_alloc_bioset(gfp_flags, nr_vecs, btrfs_bioset);
-
- if (bio == NULL && (current->flags & PF_MEMALLOC)) {
- while (!bio && (nr_vecs /= 2)) {
- bio = bio_alloc_bioset(gfp_flags,
- nr_vecs, btrfs_bioset);
- }
- }
-
- if (bio) {
- bio->bi_bdev = bdev;
- bio->bi_iter.bi_sector = first_sector;
- btrfs_bio = btrfs_io_bio(bio);
- btrfs_bio->csum = NULL;
- btrfs_bio->csum_allocated = NULL;
- btrfs_bio->end_io = NULL;
- }
+ bio->bi_bdev = bdev;
+ bio->bi_iter.bi_sector = first_sector;
+ btrfs_bio = btrfs_io_bio(bio);
+ btrfs_bio->csum = NULL;
+ btrfs_bio->csum_allocated = NULL;
+ btrfs_bio->end_io = NULL;
return bio;
}
@@ -2694,29 +2685,26 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
struct btrfs_io_bio *btrfs_bio;
struct bio *new;
+ /* Bio allocation backed by a bioset does not fail */
new = bio_clone_fast(bio, gfp_mask, btrfs_bioset);
- if (new) {
- btrfs_bio = btrfs_io_bio(new);
- btrfs_bio->csum = NULL;
- btrfs_bio->csum_allocated = NULL;
- btrfs_bio->end_io = NULL;
- }
+ btrfs_bio = btrfs_io_bio(new);
+ btrfs_bio->csum = NULL;
+ btrfs_bio->csum_allocated = NULL;
+ btrfs_bio->end_io = NULL;
return new;
}
-/* this also allocates from the btrfs_bioset */
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
{
struct btrfs_io_bio *btrfs_bio;
struct bio *bio;
+ /* Bio allocation backed by a bioset does not fail */
bio = bio_alloc_bioset(gfp_mask, nr_iovecs, btrfs_bioset);
- if (bio) {
- btrfs_bio = btrfs_io_bio(bio);
- btrfs_bio->csum = NULL;
- btrfs_bio->csum_allocated = NULL;
- btrfs_bio->end_io = NULL;
- }
+ btrfs_bio = btrfs_io_bio(bio);
+ btrfs_bio->csum = NULL;
+ btrfs_bio->csum_allocated = NULL;
+ btrfs_bio->end_io = NULL;
return bio;
}
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-02 16:58 ` [PATCH 3/8] btrfs: btrfs_bio_clone " David Sterba
` (5 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Update direct callers of btrfs_bio_alloc that do error handling, that we
can now remove.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/extent_io.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 78a787c36a35..17f80a18e787 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2807,9 +2807,6 @@ static int submit_extent_page(int op, int op_flags, struct extent_io_tree *tree,
bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
GFP_NOFS | __GFP_HIGH);
- if (!bio)
- return -ENOMEM;
-
bio_add_page(bio, page, page_size, offset);
bio->bi_end_io = end_io_func;
bio->bi_private = tree;
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 3/8] btrfs: btrfs_bio_clone never fails, skip error handling
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
2017-06-02 16:58 ` [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-07 18:19 ` Omar Sandoval
2017-06-02 16:58 ` [PATCH 4/8] btrfs: btrfs_io_bio_alloc " David Sterba
` (4 subsequent siblings)
7 siblings, 2 replies; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Update direct callers of btrfs_bio_clone that do error handling, that we
can now remove.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/inode.c | 4 ----
fs/btrfs/volumes.c | 1 -
2 files changed, 5 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0a1ec5cd3b8f..c8ed81edd40e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8584,10 +8584,6 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
bio = btrfs_bio_clone(dio_bio, GFP_NOFS);
- if (!bio) {
- ret = -ENOMEM;
- goto free_ordered;
- }
dip = kzalloc(sizeof(*dip), GFP_NOFS);
if (!dip) {
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e28c113785bb..864b203cc4aa 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6257,7 +6257,6 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
if (dev_nr < total_devs - 1) {
bio = btrfs_bio_clone(first_bio, GFP_NOFS);
- BUG_ON(!bio); /* -ENOMEM */
} else
bio = first_bio;
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 4/8] btrfs: btrfs_io_bio_alloc never fails, skip error handling
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
` (2 preceding siblings ...)
2017-06-02 16:58 ` [PATCH 3/8] btrfs: btrfs_bio_clone " David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-02 16:58 ` [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone David Sterba
` (3 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Update direct callers of btrfs_io_bio_alloc that do error handling, that
we can now remove.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/check-integrity.c | 5 -----
fs/btrfs/disk-io.c | 3 ---
fs/btrfs/extent_io.c | 5 -----
fs/btrfs/raid56.c | 3 ---
fs/btrfs/scrub.c | 25 -------------------------
5 files changed, 41 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 6cabc8acee2a..8d1ba84b61f3 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1639,11 +1639,6 @@ static int btrfsic_read_block(struct btrfsic_state *state,
unsigned int j;
bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i);
- if (!bio) {
- pr_info("btrfsic: bio_alloc() for %u pages failed!\n",
- num_pages - i);
- return -1;
- }
bio->bi_bdev = block_ctx->dev->bdev;
bio->bi_iter.bi_sector = dev_bytenr >> 9;
bio_set_op_attrs(bio, REQ_OP_READ, 0);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index cb79bce3a972..9f2ffe2c6afb 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3533,9 +3533,6 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
*/
device->flush_bio = NULL;
bio = btrfs_io_bio_alloc(GFP_NOFS, 0);
- if (!bio)
- return -ENOMEM;
-
bio->bi_end_io = btrfs_end_empty_barrier;
bio->bi_bdev = device->bdev;
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 17f80a18e787..a10906915bc9 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1988,8 +1988,6 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
BUG_ON(!mirror_num);
bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
- if (!bio)
- return -EIO;
bio->bi_iter.bi_size = 0;
map_length = length;
@@ -2334,9 +2332,6 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
struct btrfs_io_bio *btrfs_bio;
bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
- if (!bio)
- return NULL;
-
bio->bi_end_io = endio_func;
bio->bi_iter.bi_sector = failrec->logical >> 9;
bio->bi_bdev = fs_info->fs_devices->latest_bdev;
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index d8ea0eb76325..6938da452041 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1102,9 +1102,6 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
/* put a new bio on the list */
bio = btrfs_io_bio_alloc(GFP_NOFS, bio_max_len >> PAGE_SHIFT?:1);
- if (!bio)
- return -ENOMEM;
-
bio->bi_iter.bi_size = 0;
bio->bi_bdev = stripe->dev->bdev;
bio->bi_iter.bi_sector = disk_start >> 9;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index e99be644b19f..75f1966ca1d3 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1729,11 +1729,6 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
WARN_ON(!page->page);
bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
- if (!bio) {
- page->io_error = 1;
- sblock->no_io_error_seen = 0;
- continue;
- }
bio->bi_bdev = page->dev->bdev;
bio_add_page(bio, page->page, PAGE_SIZE, 0);
@@ -1822,8 +1817,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
}
bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
- if (!bio)
- return -EIO;
bio->bi_bdev = page_bad->dev->bdev;
bio->bi_iter.bi_sector = page_bad->physical >> 9;
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
@@ -1915,10 +1908,6 @@ static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx,
if (!bio) {
bio = btrfs_io_bio_alloc(GFP_KERNEL,
sctx->pages_per_wr_bio);
- if (!bio) {
- mutex_unlock(&sctx->wr_lock);
- return -ENOMEM;
- }
sbio->bio = bio;
}
@@ -2320,8 +2309,6 @@ static int scrub_add_page_to_rd_bio(struct scrub_ctx *sctx,
if (!bio) {
bio = btrfs_io_bio_alloc(GFP_KERNEL,
sctx->pages_per_rd_bio);
- if (!bio)
- return -ENOMEM;
sbio->bio = bio;
}
@@ -2448,9 +2435,6 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock)
}
bio = btrfs_io_bio_alloc(GFP_NOFS, 0);
- if (!bio)
- goto bbio_out;
-
bio->bi_iter.bi_sector = logical >> 9;
bio->bi_private = sblock;
bio->bi_end_io = scrub_missing_raid56_end_io;
@@ -3027,9 +3011,6 @@ static void scrub_parity_check_and_repair(struct scrub_parity *sparity)
goto bbio_out;
bio = btrfs_io_bio_alloc(GFP_NOFS, 0);
- if (!bio)
- goto bbio_out;
-
bio->bi_iter.bi_sector = sparity->logic_start >> 9;
bio->bi_private = sparity;
bio->bi_end_io = scrub_parity_bio_endio;
@@ -4637,12 +4618,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
return -EIO;
}
bio = btrfs_io_bio_alloc(GFP_NOFS, 1);
- if (!bio) {
- spin_lock(&sctx->stat_lock);
- sctx->stat.malloc_errors++;
- spin_unlock(&sctx->stat_lock);
- return -ENOMEM;
- }
bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = physical_for_dev_replace >> 9;
bio->bi_bdev = dev->bdev;
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
` (3 preceding siblings ...)
2017-06-02 16:58 ` [PATCH 4/8] btrfs: btrfs_io_bio_alloc " David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:12 ` Anand Jain
2017-06-02 16:58 ` [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc David Sterba
` (2 subsequent siblings)
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
All callers pass GFP_NOFS.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/extent_io.c | 4 ++--
fs/btrfs/extent_io.h | 2 +-
fs/btrfs/inode.c | 2 +-
fs/btrfs/volumes.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a10906915bc9..a8f135286fa5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2675,13 +2675,13 @@ btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
return bio;
}
-struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
+struct bio *btrfs_bio_clone(struct bio *bio)
{
struct btrfs_io_bio *btrfs_bio;
struct bio *new;
/* Bio allocation backed by a bioset does not fail */
- new = bio_clone_fast(bio, gfp_mask, btrfs_bioset);
+ new = bio_clone_fast(bio, GFP_NOFS, btrfs_bioset);
btrfs_bio = btrfs_io_bio(new);
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index e3512c5d8770..4fe643a5aeaf 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -466,7 +466,7 @@ struct bio *
btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
gfp_t gfp_flags);
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs);
-struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask);
+struct bio *btrfs_bio_clone(struct bio *bio);
struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size);
struct btrfs_fs_info;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c8ed81edd40e..5112f2c45600 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8583,7 +8583,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
- bio = btrfs_bio_clone(dio_bio, GFP_NOFS);
+ bio = btrfs_bio_clone(dio_bio);
dip = kzalloc(sizeof(*dip), GFP_NOFS);
if (!dip) {
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 864b203cc4aa..70bcebef7aa6 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6256,7 +6256,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
}
if (dev_nr < total_devs - 1) {
- bio = btrfs_bio_clone(first_bio, GFP_NOFS);
+ bio = btrfs_bio_clone(first_bio);
} else
bio = first_bio;
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
` (4 preceding siblings ...)
2017-06-02 16:58 ` [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 7:40 ` Anand Jain
2017-06-02 16:58 ` [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling David Sterba
2017-06-02 16:58 ` [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc David Sterba
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
All callers pass gfp_flags=GFP_NOFS and nr_vecs=BIO_MAX_PAGES.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 2 +-
fs/btrfs/extent_io.c | 9 +++------
fs/btrfs/extent_io.h | 4 +---
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index ba511dd454d5..7ad0a1c4be68 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -56,7 +56,7 @@ static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
static struct bio *compressed_bio_alloc(struct block_device *bdev,
u64 first_byte, gfp_t gfp_flags)
{
- return btrfs_bio_alloc(bdev, first_byte >> 9, BIO_MAX_PAGES, gfp_flags);
+ return btrfs_bio_alloc(bdev, first_byte >> 9);
}
static int check_compressed_csum(struct btrfs_inode *inode,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a8f135286fa5..5730b4e747f1 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2658,14 +2658,12 @@ static void end_bio_extent_readpage(struct bio *bio)
* never fail. We're returning a bio right now but you can call btrfs_io_bio
* for the appropriate container_of magic
*/
-struct bio *
-btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
- gfp_t gfp_flags)
+struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector)
{
struct btrfs_io_bio *btrfs_bio;
struct bio *bio;
- bio = bio_alloc_bioset(gfp_flags, nr_vecs, btrfs_bioset);
+ bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, btrfs_bioset);
bio->bi_bdev = bdev;
bio->bi_iter.bi_sector = first_sector;
btrfs_bio = btrfs_io_bio(bio);
@@ -2800,8 +2798,7 @@ static int submit_extent_page(int op, int op_flags, struct extent_io_tree *tree,
}
}
- bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
- GFP_NOFS | __GFP_HIGH);
+ bio = btrfs_bio_alloc(bdev, sector);
bio_add_page(bio, page, page_size, offset);
bio->bi_end_io = end_io_func;
bio->bi_private = tree;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 4fe643a5aeaf..fb7a938ecbc9 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -462,9 +462,7 @@ void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
u64 delalloc_end, struct page *locked_page,
unsigned bits_to_clear,
unsigned long page_ops);
-struct bio *
-btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
- gfp_t gfp_flags);
+struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector);
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs);
struct bio *btrfs_bio_clone(struct bio *bio);
struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size);
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
` (5 preceding siblings ...)
2017-06-02 16:58 ` [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:21 ` Anand Jain
2017-06-02 16:58 ` [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc David Sterba
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
compressed_bio_alloc is now a trivial wrapper around btrfs_bio_alloc, no
point keeping it. The error handling can be simplified, as we know
btrfs_bio_alloc will never fail.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7ad0a1c4be68..2df080c4ece0 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -53,12 +53,6 @@ static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
(DIV_ROUND_UP(disk_size, fs_info->sectorsize)) * csum_size;
}
-static struct bio *compressed_bio_alloc(struct block_device *bdev,
- u64 first_byte, gfp_t gfp_flags)
-{
- return btrfs_bio_alloc(bdev, first_byte >> 9);
-}
-
static int check_compressed_csum(struct btrfs_inode *inode,
struct compressed_bio *cb,
u64 disk_start)
@@ -311,11 +305,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
bdev = fs_info->fs_devices->latest_bdev;
- bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
- if (!bio) {
- kfree(cb);
- return -ENOMEM;
- }
+ bio = btrfs_bio_alloc(bdev, first_byte >> 9);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_private = cb;
bio->bi_end_io = end_compressed_bio_write;
@@ -362,8 +352,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
bio_put(bio);
- bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS);
- BUG_ON(!bio);
+ bio = btrfs_bio_alloc(bdev, first_byte >> 9);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_private = cb;
bio->bi_end_io = end_compressed_bio_write;
@@ -606,9 +595,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
/* include any pages we added in add_ra-bio_pages */
cb->len = bio->bi_iter.bi_size;
- comp_bio = compressed_bio_alloc(bdev, cur_disk_byte, GFP_NOFS);
- if (!comp_bio)
- goto fail2;
+ comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
bio_set_op_attrs (comp_bio, REQ_OP_READ, 0);
comp_bio->bi_private = cb;
comp_bio->bi_end_io = end_compressed_bio_read;
@@ -659,9 +646,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
bio_put(comp_bio);
- comp_bio = compressed_bio_alloc(bdev, cur_disk_byte,
- GFP_NOFS);
- BUG_ON(!comp_bio);
+ comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
bio_set_op_attrs(comp_bio, REQ_OP_READ, 0);
comp_bio->bi_private = cb;
comp_bio->bi_end_io = end_compressed_bio_read;
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
` (6 preceding siblings ...)
2017-06-02 16:58 ` [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling David Sterba
@ 2017-06-02 16:58 ` David Sterba
2017-06-07 9:22 ` Anand Jain
7 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2017-06-02 16:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Most callers of btrfs_bio_alloc convert from bytes to sectors. Hide that
in the helper and simplify the logic in the callsers.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/compression.c | 8 ++++----
fs/btrfs/extent_io.c | 6 +++---
fs/btrfs/extent_io.h | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 2df080c4ece0..fd6508bcff77 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -305,7 +305,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
bdev = fs_info->fs_devices->latest_bdev;
- bio = btrfs_bio_alloc(bdev, first_byte >> 9);
+ bio = btrfs_bio_alloc(bdev, first_byte);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_private = cb;
bio->bi_end_io = end_compressed_bio_write;
@@ -352,7 +352,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
bio_put(bio);
- bio = btrfs_bio_alloc(bdev, first_byte >> 9);
+ bio = btrfs_bio_alloc(bdev, first_byte);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_private = cb;
bio->bi_end_io = end_compressed_bio_write;
@@ -595,7 +595,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
/* include any pages we added in add_ra-bio_pages */
cb->len = bio->bi_iter.bi_size;
- comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
+ comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte);
bio_set_op_attrs (comp_bio, REQ_OP_READ, 0);
comp_bio->bi_private = cb;
comp_bio->bi_end_io = end_compressed_bio_read;
@@ -646,7 +646,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
bio_put(comp_bio);
- comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte >> 9);
+ comp_bio = btrfs_bio_alloc(bdev, cur_disk_byte);
bio_set_op_attrs(comp_bio, REQ_OP_READ, 0);
comp_bio->bi_private = cb;
comp_bio->bi_end_io = end_compressed_bio_read;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 5730b4e747f1..cb4754e57ace 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2658,14 +2658,14 @@ static void end_bio_extent_readpage(struct bio *bio)
* never fail. We're returning a bio right now but you can call btrfs_io_bio
* for the appropriate container_of magic
*/
-struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector)
+struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte)
{
struct btrfs_io_bio *btrfs_bio;
struct bio *bio;
bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, btrfs_bioset);
bio->bi_bdev = bdev;
- bio->bi_iter.bi_sector = first_sector;
+ bio->bi_iter.bi_sector = first_byte >> 9;
btrfs_bio = btrfs_io_bio(bio);
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
@@ -2798,7 +2798,7 @@ static int submit_extent_page(int op, int op_flags, struct extent_io_tree *tree,
}
}
- bio = btrfs_bio_alloc(bdev, sector);
+ bio = btrfs_bio_alloc(bdev, sector << 9);
bio_add_page(bio, page, page_size, offset);
bio->bi_end_io = end_io_func;
bio->bi_private = tree;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index fb7a938ecbc9..8071e3977614 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -462,7 +462,7 @@ void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
u64 delalloc_end, struct page *locked_page,
unsigned bits_to_clear,
unsigned long page_ops);
-struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_sector);
+struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte);
struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs);
struct bio *btrfs_bio_clone(struct bio *bio);
struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size);
--
2.12.0
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
@ 2017-06-03 5:10 ` Christoph Hellwig
2017-06-06 10:21 ` Anand Jain
2017-06-07 9:10 ` Anand Jain
2 siblings, 0 replies; 25+ messages in thread
From: Christoph Hellwig @ 2017-06-03 5:10 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs, Christoph Hellwig, Liu Bo
On Fri, Jun 02, 2017 at 06:58:30PM +0200, David Sterba wrote:
> Christoph pointed out that bio allocations backed by a bioset will never
> fail. As we always use a bioset for all bio allocations, we can skip
> the error handling. This patch adjusts our low-level helpers, the
> cascaded changes to all callers will come next.
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
2017-06-03 5:10 ` Christoph Hellwig
@ 2017-06-06 10:21 ` Anand Jain
2017-06-06 10:44 ` Christoph Hellwig
2017-06-06 10:51 ` David Sterba
2017-06-07 9:10 ` Anand Jain
2 siblings, 2 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-06 10:21 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs, Christoph Hellwig, Liu Bo
On 06/03/17 00:58, David Sterba wrote:
> Christoph pointed out that bio allocations backed by a bioset will never
> fail.
David,
Looks like this feature comes when __GFP_DIRECT_RECLAIM is
set and we aren't, such as [1]. Any idea why? Looks like I am
missing something ?
[1]
-----
static int submit_extent_page(int op, int op_flags, struct
extent_io_tree *tree,
::
bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
GFP_NOFS | __GFP_HIGH);
------
Thanks, Anand
> As we always use a bioset for all bio allocations, we can skip
> the error handling. This patch adjusts our low-level helpers, the
> cascaded changes to all callers will come next.
>
> CC: Christoph Hellwig <hch@lst.de>
> CC: Liu Bo <bo.li.liu@oracle.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/extent_io.c | 50 +++++++++++++++++++-------------------------------
> 1 file changed, 19 insertions(+), 31 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 5909f8214255..78a787c36a35 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2659,8 +2659,9 @@ static void end_bio_extent_readpage(struct bio *bio)
> }
>
> /*
> - * this allocates from the btrfs_bioset. We're returning a bio right now
> - * but you can call btrfs_io_bio for the appropriate container_of magic
> + * The following helpers allocate a bio. As it's backed by a bioset, it'll
> + * never fail. We're returning a bio right now but you can call btrfs_io_bio
> + * for the appropriate container_of magic
> */
> struct bio *
> btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
> @@ -2670,22 +2671,12 @@ btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
> struct bio *bio;
>
> bio = bio_alloc_bioset(gfp_flags, nr_vecs, btrfs_bioset);
> -
> - if (bio == NULL && (current->flags & PF_MEMALLOC)) {
> - while (!bio && (nr_vecs /= 2)) {
> - bio = bio_alloc_bioset(gfp_flags,
> - nr_vecs, btrfs_bioset);
> - }
> - }
> -
> - if (bio) {
> - bio->bi_bdev = bdev;
> - bio->bi_iter.bi_sector = first_sector;
> - btrfs_bio = btrfs_io_bio(bio);
> - btrfs_bio->csum = NULL;
> - btrfs_bio->csum_allocated = NULL;
> - btrfs_bio->end_io = NULL;
> - }
> + bio->bi_bdev = bdev;
> + bio->bi_iter.bi_sector = first_sector;
> + btrfs_bio = btrfs_io_bio(bio);
> + btrfs_bio->csum = NULL;
> + btrfs_bio->csum_allocated = NULL;
> + btrfs_bio->end_io = NULL;
> return bio;
> }
>
> @@ -2694,29 +2685,26 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
> struct btrfs_io_bio *btrfs_bio;
> struct bio *new;
>
> + /* Bio allocation backed by a bioset does not fail */
> new = bio_clone_fast(bio, gfp_mask, btrfs_bioset);
> - if (new) {
> - btrfs_bio = btrfs_io_bio(new);
> - btrfs_bio->csum = NULL;
> - btrfs_bio->csum_allocated = NULL;
> - btrfs_bio->end_io = NULL;
> - }
> + btrfs_bio = btrfs_io_bio(new);
> + btrfs_bio->csum = NULL;
> + btrfs_bio->csum_allocated = NULL;
> + btrfs_bio->end_io = NULL;
> return new;
> }
>
> -/* this also allocates from the btrfs_bioset */
> struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
> {
> struct btrfs_io_bio *btrfs_bio;
> struct bio *bio;
>
> + /* Bio allocation backed by a bioset does not fail */
> bio = bio_alloc_bioset(gfp_mask, nr_iovecs, btrfs_bioset);
> - if (bio) {
> - btrfs_bio = btrfs_io_bio(bio);
> - btrfs_bio->csum = NULL;
> - btrfs_bio->csum_allocated = NULL;
> - btrfs_bio->end_io = NULL;
> - }
> + btrfs_bio = btrfs_io_bio(bio);
> + btrfs_bio->csum = NULL;
> + btrfs_bio->csum_allocated = NULL;
> + btrfs_bio->end_io = NULL;
> return bio;
> }
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-06 10:21 ` Anand Jain
@ 2017-06-06 10:44 ` Christoph Hellwig
2017-06-07 6:52 ` Anand Jain
2017-06-06 10:51 ` David Sterba
1 sibling, 1 reply; 25+ messages in thread
From: Christoph Hellwig @ 2017-06-06 10:44 UTC (permalink / raw)
To: Anand Jain; +Cc: David Sterba, linux-btrfs, Christoph Hellwig, Liu Bo
On Tue, Jun 06, 2017 at 06:21:17PM +0800, Anand Jain wrote:
>
>
> On 06/03/17 00:58, David Sterba wrote:
>> Christoph pointed out that bio allocations backed by a bioset will never
>> fail.
>
> David,
>
> Looks like this feature comes when __GFP_DIRECT_RECLAIM is
> set and we aren't, such as [1]. Any idea why? Looks like I am
> missing something ?
>
>
> [1]
> -----
> static int submit_extent_page(int op, int op_flags, struct extent_io_tree
> *tree,
> ::
>
> bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
> GFP_NOFS | __GFP_HIGH);
#define __GFP_RECLAIM ((__force gfp_t)(___GFP_DIRECT_RECLAIM|___GFP_KSWAPD_RECLAIM))
#define GFP_NOFS (__GFP_RECLAIM | __GFP_IO)
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-06 10:21 ` Anand Jain
2017-06-06 10:44 ` Christoph Hellwig
@ 2017-06-06 10:51 ` David Sterba
1 sibling, 0 replies; 25+ messages in thread
From: David Sterba @ 2017-06-06 10:51 UTC (permalink / raw)
To: Anand Jain; +Cc: Christoph Hellwig, Liu Bo, linux-btrfs
On Tue, Jun 06, 2017 at 06:21:17PM +0800, Anand Jain wrote:
> On 06/03/17 00:58, David Sterba wrote:
> > Christoph pointed out that bio allocations backed by a bioset will never
> > fail.
>
> Looks like this feature comes when __GFP_DIRECT_RECLAIM is
> set and we aren't, such as [1]. Any idea why? Looks like I am
> missing something ?
bio_alloc_bioset:
406 * When @bs is not NULL, if %__GFP_DIRECT_RECLAIM is set then bio_alloc will
407 * always be able to allocate a bio. This is due to the mempool guarantees.
> [1]
> -----
> static int submit_extent_page(int op, int op_flags, struct
> extent_io_tree *tree,
> ::
>
> bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
> GFP_NOFS | __GFP_HIGH);
GFP_NOFS contains __GFP_DIRECT_RECLAIM, so what's the problem? __GFP_HIGH
allows using the reserves, but should not otherwise change the constraints.
And it's use seems unnecessary, as far as I could track in the history.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-06 10:44 ` Christoph Hellwig
@ 2017-06-07 6:52 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 6:52 UTC (permalink / raw)
To: Christoph Hellwig, David Sterba; +Cc: linux-btrfs, Liu Bo
> #define __GFP_RECLAIM ((__force gfp_t)(___GFP_DIRECT_RECLAIM|___GFP_KSWAPD_RECLAIM))
>
>
> #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO)
Ah. Thanks.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc
2017-06-02 16:58 ` [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc David Sterba
@ 2017-06-07 7:40 ` Anand Jain
2017-06-12 13:09 ` David Sterba
0 siblings, 1 reply; 25+ messages in thread
From: Anand Jain @ 2017-06-07 7:40 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> All callers pass gfp_flags=GFP_NOFS and nr_vecs=BIO_MAX_PAGES.
The line (in the other thread) mentioning the reason to remove
__GFP_HIGH can go into the commit log here.
> - bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES,
> - GFP_NOFS | __GFP_HIGH);
> + bio = btrfs_bio_alloc(bdev, sector);
Thanks, Anand
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
2017-06-03 5:10 ` Christoph Hellwig
2017-06-06 10:21 ` Anand Jain
@ 2017-06-07 9:10 ` Anand Jain
2 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:10 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba, Christoph Hellwig, Liu Bo
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling
2017-06-02 16:58 ` [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling David Sterba
@ 2017-06-07 9:11 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:11 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
On 06/03/17 00:58, David Sterba wrote:
> Update direct callers of btrfs_bio_alloc that do error handling, that we
> can now remove.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/8] btrfs: btrfs_bio_clone never fails, skip error handling
2017-06-02 16:58 ` [PATCH 3/8] btrfs: btrfs_bio_clone " David Sterba
@ 2017-06-07 9:11 ` Anand Jain
2017-06-07 18:19 ` Omar Sandoval
1 sibling, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:11 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> Update direct callers of btrfs_bio_clone that do error handling, that we
> can now remove.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 4/8] btrfs: btrfs_io_bio_alloc never fails, skip error handling
2017-06-02 16:58 ` [PATCH 4/8] btrfs: btrfs_io_bio_alloc " David Sterba
@ 2017-06-07 9:11 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:11 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> Update direct callers of btrfs_io_bio_alloc that do error handling, that
> we can now remove.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone
2017-06-02 16:58 ` [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone David Sterba
@ 2017-06-07 9:12 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:12 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> All callers pass GFP_NOFS.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling
2017-06-02 16:58 ` [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling David Sterba
@ 2017-06-07 9:21 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:21 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> compressed_bio_alloc is now a trivial wrapper around btrfs_bio_alloc, no
> point keeping it. The error handling can be simplified, as we know
> btrfs_bio_alloc will never fail.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc
2017-06-02 16:58 ` [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc David Sterba
@ 2017-06-07 9:22 ` Anand Jain
0 siblings, 0 replies; 25+ messages in thread
From: Anand Jain @ 2017-06-07 9:22 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 06/03/17 00:58, David Sterba wrote:
> Most callers of btrfs_bio_alloc convert from bytes to sectors. Hide that
> in the helper and simplify the logic in the callsers.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/8] btrfs: btrfs_bio_clone never fails, skip error handling
2017-06-02 16:58 ` [PATCH 3/8] btrfs: btrfs_bio_clone " David Sterba
2017-06-07 9:11 ` Anand Jain
@ 2017-06-07 18:19 ` Omar Sandoval
2017-06-12 13:13 ` David Sterba
1 sibling, 1 reply; 25+ messages in thread
From: Omar Sandoval @ 2017-06-07 18:19 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs
On Fri, Jun 02, 2017 at 06:58:36PM +0200, David Sterba wrote:
> Update direct callers of btrfs_bio_clone that do error handling, that we
> can now remove.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/inode.c | 4 ----
> fs/btrfs/volumes.c | 1 -
> 2 files changed, 5 deletions(-)
>
>
> if (dev_nr < total_devs - 1) {
> bio = btrfs_bio_clone(first_bio, GFP_NOFS);
> - BUG_ON(!bio); /* -ENOMEM */
> } else
> bio = first_bio;
Could you please get rid of the extra curly braces now, too?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc
2017-06-07 7:40 ` Anand Jain
@ 2017-06-12 13:09 ` David Sterba
0 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2017-06-12 13:09 UTC (permalink / raw)
To: Anand Jain; +Cc: David Sterba, linux-btrfs
On Wed, Jun 07, 2017 at 03:40:16PM +0800, Anand Jain wrote:
>
>
> On 06/03/17 00:58, David Sterba wrote:
> > All callers pass gfp_flags=GFP_NOFS and nr_vecs=BIO_MAX_PAGES.
>
> The line (in the other thread) mentioning the reason to remove
> __GFP_HIGH can go into the commit log here.
Makes sense, patch updated.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/8] btrfs: btrfs_bio_clone never fails, skip error handling
2017-06-07 18:19 ` Omar Sandoval
@ 2017-06-12 13:13 ` David Sterba
0 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2017-06-12 13:13 UTC (permalink / raw)
To: Omar Sandoval; +Cc: David Sterba, linux-btrfs
On Wed, Jun 07, 2017 at 11:19:37AM -0700, Omar Sandoval wrote:
> On Fri, Jun 02, 2017 at 06:58:36PM +0200, David Sterba wrote:
> > Update direct callers of btrfs_bio_clone that do error handling, that we
> > can now remove.
> >
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> > fs/btrfs/inode.c | 4 ----
> > fs/btrfs/volumes.c | 1 -
> > 2 files changed, 5 deletions(-)
> >
> >
> > if (dev_nr < total_devs - 1) {
> > bio = btrfs_bio_clone(first_bio, GFP_NOFS);
> > - BUG_ON(!bio); /* -ENOMEM */
> > } else
> > bio = first_bio;
>
> Could you please get rid of the extra curly braces now, too?
Sure, patch updated.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2017-06-12 13:14 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 16:58 [PATCH 0/8] Bio allocation and error handling cleanups David Sterba
2017-06-02 16:58 ` [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers David Sterba
2017-06-03 5:10 ` Christoph Hellwig
2017-06-06 10:21 ` Anand Jain
2017-06-06 10:44 ` Christoph Hellwig
2017-06-07 6:52 ` Anand Jain
2017-06-06 10:51 ` David Sterba
2017-06-07 9:10 ` Anand Jain
2017-06-02 16:58 ` [PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-02 16:58 ` [PATCH 3/8] btrfs: btrfs_bio_clone " David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-07 18:19 ` Omar Sandoval
2017-06-12 13:13 ` David Sterba
2017-06-02 16:58 ` [PATCH 4/8] btrfs: btrfs_io_bio_alloc " David Sterba
2017-06-07 9:11 ` Anand Jain
2017-06-02 16:58 ` [PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone David Sterba
2017-06-07 9:12 ` Anand Jain
2017-06-02 16:58 ` [PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc David Sterba
2017-06-07 7:40 ` Anand Jain
2017-06-12 13:09 ` David Sterba
2017-06-02 16:58 ` [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling David Sterba
2017-06-07 9:21 ` Anand Jain
2017-06-02 16:58 ` [PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc David Sterba
2017-06-07 9:22 ` Anand Jain
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.