Merge tag 'gfs2-v5.12-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull gfs2 fixes from Andreas Gruenbacher:
"Various gfs2 fixes"

* tag 'gfs2-v5.12-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
gfs2: bypass log flush if the journal is not live
gfs2: bypass signal_our_withdraw if no journal
gfs2: fix use-after-free in trans_drain
gfs2: make function gfs2_make_fs_ro() to void type

+22 -19
+5 -1
fs/gfs2/log.c
··· 998 while (!list_empty(head)) { 999 bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1000 list_del_init(&bd->bd_list); 1001 kmem_cache_free(gfs2_bufdata_cachep, bd); 1002 } 1003 head = &tr->tr_databuf; 1004 while (!list_empty(head)) { 1005 bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1006 list_del_init(&bd->bd_list); 1007 kmem_cache_free(gfs2_bufdata_cachep, bd); 1008 } 1009 } ··· 1036 * Do this check while holding the log_flush_lock to prevent new 1037 * buffers from being added to the ail via gfs2_pin() 1038 */ 1039 - if (gfs2_withdrawn(sdp)) 1040 goto out; 1041 1042 /* Log might have been flushed while we waited for the flush lock */
··· 998 while (!list_empty(head)) { 999 bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1000 list_del_init(&bd->bd_list); 1001 + if (!list_empty(&bd->bd_ail_st_list)) 1002 + gfs2_remove_from_ail(bd); 1003 kmem_cache_free(gfs2_bufdata_cachep, bd); 1004 } 1005 head = &tr->tr_databuf; 1006 while (!list_empty(head)) { 1007 bd = list_first_entry(head, struct gfs2_bufdata, bd_list); 1008 list_del_init(&bd->bd_list); 1009 + if (!list_empty(&bd->bd_ail_st_list)) 1010 + gfs2_remove_from_ail(bd); 1011 kmem_cache_free(gfs2_bufdata_cachep, bd); 1012 } 1013 } ··· 1032 * Do this check while holding the log_flush_lock to prevent new 1033 * buffers from being added to the ail via gfs2_pin() 1034 */ 1035 + if (gfs2_withdrawn(sdp) || !test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) 1036 goto out; 1037 1038 /* Log might have been flushed while we waited for the flush lock */
+1 -3
fs/gfs2/ops_fstype.c
··· 1539 return -EINVAL; 1540 1541 if (fc->sb_flags & SB_RDONLY) { 1542 - error = gfs2_make_fs_ro(sdp); 1543 - if (error) 1544 - errorfc(fc, "unable to remount read-only"); 1545 } else { 1546 error = gfs2_make_fs_rw(sdp); 1547 if (error)
··· 1539 return -EINVAL; 1540 1541 if (fc->sb_flags & SB_RDONLY) { 1542 + gfs2_make_fs_ro(sdp); 1543 } else { 1544 error = gfs2_make_fs_rw(sdp); 1545 if (error)
+2 -8
fs/gfs2/super.c
··· 587 * Returns: errno 588 */ 589 590 - int gfs2_make_fs_ro(struct gfs2_sbd *sdp) 591 { 592 - int error = 0; 593 int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 594 595 gfs2_flush_delete_work(sdp); ··· 623 624 if (!log_write_allowed) 625 sdp->sd_vfs->s_flags |= SB_RDONLY; 626 - 627 - return error; 628 } 629 630 /** ··· 634 static void gfs2_put_super(struct super_block *sb) 635 { 636 struct gfs2_sbd *sdp = sb->s_fs_info; 637 - int error; 638 struct gfs2_jdesc *jd; 639 640 /* No more recovery requests */ ··· 654 spin_unlock(&sdp->sd_jindex_spin); 655 656 if (!sb_rdonly(sb)) { 657 - error = gfs2_make_fs_ro(sdp); 658 - if (error) 659 - gfs2_io_error(sdp); 660 } 661 WARN_ON(gfs2_withdrawing(sdp)); 662
··· 587 * Returns: errno 588 */ 589 590 + void gfs2_make_fs_ro(struct gfs2_sbd *sdp) 591 { 592 int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 593 594 gfs2_flush_delete_work(sdp); ··· 624 625 if (!log_write_allowed) 626 sdp->sd_vfs->s_flags |= SB_RDONLY; 627 } 628 629 /** ··· 637 static void gfs2_put_super(struct super_block *sb) 638 { 639 struct gfs2_sbd *sdp = sb->s_fs_info; 640 struct gfs2_jdesc *jd; 641 642 /* No more recovery requests */ ··· 658 spin_unlock(&sdp->sd_jindex_spin); 659 660 if (!sb_rdonly(sb)) { 661 + gfs2_make_fs_ro(sdp); 662 } 663 WARN_ON(gfs2_withdrawing(sdp)); 664
+1 -1
fs/gfs2/super.h
··· 34 struct gfs2_inode **ipp); 35 36 extern int gfs2_make_fs_rw(struct gfs2_sbd *sdp); 37 - extern int gfs2_make_fs_ro(struct gfs2_sbd *sdp); 38 extern void gfs2_online_uevent(struct gfs2_sbd *sdp); 39 extern int gfs2_statfs_init(struct gfs2_sbd *sdp); 40 extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
··· 34 struct gfs2_inode **ipp); 35 36 extern int gfs2_make_fs_rw(struct gfs2_sbd *sdp); 37 + extern void gfs2_make_fs_ro(struct gfs2_sbd *sdp); 38 extern void gfs2_online_uevent(struct gfs2_sbd *sdp); 39 extern int gfs2_statfs_init(struct gfs2_sbd *sdp); 40 extern void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
+2
fs/gfs2/trans.c
··· 169 bd->bd_bh = bh; 170 bd->bd_gl = gl; 171 INIT_LIST_HEAD(&bd->bd_list); 172 bh->b_private = bd; 173 return bd; 174 }
··· 169 bd->bd_bh = bh; 170 bd->bd_gl = gl; 171 INIT_LIST_HEAD(&bd->bd_list); 172 + INIT_LIST_HEAD(&bd->bd_ail_st_list); 173 + INIT_LIST_HEAD(&bd->bd_ail_gl_list); 174 bh->b_private = bd; 175 return bd; 176 }
+11 -6
fs/gfs2/util.c
··· 119 static void signal_our_withdraw(struct gfs2_sbd *sdp) 120 { 121 struct gfs2_glock *live_gl = sdp->sd_live_gh.gh_gl; 122 - struct inode *inode = sdp->sd_jdesc->jd_inode; 123 - struct gfs2_inode *ip = GFS2_I(inode); 124 - struct gfs2_glock *i_gl = ip->i_gl; 125 - u64 no_formal_ino = ip->i_no_formal_ino; 126 int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 127 int ret = 0; 128 int tries; 129 130 - if (test_bit(SDF_NORECOVERY, &sdp->sd_flags)) 131 return; 132 133 /* Prevent any glock dq until withdraw recovery is complete */ 134 set_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags); ··· 161 ret = 0; 162 } 163 if (!ret) 164 - ret = gfs2_make_fs_ro(sdp); 165 gfs2_freeze_unlock(&freeze_gh); 166 } 167
··· 119 static void signal_our_withdraw(struct gfs2_sbd *sdp) 120 { 121 struct gfs2_glock *live_gl = sdp->sd_live_gh.gh_gl; 122 + struct inode *inode; 123 + struct gfs2_inode *ip; 124 + struct gfs2_glock *i_gl; 125 + u64 no_formal_ino; 126 int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); 127 int ret = 0; 128 int tries; 129 130 + if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc) 131 return; 132 + 133 + inode = sdp->sd_jdesc->jd_inode; 134 + ip = GFS2_I(inode); 135 + i_gl = ip->i_gl; 136 + no_formal_ino = ip->i_no_formal_ino; 137 138 /* Prevent any glock dq until withdraw recovery is complete */ 139 set_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags); ··· 156 ret = 0; 157 } 158 if (!ret) 159 + gfs2_make_fs_ro(sdp); 160 gfs2_freeze_unlock(&freeze_gh); 161 } 162