* [PATCH] jfs: Functions jfs_freeze() and jfs_unfreeze() always return 0
@ 2013-05-16 5:14 Vahram Martirosyan
2013-05-16 8:57 ` Gu Zheng
0 siblings, 1 reply; 2+ messages in thread
From: Vahram Martirosyan @ 2013-05-16 5:14 UTC (permalink / raw)
To: Dave Kleikamp
Cc: Vahram Martirosyan, jfs-discussion, linux-kernel, spruce-project
The mentioned functions do not pay attention to the error codes returned
by the functions updateSuper(), lmLogInit() and lmLogShutdown(). It brings to
system crash later when writing to log.
The patch adds corresponding code to check and return the error codes
and to print correct error messages in case of errors.
Found by Linux File System Verification project (linuxtesting.org).
Signed-off-by: Vahram Martirosyan <vahram.martirosyan@linuxtesting.org>
---
fs/jfs/super.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 2003e83..a3d424d 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -611,11 +611,20 @@ static int jfs_freeze(struct super_block *sb)
{
struct jfs_sb_info *sbi = JFS_SBI(sb);
struct jfs_log *log = sbi->log;
+ int rc = 0;
if (!(sb->s_flags & MS_RDONLY)) {
txQuiesce(sb);
- lmLogShutdown(log);
- updateSuper(sb, FM_CLEAN);
+ rc = lmLogShutdown(log);
+ if (rc != 0) {
+ jfs_err("lmLogShutdown failed with return code %d", rc);
+ return rc;
+ }
+ rc = updateSuper(sb, FM_CLEAN);
+ if (rc != 0) {
+ jfs_err("updateSuper failed with return code %d", rc);
+ return rc;
+ }
}
return 0;
}
@@ -627,11 +636,17 @@ static int jfs_unfreeze(struct super_block *sb)
int rc = 0;
if (!(sb->s_flags & MS_RDONLY)) {
- updateSuper(sb, FM_MOUNT);
- if ((rc = lmLogInit(log)))
- jfs_err("jfs_unlock failed with return code %d", rc);
- else
- txResume(sb);
+ rc = updateSuper(sb, FM_MOUNT);
+ if (rc != 0) {
+ jfs_err("updateSuper failed with return code %d", rc);
+ return rc;
+ }
+ rc = lmLogInit(log);
+ if (rc != 0) {
+ jfs_err("lmLogInit failed with return code %d", rc);
+ return rc;
+ }
+ txResume(sb);
}
return 0;
}
--
1.8.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] jfs: Functions jfs_freeze() and jfs_unfreeze() always return 0
2013-05-16 5:14 [PATCH] jfs: Functions jfs_freeze() and jfs_unfreeze() always return 0 Vahram Martirosyan
@ 2013-05-16 8:57 ` Gu Zheng
0 siblings, 0 replies; 2+ messages in thread
From: Gu Zheng @ 2013-05-16 8:57 UTC (permalink / raw)
To: Vahram Martirosyan
Cc: Dave Kleikamp, Vahram Martirosyan, jfs-discussion, linux-kernel,
spruce-project
On 05/16/2013 01:14 PM, Vahram Martirosyan wrote:
> The mentioned functions do not pay attention to the error codes returned
> by the functions updateSuper(), lmLogInit() and lmLogShutdown(). It brings to
> system crash later when writing to log.
>
> The patch adds corresponding code to check and return the error codes
> and to print correct error messages in case of errors.
>
> Found by Linux File System Verification project (linuxtesting.org).
>
> Signed-off-by: Vahram Martirosyan <vahram.martirosyan@linuxtesting.org>
Reviewed-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
> fs/jfs/super.c | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/fs/jfs/super.c b/fs/jfs/super.c
> index 2003e83..a3d424d 100644
> --- a/fs/jfs/super.c
> +++ b/fs/jfs/super.c
> @@ -611,11 +611,20 @@ static int jfs_freeze(struct super_block *sb)
> {
> struct jfs_sb_info *sbi = JFS_SBI(sb);
> struct jfs_log *log = sbi->log;
> + int rc = 0;
>
> if (!(sb->s_flags & MS_RDONLY)) {
> txQuiesce(sb);
> - lmLogShutdown(log);
> - updateSuper(sb, FM_CLEAN);
> + rc = lmLogShutdown(log);
> + if (rc != 0) {
"if (rc)", and the following.
Thanks,
Gu
> + jfs_err("lmLogShutdown failed with return code %d", rc);
> + return rc;
> + }
> + rc = updateSuper(sb, FM_CLEAN);
> + if (rc != 0) {
> + jfs_err("updateSuper failed with return code %d", rc);
> + return rc;
> + }
> }
> return 0;
> }
> @@ -627,11 +636,17 @@ static int jfs_unfreeze(struct super_block *sb)
> int rc = 0;
>
> if (!(sb->s_flags & MS_RDONLY)) {
> - updateSuper(sb, FM_MOUNT);
> - if ((rc = lmLogInit(log)))
> - jfs_err("jfs_unlock failed with return code %d", rc);
> - else
> - txResume(sb);
> + rc = updateSuper(sb, FM_MOUNT);
> + if (rc != 0) {
> + jfs_err("updateSuper failed with return code %d", rc);
> + return rc;
> + }
> + rc = lmLogInit(log);
> + if (rc != 0) {
> + jfs_err("lmLogInit failed with return code %d", rc);
> + return rc;
> + }
> + txResume(sb);
> }
> return 0;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-16 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-16 5:14 [PATCH] jfs: Functions jfs_freeze() and jfs_unfreeze() always return 0 Vahram Martirosyan
2013-05-16 8:57 ` Gu Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox