Skip to content

Commit c6cb7e7

Browse files
Eric Whitneytytso
authored andcommitted
ext4: create function to read journal inode
Factor out the code used in ext4_get_journal() to read a valid journal inode from storage, enabling its reuse in other functions. Signed-off-by: Eric Whitney <enwlinux@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 9b623df commit c6cb7e7

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

‎fs/ext4/super.c‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly);
7878
static void ext4_destroy_lazyinit_thread(void);
7979
static void ext4_unregister_li_request(struct super_block *sb);
8080
static void ext4_clear_request_list(void);
81+
static struct inode *ext4_get_journal_inode(struct super_block *sb,
82+
unsigned int journal_inum);
8183

8284
/*
8385
* Lock ordering
@@ -4237,18 +4239,16 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
42374239
write_unlock(&journal->j_state_lock);
42384240
}
42394241

4240-
static journal_t *ext4_get_journal(struct super_block *sb,
4241-
unsigned int journal_inum)
4242+
static struct inode *ext4_get_journal_inode(struct super_block *sb,
4243+
unsigned int journal_inum)
42424244
{
42434245
struct inode *journal_inode;
4244-
journal_t *journal;
4245-
4246-
BUG_ON(!ext4_has_feature_journal(sb));
4247-
4248-
/* First, test for the existence of a valid inode on disk. Bad
4249-
* things happen if we iget() an unused inode, as the subsequent
4250-
* iput() will try to delete it. */
42514246

4247+
/*
4248+
* Test for the existence of a valid inode on disk. Bad things
4249+
* happen if we iget() an unused inode, as the subsequent iput()
4250+
* will try to delete it.
4251+
*/
42524252
journal_inode = ext4_iget(sb, journal_inum);
42534253
if (IS_ERR(journal_inode)) {
42544254
ext4_msg(sb, KERN_ERR, "no journal found");
@@ -4268,6 +4268,20 @@ static journal_t *ext4_get_journal(struct super_block *sb,
42684268
iput(journal_inode);
42694269
return NULL;
42704270
}
4271+
return journal_inode;
4272+
}
4273+
4274+
static journal_t *ext4_get_journal(struct super_block *sb,
4275+
unsigned int journal_inum)
4276+
{
4277+
struct inode *journal_inode;
4278+
journal_t *journal;
4279+
4280+
BUG_ON(!ext4_has_feature_journal(sb));
4281+
4282+
journal_inode = ext4_get_journal_inode(sb, journal_inum);
4283+
if (!journal_inode)
4284+
return NULL;
42714285

42724286
journal = jbd2_journal_init_inode(journal_inode);
42734287
if (!journal) {

0 commit comments

Comments
 (0)