Lines Matching +full:long +full:- +full:summary

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
24 * Read and return the summary information for a given extent size,
26 * Keeps track of a current summary block, so we don't keep reading
35 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtget_summary()
36 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtget_summary()
37 xfs_suminfo_t *sum) /* out: summary info for this block */ in xfs_rtget_summary()
53 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtany_summary()
54 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtany_summary()
59 xfs_suminfo_t sum; /* summary data */ in xfs_rtany_summary()
62 if (mp->m_rsum_cache && low < mp->m_rsum_cache[bbno]) in xfs_rtany_summary()
63 low = mp->m_rsum_cache[bbno]; in xfs_rtany_summary()
70 * Get one summary datum. in xfs_rtany_summary()
90 if (mp->m_rsum_cache && log > mp->m_rsum_cache[bbno]) in xfs_rtany_summary()
91 mp->m_rsum_cache[bbno] = log; in xfs_rtany_summary()
97 * Copy and transform the summary file, given the old and new
107 xfs_buf_t *bp; /* summary buffer */ in xfs_rtcopy_summary()
109 int log; /* summary level number (log length) */ in xfs_rtcopy_summary()
110 xfs_suminfo_t sum; /* summary data */ in xfs_rtcopy_summary()
111 xfs_fsblock_t sumbno; /* summary block number */ in xfs_rtcopy_summary()
114 for (log = omp->m_rsumlevels - 1; log >= 0; log--) { in xfs_rtcopy_summary()
115 for (bbno = omp->m_sb.sb_rbmblocks - 1; in xfs_rtcopy_summary()
117 bbno--) { in xfs_rtcopy_summary()
124 error = xfs_rtmodify_summary(omp, tp, log, bbno, -sum, in xfs_rtcopy_summary()
139 * Updates all the summary information as well as the bitmap.
147 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtallocate_range()
148 xfs_fsblock_t *rsb) /* in/out: summary block number */ in xfs_rtallocate_range()
155 end = start + len - 1; in xfs_rtallocate_range()
159 * properly update the summary. in xfs_rtallocate_range()
168 error = xfs_rtfind_forw(mp, tp, end, mp->m_sb.sb_rextents - 1, in xfs_rtallocate_range()
174 * Decrement the summary information corresponding to the entire in xfs_rtallocate_range()
178 XFS_RTBLOCKLOG(postblock + 1 - preblock), in xfs_rtallocate_range()
179 XFS_BITTOBLOCK(mp, preblock), -1, rbpp, rsb); in xfs_rtallocate_range()
185 * old extent, add summary data for them to be free. in xfs_rtallocate_range()
189 XFS_RTBLOCKLOG(start - preblock), in xfs_rtallocate_range()
197 * old extent, add summary data for them to be free. in xfs_rtallocate_range()
201 XFS_RTBLOCKLOG(postblock - end), in xfs_rtallocate_range()
229 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtallocate_extent_block()
230 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtallocate_extent_block()
244 * looking for one that's long enough. in xfs_rtallocate_extent_block()
246 for (i = XFS_BLOCKTOBIT(mp, bbno), besti = -1, bestlen = 0, in xfs_rtallocate_extent_block()
247 end = XFS_BLOCKTOBIT(mp, bbno + 1) - 1; in xfs_rtallocate_extent_block()
251 maxlen = min(mp->m_sb.sb_rextents, i + maxlen) - i; in xfs_rtallocate_extent_block()
255 * If it's not so then next will contain the first non-free. in xfs_rtallocate_extent_block()
275 * In the case where we have a variable-sized allocation in xfs_rtallocate_extent_block()
283 thislen = next - i; in xfs_rtallocate_extent_block()
303 if (minlen < maxlen && besti != -1) { in xfs_rtallocate_extent_block()
312 bestlen -= p; in xfs_rtallocate_extent_block()
348 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtallocate_extent_exact()
349 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtallocate_extent_exact()
381 maxlen = next - bno; in xfs_rtallocate_extent_exact()
393 maxlen -= i; in xfs_rtallocate_extent_exact()
427 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtallocate_extent_near()
428 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtallocate_extent_near()
432 int any; /* any useful extents from summary */ in xfs_rtallocate_extent_near()
446 if (bno >= mp->m_sb.sb_rextents) in xfs_rtallocate_extent_near()
447 bno = mp->m_sb.sb_rextents - 1; in xfs_rtallocate_extent_near()
450 maxlen = min(mp->m_sb.sb_rextents, bno + maxlen) - bno; in xfs_rtallocate_extent_near()
480 * Get summary information of extents of all useful levels in xfs_rtallocate_extent_near()
483 error = xfs_rtany_summary(mp, tp, log2len, mp->m_rsumlevels - 1, in xfs_rtallocate_extent_near()
521 * the starting point-1 up to where we are now. in xfs_rtallocate_extent_near()
523 * bitmap block and is long enough. in xfs_rtallocate_extent_near()
525 for (j = -1; j > i; j--) { in xfs_rtallocate_extent_near()
527 * Grab the summary information for in xfs_rtallocate_extent_near()
531 log2len, mp->m_rsumlevels - 1, in xfs_rtallocate_extent_near()
538 * summary that means the extent we in xfs_rtallocate_extent_near()
562 * with a long enough extent, or the in xfs_rtallocate_extent_near()
565 * Try to allocate from the summary block in xfs_rtallocate_extent_near()
587 if (i > 0 && (int)bbno - i >= 0) in xfs_rtallocate_extent_near()
588 i = -i; in xfs_rtallocate_extent_near()
593 else if (i > 0 && (int)bbno + i < mp->m_sb.sb_rbmblocks - 1) in xfs_rtallocate_extent_near()
599 else if (i <= 0 && (int)bbno - i < mp->m_sb.sb_rbmblocks - 1) in xfs_rtallocate_extent_near()
600 i = 1 - i; in xfs_rtallocate_extent_near()
606 i--; in xfs_rtallocate_extent_near()
629 xfs_buf_t **rbpp, /* in/out: summary block buffer */ in xfs_rtallocate_extent_size()
630 xfs_fsblock_t *rsb, /* in/out: summary block number */ in xfs_rtallocate_extent_size()
639 xfs_suminfo_t sum; /* summary information for extents */ in xfs_rtallocate_extent_size()
647 * are extents starting there that are long enough (>= maxlen). in xfs_rtallocate_extent_size()
649 * the summary says there's an extent. in xfs_rtallocate_extent_size()
651 for (l = xfs_highbit32(maxlen); l < mp->m_rsumlevels; l++) { in xfs_rtallocate_extent_size()
655 for (i = 0; i < mp->m_sb.sb_rbmblocks; i++) { in xfs_rtallocate_extent_size()
657 * Get the summary for this level/block. in xfs_rtallocate_extent_size()
690 i = XFS_BITTOBLOCK(mp, n) - 1; in xfs_rtallocate_extent_size()
697 if (minlen > --maxlen) { in xfs_rtallocate_extent_size()
709 for (l = xfs_highbit32(maxlen); l >= xfs_highbit32(minlen); l--) { in xfs_rtallocate_extent_size()
714 for (i = 0; i < mp->m_sb.sb_rbmblocks; i++) { in xfs_rtallocate_extent_size()
716 * Get the summary information for this level/block. in xfs_rtallocate_extent_size()
731 * this summary level. in xfs_rtallocate_extent_size()
735 XFS_RTMIN(maxlen, (1 << (l + 1)) - 1), in xfs_rtallocate_extent_size()
753 i = XFS_BITTOBLOCK(mp, n) - 1; in xfs_rtallocate_extent_size()
764 * Allocate space to the bitmap or summary file, and zero it, for growfs.
771 struct xfs_inode *ip) /* inode (bitmap/summary) */ in xfs_growfs_rt_alloc()
784 if (ip == mp->m_rsumip) in xfs_growfs_rt_alloc()
793 resblks = XFS_GROWFSRT_SPACE_RES(mp, nblocks - oblocks); in xfs_growfs_rt_alloc()
797 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtalloc, resblks, in xfs_growfs_rt_alloc()
811 error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks, in xfs_growfs_rt_alloc()
814 error = -ENOSPC; in xfs_growfs_rt_alloc()
833 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtzero, in xfs_growfs_rt_alloc()
846 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, in xfs_growfs_rt_alloc()
847 mp->m_bsize, 0, &bp); in xfs_growfs_rt_alloc()
852 bp->b_ops = &xfs_rtbuf_ops; in xfs_growfs_rt_alloc()
853 memset(bp->b_addr, 0, mp->m_sb.sb_blocksize); in xfs_growfs_rt_alloc()
854 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); in xfs_growfs_rt_alloc()
885 mp->m_rsum_cache = kvzalloc(rbmblocks, GFP_KERNEL); in xfs_alloc_rsum_cache()
886 if (!mp->m_rsum_cache) in xfs_alloc_rsum_cache()
887 xfs_warn(mp, "could not allocate realtime summary cache"); in xfs_alloc_rsum_cache()
910 xfs_extlen_t nrsumblocks; /* new number of summary blocks */ in xfs_growfs_rt()
911 uint nrsumlevels; /* new rt summary levels */ in xfs_growfs_rt()
912 uint nrsumsize; /* new size of rt summary, bytes */ in xfs_growfs_rt()
915 xfs_extlen_t rsumblocks; /* current number of rt summary blks */ in xfs_growfs_rt()
917 xfs_fsblock_t sumbno; /* summary block number */ in xfs_growfs_rt()
918 uint8_t *rsum_cache; /* old summary cache */ in xfs_growfs_rt()
920 sbp = &mp->m_sb; in xfs_growfs_rt()
925 return -EPERM; in xfs_growfs_rt()
926 if (mp->m_rtdev_targp == NULL || mp->m_rbmip == NULL || in xfs_growfs_rt()
927 (nrblocks = in->newblocks) <= sbp->sb_rblocks || in xfs_growfs_rt()
928 (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize))) in xfs_growfs_rt()
929 return -EINVAL; in xfs_growfs_rt()
935 error = xfs_buf_read_uncached(mp->m_rtdev_targp, in xfs_growfs_rt()
936 XFS_FSB_TO_BB(mp, nrblocks - 1), in xfs_growfs_rt()
946 do_div(nrextents, in->extsize); in xfs_growfs_rt()
947 nrbmblocks = howmany_64(nrextents, NBBY * sbp->sb_blocksize); in xfs_growfs_rt()
954 * New summary size can't be more than half the size of in xfs_growfs_rt()
956 * since we'll log basically the whole summary file at once. in xfs_growfs_rt()
958 if (nrsumblocks > (mp->m_sb.sb_logblocks >> 1)) in xfs_growfs_rt()
959 return -EINVAL; in xfs_growfs_rt()
961 * Get the old block counts for bitmap and summary inodes. in xfs_growfs_rt()
964 rbmblocks = XFS_B_TO_FSB(mp, mp->m_rbmip->i_d.di_size); in xfs_growfs_rt()
965 rsumblocks = XFS_B_TO_FSB(mp, mp->m_rsumip->i_d.di_size); in xfs_growfs_rt()
967 * Allocate space to the bitmap and summary files, as necessary. in xfs_growfs_rt()
969 error = xfs_growfs_rt_alloc(mp, rbmblocks, nrbmblocks, mp->m_rbmip); in xfs_growfs_rt()
972 error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, mp->m_rsumip); in xfs_growfs_rt()
976 rsum_cache = mp->m_rsum_cache; in xfs_growfs_rt()
977 if (nrbmblocks != sbp->sb_rbmblocks) in xfs_growfs_rt()
990 for (bmbno = sbp->sb_rbmblocks - in xfs_growfs_rt()
991 ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); in xfs_growfs_rt()
997 nsbp = &nmp->m_sb; in xfs_growfs_rt()
1001 nsbp->sb_rextsize = in->extsize; in xfs_growfs_rt()
1002 nsbp->sb_rbmblocks = bmbno + 1; in xfs_growfs_rt()
1003 nsbp->sb_rblocks = in xfs_growfs_rt()
1005 nsbp->sb_rbmblocks * NBBY * in xfs_growfs_rt()
1006 nsbp->sb_blocksize * nsbp->sb_rextsize); in xfs_growfs_rt()
1007 nsbp->sb_rextents = nsbp->sb_rblocks; in xfs_growfs_rt()
1008 do_div(nsbp->sb_rextents, nsbp->sb_rextsize); in xfs_growfs_rt()
1009 ASSERT(nsbp->sb_rextents != 0); in xfs_growfs_rt()
1010 nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents); in xfs_growfs_rt()
1011 nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1; in xfs_growfs_rt()
1014 nsbp->sb_rbmblocks; in xfs_growfs_rt()
1016 nmp->m_rsumsize = nrsumsize = XFS_FSB_TO_B(mp, nrsumblocks); in xfs_growfs_rt()
1020 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growrtfree, 0, 0, 0, in xfs_growfs_rt()
1027 xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP); in xfs_growfs_rt()
1028 xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); in xfs_growfs_rt()
1034 mp->m_rbmip->i_d.di_size = in xfs_growfs_rt()
1035 nsbp->sb_rbmblocks * nsbp->sb_blocksize; in xfs_growfs_rt()
1036 i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size); in xfs_growfs_rt()
1037 xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); in xfs_growfs_rt()
1039 * Get the summary inode into the transaction. in xfs_growfs_rt()
1041 xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM); in xfs_growfs_rt()
1042 xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL); in xfs_growfs_rt()
1044 * Update the summary inode's size. We need to update the in xfs_growfs_rt()
1048 mp->m_rsumip->i_d.di_size = nmp->m_rsumsize; in xfs_growfs_rt()
1049 i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size); in xfs_growfs_rt()
1050 xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE); in xfs_growfs_rt()
1052 * Copy summary data from old to new sizes. in xfs_growfs_rt()
1053 * Do this when the real size (not block-aligned) changes. in xfs_growfs_rt()
1055 if (sbp->sb_rbmblocks != nsbp->sb_rbmblocks || in xfs_growfs_rt()
1056 mp->m_rsumlevels != nmp->m_rsumlevels) { in xfs_growfs_rt()
1064 if (nsbp->sb_rextsize != sbp->sb_rextsize) in xfs_growfs_rt()
1066 nsbp->sb_rextsize - sbp->sb_rextsize); in xfs_growfs_rt()
1067 if (nsbp->sb_rbmblocks != sbp->sb_rbmblocks) in xfs_growfs_rt()
1069 nsbp->sb_rbmblocks - sbp->sb_rbmblocks); in xfs_growfs_rt()
1070 if (nsbp->sb_rblocks != sbp->sb_rblocks) in xfs_growfs_rt()
1072 nsbp->sb_rblocks - sbp->sb_rblocks); in xfs_growfs_rt()
1073 if (nsbp->sb_rextents != sbp->sb_rextents) in xfs_growfs_rt()
1075 nsbp->sb_rextents - sbp->sb_rextents); in xfs_growfs_rt()
1076 if (nsbp->sb_rextslog != sbp->sb_rextslog) in xfs_growfs_rt()
1078 nsbp->sb_rextslog - sbp->sb_rextslog); in xfs_growfs_rt()
1083 error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents, in xfs_growfs_rt()
1084 nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); in xfs_growfs_rt()
1094 nsbp->sb_rextents - sbp->sb_rextents); in xfs_growfs_rt()
1098 mp->m_rsumlevels = nrsumlevels; in xfs_growfs_rt()
1099 mp->m_rsumsize = nrsumsize; in xfs_growfs_rt()
1122 if (rsum_cache != mp->m_rsum_cache) { in xfs_growfs_rt()
1124 kmem_free(mp->m_rsum_cache); in xfs_growfs_rt()
1125 mp->m_rsum_cache = rsum_cache; in xfs_growfs_rt()
1150 xfs_mount_t *mp = tp->t_mountp; in xfs_rtallocate_extent()
1153 xfs_fsblock_t sb; /* summary file block number */ in xfs_rtallocate_extent()
1154 xfs_buf_t *sumbp; /* summary file block buffer */ in xfs_rtallocate_extent()
1156 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); in xfs_rtallocate_extent()
1166 maxlen -= i; in xfs_rtallocate_extent()
1168 minlen += prod - i; in xfs_rtallocate_extent()
1192 long slen = (long)*len; in xfs_rtallocate_extent()
1196 xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FREXTENTS, -slen); in xfs_rtallocate_extent()
1198 xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, -slen); in xfs_rtallocate_extent()
1220 sbp = &mp->m_sb; in xfs_rtmount_init()
1221 if (sbp->sb_rblocks == 0) in xfs_rtmount_init()
1223 if (mp->m_rtdev_targp == NULL) { in xfs_rtmount_init()
1226 return -ENODEV; in xfs_rtmount_init()
1228 mp->m_rsumlevels = sbp->sb_rextslog + 1; in xfs_rtmount_init()
1229 mp->m_rsumsize = in xfs_rtmount_init()
1230 (uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels * in xfs_rtmount_init()
1231 sbp->sb_rbmblocks; in xfs_rtmount_init()
1232 mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize); in xfs_rtmount_init()
1233 mp->m_rbmip = mp->m_rsumip = NULL; in xfs_rtmount_init()
1237 d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks); in xfs_rtmount_init()
1238 if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_rblocks) { in xfs_rtmount_init()
1239 xfs_warn(mp, "realtime mount -- %llu != %llu", in xfs_rtmount_init()
1240 (unsigned long long) XFS_BB_TO_FSB(mp, d), in xfs_rtmount_init()
1241 (unsigned long long) mp->m_sb.sb_rblocks); in xfs_rtmount_init()
1242 return -EFBIG; in xfs_rtmount_init()
1244 error = xfs_buf_read_uncached(mp->m_rtdev_targp, in xfs_rtmount_init()
1245 d - XFS_FSB_TO_BB(mp, 1), in xfs_rtmount_init()
1256 * Get the bitmap and summary inodes and the summary cache into the mount
1266 sbp = &mp->m_sb; in xfs_rtmount_inodes()
1267 error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip); in xfs_rtmount_inodes()
1270 ASSERT(mp->m_rbmip != NULL); in xfs_rtmount_inodes()
1272 error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip); in xfs_rtmount_inodes()
1274 xfs_irele(mp->m_rbmip); in xfs_rtmount_inodes()
1277 ASSERT(mp->m_rsumip != NULL); in xfs_rtmount_inodes()
1278 xfs_alloc_rsum_cache(mp, sbp->sb_rbmblocks); in xfs_rtmount_inodes()
1286 kmem_free(mp->m_rsum_cache); in xfs_rtunmount_inodes()
1287 if (mp->m_rbmip) in xfs_rtunmount_inodes()
1288 xfs_irele(mp->m_rbmip); in xfs_rtunmount_inodes()
1289 if (mp->m_rsumip) in xfs_rtunmount_inodes()
1290 xfs_irele(mp->m_rsumip); in xfs_rtunmount_inodes()
1313 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); in xfs_rtpick_extent()
1315 seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime; in xfs_rtpick_extent()
1316 if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) { in xfs_rtpick_extent()
1317 mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; in xfs_rtpick_extent()
1321 if ((log2 = xfs_highbit64(seq)) == -1) in xfs_rtpick_extent()
1324 resid = seq - (1ULL << log2); in xfs_rtpick_extent()
1325 b = (mp->m_sb.sb_rextents * ((resid << 1) + 1ULL)) >> in xfs_rtpick_extent()
1327 if (b >= mp->m_sb.sb_rextents) in xfs_rtpick_extent()
1328 div64_u64_rem(b, mp->m_sb.sb_rextents, &b); in xfs_rtpick_extent()
1329 if (b + len > mp->m_sb.sb_rextents) in xfs_rtpick_extent()
1330 b = mp->m_sb.sb_rextents - len; in xfs_rtpick_extent()
1333 xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); in xfs_rtpick_extent()