Commit cd2c080c authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

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: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 0baaea64
...@@ -2551,13 +2551,14 @@ static int empty_dir(struct inode *inode) ...@@ -2551,13 +2551,14 @@ static int empty_dir(struct inode *inode)
int ext4_orphan_add(handle_t *handle, struct inode *inode) int ext4_orphan_add(handle_t *handle, struct inode *inode)
{ {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_iloc iloc; struct ext4_iloc iloc;
int err = 0, rc; int err = 0, rc;
if (!EXT4_SB(sb)->s_journal) if (!sbi->s_journal)
return 0; return 0;
mutex_lock(&EXT4_SB(sb)->s_orphan_lock); mutex_lock(&sbi->s_orphan_lock);
if (!list_empty(&EXT4_I(inode)->i_orphan)) if (!list_empty(&EXT4_I(inode)->i_orphan))
goto out_unlock; goto out_unlock;
...@@ -2570,8 +2571,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) ...@@ -2570,8 +2571,8 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)) || inode->i_nlink == 0); S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access"); BUFFER_TRACE(sbi->s_sbh, "get_write_access");
err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh); err = ext4_journal_get_write_access(handle, sbi->s_sbh);
if (err) if (err)
goto out_unlock; goto out_unlock;
...@@ -2583,12 +2584,12 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) ...@@ -2583,12 +2584,12 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
* orphan list. If so skip on-disk list modification. * orphan list. If so skip on-disk list modification.
*/ */
if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <=
(le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) (le32_to_cpu(sbi->s_es->s_inodes_count)))
goto mem_insert; goto mem_insert;
/* Insert this inode at the head of the on-disk orphan list... */ /* Insert this inode at the head of the on-disk orphan list... */
NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan);
EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
err = ext4_handle_dirty_super(handle, sb); err = ext4_handle_dirty_super(handle, sb);
rc = ext4_mark_iloc_dirty(handle, inode, &iloc); rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
if (!err) if (!err)
...@@ -2604,14 +2605,14 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) ...@@ -2604,14 +2605,14 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
* anyway on the next recovery. */ * anyway on the next recovery. */
mem_insert: mem_insert:
if (!err) if (!err)
list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); list_add(&EXT4_I(inode)->i_orphan, &sbi->s_orphan);
jbd_debug(4, "superblock will point to %lu\n", inode->i_ino); jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
jbd_debug(4, "orphan inode %lu will point to %d\n", jbd_debug(4, "orphan inode %lu will point to %d\n",
inode->i_ino, NEXT_ORPHAN(inode)); inode->i_ino, NEXT_ORPHAN(inode));
out_unlock: out_unlock:
mutex_unlock(&EXT4_SB(sb)->s_orphan_lock); mutex_unlock(&sbi->s_orphan_lock);
ext4_std_error(inode->i_sb, err); ext4_std_error(sb, err);
return err; return err;
} }
...@@ -2623,22 +2624,20 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) ...@@ -2623,22 +2624,20 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
{ {
struct list_head *prev; struct list_head *prev;
struct ext4_inode_info *ei = EXT4_I(inode); struct ext4_inode_info *ei = EXT4_I(inode);
struct ext4_sb_info *sbi; struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
__u32 ino_next; __u32 ino_next;
struct ext4_iloc iloc; struct ext4_iloc iloc;
int err = 0; int err = 0;
if ((!EXT4_SB(inode->i_sb)->s_journal) && if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
!(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
return 0; return 0;
mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock); mutex_lock(&sbi->s_orphan_lock);
if (list_empty(&ei->i_orphan)) if (list_empty(&ei->i_orphan))
goto out; goto out;
ino_next = NEXT_ORPHAN(inode); ino_next = NEXT_ORPHAN(inode);
prev = ei->i_orphan.prev; prev = ei->i_orphan.prev;
sbi = EXT4_SB(inode->i_sb);
jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino); jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
...@@ -2684,7 +2683,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) ...@@ -2684,7 +2683,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
out_err: out_err:
ext4_std_error(inode->i_sb, err); ext4_std_error(inode->i_sb, err);
out: out:
mutex_unlock(&EXT4_SB(inode->i_sb)->s_orphan_lock); mutex_unlock(&sbi->s_orphan_lock);
return err; return err;
out_brelse: out_brelse:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment