Skip to content

Commit 0737e01

Browse files
Heming Zhao via Ocfs2-develakpm00
authored andcommitted
ocfs2: ocfs2_mount_volume does cleanup job before return error
After this patch, when error, ocfs2_fill_super doesn't take care to release resources which are allocated in ocfs2_mount_volume. Link: https://lkml.kernel.org/r/20220424130952.2436-5-heming.zhao@suse.com Signed-off-by: Heming Zhao <heming.zhao@suse.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jun Piao <piaojun@huawei.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Mark Fasheh <mark@fasheh.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent a8a986d commit 0737e01

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

fs/ocfs2/super.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,11 +1803,10 @@ static int ocfs2_get_sector(struct super_block *sb,
18031803
static int ocfs2_mount_volume(struct super_block *sb)
18041804
{
18051805
int status = 0;
1806-
int unlock_super = 0;
18071806
struct ocfs2_super *osb = OCFS2_SB(sb);
18081807

18091808
if (ocfs2_is_hard_readonly(osb))
1810-
goto leave;
1809+
goto out;
18111810

18121811
mutex_init(&osb->obs_trim_fs_mutex);
18131812

@@ -1817,44 +1816,56 @@ static int ocfs2_mount_volume(struct super_block *sb)
18171816
if (status == -EBADR && ocfs2_userspace_stack(osb))
18181817
mlog(ML_ERROR, "couldn't mount because cluster name on"
18191818
" disk does not match the running cluster name.\n");
1820-
goto leave;
1819+
goto out;
18211820
}
18221821

18231822
status = ocfs2_super_lock(osb, 1);
18241823
if (status < 0) {
18251824
mlog_errno(status);
1826-
goto leave;
1825+
goto out_dlm;
18271826
}
1828-
unlock_super = 1;
18291827

18301828
/* This will load up the node map and add ourselves to it. */
18311829
status = ocfs2_find_slot(osb);
18321830
if (status < 0) {
18331831
mlog_errno(status);
1834-
goto leave;
1832+
goto out_super_lock;
18351833
}
18361834

18371835
/* load all node-local system inodes */
18381836
status = ocfs2_init_local_system_inodes(osb);
18391837
if (status < 0) {
18401838
mlog_errno(status);
1841-
goto leave;
1839+
goto out_super_lock;
18421840
}
18431841

18441842
status = ocfs2_check_volume(osb);
18451843
if (status < 0) {
18461844
mlog_errno(status);
1847-
goto leave;
1845+
goto out_system_inodes;
18481846
}
18491847

18501848
status = ocfs2_truncate_log_init(osb);
1851-
if (status < 0)
1849+
if (status < 0) {
18521850
mlog_errno(status);
1851+
goto out_system_inodes;
1852+
}
18531853

1854-
leave:
1855-
if (unlock_super)
1856-
ocfs2_super_unlock(osb, 1);
1854+
ocfs2_super_unlock(osb, 1);
1855+
return 0;
18571856

1857+
out_system_inodes:
1858+
if (osb->local_alloc_state == OCFS2_LA_ENABLED)
1859+
ocfs2_shutdown_local_alloc(osb);
1860+
ocfs2_release_system_inodes(osb);
1861+
/* before journal shutdown, we should release slot_info */
1862+
ocfs2_free_slot_info(osb);
1863+
ocfs2_journal_shutdown(osb);
1864+
out_super_lock:
1865+
ocfs2_super_unlock(osb, 1);
1866+
out_dlm:
1867+
ocfs2_dlm_shutdown(osb, 0);
1868+
out:
18581869
return status;
18591870
}
18601871

0 commit comments

Comments
 (0)