diff options
author | Jan Kara <jack@suse.cz> | 2014-05-26 11:39:17 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-05-26 11:39:17 -0400 |
commit | cd2c080c33fdab4ecf5ad43c88be0d3b646d272b (patch) | |
tree | 55d276f533e664259f1c81121e05267c9ee46a0f /fs/ext4 | |
parent | 0baaea64009d5edbfee36a949017f7c68926fafc (diff) |
ext4: use sbi in ext4_orphan_{add|del}()
Use sbi pointer consistently in ext4_orphan_del() instead of opencoding
it sometimes. Also ext4_orphan_add() uses EXT4_SB(sb) often so create
sbi variable for it as well and use it.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/namei.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 7ac616769706..eb61584ca5a5 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2551,13 +2551,14 @@ static int empty_dir(struct inode *inode) | |||
2551 | int ext4_orphan_add(handle_t *handle, struct inode *inode) | 2551 | int ext4_orphan_add(handle_t *handle, struct inode *inode) |
2552 | { | 2552 | { |
2553 | struct super_block *sb = inode->i_sb; | 2553 | struct super_block *sb = inode->i_sb; |
2554 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
2554 | struct ext4_iloc iloc; | 2555 | struct ext4_iloc iloc; |
2555 | int err = 0, rc; | 2556 | int err = 0, rc; |
2556 | 2557 | ||
2557 | if (!EXT4_SB(sb)->s_journal) | 2558 | if (!sbi->s_journal) |
2558 | return 0; | 2559 | return 0; |
2559 | 2560 | ||
2560 | mutex_lock(&EXT4_SB(sb)->s_orphan_lock); | 2561 | mutex_lock(&sbi->s_orphan_lock); |
2561 | if (!list_empty(&EXT4_I(inode)->i_orphan)) | 2562 | if (!list_empty(&EXT4_I(inode)->i_orphan)) |
2562 | goto out_unlock; | 2563 | goto out_unlock; |
2563 | 2564 | ||
@@ -2570,8 +2571,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) | |||
2570 | J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 2571 | J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
2571 | S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); | 2572 | S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); |
2572 | 2573 | ||
2573 | BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access"); | 2574 | BUFFER_TRACE(sbi->s_sbh, "get_write_access"); |
2574 | err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh); | 2575 | err = ext4_journal_get_write_access(handle, sbi->s_sbh); |
2575 | if (err) | 2576 | if (err) |
2576 | goto out_unlock; | 2577 | goto out_unlock; |
2577 | 2578 | ||
@@ -2583,12 +2584,12 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) | |||
2583 | * orphan list. If so skip on-disk list modification. | 2584 | * orphan list. If so skip on-disk list modification. |
2584 | */ | 2585 | */ |
2585 | if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= | 2586 | if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= |
2586 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) | 2587 | (le32_to_cpu(sbi->s_es->s_inodes_count))) |
2587 | goto mem_insert; | 2588 | goto mem_insert; |
2588 | 2589 | ||
2589 | /* Insert this inode at the head of the on-disk orphan list... */ | 2590 | /* Insert this inode at the head of the on-disk orphan list... */ |
2590 | NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); | 2591 | NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan); |
2591 | EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); | 2592 | sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); |
2592 | err = ext4_handle_dirty_super(handle, sb); | 2593 | err = ext4_handle_dirty_super(handle, sb); |
2593 | rc = ext4_mark_iloc_dirty(handle, inode, &iloc); | 2594 | rc = ext4_mark_iloc_dirty(handle, inode, &iloc); |
2594 | if (!err) | 2595 | if (!err) |
@@ -2604,14 +2605,14 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) | |||
2604 | * anyway on the next recovery. */ | 2605 | * anyway on the next recovery. */ |
2605 | mem_insert: | 2606 | mem_insert: |
2606 | if (!err) | 2607 | if (!err) |
2607 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 2608 | list_add(&EXT4_I(inode)->i_orphan, &sbi->s_orphan); |
2608 | 2609 | ||
2609 | jbd_debug(4, "superblock will point to %lu\n", inode->i_ino); | 2610 | jbd_debug(4, "superblock will point to %lu\n", inode->i_ino); |
2610 | jbd_debug(4, "orphan inode %lu will point to %d\n", | 2611 | jbd_debug(4, "orphan inode %lu will point to %d\n", |
2611 | inode->i_ino, NEXT_ORPHAN(inode)); | 2612 | inode->i_ino, NEXT_ORPHAN(inode)); |
2612 | out_unlock: | 2613 | out_unlock: |
2613 | mutex_unlock(&EXT4_SB(sb)->s_orphan_lock); | 2614 | mutex_unlock(&sbi->s_orphan_lock); |
2614 | ext4_std_error(inode->i_sb, err); | 2615 | ext4_std_error(sb, err); |
2615 | return err; | 2616 | return err; |
2616 | } | 2617 | } |
2617 | 2618 | ||
@@ -2623,22 +2624,20 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) | |||
2623 | { | 2624 | { |
2624 | struct list_head *prev; | 2625 | struct list_head *prev; |
2625 | struct ext4_inode_info *ei = EXT4_I(inode); | 2626 | struct ext4_inode_info *ei = EXT4_I(inode); |
2626 | struct ext4_sb_info *sbi; | 2627 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
2627 | __u32 ino_next; | 2628 | __u32 ino_next; |
2628 | struct ext4_iloc iloc; | 2629 | struct ext4_iloc iloc; |
2629 | int err = 0; | 2630 | int err = 0; |
2630 | 2631 | ||
2631 | if ((!EXT4_SB(inode->i_sb)->s_journal) && | 2632 | if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS)) |
2632 | !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) | ||
2633 | return 0; | 2633 | return 0; |
2634 | 2634 | ||
2635 | mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock); | 2635 | mutex_lock(&sbi->s_orphan_lock); |
2636 | if (list_empty(&ei->i_orphan)) | 2636 | if (list_empty(&ei->i_orphan)) |
2637 | goto out; | 2637 | goto out; |
2638 | 2638 | ||
2639 | ino_next = NEXT_ORPHAN(inode); | 2639 | ino_next = NEXT_ORPHAN(inode); |
2640 | prev = ei->i_orphan.prev; | 2640 | prev = ei->i_orphan.prev; |
2641 | sbi = EXT4_SB(inode->i_sb); | ||
2642 | 2641 | ||
2643 | jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino); | 2642 | jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino); |
2644 | 2643 | ||
@@ -2684,7 +2683,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) | |||
2684 | out_err: | 2683 | out_err: |
2685 | ext4_std_error(inode->i_sb, err); | 2684 | ext4_std_error(inode->i_sb, err); |
2686 | out: | 2685 | out: |
2687 | mutex_unlock(&EXT4_SB(inode->i_sb)->s_orphan_lock); | 2686 | mutex_unlock(&sbi->s_orphan_lock); |
2688 | return err; | 2687 | return err; |
2689 | 2688 | ||
2690 | out_brelse: | 2689 | out_brelse: |