1 ext4: create function to read journal inode
3 From: Eric Whitney <enwlinux@gmail.com>
5 Factor out the code used in ext4_get_journal() to read a valid journal
6 inode from storage, enabling its reuse in other functions.
8 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 fs/ext4/super.c | 32 +++++++++++++++++++++++---------
12 1 file changed, 23 insertions(+), 9 deletions(-)
14 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
15 index 50912cc..4b0ca25 100644
18 @@ -78,6 +78,8 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly);
19 static void ext4_destroy_lazyinit_thread(void);
20 static void ext4_unregister_li_request(struct super_block *sb);
21 static void ext4_clear_request_list(void);
22 +static struct inode *ext4_get_journal_inode(struct super_block *sb,
23 + unsigned int journal_inum);
27 @@ -4237,18 +4239,16 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
28 write_unlock(&journal->j_state_lock);
31 -static journal_t *ext4_get_journal(struct super_block *sb,
32 - unsigned int journal_inum)
33 +static struct inode *ext4_get_journal_inode(struct super_block *sb,
34 + unsigned int journal_inum)
36 struct inode *journal_inode;
39 - BUG_ON(!ext4_has_feature_journal(sb));
41 - /* First, test for the existence of a valid inode on disk. Bad
42 - * things happen if we iget() an unused inode, as the subsequent
43 - * iput() will try to delete it. */
46 + * Test for the existence of a valid inode on disk. Bad things
47 + * happen if we iget() an unused inode, as the subsequent iput()
48 + * will try to delete it.
50 journal_inode = ext4_iget(sb, journal_inum);
51 if (IS_ERR(journal_inode)) {
52 ext4_msg(sb, KERN_ERR, "no journal found");
53 @@ -4268,6 +4268,20 @@ static journal_t *ext4_get_journal(struct super_block *sb,
57 + return journal_inode;
60 +static journal_t *ext4_get_journal(struct super_block *sb,
61 + unsigned int journal_inum)
63 + struct inode *journal_inode;
66 + BUG_ON(!ext4_has_feature_journal(sb));
68 + journal_inode = ext4_get_journal_inode(sb, journal_inum);
72 journal = jbd2_journal_init_inode(journal_inode);