Skip to content

Commit cd2c080

Browse files
jankaratytso
authored andcommitted
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>
1 parent 0baaea6 commit cd2c080

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

‎fs/ext4/namei.c‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,13 +2551,14 @@ static int empty_dir(struct inode *inode)
25512551
int ext4_orphan_add(handle_t *handle, struct inode *inode)
25522552
{
25532553
struct super_block *sb = inode->i_sb;
2554+
struct ext4_sb_info *sbi = EXT4_SB(sb);
25542555
struct ext4_iloc iloc;
25552556
int err = 0, rc;
25562557

2557-
if (!EXT4_SB(sb)->s_journal)
2558+
if (!sbi->s_journal)
25582559
return 0;
25592560

2560-
mutex_lock(&EXT4_SB(sb)->s_orphan_lock);
2561+
mutex_lock(&sbi->s_orphan_lock);
25612562
if (!list_empty(&EXT4_I(inode)->i_orphan))
25622563
goto out_unlock;
25632564

@@ -2570,8 +2571,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
25702571
J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
25712572
S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
25722573

2573-
BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
2574-
err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
2574+
BUFFER_TRACE(sbi->s_sbh, "get_write_access");
2575+
err = ext4_journal_get_write_access(handle, sbi->s_sbh);
25752576
if (err)
25762577
goto out_unlock;
25772578

@@ -2583,12 +2584,12 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
25832584
* orphan list. If so skip on-disk list modification.
25842585
*/
25852586
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)))
25872588
goto mem_insert;
25882589

25892590
/* 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-
EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
2591+
NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan);
2592+
sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
25922593
err = ext4_handle_dirty_super(handle, sb);
25932594
rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
25942595
if (!err)
@@ -2604,14 +2605,14 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
26042605
* anyway on the next recovery. */
26052606
mem_insert:
26062607
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);
26082609

26092610
jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
26102611
jbd_debug(4, "orphan inode %lu will point to %d\n",
26112612
inode->i_ino, NEXT_ORPHAN(inode));
26122613
out_unlock:
2613-
mutex_unlock(&EXT4_SB(sb)->s_orphan_lock);
2614-
ext4_std_error(inode->i_sb, err);
2614+
mutex_unlock(&sbi->s_orphan_lock);
2615+
ext4_std_error(sb, err);
26152616
return err;
26162617
}
26172618

@@ -2623,22 +2624,20 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
26232624
{
26242625
struct list_head *prev;
26252626
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);
26272628
__u32 ino_next;
26282629
struct ext4_iloc iloc;
26292630
int err = 0;
26302631

2631-
if ((!EXT4_SB(inode->i_sb)->s_journal) &&
2632-
!(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
2632+
if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
26332633
return 0;
26342634

2635-
mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);
2635+
mutex_lock(&sbi->s_orphan_lock);
26362636
if (list_empty(&ei->i_orphan))
26372637
goto out;
26382638

26392639
ino_next = NEXT_ORPHAN(inode);
26402640
prev = ei->i_orphan.prev;
2641-
sbi = EXT4_SB(inode->i_sb);
26422641

26432642
jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
26442643

@@ -2684,7 +2683,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
26842683
out_err:
26852684
ext4_std_error(inode->i_sb, err);
26862685
out:
2687-
mutex_unlock(&EXT4_SB(inode->i_sb)->s_orphan_lock);
2686+
mutex_unlock(&sbi->s_orphan_lock);
26882687
return err;
26892688

26902689
out_brelse:

0 commit comments

Comments
 (0)