Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

JFS: Fix i_blocks accounting when allocation fails

A failure in dbAlloc caused a directory's i_blocks to be incorrectly
incremented, causing jfs_fsck to find the inode to be corrupt.

Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>

+9 -4
+9 -4
fs/jfs/jfs_dtree.c
··· 381 381 * It's time to move the inline table to an external 382 382 * page and begin to build the xtree 383 383 */ 384 - if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage) || 385 - dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) 386 - goto clean_up; /* No space */ 384 + if (DQUOT_ALLOC_BLOCK(ip, sbi->nbperpage)) 385 + goto clean_up; 386 + if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { 387 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage); 388 + goto clean_up; 389 + } 387 390 388 391 /* 389 392 * Save the table, we're going to overwrite it with the ··· 400 397 xtInitRoot(tid, ip); 401 398 402 399 /* 403 - * Allocate the first block & add it to the xtree 400 + * Add the first block to the xtree 404 401 */ 405 402 if (xtInsert(tid, ip, 0, 0, sbi->nbperpage, &xaddr, 0)) { 406 403 /* This really shouldn't fail */ 407 404 jfs_warn("add_index: xtInsert failed!"); 408 405 memcpy(&jfs_ip->i_dirtable, temp_table, 409 406 sizeof (temp_table)); 407 + dbFree(ip, xaddr, sbi->nbperpage); 408 + DQUOT_FREE_BLOCK(ip, sbi->nbperpage); 410 409 goto clean_up; 411 410 } 412 411 ip->i_size = PSIZE;