Skip to content

Commit

Permalink
Fix vdev_raidz_psize_floor()
Browse files Browse the repository at this point in the history
The original implementation could overestimate the physical size
for raidz2 and raidz3 and cause too much trimming.  Update with the
implementation provided by @ironMann in openzfs#3656.
  • Loading branch information
dweeezil committed Apr 2, 2017
1 parent 11aca97 commit 107eaf4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions module/zfs/vdev_raidz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,11 +1658,17 @@ vdev_raidz_asize(vdev_t *vd, uint64_t psize)
static uint64_t
vdev_raidz_psize_floor(vdev_t *vd, uint64_t asize)
{
uint64_t psize = (asize / vd->vdev_children) *
(vd->vdev_children - vd->vdev_nparity);
uint64_t psize;
uint64_t ashift = vd->vdev_top->vdev_ashift;
uint64_t cols = vd->vdev_children;
uint64_t nparity = vd->vdev_nparity;

psize = (asize - (nparity << ashift));
psize /= cols;
psize *= cols - nparity;
psize += (1 << ashift) - 1;

psize = P2ALIGN(psize, 1 << vd->vdev_top->vdev_ashift);
ASSERT(psize != 0);
psize = P2ALIGN(psize, 1 << ashift);

return (psize);
}
Expand Down

0 comments on commit 107eaf4

Please sign in to comment.