xfs/008: initialize "valid" bitmap in randholes.c
authorEric Sandeen <sandeen@redhat.com>
Thu, 6 Feb 2014 05:43:17 +0000 (16:43 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 6 Feb 2014 05:43:17 +0000 (16:43 +1100)
Failures were reported in xfs/008 on s390; dchinner suggested that
perhaps the uninitialized "valid" bitmap was behaving differently on
that platform, and sure enough, this patch fixes things up.

TBH, I'm not sure why using an uninitialized bitmap worked at
all, ever, anywhere...?

[ dchinner explains during review:

It depends on glibc behaviour to whether newly allocated memory is
zeroed or not. e.g. for large allocations glibc uses
mmap() to directly map anonymous pages for the allocation. These get
zeroed by the kernel before being mapped into the user address
space. If glibc allocates from the heap and needs to grow it, it
uses sbrk() to grow the heap and those pages are, again, zeroed by
the kernel. However, if the allocation comes from the heap from
previously freed memory, then it doesn't get zeroed.

I'd say that the 3rd case is occurring here - there's memory that is
allocated and freed as part of the program startup that the bitmap
is being allocated from, and so it's not newly zeroed pages that it
is being allocated from... ]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
src/randholes.c

index 5ad602eaec54c52c311985bdb99c7f52a8c6acff..ee5b6b66a0429da07a2ef00c2bba01b0504f8a6f 100644 (file)
@@ -437,6 +437,7 @@ main(int argc, char *argv[])
                perror("malloc");
                return 1;
        }
+       memset(valid, 0, size);
 
        /* Lots of arguments affect how we open the file */
        oflags = test ? O_RDONLY : O_RDWR|O_CREAT;