ext4: fix setting random pages PageUptodate

ext4_end_bio calls put_page and kmem_cache_free before calling
SetPageUpdate(). This can result in setting the PageUptodate bit on
random pages and causes the following BUG:

BUG: Bad page state in process rm pfn:52e54
page:ffffea0001222260 count:0 mapcount:0 mapping: (null) index:0x0
arch kernel: page flags: 0x4000000000000008(uptodate)

Fix the problem by moving put_io_page() after the SetPageUpdate() call.

Thanks to Hugh Dickins for analyzing this problem.

Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

authored by Markus Trippelsdorf and committed by Theodore Ts'o 08da1193 e53beacd

+2 -2
+2 -2
fs/ext4/page-io.c
··· 237 237 } while (bh != head); 238 238 } 239 239 240 - put_io_page(io_end->pages[i]); 241 - 242 240 /* 243 241 * If this is a partial write which happened to make 244 242 * all buffers uptodate then we can optimize away a ··· 246 248 */ 247 249 if (!partial_write) 248 250 SetPageUptodate(page); 251 + 252 + put_io_page(io_end->pages[i]); 249 253 } 250 254 io_end->num_io_pages = 0; 251 255 inode = io_end->inode;