All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling
Date: Fri,  2 Jun 2017 18:58:47 +0200	[thread overview]
Message-ID: <c1045c6859c18ce20d4f55e162399b708f9bfcf4.1496422340.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1496422340.git.dsterba@suse.com>

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


  parent reply	other threads:[~2017-06-02 16:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` David Sterba [this message]
2017-06-07  9:21   ` [PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1045c6859c18ce20d4f55e162399b708f9bfcf4.1496422340.git.dsterba@suse.com \
    --to=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.