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..97ac037d6889 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -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..1037ed9e350f 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2138,6 +2138,8 @@ 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"); WARN_ON_ONCE(dquot_initialize_needed(inode)); goal = ext4_group_first_block_no(sb,