xfs: Fix rounding in xfs_alloc_fix_len()
PATCH v2 1/1 xfs: Fix rounding in xfs_alloc_fix_len()
Rounding in xfs_alloc_fix_len() is wrong. As the comment states, the result should be a number of a form (k*prod+mod) however due to sign mistake the result is different. As a result allocations on raid arrays could be misaligned in some cases.
This also seems to fix occasional assertion failure:
XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0)
in xfs_alloc_ag_vextent_size().
Also add an assertion that the result of xfs_alloc_fix_len() is of expected form.
--- fs/xfs/xfs_alloc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
fs/xfs/xfs_alloc.c +8 -10
@@ -257,16 +257,14 @@ xfs_alloc_fix_len( k = rlen % args->prod;if (k == args->mod)return ; -if (k > args->mod) { -if ((int )(rlen = rlen - k - args->mod) < (int )args->minlen) -return ; - }else { -if ((int )(rlen = rlen - args->prod - (args->mod - k)) < - (int )args->minlen) -return ; - } -ASSERT (rlen >= args->minlen); -ASSERT (rlen <= args->maxlen); +if (k > args->mod) + rlen = rlen - (k - args->mod); +else + rlen = rlen - args->prod + (args->mod - k); +if ((int )rlen < (int )args->minlen) +return ; +ASSERT (rlen >= args->minlen && rlen <= args->maxlen); +ASSERT (rlen % args->prod == args->mod); args->len = rlen; }
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Jan Kara
Rounding in
xfs_alloc_fix_len()is wrong. As the comment states, the result should be a number of a form (k*prod+mod) however due to sign mistake the result is different. As a result allocations on raid arrays could be misaligned in some cases.This also seems to fix occasional assertion failure:
XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0)
inxfs_alloc_ag_vextent_size().
Quoted 5 lines
Also add an assertion that the result of
xfs_alloc_fix_len()is of expected form.Signed-off-by Jan Kara <[email protected]>---
Looks good to me. Thanks Jan.
Quoted 39 lines
fs/xfs/xfs_alloc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)fs/xfs/xfs_alloc.c +8
-10@@ -257,16 +257,14 @@ xfs_alloc_fix_len( k = rlen % args->prod;if (k == args->mod)return ; -if (k > args->mod) { -if ((int )(rlen = rlen - k - args->mod) < (int )args->minlen) -return ; - }else { -if ((int )(rlen = rlen - args->prod - (args->mod - k)) < - (int )args->minlen) -return ; - } -ASSERT (rlen >= args->minlen); -ASSERT (rlen <= args->maxlen); +if (k > args->mod) + rlen = rlen - (k - args->mod); +else + rlen = rlen - args->prod + (args->mod - k); +if ((int )rlen < (int )args->minlen) +return ; +ASSERT (rlen >= args->minlen && rlen <= args->maxlen); +ASSERT (rlen % args->prod == args->mod); args->len = rlen; }Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 13 lines · Brian Foster
Quoted 12 lines · Jan Kara
Rounding in
xfs_alloc_fix_len()is wrong. As the comment states, the result should be a number of a form (k*prod+mod) however due to sign mistake the result is different. As a result allocations on raid arrays could be misaligned in some cases.This also seems to fix occasional assertion failure:
XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0)
inxfs_alloc_ag_vextent_size().Also add an assertion that the result of
xfs_alloc_fix_len()is of expected form.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Jan Kara <[email protected]>---
Looks good to me. Thanks Jan.
Reviewed-by Brian Foster <[email protected]>
Ping Dave? Are you going to pick up this patch?
Honza
Quoted 39 lines
Quoted 39 lines
fs/xfs/xfs_alloc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)fs/xfs/xfs_alloc.c +8
-10@@ -257,16 +257,14 @@ xfs_alloc_fix_len( k = rlen % args->prod;if (k == args->mod)return ; -if (k > args->mod) { -if ((int )(rlen = rlen - k - args->mod) < (int )args->minlen) -return ; - }else { -if ((int )(rlen = rlen - args->prod - (args->mod - k)) < - (int )args->minlen) -return ; - } -ASSERT (rlen >= args->minlen); -ASSERT (rlen <= args->maxlen); +if (k > args->mod) + rlen = rlen - (k - args->mod); +else + rlen = rlen - args->prod + (args->mod - k); +if ((int )rlen < (int )args->minlen) +return ; +ASSERT (rlen >= args->minlen && rlen <= args->maxlen); +ASSERT (rlen % args->prod == args->mod); args->len = rlen; }Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 14 lines · Jan Kara
Quoted 13 lines · Brian Foster
Quoted 12 lines · Jan Kara
Rounding in
xfs_alloc_fix_len()is wrong. As the comment states, the result should be a number of a form (k*prod+mod) however due to sign mistake the result is different. As a result allocations on raid arrays could be misaligned in some cases.This also seems to fix occasional assertion failure:
XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0)
inxfs_alloc_ag_vextent_size().Also add an assertion that the result of
xfs_alloc_fix_len()is of expected form.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Jan Kara <[email protected]>---
Looks good to me. Thanks Jan.
Reviewed-by Brian Foster <[email protected]>Ping Dave? Are you going to pick up this patch?
I did - it's already in Linus' tree for 3.16:
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 18 lines · Dave Chinner
Quoted 17 lines · Jan Kara
Quoted 16 lines · Brian Foster
Quoted 14 lines · Jan Kara
Rounding in
xfs_alloc_fix_len()is wrong. As the comment states, the result should be a number of a form (k*prod+mod) however due to sign mistake the result is different. As a result allocations on raid arrays could be misaligned in some cases.This also seems to fix occasional assertion failure:
XFS_WANT_CORRUPTED_GOTO(rlen <= flen, error0)
inxfs_alloc_ag_vextent_size().Also add an assertion that the result of
xfs_alloc_fix_len()is of expected form.Signed-off-by Jan Kara <[email protected]>---
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Looks good to me. Thanks Jan.
Reviewed-by Brian Foster <[email protected]>Ping Dave? Are you going to pick up this patch?
I did - it's already in Linus' tree for 3.16:
Ah, sorry. I was expecting some email about acceptance. I'll check the git
tree next time.
Honza
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs