Thread (4 messages) 4 messages, 2 authors, 2014-10-29

Re: [PATCH] Grow: fix resize of array component size to > 32bits

From: NeilBrown <hidden>
Date: 2014-10-28 22:19:57

On Fri, 24 Oct 2014 17:55:02 -0700 Justin Maggard [off-list ref]
wrote:
If the request --size to --grow an array to is larger
than 32bits, then mdadm may make the wrong choice and
use ioctl instead of setting component_size via sysfs
and the change is ignored.
Can you explain exactly why the  current code is not sufficient?  When does
it fail?
If you include the explanation in a re-submission of the patch, and I am
convinced, then I will gladly apply your patch.

Thanks,
NeilBrown
quoted hunk ↗ jump to hunk
Instead of using casts to check for a 32-bit overflow,
just check for set bits outside of INT32_MAX.
---
 Grow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index a9c8589..a614102 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1818,7 +1818,7 @@ int Grow_reshape(char *devname, int fd,
 		if (s->size == MAX_SIZE)
 			s->size = 0;
 		array.size = s->size;
-		if (array.size != (signed)s->size) {
+		if (s->size & ~INT32_MAX) {
 			/* got truncated to 32bit, write to
 			 * component_size instead
 			 */
  

Attachments

  • (unnamed) [application/pgp-signature] 828 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help