Skip to content

Commit 3b50d50

Browse files
committed
ext4: reflect error codes from ext4_multi_mount_protect() to its callers
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>
1 parent d5e72c4 commit 3b50d50

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

fs/ext4/mmp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
282282
if (mmp_block < le32_to_cpu(es->s_first_data_block) ||
283283
mmp_block >= ext4_blocks_count(es)) {
284284
ext4_warning(sb, "Invalid MMP block in superblock");
285+
retval = -EINVAL;
285286
goto failed;
286287
}
287288

@@ -307,6 +308,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
307308

308309
if (seq == EXT4_MMP_SEQ_FSCK) {
309310
dump_mmp_msg(sb, mmp, "fsck is running on the filesystem");
311+
retval = -EBUSY;
310312
goto failed;
311313
}
312314

@@ -320,6 +322,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
320322

321323
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
322324
ext4_warning(sb, "MMP startup interrupted, failing mount\n");
325+
retval = -ETIMEDOUT;
323326
goto failed;
324327
}
325328

@@ -330,6 +333,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
330333
if (seq != le32_to_cpu(mmp->mmp_seq)) {
331334
dump_mmp_msg(sb, mmp,
332335
"Device is already active on another node.");
336+
retval = -EBUSY;
333337
goto failed;
334338
}
335339

@@ -349,6 +353,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
349353
*/
350354
if (schedule_timeout_interruptible(HZ * wait_time) != 0) {
351355
ext4_warning(sb, "MMP startup interrupted, failing mount");
356+
retval = -ETIMEDOUT;
352357
goto failed;
353358
}
354359

@@ -359,6 +364,7 @@ int ext4_multi_mount_protect(struct super_block *sb,
359364
if (seq != le32_to_cpu(mmp->mmp_seq)) {
360365
dump_mmp_msg(sb, mmp,
361366
"Device is already active on another node.");
367+
retval = -EBUSY;
362368
goto failed;
363369
}
364370

@@ -378,12 +384,13 @@ int ext4_multi_mount_protect(struct super_block *sb,
378384
EXT4_SB(sb)->s_mmp_tsk = NULL;
379385
ext4_warning(sb, "Unable to create kmmpd thread for %s.",
380386
sb->s_id);
387+
retval = -ENOMEM;
381388
goto failed;
382389
}
383390

384391
return 0;
385392

386393
failed:
387394
brelse(bh);
388-
return 1;
395+
return retval;
389396
}

fs/ext4/super.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5328,9 +5328,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
53285328
ext4_has_feature_orphan_present(sb) ||
53295329
ext4_has_feature_journal_needs_recovery(sb));
53305330

5331-
if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb))
5332-
if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
5331+
if (ext4_has_feature_mmp(sb) && !sb_rdonly(sb)) {
5332+
err = ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block));
5333+
if (err)
53335334
goto failed_mount3a;
5335+
}
53345336

53355337
/*
53365338
* The first inode we look at is the journal inode. Don't try
@@ -6565,12 +6567,12 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
65656567
goto restore_opts;
65666568

65676569
sb->s_flags &= ~SB_RDONLY;
6568-
if (ext4_has_feature_mmp(sb))
6569-
if (ext4_multi_mount_protect(sb,
6570-
le64_to_cpu(es->s_mmp_block))) {
6571-
err = -EROFS;
6570+
if (ext4_has_feature_mmp(sb)) {
6571+
err = ext4_multi_mount_protect(sb,
6572+
le64_to_cpu(es->s_mmp_block));
6573+
if (err)
65726574
goto restore_opts;
6573-
}
6575+
}
65746576
#ifdef CONFIG_QUOTA
65756577
enable_quota = 1;
65766578
#endif

0 commit comments

Comments
 (0)