提交 cb08fca0 编写于 作者: M Ming Lei 提交者: Xie XiuQi

block: cleanup __blkdev_issue_discard()

mainline inclusion
from mainline-4.20-rc2
commit ba5d73851e71847ba7f7f4c27a1a6e1f5ab91c79
category: bugfix
bugzilla: 7403
CVE: NA

---------------------------

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: NRui Salvaterra <rsalvaterra@gmail.com>
Signed-off-by: NMing Lei <ming.lei@redhat.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: Nzhengbin <zhengbin13@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 325d9be9
...@@ -52,15 +52,12 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, ...@@ -52,15 +52,12 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
if ((sector | nr_sects) & bs_mask) if ((sector | nr_sects) & bs_mask)
return -EINVAL; return -EINVAL;
while (nr_sects) { if (!nr_sects)
unsigned int req_sects = nr_sects; return -EINVAL;
sector_t end_sect;
if (!req_sects)
goto fail;
req_sects = min(req_sects, bio_allowed_max_sectors(q));
end_sect = sector + req_sects; while (nr_sects) {
unsigned int req_sects = min_t(unsigned int, nr_sects,
bio_allowed_max_sectors(q));
bio = next_bio(bio, 0, gfp_mask); bio = next_bio(bio, 0, gfp_mask);
bio->bi_iter.bi_sector = sector; bio->bi_iter.bi_sector = sector;
...@@ -68,8 +65,8 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, ...@@ -68,8 +65,8 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
bio_set_op_attrs(bio, op, 0); bio_set_op_attrs(bio, op, 0);
bio->bi_iter.bi_size = req_sects << 9; bio->bi_iter.bi_size = req_sects << 9;
sector += req_sects;
nr_sects -= req_sects; nr_sects -= req_sects;
sector = end_sect;
/* /*
* We can loop for a long time in here, if someone does * We can loop for a long time in here, if someone does
...@@ -82,14 +79,6 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, ...@@ -82,14 +79,6 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
*biop = bio; *biop = bio;
return 0; return 0;
fail:
if (bio) {
submit_bio_wait(bio);
bio_put(bio);
}
*biop = NULL;
return -EOPNOTSUPP;
} }
EXPORT_SYMBOL(__blkdev_issue_discard); EXPORT_SYMBOL(__blkdev_issue_discard);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册