Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 361512
b: refs/heads/master
c: 58051b9
h: refs/heads/master
v: v3
  • Loading branch information
Joe Thornber authored and Alasdair G Kergon committed Mar 20, 2013
1 parent 5b856ac commit d099a41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 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: f046f89a99ccfd9408b94c653374ff3065c7edb3
refs/heads/master: 58051b94e05a59c4d34f9f1a441af40894817c59
7 changes: 6 additions & 1 deletion trunk/drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,11 @@ static bool data_dev_supports_discard(struct pool_c *pt)
return q && blk_queue_discard(q);
}

static bool is_factor(sector_t block_size, uint32_t n)
{
return !sector_div(block_size, n);
}

/*
* If discard_passdown was enabled verify that the data device
* supports discards. Disable discard_passdown if not.
Expand All @@ -1602,7 +1607,7 @@ static void disable_passdown_if_not_supported(struct pool_c *pt)
else if (data_limits->discard_granularity > block_size)
reason = "discard granularity larger than a block";

else if (block_size & (data_limits->discard_granularity - 1))
else if (!is_factor(block_size, data_limits->discard_granularity))
reason = "discard granularity not a factor of block size";

if (reason) {
Expand Down

0 comments on commit d099a41

Please sign in to comment.