Commit eb8ab444 authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

ext4: make ext4_forced_shutdown() take struct super_block

Currently ext4_forced_shutdown() takes struct ext4_sb_info but most
callers need to get it from struct super_block anyway. So just pass in
struct super_block to save all callers from some boilerplate code. No
functional changes.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230616165109.21695-3-jack@suse.czSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent d5d020b3
...@@ -2222,9 +2222,9 @@ extern int ext4_feature_set_ok(struct super_block *sb, int readonly); ...@@ -2222,9 +2222,9 @@ extern int ext4_feature_set_ok(struct super_block *sb, int readonly);
#define EXT4_FLAGS_SHUTDOWN 1 #define EXT4_FLAGS_SHUTDOWN 1
#define EXT4_FLAGS_BDEV_IS_DAX 2 #define EXT4_FLAGS_BDEV_IS_DAX 2
static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi) static inline int ext4_forced_shutdown(struct super_block *sb)
{ {
return test_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); return test_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
} }
/* /*
......
...@@ -67,7 +67,7 @@ static int ext4_journal_check_start(struct super_block *sb) ...@@ -67,7 +67,7 @@ static int ext4_journal_check_start(struct super_block *sb)
might_sleep(); might_sleep();
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) if (unlikely(ext4_forced_shutdown(sb)))
return -EIO; return -EIO;
if (sb_rdonly(sb)) if (sb_rdonly(sb))
......
...@@ -131,7 +131,7 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) ...@@ -131,7 +131,7 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
{ {
struct inode *inode = file_inode(iocb->ki_filp); struct inode *inode = file_inode(iocb->ki_filp);
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
if (!iov_iter_count(to)) if (!iov_iter_count(to))
...@@ -153,7 +153,7 @@ static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos, ...@@ -153,7 +153,7 @@ static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos,
{ {
struct inode *inode = file_inode(in); struct inode *inode = file_inode(in);
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
return filemap_splice_read(in, ppos, pipe, len, flags); return filemap_splice_read(in, ppos, pipe, len, flags);
} }
...@@ -709,7 +709,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -709,7 +709,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{ {
struct inode *inode = file_inode(iocb->ki_filp); struct inode *inode = file_inode(iocb->ki_filp);
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
#ifdef CONFIG_FS_DAX #ifdef CONFIG_FS_DAX
...@@ -807,10 +807,9 @@ static const struct vm_operations_struct ext4_file_vm_ops = { ...@@ -807,10 +807,9 @@ static const struct vm_operations_struct ext4_file_vm_ops = {
static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct dax_device *dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
struct dax_device *dax_dev = sbi->s_daxdev;
if (unlikely(ext4_forced_shutdown(sbi))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
/* /*
...@@ -886,7 +885,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp) ...@@ -886,7 +885,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
{ {
int ret; int ret;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
ret = ext4_sample_last_mounted(inode->i_sb, filp->f_path.mnt); ret = ext4_sample_last_mounted(inode->i_sb, filp->f_path.mnt);
......
...@@ -133,7 +133,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -133,7 +133,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
if (unlikely(ext4_forced_shutdown(sbi))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
ASSERT(ext4_journal_current_handle() == NULL); ASSERT(ext4_journal_current_handle() == NULL);
......
...@@ -950,7 +950,7 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap, ...@@ -950,7 +950,7 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
sb = dir->i_sb; sb = dir->i_sb;
sbi = EXT4_SB(sb); sbi = EXT4_SB(sb);
if (unlikely(ext4_forced_shutdown(sbi))) if (unlikely(ext4_forced_shutdown(sb)))
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
ngroups = ext4_get_groups_count(sb); ngroups = ext4_get_groups_count(sb);
......
...@@ -228,7 +228,7 @@ static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc, ...@@ -228,7 +228,7 @@ static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc,
struct ext4_inode *raw_inode; struct ext4_inode *raw_inode;
int cp_len = 0; int cp_len = 0;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return; return;
BUG_ON(!EXT4_I(inode)->i_inline_off); BUG_ON(!EXT4_I(inode)->i_inline_off);
......
...@@ -1114,7 +1114,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping, ...@@ -1114,7 +1114,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
pgoff_t index; pgoff_t index;
unsigned from, to; unsigned from, to;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
trace_ext4_write_begin(inode, pos, len); trace_ext4_write_begin(inode, pos, len);
...@@ -2213,7 +2213,7 @@ static int mpage_map_and_submit_extent(handle_t *handle, ...@@ -2213,7 +2213,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
if (err < 0) { if (err < 0) {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
if (ext4_forced_shutdown(EXT4_SB(sb)) || if (ext4_forced_shutdown(sb) ||
ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED))
goto invalidate_dirty_pages; goto invalidate_dirty_pages;
/* /*
...@@ -2540,7 +2540,7 @@ static int ext4_do_writepages(struct mpage_da_data *mpd) ...@@ -2540,7 +2540,7 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
* *never* be called, so if that ever happens, we would want * *never* be called, so if that ever happens, we would want
* the stack trace. * the stack trace.
*/ */
if (unlikely(ext4_forced_shutdown(EXT4_SB(mapping->host->i_sb)) || if (unlikely(ext4_forced_shutdown(mapping->host->i_sb) ||
ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))) { ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))) {
ret = -EROFS; ret = -EROFS;
goto out_writepages; goto out_writepages;
...@@ -2759,7 +2759,7 @@ static int ext4_writepages(struct address_space *mapping, ...@@ -2759,7 +2759,7 @@ static int ext4_writepages(struct address_space *mapping,
int ret; int ret;
int alloc_ctx; int alloc_ctx;
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) if (unlikely(ext4_forced_shutdown(sb)))
return -EIO; return -EIO;
alloc_ctx = ext4_writepages_down_read(sb); alloc_ctx = ext4_writepages_down_read(sb);
...@@ -2798,16 +2798,16 @@ static int ext4_dax_writepages(struct address_space *mapping, ...@@ -2798,16 +2798,16 @@ static int ext4_dax_writepages(struct address_space *mapping,
int ret; int ret;
long nr_to_write = wbc->nr_to_write; long nr_to_write = wbc->nr_to_write;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
int alloc_ctx; int alloc_ctx;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
alloc_ctx = ext4_writepages_down_read(inode->i_sb); alloc_ctx = ext4_writepages_down_read(inode->i_sb);
trace_ext4_writepages(inode, wbc); trace_ext4_writepages(inode, wbc);
ret = dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc); ret = dax_writeback_mapping_range(mapping,
EXT4_SB(inode->i_sb)->s_daxdev, wbc);
trace_ext4_writepages_result(inode, wbc, ret, trace_ext4_writepages_result(inode, wbc, ret,
nr_to_write - wbc->nr_to_write); nr_to_write - wbc->nr_to_write);
ext4_writepages_up_read(inode->i_sb, alloc_ctx); ext4_writepages_up_read(inode->i_sb, alloc_ctx);
...@@ -2857,7 +2857,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, ...@@ -2857,7 +2857,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
pgoff_t index; pgoff_t index;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
index = pos >> PAGE_SHIFT; index = pos >> PAGE_SHIFT;
...@@ -5135,7 +5135,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -5135,7 +5135,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
sb_rdonly(inode->i_sb)) sb_rdonly(inode->i_sb))
return 0; return 0;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
if (EXT4_SB(inode->i_sb)->s_journal) { if (EXT4_SB(inode->i_sb)->s_journal) {
...@@ -5255,7 +5255,7 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ...@@ -5255,7 +5255,7 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
const unsigned int ia_valid = attr->ia_valid; const unsigned int ia_valid = attr->ia_valid;
bool inc_ivers = true; bool inc_ivers = true;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
if (unlikely(IS_IMMUTABLE(inode))) if (unlikely(IS_IMMUTABLE(inode)))
...@@ -5676,7 +5676,7 @@ int ext4_mark_iloc_dirty(handle_t *handle, ...@@ -5676,7 +5676,7 @@ int ext4_mark_iloc_dirty(handle_t *handle,
{ {
int err = 0; int err = 0;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) { if (unlikely(ext4_forced_shutdown(inode->i_sb))) {
put_bh(iloc->bh); put_bh(iloc->bh);
return -EIO; return -EIO;
} }
...@@ -5702,7 +5702,7 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode, ...@@ -5702,7 +5702,7 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
{ {
int err; int err;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
err = ext4_get_inode_loc(inode, iloc); err = ext4_get_inode_loc(inode, iloc);
......
...@@ -801,7 +801,7 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) ...@@ -801,7 +801,7 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
if (flags > EXT4_GOING_FLAGS_NOLOGFLUSH) if (flags > EXT4_GOING_FLAGS_NOLOGFLUSH)
return -EINVAL; return -EINVAL;
if (ext4_forced_shutdown(sbi)) if (ext4_forced_shutdown(sb))
return 0; return 0;
ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags); ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags);
......
...@@ -3142,7 +3142,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -3142,7 +3142,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
struct ext4_dir_entry_2 *de; struct ext4_dir_entry_2 *de;
handle_t *handle = NULL; handle_t *handle = NULL;
if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) if (unlikely(ext4_forced_shutdown(dir->i_sb)))
return -EIO; return -EIO;
/* Initialize quotas before so that eventual writes go in /* Initialize quotas before so that eventual writes go in
...@@ -3301,7 +3301,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) ...@@ -3301,7 +3301,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
{ {
int retval; int retval;
if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) if (unlikely(ext4_forced_shutdown(dir->i_sb)))
return -EIO; return -EIO;
trace_ext4_unlink_enter(dir, dentry); trace_ext4_unlink_enter(dir, dentry);
...@@ -3369,7 +3369,7 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, ...@@ -3369,7 +3369,7 @@ static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir,
struct fscrypt_str disk_link; struct fscrypt_str disk_link;
int retries = 0; int retries = 0;
if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) if (unlikely(ext4_forced_shutdown(dir->i_sb)))
return -EIO; return -EIO;
err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize,
...@@ -4189,7 +4189,7 @@ static int ext4_rename2(struct mnt_idmap *idmap, ...@@ -4189,7 +4189,7 @@ static int ext4_rename2(struct mnt_idmap *idmap,
{ {
int err; int err;
if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb)))) if (unlikely(ext4_forced_shutdown(old_dir->i_sb)))
return -EIO; return -EIO;
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
......
...@@ -184,7 +184,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end) ...@@ -184,7 +184,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
io_end->handle = NULL; /* Following call will use up the handle */ io_end->handle = NULL; /* Following call will use up the handle */
ret = ext4_convert_unwritten_io_end_vec(handle, io_end); ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode->i_sb))) { if (ret < 0 && !ext4_forced_shutdown(inode->i_sb)) {
ext4_msg(inode->i_sb, KERN_EMERG, ext4_msg(inode->i_sb, KERN_EMERG,
"failed to convert unwritten extents to written " "failed to convert unwritten extents to written "
"extents -- potential data loss! " "extents -- potential data loss! "
......
...@@ -758,7 +758,7 @@ void __ext4_error(struct super_block *sb, const char *function, ...@@ -758,7 +758,7 @@ void __ext4_error(struct super_block *sb, const char *function,
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) if (unlikely(ext4_forced_shutdown(sb)))
return; return;
trace_ext4_error(sb, function, line); trace_ext4_error(sb, function, line);
...@@ -783,7 +783,7 @@ void __ext4_error_inode(struct inode *inode, const char *function, ...@@ -783,7 +783,7 @@ void __ext4_error_inode(struct inode *inode, const char *function,
va_list args; va_list args;
struct va_format vaf; struct va_format vaf;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return; return;
trace_ext4_error(inode->i_sb, function, line); trace_ext4_error(inode->i_sb, function, line);
...@@ -818,7 +818,7 @@ void __ext4_error_file(struct file *file, const char *function, ...@@ -818,7 +818,7 @@ void __ext4_error_file(struct file *file, const char *function,
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
char pathname[80], *path; char pathname[80], *path;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return; return;
trace_ext4_error(inode->i_sb, function, line); trace_ext4_error(inode->i_sb, function, line);
...@@ -898,7 +898,7 @@ void __ext4_std_error(struct super_block *sb, const char *function, ...@@ -898,7 +898,7 @@ void __ext4_std_error(struct super_block *sb, const char *function,
char nbuf[16]; char nbuf[16];
const char *errstr; const char *errstr;
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) if (unlikely(ext4_forced_shutdown(sb)))
return; return;
/* Special case: if the error is EROFS, and we're not already /* Special case: if the error is EROFS, and we're not already
...@@ -992,7 +992,7 @@ __acquires(bitlock) ...@@ -992,7 +992,7 @@ __acquires(bitlock)
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) if (unlikely(ext4_forced_shutdown(sb)))
return; return;
trace_ext4_error(sb, function, line); trace_ext4_error(sb, function, line);
...@@ -6298,7 +6298,7 @@ static int ext4_sync_fs(struct super_block *sb, int wait) ...@@ -6298,7 +6298,7 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
bool needs_barrier = false; bool needs_barrier = false;
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
if (unlikely(ext4_forced_shutdown(sbi))) if (unlikely(ext4_forced_shutdown(sb)))
return 0; return 0;
trace_ext4_sync_fs(sb, wait); trace_ext4_sync_fs(sb, wait);
...@@ -6381,7 +6381,7 @@ static int ext4_freeze(struct super_block *sb) ...@@ -6381,7 +6381,7 @@ static int ext4_freeze(struct super_block *sb)
*/ */
static int ext4_unfreeze(struct super_block *sb) static int ext4_unfreeze(struct super_block *sb)
{ {
if (ext4_forced_shutdown(EXT4_SB(sb))) if (ext4_forced_shutdown(sb))
return 0; return 0;
if (EXT4_SB(sb)->s_journal) { if (EXT4_SB(sb)->s_journal) {
......
...@@ -701,7 +701,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name, ...@@ -701,7 +701,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name,
{ {
int error; int error;
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) if (unlikely(ext4_forced_shutdown(inode->i_sb)))
return -EIO; return -EIO;
if (strlen(name) > 255) if (strlen(name) > 255)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment