Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347087
b: refs/heads/master
c: 5977107
h: refs/heads/master
i:
  347085: 3aa68b8
  347083: fcdf68a
  347079: f816fcc
  347071: d2e2e6d
v: v3
  • Loading branch information
Linus Torvalds committed Dec 19, 2012
1 parent 3ebdaf5 commit 6b42f1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 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: 752451f01c4567b506bf4343082682dbb8fb30dd
refs/heads/master: 59771079c18c44e39106f0f30054025acafadb41
19 changes: 15 additions & 4 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,25 @@ static inline int queue_discard_alignment(struct request_queue *q)

static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector_t sector)
{
sector_t alignment = sector << 9;
alignment = sector_div(alignment, lim->discard_granularity);
unsigned int alignment, granularity, offset;

if (!lim->max_discard_sectors)
return 0;

alignment = lim->discard_granularity + lim->discard_alignment - alignment;
return sector_div(alignment, lim->discard_granularity);
/* Why are these in bytes, not sectors? */
alignment = lim->discard_alignment >> 9;
granularity = lim->discard_granularity >> 9;
if (!granularity)
return 0;

/* Offset of the partition start in 'granularity' sectors */
offset = sector_div(sector, granularity);

/* And why do we do this modulus *again* in blkdev_issue_discard()? */
offset = (granularity + alignment - offset) % granularity;

/* Turn it back into bytes, gaah */
return offset << 9;
}

static inline int bdev_discard_alignment(struct block_device *bdev)
Expand Down

0 comments on commit 6b42f1b

Please sign in to comment.