@@ -1150,8 +1150,9 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
11501150 pgoff_t index ;
11511151 unsigned from , to ;
11521152
1153- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
1154- return - EIO ;
1153+ ret = ext4_emergency_state (inode -> i_sb );
1154+ if (unlikely (ret ))
1155+ return ret ;
11551156
11561157 trace_ext4_write_begin (inode , pos , len );
11571158 /*
@@ -2274,7 +2275,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
22742275 if (err < 0 ) {
22752276 struct super_block * sb = inode -> i_sb ;
22762277
2277- if (ext4_forced_shutdown (sb ))
2278+ if (ext4_emergency_state (sb ))
22782279 goto invalidate_dirty_pages ;
22792280 /*
22802281 * Let the uper layers retry transient errors.
@@ -2600,10 +2601,9 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
26002601 * *never* be called, so if that ever happens, we would want
26012602 * the stack trace.
26022603 */
2603- if ( unlikely ( ext4_forced_shutdown ( mapping -> host -> i_sb ))) {
2604- ret = - EROFS ;
2604+ ret = ext4_emergency_state ( mapping -> host -> i_sb );
2605+ if ( unlikely ( ret ))
26052606 goto out_writepages ;
2606- }
26072607
26082608 /*
26092609 * If we have inline data and arrive here, it means that
@@ -2818,8 +2818,9 @@ static int ext4_writepages(struct address_space *mapping,
28182818 int ret ;
28192819 int alloc_ctx ;
28202820
2821- if (unlikely (ext4_forced_shutdown (sb )))
2822- return - EIO ;
2821+ ret = ext4_emergency_state (sb );
2822+ if (unlikely (ret ))
2823+ return ret ;
28232824
28242825 alloc_ctx = ext4_writepages_down_read (sb );
28252826 ret = ext4_do_writepages (& mpd );
@@ -2859,8 +2860,9 @@ static int ext4_dax_writepages(struct address_space *mapping,
28592860 struct inode * inode = mapping -> host ;
28602861 int alloc_ctx ;
28612862
2862- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
2863- return - EIO ;
2863+ ret = ext4_emergency_state (inode -> i_sb );
2864+ if (unlikely (ret ))
2865+ return ret ;
28642866
28652867 alloc_ctx = ext4_writepages_down_read (inode -> i_sb );
28662868 trace_ext4_writepages (inode , wbc );
@@ -2916,8 +2918,9 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
29162918 pgoff_t index ;
29172919 struct inode * inode = mapping -> host ;
29182920
2919- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
2920- return - EIO ;
2921+ ret = ext4_emergency_state (inode -> i_sb );
2922+ if (unlikely (ret ))
2923+ return ret ;
29212924
29222925 index = pos >> PAGE_SHIFT ;
29232926
@@ -5247,8 +5250,9 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
52475250 if (WARN_ON_ONCE (current -> flags & PF_MEMALLOC ))
52485251 return 0 ;
52495252
5250- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
5251- return - EIO ;
5253+ err = ext4_emergency_state (inode -> i_sb );
5254+ if (unlikely (err ))
5255+ return err ;
52525256
52535257 if (EXT4_SB (inode -> i_sb )-> s_journal ) {
52545258 if (ext4_journal_current_handle ()) {
@@ -5370,8 +5374,9 @@ int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
53705374 const unsigned int ia_valid = attr -> ia_valid ;
53715375 bool inc_ivers = true;
53725376
5373- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
5374- return - EIO ;
5377+ error = ext4_emergency_state (inode -> i_sb );
5378+ if (unlikely (error ))
5379+ return error ;
53755380
53765381 if (unlikely (IS_IMMUTABLE (inode )))
53775382 return - EPERM ;
@@ -5815,9 +5820,10 @@ int ext4_mark_iloc_dirty(handle_t *handle,
58155820{
58165821 int err = 0 ;
58175822
5818- if (unlikely (ext4_forced_shutdown (inode -> i_sb ))) {
5823+ err = ext4_emergency_state (inode -> i_sb );
5824+ if (unlikely (err )) {
58195825 put_bh (iloc -> bh );
5820- return - EIO ;
5826+ return err ;
58215827 }
58225828 ext4_fc_track_inode (handle , inode );
58235829
@@ -5841,8 +5847,9 @@ ext4_reserve_inode_write(handle_t *handle, struct inode *inode,
58415847{
58425848 int err ;
58435849
5844- if (unlikely (ext4_forced_shutdown (inode -> i_sb )))
5845- return - EIO ;
5850+ err = ext4_emergency_state (inode -> i_sb );
5851+ if (unlikely (err ))
5852+ return err ;
58465853
58475854 err = ext4_get_inode_loc (inode , iloc );
58485855 if (!err ) {
0 commit comments