Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230616165109.21695-3-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Jan Kara and committed by
Theodore Ts'o
eb8ab444 d5d020b3

+38 -39
+2 -2
fs/ext4/ext4.h
··· 2222 2222 #define EXT4_FLAGS_SHUTDOWN 1 2223 2223 #define EXT4_FLAGS_BDEV_IS_DAX 2 2224 2224 2225 - static inline int ext4_forced_shutdown(struct ext4_sb_info *sbi) 2225 + static inline int ext4_forced_shutdown(struct super_block *sb) 2226 2226 { 2227 - return test_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); 2227 + return test_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags); 2228 2228 } 2229 2229 2230 2230 /*
+1 -1
fs/ext4/ext4_jbd2.c
··· 67 67 68 68 might_sleep(); 69 69 70 - if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) 70 + if (unlikely(ext4_forced_shutdown(sb))) 71 71 return -EIO; 72 72 73 73 if (sb_rdonly(sb))
+6 -7
fs/ext4/file.c
··· 131 131 { 132 132 struct inode *inode = file_inode(iocb->ki_filp); 133 133 134 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 134 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 135 135 return -EIO; 136 136 137 137 if (!iov_iter_count(to)) ··· 153 153 { 154 154 struct inode *inode = file_inode(in); 155 155 156 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 156 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 157 157 return -EIO; 158 158 return filemap_splice_read(in, ppos, pipe, len, flags); 159 159 } ··· 709 709 { 710 710 struct inode *inode = file_inode(iocb->ki_filp); 711 711 712 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 712 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 713 713 return -EIO; 714 714 715 715 #ifdef CONFIG_FS_DAX ··· 807 807 static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) 808 808 { 809 809 struct inode *inode = file->f_mapping->host; 810 - struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 811 - struct dax_device *dax_dev = sbi->s_daxdev; 810 + struct dax_device *dax_dev = EXT4_SB(inode->i_sb)->s_daxdev; 812 811 813 - if (unlikely(ext4_forced_shutdown(sbi))) 812 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 814 813 return -EIO; 815 814 816 815 /* ··· 885 886 { 886 887 int ret; 887 888 888 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 889 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 889 890 return -EIO; 890 891 891 892 ret = ext4_sample_last_mounted(inode->i_sb, filp->f_path.mnt);
+1 -1
fs/ext4/fsync.c
··· 133 133 struct inode *inode = file->f_mapping->host; 134 134 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 135 135 136 - if (unlikely(ext4_forced_shutdown(sbi))) 136 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 137 137 return -EIO; 138 138 139 139 ASSERT(ext4_journal_current_handle() == NULL);
+1 -1
fs/ext4/ialloc.c
··· 950 950 sb = dir->i_sb; 951 951 sbi = EXT4_SB(sb); 952 952 953 - if (unlikely(ext4_forced_shutdown(sbi))) 953 + if (unlikely(ext4_forced_shutdown(sb))) 954 954 return ERR_PTR(-EIO); 955 955 956 956 ngroups = ext4_get_groups_count(sb);
+1 -1
fs/ext4/inline.c
··· 228 228 struct ext4_inode *raw_inode; 229 229 int cp_len = 0; 230 230 231 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 231 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 232 232 return; 233 233 234 234 BUG_ON(!EXT4_I(inode)->i_inline_off);
+12 -12
fs/ext4/inode.c
··· 1114 1114 pgoff_t index; 1115 1115 unsigned from, to; 1116 1116 1117 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 1117 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 1118 1118 return -EIO; 1119 1119 1120 1120 trace_ext4_write_begin(inode, pos, len); ··· 2213 2213 if (err < 0) { 2214 2214 struct super_block *sb = inode->i_sb; 2215 2215 2216 - if (ext4_forced_shutdown(EXT4_SB(sb)) || 2216 + if (ext4_forced_shutdown(sb) || 2217 2217 ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) 2218 2218 goto invalidate_dirty_pages; 2219 2219 /* ··· 2540 2540 * *never* be called, so if that ever happens, we would want 2541 2541 * the stack trace. 2542 2542 */ 2543 - if (unlikely(ext4_forced_shutdown(EXT4_SB(mapping->host->i_sb)) || 2543 + if (unlikely(ext4_forced_shutdown(mapping->host->i_sb) || 2544 2544 ext4_test_mount_flag(inode->i_sb, EXT4_MF_FS_ABORTED))) { 2545 2545 ret = -EROFS; 2546 2546 goto out_writepages; ··· 2759 2759 int ret; 2760 2760 int alloc_ctx; 2761 2761 2762 - if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) 2762 + if (unlikely(ext4_forced_shutdown(sb))) 2763 2763 return -EIO; 2764 2764 2765 2765 alloc_ctx = ext4_writepages_down_read(sb); ··· 2798 2798 int ret; 2799 2799 long nr_to_write = wbc->nr_to_write; 2800 2800 struct inode *inode = mapping->host; 2801 - struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); 2802 2801 int alloc_ctx; 2803 2802 2804 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 2803 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 2805 2804 return -EIO; 2806 2805 2807 2806 alloc_ctx = ext4_writepages_down_read(inode->i_sb); 2808 2807 trace_ext4_writepages(inode, wbc); 2809 2808 2810 - ret = dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc); 2809 + ret = dax_writeback_mapping_range(mapping, 2810 + EXT4_SB(inode->i_sb)->s_daxdev, wbc); 2811 2811 trace_ext4_writepages_result(inode, wbc, ret, 2812 2812 nr_to_write - wbc->nr_to_write); 2813 2813 ext4_writepages_up_read(inode->i_sb, alloc_ctx); ··· 2857 2857 pgoff_t index; 2858 2858 struct inode *inode = mapping->host; 2859 2859 2860 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 2860 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 2861 2861 return -EIO; 2862 2862 2863 2863 index = pos >> PAGE_SHIFT; ··· 5135 5135 sb_rdonly(inode->i_sb)) 5136 5136 return 0; 5137 5137 5138 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 5138 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 5139 5139 return -EIO; 5140 5140 5141 5141 if (EXT4_SB(inode->i_sb)->s_journal) { ··· 5255 5255 const unsigned int ia_valid = attr->ia_valid; 5256 5256 bool inc_ivers = true; 5257 5257 5258 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 5258 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 5259 5259 return -EIO; 5260 5260 5261 5261 if (unlikely(IS_IMMUTABLE(inode))) ··· 5676 5676 { 5677 5677 int err = 0; 5678 5678 5679 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) { 5679 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) { 5680 5680 put_bh(iloc->bh); 5681 5681 return -EIO; 5682 5682 } ··· 5702 5702 { 5703 5703 int err; 5704 5704 5705 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 5705 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 5706 5706 return -EIO; 5707 5707 5708 5708 err = ext4_get_inode_loc(inode, iloc);
+1 -1
fs/ext4/ioctl.c
··· 801 801 if (flags > EXT4_GOING_FLAGS_NOLOGFLUSH) 802 802 return -EINVAL; 803 803 804 - if (ext4_forced_shutdown(sbi)) 804 + if (ext4_forced_shutdown(sb)) 805 805 return 0; 806 806 807 807 ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags);
+4 -4
fs/ext4/namei.c
··· 3142 3142 struct ext4_dir_entry_2 *de; 3143 3143 handle_t *handle = NULL; 3144 3144 3145 - if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) 3145 + if (unlikely(ext4_forced_shutdown(dir->i_sb))) 3146 3146 return -EIO; 3147 3147 3148 3148 /* Initialize quotas before so that eventual writes go in ··· 3301 3301 { 3302 3302 int retval; 3303 3303 3304 - if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) 3304 + if (unlikely(ext4_forced_shutdown(dir->i_sb))) 3305 3305 return -EIO; 3306 3306 3307 3307 trace_ext4_unlink_enter(dir, dentry); ··· 3369 3369 struct fscrypt_str disk_link; 3370 3370 int retries = 0; 3371 3371 3372 - if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) 3372 + if (unlikely(ext4_forced_shutdown(dir->i_sb))) 3373 3373 return -EIO; 3374 3374 3375 3375 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, ··· 4189 4189 { 4190 4190 int err; 4191 4191 4192 - if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb)))) 4192 + if (unlikely(ext4_forced_shutdown(old_dir->i_sb))) 4193 4193 return -EIO; 4194 4194 4195 4195 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
+1 -1
fs/ext4/page-io.c
··· 184 184 185 185 io_end->handle = NULL; /* Following call will use up the handle */ 186 186 ret = ext4_convert_unwritten_io_end_vec(handle, io_end); 187 - if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode->i_sb))) { 187 + if (ret < 0 && !ext4_forced_shutdown(inode->i_sb)) { 188 188 ext4_msg(inode->i_sb, KERN_EMERG, 189 189 "failed to convert unwritten extents to written " 190 190 "extents -- potential data loss! "
+7 -7
fs/ext4/super.c
··· 758 758 struct va_format vaf; 759 759 va_list args; 760 760 761 - if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) 761 + if (unlikely(ext4_forced_shutdown(sb))) 762 762 return; 763 763 764 764 trace_ext4_error(sb, function, line); ··· 783 783 va_list args; 784 784 struct va_format vaf; 785 785 786 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 786 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 787 787 return; 788 788 789 789 trace_ext4_error(inode->i_sb, function, line); ··· 818 818 struct inode *inode = file_inode(file); 819 819 char pathname[80], *path; 820 820 821 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 821 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 822 822 return; 823 823 824 824 trace_ext4_error(inode->i_sb, function, line); ··· 898 898 char nbuf[16]; 899 899 const char *errstr; 900 900 901 - if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) 901 + if (unlikely(ext4_forced_shutdown(sb))) 902 902 return; 903 903 904 904 /* Special case: if the error is EROFS, and we're not already ··· 992 992 struct va_format vaf; 993 993 va_list args; 994 994 995 - if (unlikely(ext4_forced_shutdown(EXT4_SB(sb)))) 995 + if (unlikely(ext4_forced_shutdown(sb))) 996 996 return; 997 997 998 998 trace_ext4_error(sb, function, line); ··· 6298 6298 bool needs_barrier = false; 6299 6299 struct ext4_sb_info *sbi = EXT4_SB(sb); 6300 6300 6301 - if (unlikely(ext4_forced_shutdown(sbi))) 6301 + if (unlikely(ext4_forced_shutdown(sb))) 6302 6302 return 0; 6303 6303 6304 6304 trace_ext4_sync_fs(sb, wait); ··· 6381 6381 */ 6382 6382 static int ext4_unfreeze(struct super_block *sb) 6383 6383 { 6384 - if (ext4_forced_shutdown(EXT4_SB(sb))) 6384 + if (ext4_forced_shutdown(sb)) 6385 6385 return 0; 6386 6386 6387 6387 if (EXT4_SB(sb)->s_journal) {
+1 -1
fs/ext4/xattr.c
··· 701 701 { 702 702 int error; 703 703 704 - if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) 704 + if (unlikely(ext4_forced_shutdown(inode->i_sb))) 705 705 return -EIO; 706 706 707 707 if (strlen(name) > 255)