94 while (oblocks < nblocks) {
115 xfs_bmap_init(&flist, &firstblock);
123 resblks, &map, &nmap, &flist);
124 if (!error && nmap < 1)
161 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
252 if (minlen < maxlen) {
256 if (thislen >= minlen && thislen > bestlen) {
275 if (minlen < maxlen && besti != -1) {
281 if (prod > 1 && (p =
do_mod(bestlen, prod)))
326 ASSERT(minlen % prod == 0 && maxlen % prod == 0);
350 if (maxlen < minlen) {
360 if (prod > 1 && (i = maxlen % prod)) {
362 if (maxlen < minlen) {
409 ASSERT(minlen % prod == 0 && maxlen % prod == 0);
414 if (bno >= mp->m_sb.sb_rextents)
415 bno = mp->m_sb.sb_rextents - 1;
420 rbpp, rsb, prod, &r);
434 log2len = xfs_highbit32(minlen);
444 bbno + i, rbpp, rsb, &any);
462 bbno + i, minlen, maxlen, len, &n, rbpp,
485 for (j = -1; j >
i; j--) {
491 log2len, mp->m_rsumlevels - 1,
492 bbno + j, rbpp, rsb, &any);
507 tp, bbno + j, minlen, maxlen,
508 len, &n, rbpp, rsb, prod, &r);
529 bbno + i, minlen, maxlen, len, &n, rbpp,
547 if (i > 0 && (
int)bbno - i >= 0)
553 else if (i > 0 && (
int)bbno + i < mp->m_sb.sb_rbmblocks - 1)
559 else if (i <= 0 && (
int)bbno - i < mp->m_sb.sb_rbmblocks - 1)
565 else if (i <= 0 && (
int)bbno + i > 0)
601 ASSERT(minlen % prod == 0 && maxlen % prod == 0);
611 for (l = xfs_highbit32(maxlen); l < mp->m_rsumlevels; l++) {
615 for (i = 0; i < mp->m_sb.sb_rbmblocks; i++) {
633 maxlen, len, &n, rbpp, rsb, prod, &r);
657 if (minlen > --maxlen) {
669 for (l = xfs_highbit32(maxlen); l >= xfs_highbit32(minlen); l--) {
674 for (i = 0; i < mp->m_sb.sb_rbmblocks; i++) {
696 len, &n, rbpp, rsb, prod, &r);
741 end = start + len - 1;
773 if (preblock < start) {
785 if (postblock > end) {
822 for (log = low; log <=
high; log++) {
863 ip = issum ? mp->m_rsumip : mp->m_rbmip;
870 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
872 mp->m_bsize, 0, &bp);
875 ASSERT(!xfs_buf_geterror(bp));
885 xfs_rtcheck_alloc_range(
962 if ((wdiff = (*b ^ val) &
mask)) {
1008 if ((wdiff = *b ^ val)) {
1045 if ((lastbit = len - i)) {
1053 if ((wdiff = (*b ^ val) &
mask)) {
1092 for (log = omp->m_rsumlevels - 1; log >= 0; log--) {
1093 for (bbno = omp->m_sb.sb_rbmblocks - 1;
1157 len = start - limit + 1;
1173 mask = (((
xfs_rtword_t)1 << (bit - firstbit + 1)) - 1) <<
1179 if ((wdiff = (*b ^ want) &
mask)) {
1185 *rtblock = start - i + 1;
1188 i = bit - firstbit + 1;
1193 if (--word == -1 && i < len) {
1225 if ((wdiff = *b ^ want)) {
1231 *rtblock = start - i + 1;
1239 if (--word == -1 && i < len) {
1268 mask = (((
xfs_rtword_t)1 << (len - i)) - 1) << firstbit;
1272 if ((wdiff = (*b ^ want) &
mask)) {
1278 *rtblock = start - i + 1;
1287 *rtblock = start - i + 1;
1332 len = limit - start + 1;
1353 if ((wdiff = (*b ^ want) &
mask)) {
1359 *rtblock = start + i - 1;
1398 if ((wdiff = *b ^ want)) {
1404 *rtblock = start + i - 1;
1434 if ((lastbit = len - i)) {
1442 if ((wdiff = (*b ^ want) &
mask)) {
1448 *rtblock = start + i - 1;
1457 *rtblock = start + i - 1;
1479 end = start + len - 1;
1507 if (preblock < start) {
1519 if (postblock > end) {
1570 if (rbpp && *rbpp && *rsb == sb)
1646 first = b = &bufp[
word];
1680 (
uint)((
char *)first - (
char *)bufp),
1681 (
uint)((
char *)b - (
char *)bufp));
1686 first = b = bufp = bp->
b_addr;
1720 (
uint)((
char *)first - (
char *)bufp),
1721 (
uint)((
char *)b - (
char *)bufp));
1726 first = b = bufp = bp->
b_addr;
1739 if ((lastbit = len - i)) {
1759 (
uint)((
char *)b - (
char *)bufp - 1));
1796 if (rbpp && *rbpp && *rsb == sb)
1825 (
uint)((
char *)sp - (
char *)bp->
b_addr +
sizeof(*sp) - 1));
1864 if (mp->m_rtdev_targp ==
NULL || mp->m_rbmip ==
NULL ||
1883 nrextents = nrblocks;
1886 nrextslog = xfs_highbit32(nrextents);
1887 nrsumlevels = nrextslog + 1;
1896 if (nrsumblocks > (mp->m_sb.sb_logblocks >> 1))
1902 rbmblocks =
XFS_B_TO_FSB(mp, mp->m_rbmip->i_d.di_size);
1903 rsumblocks =
XFS_B_TO_FSB(mp, mp->m_rsumip->i_d.di_size);
1924 ((sbp->
sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
1928 int cancelflags = 0;
1945 nrsumlevels = nmp->m_rsumlevels = nsbp->
sb_rextslog + 1;
1950 nmp->m_rsumsize = nrsumsize =
XFS_FSB_TO_B(mp, nrsumblocks);
1966 mp->m_rbmip->i_d.di_size =
1973 xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL);
1978 mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
1985 mp->m_rsumlevels != nmp->m_rsumlevels) {
2027 mp->m_rsumlevels = nrsumlevels;
2028 mp->m_rsumsize = nrsumsize;
2060 xfs_mount_t *
mp = tp->t_mountp;
2066 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
2067 ASSERT(minlen > 0 && minlen <= maxlen);
2075 if ((i = maxlen % prod))
2077 if ((i = minlen % prod))
2079 if (maxlen < minlen) {
2092 &sumbp, &sb, prod, &r);
2096 len, &sumbp, &sb, prod, &r);
2100 len, &sumbp, &sb, prod, &r);
2113 long slen = (
long)*len;
2115 ASSERT(*len >= minlen && *len <= maxlen);
2143 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
2145 #if defined(__KERNEL__) && defined(DEBUG)
2152 error = xfs_rtcheck_alloc_range(mp, tp, bno, len, &stat);
2175 if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
2176 mp->m_sb.sb_rextents) {
2179 *(__uint64_t *)&mp->m_rbmip->i_d.di_atime = 0;
2199 if (mp->m_rtdev_targp ==
NULL) {
2201 "Filesystem has a realtime volume, use rtdev=device option");
2209 mp->m_rbmip = mp->m_rsumip =
NULL;
2215 xfs_warn(mp,
"realtime mount -- %llu != %llu",
2217 (
unsigned long long) mp->m_sb.sb_rblocks);
2224 xfs_warn(mp,
"realtime device size check failed");
2261 struct xfs_mount *
mp)
2266 IRELE(mp->m_rsumip);
2289 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
2291 seqp = (__uint64_t *)&mp->m_rbmip->i_d.di_atime;
2297 if ((log2 = xfs_highbit64(seq)) == -1)
2300 resid = seq - (1ULL << log2);
2301 b = (mp->m_sb.sb_rextents * ((resid << 1) + 1ULL)) >>
2303 if (b >= mp->m_sb.sb_rextents)
2304 b =
do_mod(b, mp->m_sb.sb_rextents);
2305 if (b + len > mp->m_sb.sb_rextents)
2306 b = mp->m_sb.sb_rextents - len;