The logs seem to be showing a different race this time. Could it be
that the VFS is creating two different struct super's for the same
block device?!? It looks like there are two separate loop3 mounts
from two different racing threads from the syzbot reproducer.
Adding yet more debugging messages...
#syz test git://
git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 787ab89c2c26..4d818a9249bc 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -950,6 +950,11 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
sb = dir->i_sb;
sbi = EXT4_SB(sb);
+ if (unlikely(sb_rdonly(sb))) {
+ ext4_warning(sb, "sb read-only");
+ // return ERR_PTR(-EROFS);
+ }
+
if (unlikely(ext4_forced_shutdown(sbi)))
return ERR_PTR(-EIO);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 39f00f05f981..883ce83968e9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -767,8 +767,8 @@ void __ext4_error(struct super_block *sb, const char *function,
vaf.fmt = fmt;
vaf.va = &args;
printk(KERN_CRIT
- "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n",
- sb->s_id, function, line, current->comm, &vaf);
+ "EXT4-fs error (device %s ptr %px): %s:%d: comm %s: %pV\n",
+ sb->s_id, sb, function, line, current->comm, &vaf);
va_end(args);
}
fsnotify_sb_error(sb, NULL, error ? error : EFSCORRUPTED);
@@ -792,14 +792,14 @@ void __ext4_error_inode(struct inode *inode, const char *function,
vaf.fmt = fmt;
vaf.va = &args;
if (block)
- printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
+ printk(KERN_CRIT "EXT4-fs error (device %s ptr %px): %s:%d: "
"inode #%lu: block %llu: comm %s: %pV\n",
- inode->i_sb->s_id, function, line, inode->i_ino,
+ inode->i_sb->s_id, inode->i_sb, function, line, inode->i_ino,
block, current->comm, &vaf);
else
- printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
+ printk(KERN_CRIT "EXT4-fs error (device %s ptr %px): %s:%d: "
"inode #%lu: comm %s: %pV\n",
- inode->i_sb->s_id, function, line, inode->i_ino,
+ inode->i_sb->s_id, inode->i_sb, function, line, inode->i_ino,
current->comm, &vaf);
va_end(args);
}
@@ -831,15 +831,15 @@ void __ext4_error_file(struct file *file, const char *function,
vaf.va = &args;
if (block)
printk(KERN_CRIT
- "EXT4-fs error (device %s): %s:%d: inode #%lu: "
+ "EXT4-fs error (device %s ptr %px): %s:%d: inode #%lu: "
"block %llu: comm %s: path %s: %pV\n",
- inode->i_sb->s_id, function, line, inode->i_ino,
+ inode->i_sb->s_id, inode->i_sb, function, line, inode->i_ino,
block, current->comm, path, &vaf);
else
printk(KERN_CRIT
- "EXT4-fs error (device %s): %s:%d: inode #%lu: "
+ "EXT4-fs error (device %s ptr %px): %s:%d: inode #%lu: "
"comm %s: path %s: %pV\n",
- inode->i_sb->s_id, function, line, inode->i_ino,
+ inode->i_sb->s_id, inode->i_sb, function, line, inode->i_ino,
current->comm, path, &vaf);
va_end(args);
}
@@ -909,8 +909,8 @@ void __ext4_std_error(struct super_block *sb, const char *function,
if (ext4_error_ratelimit(sb)) {
errstr = ext4_decode_error(sb, errno, nbuf);
- printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
- sb->s_id, function, line, errstr);
+ printk(KERN_CRIT "EXT4-fs error (device %s ptr %px) in %s:%d: %s\n",
+ sb->s_id, sb, function, line, errstr);
}
fsnotify_sb_error(sb, NULL, errno ? errno : EFSCORRUPTED);
@@ -959,8 +959,8 @@ void __ext4_warning(struct super_block *sb, const char *function,
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
- printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: %pV\n",
- sb->s_id, function, line, &vaf);
+ printk(KERN_WARNING "EXT4-fs warning (device %s ptr %px): %s:%d: %pV\n",
+ sb->s_id, sb, function, line, &vaf);
va_end(args);
}
@@ -1000,8 +1000,8 @@ __acquires(bitlock)
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
- printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u, ",
- sb->s_id, function, line, grp);
+ printk(KERN_CRIT "EXT4-fs error (device %s ptr %px): %s:%d: group %u, ",
+ sb->s_id, sb, function, line, grp);
if (ino)
printk(KERN_CONT "inode %lu: ", ino);
if (block)
index 767454d74cd6..fe47fc8e1b02 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2138,6 +2138,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
/* We need to allocate a new block */
ext4_fsblk_t goal, block;
+ if (dquot_initialize_needed(inode))
+ ext4_warning(sb, "dquot initialize needed %s",
+ sb_rdonly(sb) ? "ro" : "rw");
WARN_ON_ONCE(dquot_initialize_needed(inode));
goal = ext4_group_first_block_no(sb,