ext4: reflect error codes from ext4_multi_mount_protect() to its callers
[ Upstream commit 3b50d5018ed06a647bb26c44bb5ae74e59c903c7 ] This will allow more fine-grained errno codes to be returned by the mount system call. Cc: Andreas Dilger <adilger.kernel@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Stable-dep-of: a44be64bbecb ("ext4: don't clear SB_RDONLY when remounting r/w until quota is re-enabled") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
5a08a72da3
commit
cc4086759f
@ -296,6 +296,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
|
|||||||
if (mmp_block < le32_to_cpu(es->s_first_data_block) ||
|
if (mmp_block < le32_to_cpu(es->s_first_data_block) ||
|
||||||
mmp_block >= ext4_blocks_count(es)) {
|
mmp_block >= ext4_blocks_count(es)) {
|
||||||
ext4_warning(sb, "Invalid MMP block in superblock");
|
ext4_warning(sb, "Invalid MMP block in superblock");
|
||||||
|
retval = -EINVAL;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,6 +322,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
|
|||||||
|
|
||||||
if (seq == EXT4_MMP_SEQ_FSCK) {
|
if (seq == EXT4_MMP_SEQ_FSCK) {
|
||||||
dump_mmp_msg(sb, mmp, "fsck is running on the filesystem");
|
dump_mmp_msg(sb, mmp, "fsck is running on the filesystem");
|
||||||
|
retval = -EBUSY;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,6 +336,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
|
|||||||
|
|
||||||
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
|
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
|
||||||
ext4_warning(sb, "MMP startup interrupted, failing mount\n");
|
ext4_warning(sb, "MMP startup interrupted, failing mount\n");
|
||||||
|
retval = -ETIMEDOUT;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,6 +347,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
|
|||||||
if (seq != le32_to_cpu(mmp->mmp_seq)) {
|
if (seq != le32_to_cpu(mmp->mmp_seq)) {
|
||||||
dump_mmp_msg(sb, mmp,
|
dump_mmp_msg(sb, mmp,
|
||||||
"Device is already active on another node.");
|
"Device is already active on another node.");
|
||||||
|
retval = -EBUSY;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,6 +371,7 @@ skip:
|
|||||||
*/
|
*/
|
||||||
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
|
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
|
||||||
ext4_warning(sb, "MMP startup interrupted, failing mount");
|
ext4_warning(sb, "MMP startup interrupted, failing mount");
|
||||||
|
retval = -ETIMEDOUT;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,6 +382,7 @@ skip:
|
|||||||
if (seq != le32_to_cpu(mmp->mmp_seq)) {
|
if (seq != le32_to_cpu(mmp->mmp_seq)) {
|
||||||
dump_mmp_msg(sb, mmp,
|
dump_mmp_msg(sb, mmp,
|
||||||
"Device is already active on another node.");
|
"Device is already active on another node.");
|
||||||
|
retval = -EBUSY;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,6 +402,7 @@ skip:
|
|||||||
EXT4_SB(sb)->s_mmp_tsk = NULL;
|
EXT4_SB(sb)->s_mmp_tsk = NULL;
|
||||||
ext4_warning(sb, "Unable to create kmmpd thread for %s.",
|
ext4_warning(sb, "Unable to create kmmpd thread for %s.",
|
||||||
sb->s_id);
|
sb->s_id);
|
||||||
|
retval = -ENOMEM;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,5 +410,5 @@ skip:
|
|||||||
|
|
||||||
failed:
|
failed:
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
return 1;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -5281,9 +5281,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
|
|||||||
ext4_has_feature_orphan_present(sb) ||
|
ext4_has_feature_orphan_present(sb) ||
|
||||||
ext4_has_feature_journal_needs_recovery(sb));
|
ext4_has_feature_journal_needs_recovery(sb));
|
||||||
|
|
||||||
if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb))
|
if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb)) {
|
||||||
if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
|
err = ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block));
|
||||||
|
if (err)
|
||||||
goto failed_mount3a;
|
goto failed_mount3a;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The first inode we look at is the journal inode. Don't try
|
* The first inode we look at is the journal inode. Don't try
|
||||||
@ -6524,12 +6526,12 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
|
|||||||
goto restore_opts;
|
goto restore_opts;
|
||||||
|
|
||||||
sb->s_flags &= ~SB_RDONLY;
|
sb->s_flags &= ~SB_RDONLY;
|
||||||
if (ext4_has_feature_mmp(sb))
|
if (ext4_has_feature_mmp(sb)) {
|
||||||
if (ext4_multi_mount_protect(sb,
|
err = ext4_multi_mount_protect(sb,
|
||||||
le64_to_cpu(es->s_mmp_block))) {
|
le64_to_cpu(es->s_mmp_block));
|
||||||
err = -EROFS;
|
if (err)
|
||||||
goto restore_opts;
|
goto restore_opts;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_QUOTA
|
#ifdef CONFIG_QUOTA
|
||||||
enable_quota = 1;
|
enable_quota = 1;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user