2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "xfs_shared.h"
21 #include "xfs_format.h"
22 #include "xfs_log_format.h"
23 #include "xfs_trans_resv.h"
27 #include "xfs_mount.h"
28 #include "xfs_inode.h"
30 #include "xfs_bmap_util.h"
31 #include "xfs_bmap_btree.h"
32 #include "xfs_alloc.h"
33 #include "xfs_error.h"
34 #include "xfs_trans.h"
35 #include "xfs_trans_space.h"
36 #include "xfs_trace.h"
38 #include "xfs_icache.h"
39 #include "xfs_dinode.h"
40 #include "xfs_rtalloc.h"
44 * Realtime allocator bitmap functions shared with userspace.
48 * Get a buffer for the bitmap or summary file block specified.
49 * The buffer is returned read and locked.
53 xfs_mount_t
*mp
, /* file system mount structure */
54 xfs_trans_t
*tp
, /* transaction pointer */
55 xfs_rtblock_t block
, /* block number in bitmap or summary */
56 int issum
, /* is summary not bitmap */
57 xfs_buf_t
**bpp
) /* output: buffer for the block */
59 xfs_buf_t
*bp
; /* block buffer, result */
60 xfs_inode_t
*ip
; /* bitmap or summary inode */
63 int error
; /* error value */
65 ip
= issum
? mp
->m_rsumip
: mp
->m_rbmip
;
67 error
= xfs_bmapi_read(ip
, block
, 1, &map
, &nmap
, XFS_DATA_FORK
);
71 ASSERT(map
.br_startblock
!= NULLFSBLOCK
);
72 error
= xfs_trans_read_buf(mp
, tp
, mp
->m_ddev_targp
,
73 XFS_FSB_TO_DADDR(mp
, map
.br_startblock
),
74 mp
->m_bsize
, 0, &bp
, NULL
);
82 * Searching backward from start to limit, find the first block whose
83 * allocated/free state is different from start's.
87 xfs_mount_t
*mp
, /* file system mount point */
88 xfs_trans_t
*tp
, /* transaction pointer */
89 xfs_rtblock_t start
, /* starting block to look at */
90 xfs_rtblock_t limit
, /* last block to look at */
91 xfs_rtblock_t
*rtblock
) /* out: start block found */
93 xfs_rtword_t
*b
; /* current word in buffer */
94 int bit
; /* bit number in the word */
95 xfs_rtblock_t block
; /* bitmap block number */
96 xfs_buf_t
*bp
; /* buf for the block */
97 xfs_rtword_t
*bufp
; /* starting word in buffer */
98 int error
; /* error value */
99 xfs_rtblock_t firstbit
; /* first useful bit in the word */
100 xfs_rtblock_t i
; /* current bit number rel. to start */
101 xfs_rtblock_t len
; /* length of inspected area */
102 xfs_rtword_t mask
; /* mask of relevant bits for value */
103 xfs_rtword_t want
; /* mask for "good" values */
104 xfs_rtword_t wdiff
; /* difference from wanted value */
105 int word
; /* word number in the buffer */
108 * Compute and read in starting bitmap block for starting block.
110 block
= XFS_BITTOBLOCK(mp
, start
);
111 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
117 * Get the first word's index & point to it.
119 word
= XFS_BITTOWORD(mp
, start
);
121 bit
= (int)(start
& (XFS_NBWORD
- 1));
122 len
= start
- limit
+ 1;
124 * Compute match value, based on the bit at start: if 1 (free)
125 * then all-ones, else all-zeroes.
127 want
= (*b
& ((xfs_rtword_t
)1 << bit
)) ? -1 : 0;
129 * If the starting position is not word-aligned, deal with the
132 if (bit
< XFS_NBWORD
- 1) {
134 * Calculate first (leftmost) bit number to look at,
135 * and mask for all the relevant bits in this word.
137 firstbit
= XFS_RTMAX((xfs_srtblock_t
)(bit
- len
+ 1), 0);
138 mask
= (((xfs_rtword_t
)1 << (bit
- firstbit
+ 1)) - 1) <<
141 * Calculate the difference between the value there
142 * and what we're looking for.
144 if ((wdiff
= (*b
^ want
) & mask
)) {
146 * Different. Mark where we are and return.
148 xfs_trans_brelse(tp
, bp
);
149 i
= bit
- XFS_RTHIBIT(wdiff
);
150 *rtblock
= start
- i
+ 1;
153 i
= bit
- firstbit
+ 1;
155 * Go on to previous block if that's where the previous word is
156 * and we need the previous word.
158 if (--word
== -1 && i
< len
) {
160 * If done with this block, get the previous one.
162 xfs_trans_brelse(tp
, bp
);
163 error
= xfs_rtbuf_get(mp
, tp
, --block
, 0, &bp
);
168 word
= XFS_BLOCKWMASK(mp
);
172 * Go on to the previous word in the buffer.
178 * Starting on a word boundary, no partial word.
183 * Loop over whole words in buffers. When we use up one buffer
184 * we move on to the previous one.
186 while (len
- i
>= XFS_NBWORD
) {
188 * Compute difference between actual and desired value.
190 if ((wdiff
= *b
^ want
)) {
192 * Different, mark where we are and return.
194 xfs_trans_brelse(tp
, bp
);
195 i
+= XFS_NBWORD
- 1 - XFS_RTHIBIT(wdiff
);
196 *rtblock
= start
- i
+ 1;
201 * Go on to previous block if that's where the previous word is
202 * and we need the previous word.
204 if (--word
== -1 && i
< len
) {
206 * If done with this block, get the previous one.
208 xfs_trans_brelse(tp
, bp
);
209 error
= xfs_rtbuf_get(mp
, tp
, --block
, 0, &bp
);
214 word
= XFS_BLOCKWMASK(mp
);
218 * Go on to the previous word in the buffer.
224 * If not ending on a word boundary, deal with the last
229 * Calculate first (leftmost) bit number to look at,
230 * and mask for all the relevant bits in this word.
232 firstbit
= XFS_NBWORD
- (len
- i
);
233 mask
= (((xfs_rtword_t
)1 << (len
- i
)) - 1) << firstbit
;
235 * Compute difference between actual and desired value.
237 if ((wdiff
= (*b
^ want
) & mask
)) {
239 * Different, mark where we are and return.
241 xfs_trans_brelse(tp
, bp
);
242 i
+= XFS_NBWORD
- 1 - XFS_RTHIBIT(wdiff
);
243 *rtblock
= start
- i
+ 1;
249 * No match, return that we scanned the whole area.
251 xfs_trans_brelse(tp
, bp
);
252 *rtblock
= start
- i
+ 1;
257 * Searching forward from start to limit, find the first block whose
258 * allocated/free state is different from start's.
262 xfs_mount_t
*mp
, /* file system mount point */
263 xfs_trans_t
*tp
, /* transaction pointer */
264 xfs_rtblock_t start
, /* starting block to look at */
265 xfs_rtblock_t limit
, /* last block to look at */
266 xfs_rtblock_t
*rtblock
) /* out: start block found */
268 xfs_rtword_t
*b
; /* current word in buffer */
269 int bit
; /* bit number in the word */
270 xfs_rtblock_t block
; /* bitmap block number */
271 xfs_buf_t
*bp
; /* buf for the block */
272 xfs_rtword_t
*bufp
; /* starting word in buffer */
273 int error
; /* error value */
274 xfs_rtblock_t i
; /* current bit number rel. to start */
275 xfs_rtblock_t lastbit
; /* last useful bit in the word */
276 xfs_rtblock_t len
; /* length of inspected area */
277 xfs_rtword_t mask
; /* mask of relevant bits for value */
278 xfs_rtword_t want
; /* mask for "good" values */
279 xfs_rtword_t wdiff
; /* difference from wanted value */
280 int word
; /* word number in the buffer */
283 * Compute and read in starting bitmap block for starting block.
285 block
= XFS_BITTOBLOCK(mp
, start
);
286 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
292 * Get the first word's index & point to it.
294 word
= XFS_BITTOWORD(mp
, start
);
296 bit
= (int)(start
& (XFS_NBWORD
- 1));
297 len
= limit
- start
+ 1;
299 * Compute match value, based on the bit at start: if 1 (free)
300 * then all-ones, else all-zeroes.
302 want
= (*b
& ((xfs_rtword_t
)1 << bit
)) ? -1 : 0;
304 * If the starting position is not word-aligned, deal with the
309 * Calculate last (rightmost) bit number to look at,
310 * and mask for all the relevant bits in this word.
312 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
313 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
315 * Calculate the difference between the value there
316 * and what we're looking for.
318 if ((wdiff
= (*b
^ want
) & mask
)) {
320 * Different. Mark where we are and return.
322 xfs_trans_brelse(tp
, bp
);
323 i
= XFS_RTLOBIT(wdiff
) - bit
;
324 *rtblock
= start
+ i
- 1;
329 * Go on to next block if that's where the next word is
330 * and we need the next word.
332 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
334 * If done with this block, get the previous one.
336 xfs_trans_brelse(tp
, bp
);
337 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
341 b
= bufp
= bp
->b_addr
;
345 * Go on to the previous word in the buffer.
351 * Starting on a word boundary, no partial word.
356 * Loop over whole words in buffers. When we use up one buffer
357 * we move on to the next one.
359 while (len
- i
>= XFS_NBWORD
) {
361 * Compute difference between actual and desired value.
363 if ((wdiff
= *b
^ want
)) {
365 * Different, mark where we are and return.
367 xfs_trans_brelse(tp
, bp
);
368 i
+= XFS_RTLOBIT(wdiff
);
369 *rtblock
= start
+ i
- 1;
374 * Go on to next block if that's where the next word is
375 * and we need the next word.
377 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
379 * If done with this block, get the next one.
381 xfs_trans_brelse(tp
, bp
);
382 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
386 b
= bufp
= bp
->b_addr
;
390 * Go on to the next word in the buffer.
396 * If not ending on a word boundary, deal with the last
399 if ((lastbit
= len
- i
)) {
401 * Calculate mask for all the relevant bits in this word.
403 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
405 * Compute difference between actual and desired value.
407 if ((wdiff
= (*b
^ want
) & mask
)) {
409 * Different, mark where we are and return.
411 xfs_trans_brelse(tp
, bp
);
412 i
+= XFS_RTLOBIT(wdiff
);
413 *rtblock
= start
+ i
- 1;
419 * No match, return that we scanned the whole area.
421 xfs_trans_brelse(tp
, bp
);
422 *rtblock
= start
+ i
- 1;
427 * Read and modify the summary information for a given extent size,
428 * bitmap block combination.
429 * Keeps track of a current summary block, so we don't keep reading
430 * it from the buffer cache.
433 xfs_rtmodify_summary(
434 xfs_mount_t
*mp
, /* file system mount point */
435 xfs_trans_t
*tp
, /* transaction pointer */
436 int log
, /* log2 of extent size */
437 xfs_rtblock_t bbno
, /* bitmap block number */
438 int delta
, /* change to make to summary info */
439 xfs_buf_t
**rbpp
, /* in/out: summary block buffer */
440 xfs_fsblock_t
*rsb
) /* in/out: summary block number */
442 xfs_buf_t
*bp
; /* buffer for the summary block */
443 int error
; /* error value */
444 xfs_fsblock_t sb
; /* summary fsblock */
445 int so
; /* index into the summary file */
446 xfs_suminfo_t
*sp
; /* pointer to returned data */
449 * Compute entry number in the summary file.
451 so
= XFS_SUMOFFS(mp
, log
, bbno
);
453 * Compute the block number in the summary file.
455 sb
= XFS_SUMOFFSTOBLOCK(mp
, so
);
457 * If we have an old buffer, and the block number matches, use that.
459 if (rbpp
&& *rbpp
&& *rsb
== sb
)
462 * Otherwise we have to get the buffer.
466 * If there was an old one, get rid of it first.
469 xfs_trans_brelse(tp
, *rbpp
);
470 error
= xfs_rtbuf_get(mp
, tp
, sb
, 1, &bp
);
475 * Remember this buffer and block for the next call.
483 * Point to the summary information, modify and log it.
485 sp
= XFS_SUMPTR(mp
, bp
, so
);
487 xfs_trans_log_buf(tp
, bp
, (uint
)((char *)sp
- (char *)bp
->b_addr
),
488 (uint
)((char *)sp
- (char *)bp
->b_addr
+ sizeof(*sp
) - 1));
493 * Set the given range of bitmap bits to the given value.
494 * Do whatever I/O and logging is required.
498 xfs_mount_t
*mp
, /* file system mount point */
499 xfs_trans_t
*tp
, /* transaction pointer */
500 xfs_rtblock_t start
, /* starting block to modify */
501 xfs_extlen_t len
, /* length of extent to modify */
502 int val
) /* 1 for free, 0 for allocated */
504 xfs_rtword_t
*b
; /* current word in buffer */
505 int bit
; /* bit number in the word */
506 xfs_rtblock_t block
; /* bitmap block number */
507 xfs_buf_t
*bp
; /* buf for the block */
508 xfs_rtword_t
*bufp
; /* starting word in buffer */
509 int error
; /* error value */
510 xfs_rtword_t
*first
; /* first used word in the buffer */
511 int i
; /* current bit number rel. to start */
512 int lastbit
; /* last useful bit in word */
513 xfs_rtword_t mask
; /* mask o frelevant bits for value */
514 int word
; /* word number in the buffer */
517 * Compute starting bitmap block number.
519 block
= XFS_BITTOBLOCK(mp
, start
);
521 * Read the bitmap block, and point to its data.
523 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
529 * Compute the starting word's address, and starting bit.
531 word
= XFS_BITTOWORD(mp
, start
);
532 first
= b
= &bufp
[word
];
533 bit
= (int)(start
& (XFS_NBWORD
- 1));
535 * 0 (allocated) => all zeroes; 1 (free) => all ones.
539 * If not starting on a word boundary, deal with the first
544 * Compute first bit not changed and mask of relevant bits.
546 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
547 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
549 * Set/clear the active bits.
557 * Go on to the next block if that's where the next word is
558 * and we need the next word.
560 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
562 * Log the changed part of this block.
565 xfs_trans_log_buf(tp
, bp
,
566 (uint
)((char *)first
- (char *)bufp
),
567 (uint
)((char *)b
- (char *)bufp
));
568 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
572 first
= b
= bufp
= bp
->b_addr
;
576 * Go on to the next word in the buffer
582 * Starting on a word boundary, no partial word.
587 * Loop over whole words in buffers. When we use up one buffer
588 * we move on to the next one.
590 while (len
- i
>= XFS_NBWORD
) {
592 * Set the word value correctly.
597 * Go on to the next block if that's where the next word is
598 * and we need the next word.
600 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
602 * Log the changed part of this block.
605 xfs_trans_log_buf(tp
, bp
,
606 (uint
)((char *)first
- (char *)bufp
),
607 (uint
)((char *)b
- (char *)bufp
));
608 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
612 first
= b
= bufp
= bp
->b_addr
;
616 * Go on to the next word in the buffer
622 * If not ending on a word boundary, deal with the last
625 if ((lastbit
= len
- i
)) {
627 * Compute a mask of relevant bits.
630 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
632 * Set/clear the active bits.
641 * Log any remaining changed bytes.
644 xfs_trans_log_buf(tp
, bp
, (uint
)((char *)first
- (char *)bufp
),
645 (uint
)((char *)b
- (char *)bufp
- 1));
650 * Mark an extent specified by start and len freed.
651 * Updates all the summary information as well as the bitmap.
655 xfs_mount_t
*mp
, /* file system mount point */
656 xfs_trans_t
*tp
, /* transaction pointer */
657 xfs_rtblock_t start
, /* starting block to free */
658 xfs_extlen_t len
, /* length to free */
659 xfs_buf_t
**rbpp
, /* in/out: summary block buffer */
660 xfs_fsblock_t
*rsb
) /* in/out: summary block number */
662 xfs_rtblock_t end
; /* end of the freed extent */
663 int error
; /* error value */
664 xfs_rtblock_t postblock
; /* first block freed > end */
665 xfs_rtblock_t preblock
; /* first block freed < start */
667 end
= start
+ len
- 1;
669 * Modify the bitmap to mark this extent freed.
671 error
= xfs_rtmodify_range(mp
, tp
, start
, len
, 1);
676 * Assume we're freeing out of the middle of an allocated extent.
677 * We need to find the beginning and end of the extent so we can
678 * properly update the summary.
680 error
= xfs_rtfind_back(mp
, tp
, start
, 0, &preblock
);
685 * Find the next allocated block (end of allocated extent).
687 error
= xfs_rtfind_forw(mp
, tp
, end
, mp
->m_sb
.sb_rextents
- 1,
692 * If there are blocks not being freed at the front of the
693 * old extent, add summary data for them to be allocated.
695 if (preblock
< start
) {
696 error
= xfs_rtmodify_summary(mp
, tp
,
697 XFS_RTBLOCKLOG(start
- preblock
),
698 XFS_BITTOBLOCK(mp
, preblock
), -1, rbpp
, rsb
);
704 * If there are blocks not being freed at the end of the
705 * old extent, add summary data for them to be allocated.
707 if (postblock
> end
) {
708 error
= xfs_rtmodify_summary(mp
, tp
,
709 XFS_RTBLOCKLOG(postblock
- end
),
710 XFS_BITTOBLOCK(mp
, end
+ 1), -1, rbpp
, rsb
);
716 * Increment the summary information corresponding to the entire
719 error
= xfs_rtmodify_summary(mp
, tp
,
720 XFS_RTBLOCKLOG(postblock
+ 1 - preblock
),
721 XFS_BITTOBLOCK(mp
, preblock
), 1, rbpp
, rsb
);
726 * Check that the given range is either all allocated (val = 0) or
727 * all free (val = 1).
731 xfs_mount_t
*mp
, /* file system mount point */
732 xfs_trans_t
*tp
, /* transaction pointer */
733 xfs_rtblock_t start
, /* starting block number of extent */
734 xfs_extlen_t len
, /* length of extent */
735 int val
, /* 1 for free, 0 for allocated */
736 xfs_rtblock_t
*new, /* out: first block not matching */
737 int *stat
) /* out: 1 for matches, 0 for not */
739 xfs_rtword_t
*b
; /* current word in buffer */
740 int bit
; /* bit number in the word */
741 xfs_rtblock_t block
; /* bitmap block number */
742 xfs_buf_t
*bp
; /* buf for the block */
743 xfs_rtword_t
*bufp
; /* starting word in buffer */
744 int error
; /* error value */
745 xfs_rtblock_t i
; /* current bit number rel. to start */
746 xfs_rtblock_t lastbit
; /* last useful bit in word */
747 xfs_rtword_t mask
; /* mask of relevant bits for value */
748 xfs_rtword_t wdiff
; /* difference from wanted value */
749 int word
; /* word number in the buffer */
752 * Compute starting bitmap block number
754 block
= XFS_BITTOBLOCK(mp
, start
);
756 * Read the bitmap block.
758 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
764 * Compute the starting word's address, and starting bit.
766 word
= XFS_BITTOWORD(mp
, start
);
768 bit
= (int)(start
& (XFS_NBWORD
- 1));
770 * 0 (allocated) => all zero's; 1 (free) => all one's.
774 * If not starting on a word boundary, deal with the first
779 * Compute first bit not examined.
781 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
783 * Mask of relevant bits.
785 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
787 * Compute difference between actual and desired value.
789 if ((wdiff
= (*b
^ val
) & mask
)) {
791 * Different, compute first wrong bit and return.
793 xfs_trans_brelse(tp
, bp
);
794 i
= XFS_RTLOBIT(wdiff
) - bit
;
801 * Go on to next block if that's where the next word is
802 * and we need the next word.
804 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
806 * If done with this block, get the next one.
808 xfs_trans_brelse(tp
, bp
);
809 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
813 b
= bufp
= bp
->b_addr
;
817 * Go on to the next word in the buffer.
823 * Starting on a word boundary, no partial word.
828 * Loop over whole words in buffers. When we use up one buffer
829 * we move on to the next one.
831 while (len
- i
>= XFS_NBWORD
) {
833 * Compute difference between actual and desired value.
835 if ((wdiff
= *b
^ val
)) {
837 * Different, compute first wrong bit and return.
839 xfs_trans_brelse(tp
, bp
);
840 i
+= XFS_RTLOBIT(wdiff
);
847 * Go on to next block if that's where the next word is
848 * and we need the next word.
850 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
852 * If done with this block, get the next one.
854 xfs_trans_brelse(tp
, bp
);
855 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
859 b
= bufp
= bp
->b_addr
;
863 * Go on to the next word in the buffer.
869 * If not ending on a word boundary, deal with the last
872 if ((lastbit
= len
- i
)) {
874 * Mask of relevant bits.
876 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
878 * Compute difference between actual and desired value.
880 if ((wdiff
= (*b
^ val
) & mask
)) {
882 * Different, compute first wrong bit and return.
884 xfs_trans_brelse(tp
, bp
);
885 i
+= XFS_RTLOBIT(wdiff
);
893 * Successful, return.
895 xfs_trans_brelse(tp
, bp
);
903 * Check that the given extent (block range) is allocated already.
905 STATIC
int /* error */
906 xfs_rtcheck_alloc_range(
907 xfs_mount_t
*mp
, /* file system mount point */
908 xfs_trans_t
*tp
, /* transaction pointer */
909 xfs_rtblock_t bno
, /* starting block number of extent */
910 xfs_extlen_t len
) /* length of extent */
912 xfs_rtblock_t
new; /* dummy for xfs_rtcheck_range */
916 error
= xfs_rtcheck_range(mp
, tp
, bno
, len
, 0, &new, &stat
);
923 #define xfs_rtcheck_alloc_range(m,t,b,l) (0)
926 * Free an extent in the realtime subvolume. Length is expressed in
927 * realtime extents, as is the block number.
931 xfs_trans_t
*tp
, /* transaction pointer */
932 xfs_rtblock_t bno
, /* starting block number to free */
933 xfs_extlen_t len
) /* length of extent freed */
935 int error
; /* error value */
936 xfs_mount_t
*mp
; /* file system mount structure */
937 xfs_fsblock_t sb
; /* summary file block number */
938 xfs_buf_t
*sumbp
= NULL
; /* summary file block buffer */
942 ASSERT(mp
->m_rbmip
->i_itemp
!= NULL
);
943 ASSERT(xfs_isilocked(mp
->m_rbmip
, XFS_ILOCK_EXCL
));
945 error
= xfs_rtcheck_alloc_range(mp
, tp
, bno
, len
);
950 * Free the range of realtime blocks.
952 error
= xfs_rtfree_range(mp
, tp
, bno
, len
, &sumbp
, &sb
);
957 * Mark more blocks free in the superblock.
959 xfs_trans_mod_sb(tp
, XFS_TRANS_SB_FREXTENTS
, (long)len
);
961 * If we've now freed all the blocks, reset the file sequence
964 if (tp
->t_frextents_delta
+ mp
->m_sb
.sb_frextents
==
965 mp
->m_sb
.sb_rextents
) {
966 if (!(mp
->m_rbmip
->i_d
.di_flags
& XFS_DIFLAG_NEWRTBM
))
967 mp
->m_rbmip
->i_d
.di_flags
|= XFS_DIFLAG_NEWRTBM
;
968 *(__uint64_t
*)&mp
->m_rbmip
->i_d
.di_atime
= 0;
969 xfs_trans_log_inode(tp
, mp
->m_rbmip
, XFS_ILOG_CORE
);