md: fix loading of out-of-date bitmap.

When md is loading a bitmap which it knows is out of date, it fills
each page with 1s and writes it back out again. However the
write_page call makes used of bitmap->file_pages and
bitmap->last_page_size which haven't been set correctly yet. So this
can sometimes fail.

Move the setting of file_pages and last_page_size to before the call
to write_page.

This bug can cause the assembly on an array to fail, thus making the
data inaccessible. Hence I think it is a suitable candidate for
-stable.

Cc: stable@kernel.org
Reported-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>

NeilBrown b74fd282 b4348f32

+4 -7
+4 -7
drivers/md/bitmap.c
··· 986 986 oldindex = index; 987 987 oldpage = page; 988 988 989 + bitmap->filemap[bitmap->file_pages++] = page; 990 + bitmap->last_page_size = count; 991 + 989 992 if (outofdate) { 990 993 /* 991 994 * if bitmap is out of date, dirty the ··· 1001 998 write_page(bitmap, page, 1); 1002 999 1003 1000 ret = -EIO; 1004 - if (bitmap->flags & BITMAP_WRITE_ERROR) { 1005 - /* release, page not in filemap yet */ 1006 - put_page(page); 1001 + if (bitmap->flags & BITMAP_WRITE_ERROR) 1007 1002 goto err; 1008 - } 1009 1003 } 1010 - 1011 - bitmap->filemap[bitmap->file_pages++] = page; 1012 - bitmap->last_page_size = count; 1013 1004 } 1014 1005 paddr = kmap_atomic(page, KM_USER0); 1015 1006 if (bitmap->flags & BITMAP_HOSTENDIAN)