@@ -821,51 +821,58 @@ xfs_growfs_rt(
821
821
/* Needs to have been mounted with an rt device. */
822
822
if (!XFS_IS_REALTIME_MOUNT (mp ))
823
823
return - EINVAL ;
824
+
825
+ if (!mutex_trylock (& mp -> m_growlock ))
826
+ return - EWOULDBLOCK ;
824
827
/*
825
828
* Mount should fail if the rt bitmap/summary files don't load, but
826
829
* we'll check anyway.
827
830
*/
831
+ error = - EINVAL ;
828
832
if (!mp -> m_rbmip || !mp -> m_rsumip )
829
- return - EINVAL ;
833
+ goto out_unlock ;
830
834
831
835
/* Shrink not supported. */
832
836
if (in -> newblocks <= sbp -> sb_rblocks )
833
- return - EINVAL ;
837
+ goto out_unlock ;
834
838
835
839
/* Can only change rt extent size when adding rt volume. */
836
840
if (sbp -> sb_rblocks > 0 && in -> extsize != sbp -> sb_rextsize )
837
- return - EINVAL ;
841
+ goto out_unlock ;
838
842
839
843
/* Range check the extent size. */
840
844
if (XFS_FSB_TO_B (mp , in -> extsize ) > XFS_MAX_RTEXTSIZE ||
841
845
XFS_FSB_TO_B (mp , in -> extsize ) < XFS_MIN_RTEXTSIZE )
842
- return - EINVAL ;
846
+ goto out_unlock ;
843
847
844
848
/* Unsupported realtime features. */
849
+ error = - EOPNOTSUPP ;
845
850
if (xfs_has_rmapbt (mp ) || xfs_has_reflink (mp ) || xfs_has_quota (mp ))
846
- return - EOPNOTSUPP ;
851
+ goto out_unlock ;
847
852
848
853
nrblocks = in -> newblocks ;
849
854
error = xfs_sb_validate_fsb_count (sbp , nrblocks );
850
855
if (error )
851
- return error ;
856
+ goto out_unlock ;
852
857
/*
853
858
* Read in the last block of the device, make sure it exists.
854
859
*/
855
860
error = xfs_buf_read_uncached (mp -> m_rtdev_targp ,
856
861
XFS_FSB_TO_BB (mp , nrblocks - 1 ),
857
862
XFS_FSB_TO_BB (mp , 1 ), 0 , & bp , NULL );
858
863
if (error )
859
- return error ;
864
+ goto out_unlock ;
860
865
xfs_buf_relse (bp );
861
866
862
867
/*
863
868
* Calculate new parameters. These are the final values to be reached.
864
869
*/
865
870
nrextents = nrblocks ;
866
871
do_div (nrextents , in -> extsize );
867
- if (!xfs_validate_rtextents (nrextents ))
868
- return - EINVAL ;
872
+ if (!xfs_validate_rtextents (nrextents )) {
873
+ error = - EINVAL ;
874
+ goto out_unlock ;
875
+ }
869
876
nrbmblocks = xfs_rtbitmap_blockcount (mp , nrextents );
870
877
nrextslog = xfs_compute_rextslog (nrextents );
871
878
nrsumlevels = nrextslog + 1 ;
@@ -876,8 +883,11 @@ xfs_growfs_rt(
876
883
* the log. This prevents us from getting a log overflow,
877
884
* since we'll log basically the whole summary file at once.
878
885
*/
879
- if (nrsumblocks > (mp -> m_sb .sb_logblocks >> 1 ))
880
- return - EINVAL ;
886
+ if (nrsumblocks > (mp -> m_sb .sb_logblocks >> 1 )) {
887
+ error = - EINVAL ;
888
+ goto out_unlock ;
889
+ }
890
+
881
891
/*
882
892
* Get the old block counts for bitmap and summary inodes.
883
893
* These can't change since other growfs callers are locked out.
@@ -889,10 +899,10 @@ xfs_growfs_rt(
889
899
*/
890
900
error = xfs_growfs_rt_alloc (mp , rbmblocks , nrbmblocks , mp -> m_rbmip );
891
901
if (error )
892
- return error ;
902
+ goto out_unlock ;
893
903
error = xfs_growfs_rt_alloc (mp , rsumblocks , nrsumblocks , mp -> m_rsumip );
894
904
if (error )
895
- return error ;
905
+ goto out_unlock ;
896
906
897
907
rsum_cache = mp -> m_rsum_cache ;
898
908
if (nrbmblocks != sbp -> sb_rbmblocks )
@@ -1059,6 +1069,8 @@ xfs_growfs_rt(
1059
1069
}
1060
1070
}
1061
1071
1072
+ out_unlock :
1073
+ mutex_unlock (& mp -> m_growlock );
1062
1074
return error ;
1063
1075
}
1064
1076
0 commit comments