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"
25 #include "xfs_mount.h"
26 #include "xfs_inode.h"
28 #include "xfs_bmap_util.h"
29 #include "xfs_bmap_btree.h"
30 #include "xfs_alloc.h"
31 #include "xfs_error.h"
32 #include "xfs_trans.h"
33 #include "xfs_trans_space.h"
34 #include "xfs_trace.h"
36 #include "xfs_icache.h"
37 #include "xfs_rtalloc.h"
41 * Realtime allocator bitmap functions shared with userspace.
45 * Get a buffer for the bitmap or summary file block specified.
46 * The buffer is returned read and locked.
50 xfs_mount_t
*mp
, /* file system mount structure */
51 xfs_trans_t
*tp
, /* transaction pointer */
52 xfs_rtblock_t block
, /* block number in bitmap or summary */
53 int issum
, /* is summary not bitmap */
54 xfs_buf_t
**bpp
) /* output: buffer for the block */
56 xfs_buf_t
*bp
; /* block buffer, result */
57 xfs_inode_t
*ip
; /* bitmap or summary inode */
60 int error
; /* error value */
62 ip
= issum
? mp
->m_rsumip
: mp
->m_rbmip
;
64 error
= xfs_bmapi_read(ip
, block
, 1, &map
, &nmap
, XFS_DATA_FORK
);
68 ASSERT(map
.br_startblock
!= NULLFSBLOCK
);
69 error
= xfs_trans_read_buf(mp
, tp
, mp
->m_ddev_targp
,
70 XFS_FSB_TO_DADDR(mp
, map
.br_startblock
),
71 mp
->m_bsize
, 0, &bp
, NULL
);
79 * Searching backward from start to limit, find the first block whose
80 * allocated/free state is different from start's.
84 xfs_mount_t
*mp
, /* file system mount point */
85 xfs_trans_t
*tp
, /* transaction pointer */
86 xfs_rtblock_t start
, /* starting block to look at */
87 xfs_rtblock_t limit
, /* last block to look at */
88 xfs_rtblock_t
*rtblock
) /* out: start block found */
90 xfs_rtword_t
*b
; /* current word in buffer */
91 int bit
; /* bit number in the word */
92 xfs_rtblock_t block
; /* bitmap block number */
93 xfs_buf_t
*bp
; /* buf for the block */
94 xfs_rtword_t
*bufp
; /* starting word in buffer */
95 int error
; /* error value */
96 xfs_rtblock_t firstbit
; /* first useful bit in the word */
97 xfs_rtblock_t i
; /* current bit number rel. to start */
98 xfs_rtblock_t len
; /* length of inspected area */
99 xfs_rtword_t mask
; /* mask of relevant bits for value */
100 xfs_rtword_t want
; /* mask for "good" values */
101 xfs_rtword_t wdiff
; /* difference from wanted value */
102 int word
; /* word number in the buffer */
105 * Compute and read in starting bitmap block for starting block.
107 block
= XFS_BITTOBLOCK(mp
, start
);
108 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
114 * Get the first word's index & point to it.
116 word
= XFS_BITTOWORD(mp
, start
);
118 bit
= (int)(start
& (XFS_NBWORD
- 1));
119 len
= start
- limit
+ 1;
121 * Compute match value, based on the bit at start: if 1 (free)
122 * then all-ones, else all-zeroes.
124 want
= (*b
& ((xfs_rtword_t
)1 << bit
)) ? -1 : 0;
126 * If the starting position is not word-aligned, deal with the
129 if (bit
< XFS_NBWORD
- 1) {
131 * Calculate first (leftmost) bit number to look at,
132 * and mask for all the relevant bits in this word.
134 firstbit
= XFS_RTMAX((xfs_srtblock_t
)(bit
- len
+ 1), 0);
135 mask
= (((xfs_rtword_t
)1 << (bit
- firstbit
+ 1)) - 1) <<
138 * Calculate the difference between the value there
139 * and what we're looking for.
141 if ((wdiff
= (*b
^ want
) & mask
)) {
143 * Different. Mark where we are and return.
145 xfs_trans_brelse(tp
, bp
);
146 i
= bit
- XFS_RTHIBIT(wdiff
);
147 *rtblock
= start
- i
+ 1;
150 i
= bit
- firstbit
+ 1;
152 * Go on to previous block if that's where the previous word is
153 * and we need the previous word.
155 if (--word
== -1 && i
< len
) {
157 * If done with this block, get the previous one.
159 xfs_trans_brelse(tp
, bp
);
160 error
= xfs_rtbuf_get(mp
, tp
, --block
, 0, &bp
);
165 word
= XFS_BLOCKWMASK(mp
);
169 * Go on to the previous word in the buffer.
175 * Starting on a word boundary, no partial word.
180 * Loop over whole words in buffers. When we use up one buffer
181 * we move on to the previous one.
183 while (len
- i
>= XFS_NBWORD
) {
185 * Compute difference between actual and desired value.
187 if ((wdiff
= *b
^ want
)) {
189 * Different, mark where we are and return.
191 xfs_trans_brelse(tp
, bp
);
192 i
+= XFS_NBWORD
- 1 - XFS_RTHIBIT(wdiff
);
193 *rtblock
= start
- i
+ 1;
198 * Go on to previous block if that's where the previous word is
199 * and we need the previous word.
201 if (--word
== -1 && i
< len
) {
203 * If done with this block, get the previous one.
205 xfs_trans_brelse(tp
, bp
);
206 error
= xfs_rtbuf_get(mp
, tp
, --block
, 0, &bp
);
211 word
= XFS_BLOCKWMASK(mp
);
215 * Go on to the previous word in the buffer.
221 * If not ending on a word boundary, deal with the last
226 * Calculate first (leftmost) bit number to look at,
227 * and mask for all the relevant bits in this word.
229 firstbit
= XFS_NBWORD
- (len
- i
);
230 mask
= (((xfs_rtword_t
)1 << (len
- i
)) - 1) << firstbit
;
232 * Compute difference between actual and desired value.
234 if ((wdiff
= (*b
^ want
) & mask
)) {
236 * Different, mark where we are and return.
238 xfs_trans_brelse(tp
, bp
);
239 i
+= XFS_NBWORD
- 1 - XFS_RTHIBIT(wdiff
);
240 *rtblock
= start
- i
+ 1;
246 * No match, return that we scanned the whole area.
248 xfs_trans_brelse(tp
, bp
);
249 *rtblock
= start
- i
+ 1;
254 * Searching forward from start to limit, find the first block whose
255 * allocated/free state is different from start's.
259 xfs_mount_t
*mp
, /* file system mount point */
260 xfs_trans_t
*tp
, /* transaction pointer */
261 xfs_rtblock_t start
, /* starting block to look at */
262 xfs_rtblock_t limit
, /* last block to look at */
263 xfs_rtblock_t
*rtblock
) /* out: start block found */
265 xfs_rtword_t
*b
; /* current word in buffer */
266 int bit
; /* bit number in the word */
267 xfs_rtblock_t block
; /* bitmap block number */
268 xfs_buf_t
*bp
; /* buf for the block */
269 xfs_rtword_t
*bufp
; /* starting word in buffer */
270 int error
; /* error value */
271 xfs_rtblock_t i
; /* current bit number rel. to start */
272 xfs_rtblock_t lastbit
; /* last useful bit in the word */
273 xfs_rtblock_t len
; /* length of inspected area */
274 xfs_rtword_t mask
; /* mask of relevant bits for value */
275 xfs_rtword_t want
; /* mask for "good" values */
276 xfs_rtword_t wdiff
; /* difference from wanted value */
277 int word
; /* word number in the buffer */
280 * Compute and read in starting bitmap block for starting block.
282 block
= XFS_BITTOBLOCK(mp
, start
);
283 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
289 * Get the first word's index & point to it.
291 word
= XFS_BITTOWORD(mp
, start
);
293 bit
= (int)(start
& (XFS_NBWORD
- 1));
294 len
= limit
- start
+ 1;
296 * Compute match value, based on the bit at start: if 1 (free)
297 * then all-ones, else all-zeroes.
299 want
= (*b
& ((xfs_rtword_t
)1 << bit
)) ? -1 : 0;
301 * If the starting position is not word-aligned, deal with the
306 * Calculate last (rightmost) bit number to look at,
307 * and mask for all the relevant bits in this word.
309 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
310 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
312 * Calculate the difference between the value there
313 * and what we're looking for.
315 if ((wdiff
= (*b
^ want
) & mask
)) {
317 * Different. Mark where we are and return.
319 xfs_trans_brelse(tp
, bp
);
320 i
= XFS_RTLOBIT(wdiff
) - bit
;
321 *rtblock
= start
+ i
- 1;
326 * Go on to next block if that's where the next word is
327 * and we need the next word.
329 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
331 * If done with this block, get the previous one.
333 xfs_trans_brelse(tp
, bp
);
334 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
338 b
= bufp
= bp
->b_addr
;
342 * Go on to the previous word in the buffer.
348 * Starting on a word boundary, no partial word.
353 * Loop over whole words in buffers. When we use up one buffer
354 * we move on to the next one.
356 while (len
- i
>= XFS_NBWORD
) {
358 * Compute difference between actual and desired value.
360 if ((wdiff
= *b
^ want
)) {
362 * Different, mark where we are and return.
364 xfs_trans_brelse(tp
, bp
);
365 i
+= XFS_RTLOBIT(wdiff
);
366 *rtblock
= start
+ i
- 1;
371 * Go on to next block if that's where the next word is
372 * and we need the next word.
374 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
376 * If done with this block, get the next one.
378 xfs_trans_brelse(tp
, bp
);
379 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
383 b
= bufp
= bp
->b_addr
;
387 * Go on to the next word in the buffer.
393 * If not ending on a word boundary, deal with the last
396 if ((lastbit
= len
- i
)) {
398 * Calculate mask for all the relevant bits in this word.
400 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
402 * Compute difference between actual and desired value.
404 if ((wdiff
= (*b
^ want
) & mask
)) {
406 * Different, mark where we are and return.
408 xfs_trans_brelse(tp
, bp
);
409 i
+= XFS_RTLOBIT(wdiff
);
410 *rtblock
= start
+ i
- 1;
416 * No match, return that we scanned the whole area.
418 xfs_trans_brelse(tp
, bp
);
419 *rtblock
= start
+ i
- 1;
424 * Read and/or modify the summary information for a given extent size,
425 * bitmap block combination.
426 * Keeps track of a current summary block, so we don't keep reading
427 * it from the buffer cache.
429 * Summary information is returned in *sum if specified.
430 * If no delta is specified, returns summary only.
433 xfs_rtmodify_summary_int(
434 xfs_mount_t
*mp
, /* file system mount structure */
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 */
441 xfs_suminfo_t
*sum
) /* out: summary info for this block */
443 xfs_buf_t
*bp
; /* buffer for the summary block */
444 int error
; /* error value */
445 xfs_fsblock_t sb
; /* summary fsblock */
446 int so
; /* index into the summary file */
447 xfs_suminfo_t
*sp
; /* pointer to returned data */
450 * Compute entry number in the summary file.
452 so
= XFS_SUMOFFS(mp
, log
, bbno
);
454 * Compute the block number in the summary file.
456 sb
= XFS_SUMOFFSTOBLOCK(mp
, so
);
458 * If we have an old buffer, and the block number matches, use that.
460 if (*rbpp
&& *rsb
== sb
)
463 * Otherwise we have to get the buffer.
467 * If there was an old one, get rid of it first.
470 xfs_trans_brelse(tp
, *rbpp
);
471 error
= xfs_rtbuf_get(mp
, tp
, sb
, 1, &bp
);
476 * Remember this buffer and block for the next call.
482 * Point to the summary information, modify/log it, and/or copy it out.
484 sp
= XFS_SUMPTR(mp
, bp
, so
);
486 uint first
= (uint
)((char *)sp
- (char *)bp
->b_addr
);
489 xfs_trans_log_buf(tp
, bp
, first
, first
+ sizeof(*sp
) - 1);
497 xfs_rtmodify_summary(
498 xfs_mount_t
*mp
, /* file system mount structure */
499 xfs_trans_t
*tp
, /* transaction pointer */
500 int log
, /* log2 of extent size */
501 xfs_rtblock_t bbno
, /* bitmap block number */
502 int delta
, /* change to make to summary info */
503 xfs_buf_t
**rbpp
, /* in/out: summary block buffer */
504 xfs_fsblock_t
*rsb
) /* in/out: summary block number */
506 return xfs_rtmodify_summary_int(mp
, tp
, log
, bbno
,
507 delta
, rbpp
, rsb
, NULL
);
511 * Set the given range of bitmap bits to the given value.
512 * Do whatever I/O and logging is required.
516 xfs_mount_t
*mp
, /* file system mount point */
517 xfs_trans_t
*tp
, /* transaction pointer */
518 xfs_rtblock_t start
, /* starting block to modify */
519 xfs_extlen_t len
, /* length of extent to modify */
520 int val
) /* 1 for free, 0 for allocated */
522 xfs_rtword_t
*b
; /* current word in buffer */
523 int bit
; /* bit number in the word */
524 xfs_rtblock_t block
; /* bitmap block number */
525 xfs_buf_t
*bp
; /* buf for the block */
526 xfs_rtword_t
*bufp
; /* starting word in buffer */
527 int error
; /* error value */
528 xfs_rtword_t
*first
; /* first used word in the buffer */
529 int i
; /* current bit number rel. to start */
530 int lastbit
; /* last useful bit in word */
531 xfs_rtword_t mask
; /* mask o frelevant bits for value */
532 int word
; /* word number in the buffer */
535 * Compute starting bitmap block number.
537 block
= XFS_BITTOBLOCK(mp
, start
);
539 * Read the bitmap block, and point to its data.
541 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
547 * Compute the starting word's address, and starting bit.
549 word
= XFS_BITTOWORD(mp
, start
);
550 first
= b
= &bufp
[word
];
551 bit
= (int)(start
& (XFS_NBWORD
- 1));
553 * 0 (allocated) => all zeroes; 1 (free) => all ones.
557 * If not starting on a word boundary, deal with the first
562 * Compute first bit not changed and mask of relevant bits.
564 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
565 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
567 * Set/clear the active bits.
575 * Go on to the next block if that's where the next word is
576 * and we need the next word.
578 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
580 * Log the changed part of this block.
583 xfs_trans_log_buf(tp
, bp
,
584 (uint
)((char *)first
- (char *)bufp
),
585 (uint
)((char *)b
- (char *)bufp
));
586 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
590 first
= b
= bufp
= bp
->b_addr
;
594 * Go on to the next word in the buffer
600 * Starting on a word boundary, no partial word.
605 * Loop over whole words in buffers. When we use up one buffer
606 * we move on to the next one.
608 while (len
- i
>= XFS_NBWORD
) {
610 * Set the word value correctly.
615 * Go on to the next block if that's where the next word is
616 * and we need the next word.
618 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
620 * Log the changed part of this block.
623 xfs_trans_log_buf(tp
, bp
,
624 (uint
)((char *)first
- (char *)bufp
),
625 (uint
)((char *)b
- (char *)bufp
));
626 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
630 first
= b
= bufp
= bp
->b_addr
;
634 * Go on to the next word in the buffer
640 * If not ending on a word boundary, deal with the last
643 if ((lastbit
= len
- i
)) {
645 * Compute a mask of relevant bits.
648 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
650 * Set/clear the active bits.
659 * Log any remaining changed bytes.
662 xfs_trans_log_buf(tp
, bp
, (uint
)((char *)first
- (char *)bufp
),
663 (uint
)((char *)b
- (char *)bufp
- 1));
668 * Mark an extent specified by start and len freed.
669 * Updates all the summary information as well as the bitmap.
673 xfs_mount_t
*mp
, /* file system mount point */
674 xfs_trans_t
*tp
, /* transaction pointer */
675 xfs_rtblock_t start
, /* starting block to free */
676 xfs_extlen_t len
, /* length to free */
677 xfs_buf_t
**rbpp
, /* in/out: summary block buffer */
678 xfs_fsblock_t
*rsb
) /* in/out: summary block number */
680 xfs_rtblock_t end
; /* end of the freed extent */
681 int error
; /* error value */
682 xfs_rtblock_t postblock
; /* first block freed > end */
683 xfs_rtblock_t preblock
; /* first block freed < start */
685 end
= start
+ len
- 1;
687 * Modify the bitmap to mark this extent freed.
689 error
= xfs_rtmodify_range(mp
, tp
, start
, len
, 1);
694 * Assume we're freeing out of the middle of an allocated extent.
695 * We need to find the beginning and end of the extent so we can
696 * properly update the summary.
698 error
= xfs_rtfind_back(mp
, tp
, start
, 0, &preblock
);
703 * Find the next allocated block (end of allocated extent).
705 error
= xfs_rtfind_forw(mp
, tp
, end
, mp
->m_sb
.sb_rextents
- 1,
710 * If there are blocks not being freed at the front of the
711 * old extent, add summary data for them to be allocated.
713 if (preblock
< start
) {
714 error
= xfs_rtmodify_summary(mp
, tp
,
715 XFS_RTBLOCKLOG(start
- preblock
),
716 XFS_BITTOBLOCK(mp
, preblock
), -1, rbpp
, rsb
);
722 * If there are blocks not being freed at the end of the
723 * old extent, add summary data for them to be allocated.
725 if (postblock
> end
) {
726 error
= xfs_rtmodify_summary(mp
, tp
,
727 XFS_RTBLOCKLOG(postblock
- end
),
728 XFS_BITTOBLOCK(mp
, end
+ 1), -1, rbpp
, rsb
);
734 * Increment the summary information corresponding to the entire
737 error
= xfs_rtmodify_summary(mp
, tp
,
738 XFS_RTBLOCKLOG(postblock
+ 1 - preblock
),
739 XFS_BITTOBLOCK(mp
, preblock
), 1, rbpp
, rsb
);
744 * Check that the given range is either all allocated (val = 0) or
745 * all free (val = 1).
749 xfs_mount_t
*mp
, /* file system mount point */
750 xfs_trans_t
*tp
, /* transaction pointer */
751 xfs_rtblock_t start
, /* starting block number of extent */
752 xfs_extlen_t len
, /* length of extent */
753 int val
, /* 1 for free, 0 for allocated */
754 xfs_rtblock_t
*new, /* out: first block not matching */
755 int *stat
) /* out: 1 for matches, 0 for not */
757 xfs_rtword_t
*b
; /* current word in buffer */
758 int bit
; /* bit number in the word */
759 xfs_rtblock_t block
; /* bitmap block number */
760 xfs_buf_t
*bp
; /* buf for the block */
761 xfs_rtword_t
*bufp
; /* starting word in buffer */
762 int error
; /* error value */
763 xfs_rtblock_t i
; /* current bit number rel. to start */
764 xfs_rtblock_t lastbit
; /* last useful bit in word */
765 xfs_rtword_t mask
; /* mask of relevant bits for value */
766 xfs_rtword_t wdiff
; /* difference from wanted value */
767 int word
; /* word number in the buffer */
770 * Compute starting bitmap block number
772 block
= XFS_BITTOBLOCK(mp
, start
);
774 * Read the bitmap block.
776 error
= xfs_rtbuf_get(mp
, tp
, block
, 0, &bp
);
782 * Compute the starting word's address, and starting bit.
784 word
= XFS_BITTOWORD(mp
, start
);
786 bit
= (int)(start
& (XFS_NBWORD
- 1));
788 * 0 (allocated) => all zero's; 1 (free) => all one's.
792 * If not starting on a word boundary, deal with the first
797 * Compute first bit not examined.
799 lastbit
= XFS_RTMIN(bit
+ len
, XFS_NBWORD
);
801 * Mask of relevant bits.
803 mask
= (((xfs_rtword_t
)1 << (lastbit
- bit
)) - 1) << bit
;
805 * Compute difference between actual and desired value.
807 if ((wdiff
= (*b
^ val
) & mask
)) {
809 * Different, compute first wrong bit and return.
811 xfs_trans_brelse(tp
, bp
);
812 i
= XFS_RTLOBIT(wdiff
) - bit
;
819 * Go on to next block if that's where the next word is
820 * and we need the next word.
822 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
824 * If done with this block, get the next one.
826 xfs_trans_brelse(tp
, bp
);
827 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
831 b
= bufp
= bp
->b_addr
;
835 * Go on to the next word in the buffer.
841 * Starting on a word boundary, no partial word.
846 * Loop over whole words in buffers. When we use up one buffer
847 * we move on to the next one.
849 while (len
- i
>= XFS_NBWORD
) {
851 * Compute difference between actual and desired value.
853 if ((wdiff
= *b
^ val
)) {
855 * Different, compute first wrong bit and return.
857 xfs_trans_brelse(tp
, bp
);
858 i
+= XFS_RTLOBIT(wdiff
);
865 * Go on to next block if that's where the next word is
866 * and we need the next word.
868 if (++word
== XFS_BLOCKWSIZE(mp
) && i
< len
) {
870 * If done with this block, get the next one.
872 xfs_trans_brelse(tp
, bp
);
873 error
= xfs_rtbuf_get(mp
, tp
, ++block
, 0, &bp
);
877 b
= bufp
= bp
->b_addr
;
881 * Go on to the next word in the buffer.
887 * If not ending on a word boundary, deal with the last
890 if ((lastbit
= len
- i
)) {
892 * Mask of relevant bits.
894 mask
= ((xfs_rtword_t
)1 << lastbit
) - 1;
896 * Compute difference between actual and desired value.
898 if ((wdiff
= (*b
^ val
) & mask
)) {
900 * Different, compute first wrong bit and return.
902 xfs_trans_brelse(tp
, bp
);
903 i
+= XFS_RTLOBIT(wdiff
);
911 * Successful, return.
913 xfs_trans_brelse(tp
, bp
);
921 * Check that the given extent (block range) is allocated already.
923 STATIC
int /* error */
924 xfs_rtcheck_alloc_range(
925 xfs_mount_t
*mp
, /* file system mount point */
926 xfs_trans_t
*tp
, /* transaction pointer */
927 xfs_rtblock_t bno
, /* starting block number of extent */
928 xfs_extlen_t len
) /* length of extent */
930 xfs_rtblock_t
new; /* dummy for xfs_rtcheck_range */
934 error
= xfs_rtcheck_range(mp
, tp
, bno
, len
, 0, &new, &stat
);
941 #define xfs_rtcheck_alloc_range(m,t,b,l) (0)
944 * Free an extent in the realtime subvolume. Length is expressed in
945 * realtime extents, as is the block number.
949 xfs_trans_t
*tp
, /* transaction pointer */
950 xfs_rtblock_t bno
, /* starting block number to free */
951 xfs_extlen_t len
) /* length of extent freed */
953 int error
; /* error value */
954 xfs_mount_t
*mp
; /* file system mount structure */
955 xfs_fsblock_t sb
; /* summary file block number */
956 xfs_buf_t
*sumbp
= NULL
; /* summary file block buffer */
960 ASSERT(mp
->m_rbmip
->i_itemp
!= NULL
);
961 ASSERT(xfs_isilocked(mp
->m_rbmip
, XFS_ILOCK_EXCL
));
963 error
= xfs_rtcheck_alloc_range(mp
, tp
, bno
, len
);
968 * Free the range of realtime blocks.
970 error
= xfs_rtfree_range(mp
, tp
, bno
, len
, &sumbp
, &sb
);
975 * Mark more blocks free in the superblock.
977 xfs_trans_mod_sb(tp
, XFS_TRANS_SB_FREXTENTS
, (long)len
);
979 * If we've now freed all the blocks, reset the file sequence
982 if (tp
->t_frextents_delta
+ mp
->m_sb
.sb_frextents
==
983 mp
->m_sb
.sb_rextents
) {
984 if (!(mp
->m_rbmip
->i_d
.di_flags
& XFS_DIFLAG_NEWRTBM
))
985 mp
->m_rbmip
->i_d
.di_flags
|= XFS_DIFLAG_NEWRTBM
;
986 *(__uint64_t
*)&mp
->m_rbmip
->i_d
.di_atime
= 0;
987 xfs_trans_log_inode(tp
, mp
->m_rbmip
, XFS_ILOG_CORE
);
This page took 0.071528 seconds and 5 git commands to generate.