aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/resize.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-01-10 12:46:59 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-01-10 12:46:59 -0500
commitb40971426a837e9dc9c66e1b6bbcb3874eafe4e0 (patch)
tree34b2a745719ed18bd1f0c81cfad200b9d8b2e309 /fs/ext4/resize.c
parentca6e909f9bebe709bc65a3ee605ce32969db0452 (diff)
ext4: add error checking to calls to ext4_handle_dirty_metadata()
Call ext4_std_error() in various places when we can't bail out cleanly, so the file system can be marked as in error. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/resize.c')
-rw-r--r--fs/ext4/resize.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index dc963929de65..7faf47dde7fb 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -220,7 +220,11 @@ static int setup_new_group_blocks(struct super_block *sb,
220 memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size); 220 memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size);
221 set_buffer_uptodate(gdb); 221 set_buffer_uptodate(gdb);
222 unlock_buffer(gdb); 222 unlock_buffer(gdb);
223 ext4_handle_dirty_metadata(handle, NULL, gdb); 223 err = ext4_handle_dirty_metadata(handle, NULL, gdb);
224 if (unlikely(err)) {
225 brelse(gdb);
226 goto exit_bh;
227 }
224 ext4_set_bit(bit, bh->b_data); 228 ext4_set_bit(bit, bh->b_data);
225 brelse(gdb); 229 brelse(gdb);
226 } 230 }
@@ -253,7 +257,11 @@ static int setup_new_group_blocks(struct super_block *sb,
253 257
254 ext4_mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8, 258 ext4_mark_bitmap_end(input->blocks_count, sb->s_blocksize * 8,
255 bh->b_data); 259 bh->b_data);
256 ext4_handle_dirty_metadata(handle, NULL, bh); 260 err = ext4_handle_dirty_metadata(handle, NULL, bh);
261 if (unlikely(err)) {
262 ext4_std_error(sb, err);
263 goto exit_bh;
264 }
257 brelse(bh); 265 brelse(bh);
258 /* Mark unused entries in inode bitmap used */ 266 /* Mark unused entries in inode bitmap used */
259 ext4_debug("clear inode bitmap %#04llx (+%llu)\n", 267 ext4_debug("clear inode bitmap %#04llx (+%llu)\n",
@@ -265,7 +273,9 @@ static int setup_new_group_blocks(struct super_block *sb,
265 273
266 ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, 274 ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8,
267 bh->b_data); 275 bh->b_data);
268 ext4_handle_dirty_metadata(handle, NULL, bh); 276 err = ext4_handle_dirty_metadata(handle, NULL, bh);
277 if (unlikely(err))
278 ext4_std_error(sb, err);
269exit_bh: 279exit_bh:
270 brelse(bh); 280 brelse(bh);
271 281
@@ -417,17 +427,21 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
417 goto exit_dind; 427 goto exit_dind;
418 } 428 }
419 429
420 if ((err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh))) 430 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
431 if (unlikely(err))
421 goto exit_dind; 432 goto exit_dind;
422 433
423 if ((err = ext4_journal_get_write_access(handle, *primary))) 434 err = ext4_journal_get_write_access(handle, *primary);
435 if (unlikely(err))
424 goto exit_sbh; 436 goto exit_sbh;
425 437
426 if ((err = ext4_journal_get_write_access(handle, dind))) 438 err = ext4_journal_get_write_access(handle, dind);
427 goto exit_primary; 439 if (unlikely(err))
440 ext4_std_error(sb, err);
428 441
429 /* ext4_reserve_inode_write() gets a reference on the iloc */ 442 /* ext4_reserve_inode_write() gets a reference on the iloc */
430 if ((err = ext4_reserve_inode_write(handle, inode, &iloc))) 443 err = ext4_reserve_inode_write(handle, inode, &iloc);
444 if (unlikely(err))
431 goto exit_dindj; 445 goto exit_dindj;
432 446
433 n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *), 447 n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
@@ -449,12 +463,20 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
449 * reserved inode, and will become GDT blocks (primary and backup). 463 * reserved inode, and will become GDT blocks (primary and backup).
450 */ 464 */
451 data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0; 465 data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0;
452 ext4_handle_dirty_metadata(handle, NULL, dind); 466 err = ext4_handle_dirty_metadata(handle, NULL, dind);
453 brelse(dind); 467 if (unlikely(err)) {
468 ext4_std_error(sb, err);
469 goto exit_inode;
470 }
454 inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9; 471 inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
455 ext4_mark_iloc_dirty(handle, inode, &iloc); 472 ext4_mark_iloc_dirty(handle, inode, &iloc);
456 memset((*primary)->b_data, 0, sb->s_blocksize); 473 memset((*primary)->b_data, 0, sb->s_blocksize);
457 ext4_handle_dirty_metadata(handle, NULL, *primary); 474 err = ext4_handle_dirty_metadata(handle, NULL, *primary);
475 if (unlikely(err)) {
476 ext4_std_error(sb, err);
477 goto exit_inode;
478 }
479 brelse(dind);
458 480
459 o_group_desc = EXT4_SB(sb)->s_group_desc; 481 o_group_desc = EXT4_SB(sb)->s_group_desc;
460 memcpy(n_group_desc, o_group_desc, 482 memcpy(n_group_desc, o_group_desc,
@@ -465,19 +487,19 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
465 kfree(o_group_desc); 487 kfree(o_group_desc);
466 488
467 le16_add_cpu(&es->s_reserved_gdt_blocks, -1); 489 le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
468 ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); 490 err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
491 if (err)
492 ext4_std_error(sb, err);
469 493
470 return 0; 494 return err;
471 495
472exit_inode: 496exit_inode:
473 /* ext4_journal_release_buffer(handle, iloc.bh); */ 497 /* ext4_journal_release_buffer(handle, iloc.bh); */
474 brelse(iloc.bh); 498 brelse(iloc.bh);
475exit_dindj: 499exit_dindj:
476 /* ext4_journal_release_buffer(handle, dind); */ 500 /* ext4_journal_release_buffer(handle, dind); */
477exit_primary:
478 /* ext4_journal_release_buffer(handle, *primary); */
479exit_sbh: 501exit_sbh:
480 /* ext4_journal_release_buffer(handle, *primary); */ 502 /* ext4_journal_release_buffer(handle, EXT4_SB(sb)->s_sbh); */
481exit_dind: 503exit_dind:
482 brelse(dind); 504 brelse(dind);
483exit_bh: 505exit_bh:
@@ -660,7 +682,9 @@ static void update_backups(struct super_block *sb,
660 memset(bh->b_data + size, 0, rest); 682 memset(bh->b_data + size, 0, rest);
661 set_buffer_uptodate(bh); 683 set_buffer_uptodate(bh);
662 unlock_buffer(bh); 684 unlock_buffer(bh);
663 ext4_handle_dirty_metadata(handle, NULL, bh); 685 err = ext4_handle_dirty_metadata(handle, NULL, bh);
686 if (unlikely(err))
687 ext4_std_error(sb, err);
664 brelse(bh); 688 brelse(bh);
665 } 689 }
666 if ((err2 = ext4_journal_stop(handle)) && !err) 690 if ((err2 = ext4_journal_stop(handle)) && !err)
@@ -878,7 +902,11 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
878 /* Update the global fs size fields */ 902 /* Update the global fs size fields */
879 sbi->s_groups_count++; 903 sbi->s_groups_count++;
880 904
881 ext4_handle_dirty_metadata(handle, NULL, primary); 905 err = ext4_handle_dirty_metadata(handle, NULL, primary);
906 if (unlikely(err)) {
907 ext4_std_error(sb, err);
908 goto exit_journal;
909 }
882 910
883 /* Update the reserved block counts only once the new group is 911 /* Update the reserved block counts only once the new group is
884 * active. */ 912 * active. */