1 ext4: use sbi in ext4_orphan_{add|del}()
3 From: Jan Kara <jack@suse.cz>
5 Use sbi pointer consistently in ext4_orphan_del() instead of opencoding
6 it sometimes. Also ext4_orphan_add() uses EXT4_SB(sb) often so create
7 sbi variable for it as well and use it.
9 Signed-off-by: Jan Kara <jack@suse.cz>
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 fs/ext4/namei.c | 31 +++++++++++++++----------------
13 1 file changed, 15 insertions(+), 16 deletions(-)
15 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
16 index 7ac6167..eb61584 100644
19 @@ -2551,13 +2551,14 @@ static int empty_dir(struct inode *inode)
20 int ext4_orphan_add(handle_t *handle, struct inode *inode)
22 struct super_block *sb = inode->i_sb;
23 + struct ext4_sb_info *sbi = EXT4_SB(sb);
24 struct ext4_iloc iloc;
27 - if (!EXT4_SB(sb)->s_journal)
28 + if (!sbi->s_journal)
31 - mutex_lock(&EXT4_SB(sb)->s_orphan_lock);
32 + mutex_lock(&sbi->s_orphan_lock);
33 if (!list_empty(&EXT4_I(inode)->i_orphan))
36 @@ -2570,8 +2571,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
37 J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
38 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
40 - BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
41 - err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
42 + BUFFER_TRACE(sbi->s_sbh, "get_write_access");
43 + err = ext4_journal_get_write_access(handle, sbi->s_sbh);
47 @@ -2583,12 +2584,12 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
48 * orphan list. If so skip on-disk list modification.
50 if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <=
51 - (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)))
52 + (le32_to_cpu(sbi->s_es->s_inodes_count)))
55 /* Insert this inode at the head of the on-disk orphan list... */
56 - NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan);
57 - EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
58 + NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan);
59 + sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
60 err = ext4_handle_dirty_super(handle, sb);
61 rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
63 @@ -2604,14 +2605,14 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
64 * anyway on the next recovery. */
67 - list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
68 + list_add(&EXT4_I(inode)->i_orphan, &sbi->s_orphan);
70 jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
71 jbd_debug(4, "orphan inode %lu will point to %d\n",
72 inode->i_ino, NEXT_ORPHAN(inode));
74 - mutex_unlock(&EXT4_SB(sb)->s_orphan_lock);
75 - ext4_std_error(inode->i_sb, err);
76 + mutex_unlock(&sbi->s_orphan_lock);
77 + ext4_std_error(sb, err);
81 @@ -2623,22 +2624,20 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
83 struct list_head *prev;
84 struct ext4_inode_info *ei = EXT4_I(inode);
85 - struct ext4_sb_info *sbi;
86 + struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
88 struct ext4_iloc iloc;
91 - if ((!EXT4_SB(inode->i_sb)->s_journal) &&
92 - !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
93 + if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
96 - mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);
97 + mutex_lock(&sbi->s_orphan_lock);
98 if (list_empty(&ei->i_orphan))
101 ino_next = NEXT_ORPHAN(inode);
102 prev = ei->i_orphan.prev;
103 - sbi = EXT4_SB(inode->i_sb);
105 jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
107 @@ -2684,7 +2683,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
109 ext4_std_error(inode->i_sb, err);
111 - mutex_unlock(&EXT4_SB(inode->i_sb)->s_orphan_lock);
112 + mutex_unlock(&sbi->s_orphan_lock);