diff options
author | Ming Lei <ming.lei@redhat.com> | 2018-10-29 08:57:18 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-11-09 08:23:16 -0500 |
commit | ba5d73851e71847ba7f7f4c27a1a6e1f5ab91c79 (patch) | |
tree | d876a86a4b9afda2edc702071d0f2775ae975f01 | |
parent | 1adfc5e4136f5967d591c399aff95b3b035f16b7 (diff) |
block: cleanup __blkdev_issue_discard()
Cleanup __blkdev_issue_discard() a bit:
- remove local variable of 'end_sect'
- remove code block of 'fail'
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Xiao Ni <xni@redhat.com>
Cc: Mariusz Dabrowski <mariusz.dabrowski@intel.com>
Tested-by: Rui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-lib.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index d56fd159d2e8..d58d5d87dd88 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -51,15 +51,12 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
51 | if ((sector | nr_sects) & bs_mask) | 51 | if ((sector | nr_sects) & bs_mask) |
52 | return -EINVAL; | 52 | return -EINVAL; |
53 | 53 | ||
54 | while (nr_sects) { | 54 | if (!nr_sects) |
55 | unsigned int req_sects = nr_sects; | 55 | return -EINVAL; |
56 | sector_t end_sect; | ||
57 | |||
58 | if (!req_sects) | ||
59 | goto fail; | ||
60 | req_sects = min(req_sects, bio_allowed_max_sectors(q)); | ||
61 | 56 | ||
62 | end_sect = sector + req_sects; | 57 | while (nr_sects) { |
58 | unsigned int req_sects = min_t(unsigned int, nr_sects, | ||
59 | bio_allowed_max_sectors(q)); | ||
63 | 60 | ||
64 | bio = blk_next_bio(bio, 0, gfp_mask); | 61 | bio = blk_next_bio(bio, 0, gfp_mask); |
65 | bio->bi_iter.bi_sector = sector; | 62 | bio->bi_iter.bi_sector = sector; |
@@ -67,8 +64,8 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
67 | bio_set_op_attrs(bio, op, 0); | 64 | bio_set_op_attrs(bio, op, 0); |
68 | 65 | ||
69 | bio->bi_iter.bi_size = req_sects << 9; | 66 | bio->bi_iter.bi_size = req_sects << 9; |
67 | sector += req_sects; | ||
70 | nr_sects -= req_sects; | 68 | nr_sects -= req_sects; |
71 | sector = end_sect; | ||
72 | 69 | ||
73 | /* | 70 | /* |
74 | * We can loop for a long time in here, if someone does | 71 | * We can loop for a long time in here, if someone does |
@@ -81,14 +78,6 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
81 | 78 | ||
82 | *biop = bio; | 79 | *biop = bio; |
83 | return 0; | 80 | return 0; |
84 | |||
85 | fail: | ||
86 | if (bio) { | ||
87 | submit_bio_wait(bio); | ||
88 | bio_put(bio); | ||
89 | } | ||
90 | *biop = NULL; | ||
91 | return -EOPNOTSUPP; | ||
92 | } | 81 | } |
93 | EXPORT_SYMBOL(__blkdev_issue_discard); | 82 | EXPORT_SYMBOL(__blkdev_issue_discard); |
94 | 83 | ||