Skip to content

Commit

Permalink
jfs: Several bugs in jfs_freeze() and jfs_unfreeze()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Gu Zheng <[email protected]>
Signed-off-by: Dave Kleikamp <[email protected]>
  • Loading branch information
vmartirosyan authored and kleikamp committed May 24, 2013
1 parent 514e250 commit e9b3766
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,28 @@ 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) {
jfs_error(sb, "jfs_freeze: lmLogShutdown failed");

/* let operations fail rather than hang */
txResume(sb);

return rc;
}
rc = updateSuper(sb, FM_CLEAN);
if (rc) {
jfs_err("jfs_freeze: updateSuper failed\n");
/*
* Don't fail here. Everything succeeded except
* marking the superblock clean, so there's really
* no harm in leaving it frozen for now.
*/
}
}
return 0;
}
Expand All @@ -627,13 +644,18 @@ 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) {
jfs_error(sb, "jfs_unfreeze: updateSuper failed");
goto out;
}
rc = lmLogInit(log);
if (rc)
jfs_error(sb, "jfs_unfreeze: lmLogInit failed");
out:
txResume(sb);
}
return 0;
return rc;
}

static struct dentry *jfs_do_mount(struct file_system_type *fs_type,
Expand Down

0 comments on commit e9b3766

Please sign in to comment.