Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208272
b: refs/heads/master
c: 10d1f9e
h: refs/heads/master
v: v3
  • Loading branch information
Jens Axboe committed Aug 7, 2010
1 parent 67be290 commit 52c5b45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f10d9f617a65905c556c3b37c9b9646ae7d04ed7
refs/heads/master: 10d1f9e2ccfff40665a00ea0e0a0d11e54c9cbb1
15 changes: 12 additions & 3 deletions trunk/block/blk-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
struct request_queue *q = bdev_get_queue(bdev);
int type = flags & BLKDEV_IFL_BARRIER ?
DISCARD_BARRIER : DISCARD_NOBARRIER;
unsigned int max_discard_sectors;
struct bio *bio;
int ret = 0;

Expand All @@ -50,10 +51,18 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
if (!blk_queue_discard(q))
return -EOPNOTSUPP;

while (nr_sects && !ret) {
unsigned int max_discard_sectors =
min(q->limits.max_discard_sectors, UINT_MAX >> 9);
/*
* Ensure that max_discard_sectors is of the proper
* granularity
*/
max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9);
if (q->limits.discard_granularity) {
unsigned int disc_sects = q->limits.discard_granularity >> 9;

max_discard_sectors &= ~(disc_sects - 1);
}

while (nr_sects && !ret) {
bio = bio_alloc(gfp_mask, 1);
if (!bio) {
ret = -ENOMEM;
Expand Down

0 comments on commit 52c5b45

Please sign in to comment.