* [Ocfs2-devel] + ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch added to -mm tree
@ 2022-04-28 22:00 Andrew Morton via Ocfs2-devel
2022-04-29 2:47 ` Joseph Qi via Ocfs2-devel
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton via Ocfs2-devel @ 2022-04-28 22:00 UTC (permalink / raw)
To: mm-commits, piaojun, mark, junxiao.bi, joseph.qi, jlbec,
heming.zhao, ghe, gechangwei, ocfs2-devel, akpm
The patch titled
Subject: ocfs2: rewrite error handling of ocfs2_fill_super
has been added to the -mm tree. Its filename is
ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Heming Zhao via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
Subject: ocfs2: rewrite error handling of ocfs2_fill_super
Current ocfs2_fill_super() uses one goto label "read_super_error" to
handle all error cases. And with previous serial patches, the error
handling should fork more branches to handle different error cases. This
patch rewrite the error handling of ocfs2_fill_super.
Link: https://lkml.kernel.org/r/20220424130952.2436-6-heming.zhao@suse.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
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>
---
fs/ocfs2/super.c | 67 +++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 35 deletions(-)
--- a/fs/ocfs2/super.c~ocfs2-rewrite-error-handling-of-ocfs2_fill_super
+++ a/fs/ocfs2/super.c
@@ -989,28 +989,27 @@ static int ocfs2_fill_super(struct super
if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) {
status = -EINVAL;
- goto read_super_error;
+ goto out;
}
/* probe for superblock */
status = ocfs2_sb_probe(sb, &bh, §or_size, &stats);
if (status < 0) {
mlog(ML_ERROR, "superblock probe failed!\n");
- goto read_super_error;
+ goto out;
}
status = ocfs2_initialize_super(sb, bh, sector_size, &stats);
- osb = OCFS2_SB(sb);
- if (status < 0) {
- mlog_errno(status);
- goto read_super_error;
- }
brelse(bh);
bh = NULL;
+ if (status < 0)
+ goto out;
+
+ osb = OCFS2_SB(sb);
if (!ocfs2_check_set_options(sb, &parsed_options)) {
status = -EINVAL;
- goto read_super_error;
+ goto out_super;
}
osb->s_mount_opt = parsed_options.mount_opt;
osb->s_atime_quantum = parsed_options.atime_quantum;
@@ -1027,7 +1026,7 @@ static int ocfs2_fill_super(struct super
status = ocfs2_verify_userspace_stack(osb, &parsed_options);
if (status)
- goto read_super_error;
+ goto out_super;
sb->s_magic = OCFS2_SUPER_MAGIC;
@@ -1041,7 +1040,7 @@ static int ocfs2_fill_super(struct super
status = -EACCES;
mlog(ML_ERROR, "Readonly device detected but readonly "
"mount was not specified.\n");
- goto read_super_error;
+ goto out_super;
}
/* You should not be able to start a local heartbeat
@@ -1050,7 +1049,7 @@ static int ocfs2_fill_super(struct super
status = -EROFS;
mlog(ML_ERROR, "Local heartbeat specified on readonly "
"device.\n");
- goto read_super_error;
+ goto out_super;
}
status = ocfs2_check_journals_nolocks(osb);
@@ -1059,9 +1058,7 @@ static int ocfs2_fill_super(struct super
mlog(ML_ERROR, "Recovery required on readonly "
"file system, but write access is "
"unavailable.\n");
- else
- mlog_errno(status);
- goto read_super_error;
+ goto out_super;
}
ocfs2_set_ro_flag(osb, 1);
@@ -1077,10 +1074,8 @@ static int ocfs2_fill_super(struct super
}
status = ocfs2_verify_heartbeat(osb);
- if (status < 0) {
- mlog_errno(status);
- goto read_super_error;
- }
+ if (status < 0)
+ goto out_super;
osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
ocfs2_debugfs_root);
@@ -1094,15 +1089,14 @@ static int ocfs2_fill_super(struct super
status = ocfs2_mount_volume(sb);
if (status < 0)
- goto read_super_error;
+ goto out_debugfs;
if (osb->root_inode)
inode = igrab(osb->root_inode);
if (!inode) {
status = -EIO;
- mlog_errno(status);
- goto read_super_error;
+ goto out_dismount;
}
osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
@@ -1110,7 +1104,7 @@ static int ocfs2_fill_super(struct super
if (!osb->osb_dev_kset) {
status = -ENOMEM;
mlog(ML_ERROR, "Unable to create device kset %s.\n", sb->s_id);
- goto read_super_error;
+ goto out_dismount;
}
/* Create filecheck sysfs related directories/files at
@@ -1119,14 +1113,13 @@ static int ocfs2_fill_super(struct super
status = -ENOMEM;
mlog(ML_ERROR, "Unable to create filecheck sysfs directory at "
"/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id);
- goto read_super_error;
+ goto out_dismount;
}
root = d_make_root(inode);
if (!root) {
status = -ENOMEM;
- mlog_errno(status);
- goto read_super_error;
+ goto out_dismount;
}
sb->s_root = root;
@@ -1178,17 +1171,21 @@ static int ocfs2_fill_super(struct super
return status;
-read_super_error:
- brelse(bh);
-
- if (status)
- mlog_errno(status);
+out_dismount:
+ atomic_set(&osb->vol_state, VOLUME_DISABLED);
+ wake_up(&osb->osb_mount_event);
+ ocfs2_dismount_volume(sb, 1);
+ goto out;
- if (osb) {
- atomic_set(&osb->vol_state, VOLUME_DISABLED);
- wake_up(&osb->osb_mount_event);
- ocfs2_dismount_volume(sb, 1);
- }
+out_debugfs:
+ debugfs_remove_recursive(osb->osb_debug_root);
+out_super:
+ ocfs2_release_system_inodes(osb);
+ kfree(osb->recovery_map);
+ ocfs2_delete_osb(osb);
+ kfree(osb);
+out:
+ mlog_errno(status);
return status;
}
_
Patches currently in -mm which might be from ocfs2-devel@oss.oracle.com are
ocfs2-fix-mounting-crash-if-journal-is-not-alloced.patch
ocfs2-change-return-type-of-ocfs2_resmap_init.patch
ocfs2-ocfs2_initialize_super-does-cleanup-job-before-return-error.patch
ocfs2-ocfs2_mount_volume-does-cleanup-job-before-return-error.patch
ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Ocfs2-devel] + ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch added to -mm tree
2022-04-28 22:00 [Ocfs2-devel] + ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch added to -mm tree Andrew Morton via Ocfs2-devel
@ 2022-04-29 2:47 ` Joseph Qi via Ocfs2-devel
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Qi via Ocfs2-devel @ 2022-04-29 2:47 UTC (permalink / raw)
To: Andrew Morton, mm-commits, piaojun, mark, junxiao.bi, jlbec,
heming.zhao, ghe, gechangwei, ocfs2-devel
On 4/29/22 6:00 AM, Andrew Morton wrote:
> The patch titled
> Subject: ocfs2: rewrite error handling of ocfs2_fill_super
> has been added to the -mm tree. Its filename is
> ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
>
> This patch should soon appear at
> https://ozlabs.org/~akpm/mmots/broken-out/ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
> and later at
> https://ozlabs.org/~akpm/mmotm/broken-out/ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next and is updated
> there every 3-4 working days
>
> ------------------------------------------------------
> From: Heming Zhao via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
> Subject: ocfs2: rewrite error handling of ocfs2_fill_super
>
> Current ocfs2_fill_super() uses one goto label "read_super_error" to
> handle all error cases. And with previous serial patches, the error
> handling should fork more branches to handle different error cases. This
> patch rewrite the error handling of ocfs2_fill_super.
>
> Link: https://lkml.kernel.org/r/20220424130952.2436-6-heming.zhao@suse.com
> Signed-off-by: Heming Zhao <heming.zhao@suse.com>
> Cc: Changwei Ge <gechangwei@live.cn>
> Cc: Gang He <ghe@suse.com>
> Cc: Joel Becker <jlbec@evilplan.org>
> Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> 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>
> ---
>
> fs/ocfs2/super.c | 67 +++++++++++++++++++++------------------------
> 1 file changed, 32 insertions(+), 35 deletions(-)
>
> --- a/fs/ocfs2/super.c~ocfs2-rewrite-error-handling-of-ocfs2_fill_super
> +++ a/fs/ocfs2/super.c
> @@ -989,28 +989,27 @@ static int ocfs2_fill_super(struct super
>
> if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) {
> status = -EINVAL;
> - goto read_super_error;
> + goto out;
> }
>
> /* probe for superblock */
> status = ocfs2_sb_probe(sb, &bh, §or_size, &stats);
> if (status < 0) {
> mlog(ML_ERROR, "superblock probe failed!\n");
> - goto read_super_error;
> + goto out;
> }
>
> status = ocfs2_initialize_super(sb, bh, sector_size, &stats);
> - osb = OCFS2_SB(sb);
> - if (status < 0) {
> - mlog_errno(status);
> - goto read_super_error;
> - }
> brelse(bh);
> bh = NULL;
> + if (status < 0)
> + goto out;
> +
> + osb = OCFS2_SB(sb);
>
> if (!ocfs2_check_set_options(sb, &parsed_options)) {
> status = -EINVAL;
> - goto read_super_error;
> + goto out_super;
> }
> osb->s_mount_opt = parsed_options.mount_opt;
> osb->s_atime_quantum = parsed_options.atime_quantum;
> @@ -1027,7 +1026,7 @@ static int ocfs2_fill_super(struct super
>
> status = ocfs2_verify_userspace_stack(osb, &parsed_options);
> if (status)
> - goto read_super_error;
> + goto out_super;
>
> sb->s_magic = OCFS2_SUPER_MAGIC;
>
> @@ -1041,7 +1040,7 @@ static int ocfs2_fill_super(struct super
> status = -EACCES;
> mlog(ML_ERROR, "Readonly device detected but readonly "
> "mount was not specified.\n");
> - goto read_super_error;
> + goto out_super;
> }
>
> /* You should not be able to start a local heartbeat
> @@ -1050,7 +1049,7 @@ static int ocfs2_fill_super(struct super
> status = -EROFS;
> mlog(ML_ERROR, "Local heartbeat specified on readonly "
> "device.\n");
> - goto read_super_error;
> + goto out_super;
> }
>
> status = ocfs2_check_journals_nolocks(osb);
> @@ -1059,9 +1058,7 @@ static int ocfs2_fill_super(struct super
> mlog(ML_ERROR, "Recovery required on readonly "
> "file system, but write access is "
> "unavailable.\n");
> - else
> - mlog_errno(status);
> - goto read_super_error;
> + goto out_super;
> }
>
> ocfs2_set_ro_flag(osb, 1);
> @@ -1077,10 +1074,8 @@ static int ocfs2_fill_super(struct super
> }
>
> status = ocfs2_verify_heartbeat(osb);
> - if (status < 0) {
> - mlog_errno(status);
> - goto read_super_error;
> - }
> + if (status < 0)
> + goto out_super;
>
> osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
> ocfs2_debugfs_root);
> @@ -1094,15 +1089,14 @@ static int ocfs2_fill_super(struct super
>
> status = ocfs2_mount_volume(sb);
> if (status < 0)
> - goto read_super_error;
> + goto out_debugfs;
>
> if (osb->root_inode)
> inode = igrab(osb->root_inode);
>
> if (!inode) {
> status = -EIO;
> - mlog_errno(status);
> - goto read_super_error;
> + goto out_dismount;
> }
>
> osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
> @@ -1110,7 +1104,7 @@ static int ocfs2_fill_super(struct super
> if (!osb->osb_dev_kset) {
> status = -ENOMEM;
> mlog(ML_ERROR, "Unable to create device kset %s.\n", sb->s_id);
> - goto read_super_error;
> + goto out_dismount;
> }
>
> /* Create filecheck sysfs related directories/files at
> @@ -1119,14 +1113,13 @@ static int ocfs2_fill_super(struct super
> status = -ENOMEM;
> mlog(ML_ERROR, "Unable to create filecheck sysfs directory at "
> "/sys/fs/ocfs2/%s/filecheck.\n", sb->s_id);
> - goto read_super_error;
> + goto out_dismount;
> }
>
> root = d_make_root(inode);
> if (!root) {
> status = -ENOMEM;
> - mlog_errno(status);
> - goto read_super_error;
> + goto out_dismount;
> }
>
> sb->s_root = root;
> @@ -1178,17 +1171,21 @@ static int ocfs2_fill_super(struct super
>
> return status;
>
> -read_super_error:
> - brelse(bh);
> -
> - if (status)
> - mlog_errno(status);
> +out_dismount:
> + atomic_set(&osb->vol_state, VOLUME_DISABLED);
> + wake_up(&osb->osb_mount_event);
> + ocfs2_dismount_volume(sb, 1);
> + goto out;
>
> - if (osb) {
> - atomic_set(&osb->vol_state, VOLUME_DISABLED);
> - wake_up(&osb->osb_mount_event);
> - ocfs2_dismount_volume(sb, 1);
> - }
> +out_debugfs:
> + debugfs_remove_recursive(osb->osb_debug_root);
> +out_super:
> + ocfs2_release_system_inodes(osb);
> + kfree(osb->recovery_map);
> + ocfs2_delete_osb(osb);
> + kfree(osb);
> +out:
> + mlog_errno(status);
>
> return status;
> }
> _
>
> Patches currently in -mm which might be from ocfs2-devel@oss.oracle.com are
>
> ocfs2-fix-mounting-crash-if-journal-is-not-alloced.patch
> ocfs2-change-return-type-of-ocfs2_resmap_init.patch
> ocfs2-ocfs2_initialize_super-does-cleanup-job-before-return-error.patch
> ocfs2-ocfs2_mount_volume-does-cleanup-job-before-return-error.patch
> ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-29 2:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 22:00 [Ocfs2-devel] + ocfs2-rewrite-error-handling-of-ocfs2_fill_super.patch added to -mm tree Andrew Morton via Ocfs2-devel
2022-04-29 2:47 ` Joseph Qi via Ocfs2-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).