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) @@ -6487,12 +6487,14 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) } if (fc->sb_flags & SB_RDONLY) { + ext4_warning(sb, "Remounting file system r/o"); err = sync_filesystem(sb); if (err < 0) goto restore_opts; err = dquot_suspend(sb, -1); if (err < 0) goto restore_opts; + ext4_warning(sb, "Quota suspended"); /* * First of all, the unconditional stuff we have to do @@ -6620,12 +6622,20 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) for (i = 0; i < EXT4_MAXQUOTAS; i++) kfree(old_opts.s_qf_names[i]); if (enable_quota) { - if (sb_any_quota_suspended(sb)) + ext4_warning(sb, "trying to enable quota"); + if (sb_any_quota_suspended(sb)) { dquot_resume(sb, -1); + ext4_warning(sb, "resumed quota"); + } else if (ext4_has_feature_quota(sb)) { err = ext4_enable_quotas(sb); - if (err) + if (err) { + ext4_warning(sb, "failed to enable quota: %d", + err); goto restore_opts; + } + ext4_warning(sb, "enabled quota"); + } } #endif @@ -6638,6 +6648,17 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) return 0; restore_opts: + ext4_warning(sb, "remount failed! was %s attempted %s", + (old_sb_flags & SB_RDONLY) ? "ro" : "rw", + (sb->s_flags & SB_RDONLY) ? "ro" : "rw"); + if ((sb->s_flags & SB_RDONLY) && + !(old_sb_flags & SB_RDONLY)) { + ext4_warning(sb, "failing rw->ro transition"); + if (sb_any_quota_suspended(sb)) { + ext4_warning(sb, "would resume quotas"); +// dquot_resume(sb, -1); + } + } sb->s_flags = old_sb_flags; sbi->s_mount_opt = old_opts.s_mount_opt; sbi->s_mount_opt2 = old_opts.s_mount_opt2; @@ -6678,8 +6699,8 @@ static int ext4_reconfigure(struct fs_context *fc) if (ret < 0) return ret; - ext4_msg(sb, KERN_INFO, "re-mounted %pU. Quota mode: %s.", - &sb->s_uuid, ext4_quota_mode(sb)); + ext4_msg(sb, KERN_INFO, "re-mounted %pU %s. Quota mode: %s.", + &sb->s_uuid, sb_rdonly(sb) ? "ro" : "rw", ext4_quota_mode(sb)); return 0; } diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c 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,