Lines Matching +full:exact +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0
30 * Lookup the first record less than or equal to [bno, len, owner, offset]
46 cur->bc_rec.r.rm_startblock = bno; in xfs_rmap_lookup_le()
47 cur->bc_rec.r.rm_blockcount = 0; in xfs_rmap_lookup_le()
48 cur->bc_rec.r.rm_owner = owner; in xfs_rmap_lookup_le()
49 cur->bc_rec.r.rm_offset = offset; in xfs_rmap_lookup_le()
50 cur->bc_rec.r.rm_flags = flags; in xfs_rmap_lookup_le()
60 return -EFSCORRUPTED; in xfs_rmap_lookup_le()
66 * Lookup the record exactly matching [bno, len, owner, offset]
73 xfs_extlen_t len, in xfs_rmap_lookup_eq() argument
79 cur->bc_rec.r.rm_startblock = bno; in xfs_rmap_lookup_eq()
80 cur->bc_rec.r.rm_blockcount = len; in xfs_rmap_lookup_eq()
81 cur->bc_rec.r.rm_owner = owner; in xfs_rmap_lookup_eq()
82 cur->bc_rec.r.rm_offset = offset; in xfs_rmap_lookup_eq()
83 cur->bc_rec.r.rm_flags = flags; in xfs_rmap_lookup_eq()
89 * by [bno, len, owner, offset].
100 trace_xfs_rmap_update(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_update()
101 irec->rm_startblock, irec->rm_blockcount, in xfs_rmap_update()
102 irec->rm_owner, irec->rm_offset, irec->rm_flags); in xfs_rmap_update()
104 rec.rmap.rm_startblock = cpu_to_be32(irec->rm_startblock); in xfs_rmap_update()
105 rec.rmap.rm_blockcount = cpu_to_be32(irec->rm_blockcount); in xfs_rmap_update()
106 rec.rmap.rm_owner = cpu_to_be64(irec->rm_owner); in xfs_rmap_update()
111 trace_xfs_rmap_update_error(cur->bc_mp, in xfs_rmap_update()
112 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_update()
120 xfs_extlen_t len, in xfs_rmap_insert() argument
128 trace_xfs_rmap_insert(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, in xfs_rmap_insert()
129 len, owner, offset, flags); in xfs_rmap_insert()
131 error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); in xfs_rmap_insert()
134 if (XFS_IS_CORRUPT(rcur->bc_mp, i != 0)) { in xfs_rmap_insert()
135 error = -EFSCORRUPTED; in xfs_rmap_insert()
139 rcur->bc_rec.r.rm_startblock = agbno; in xfs_rmap_insert()
140 rcur->bc_rec.r.rm_blockcount = len; in xfs_rmap_insert()
141 rcur->bc_rec.r.rm_owner = owner; in xfs_rmap_insert()
142 rcur->bc_rec.r.rm_offset = offset; in xfs_rmap_insert()
143 rcur->bc_rec.r.rm_flags = flags; in xfs_rmap_insert()
147 if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { in xfs_rmap_insert()
148 error = -EFSCORRUPTED; in xfs_rmap_insert()
153 trace_xfs_rmap_insert_error(rcur->bc_mp, in xfs_rmap_insert()
154 rcur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_insert()
162 xfs_extlen_t len, in xfs_rmap_delete() argument
170 trace_xfs_rmap_delete(rcur->bc_mp, rcur->bc_ag.pag->pag_agno, agbno, in xfs_rmap_delete()
171 len, owner, offset, flags); in xfs_rmap_delete()
173 error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); in xfs_rmap_delete()
176 if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { in xfs_rmap_delete()
177 error = -EFSCORRUPTED; in xfs_rmap_delete()
184 if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { in xfs_rmap_delete()
185 error = -EFSCORRUPTED; in xfs_rmap_delete()
190 trace_xfs_rmap_delete_error(rcur->bc_mp, in xfs_rmap_delete()
191 rcur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_delete()
201 irec->rm_startblock = be32_to_cpu(rec->rmap.rm_startblock); in xfs_rmap_btrec_to_irec()
202 irec->rm_blockcount = be32_to_cpu(rec->rmap.rm_blockcount); in xfs_rmap_btrec_to_irec()
203 irec->rm_owner = be64_to_cpu(rec->rmap.rm_owner); in xfs_rmap_btrec_to_irec()
204 return xfs_rmap_irec_offset_unpack(be64_to_cpu(rec->rmap.rm_offset), in xfs_rmap_btrec_to_irec()
214 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_check_irec()
220 if (irec->rm_blockcount == 0) in xfs_rmap_check_irec()
222 if (irec->rm_startblock <= XFS_AGFL_BLOCK(mp)) { in xfs_rmap_check_irec()
223 if (irec->rm_owner != XFS_RMAP_OWN_FS) in xfs_rmap_check_irec()
225 if (irec->rm_blockcount != XFS_AGFL_BLOCK(mp) + 1) in xfs_rmap_check_irec()
229 if (!xfs_verify_agbext(cur->bc_ag.pag, irec->rm_startblock, in xfs_rmap_check_irec()
230 irec->rm_blockcount)) in xfs_rmap_check_irec()
234 if (!(xfs_verify_ino(mp, irec->rm_owner) || in xfs_rmap_check_irec()
235 (irec->rm_owner <= XFS_RMAP_OWN_FS && in xfs_rmap_check_irec()
236 irec->rm_owner >= XFS_RMAP_OWN_MIN))) in xfs_rmap_check_irec()
240 is_inode = !XFS_RMAP_NON_INODE_OWNER(irec->rm_owner); in xfs_rmap_check_irec()
241 is_bmbt = irec->rm_flags & XFS_RMAP_BMBT_BLOCK; in xfs_rmap_check_irec()
242 is_attr = irec->rm_flags & XFS_RMAP_ATTR_FORK; in xfs_rmap_check_irec()
243 is_unwritten = irec->rm_flags & XFS_RMAP_UNWRITTEN; in xfs_rmap_check_irec()
245 if (is_bmbt && irec->rm_offset != 0) in xfs_rmap_check_irec()
248 if (!is_inode && irec->rm_offset != 0) in xfs_rmap_check_irec()
259 !xfs_verify_fileext(mp, irec->rm_offset, irec->rm_blockcount)) in xfs_rmap_check_irec()
271 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_complain_bad_rec()
275 cur->bc_ag.pag->pag_agno, fa); in xfs_rmap_complain_bad_rec()
278 irec->rm_owner, irec->rm_flags, irec->rm_startblock, in xfs_rmap_complain_bad_rec()
279 irec->rm_blockcount); in xfs_rmap_complain_bad_rec()
280 return -EFSCORRUPTED; in xfs_rmap_complain_bad_rec()
284 * Get the data from the pointed-to record.
323 trace_xfs_rmap_find_left_neighbor_candidate(cur->bc_mp, in xfs_rmap_find_left_neighbor_helper()
324 cur->bc_ag.pag->pag_agno, rec->rm_startblock, in xfs_rmap_find_left_neighbor_helper()
325 rec->rm_blockcount, rec->rm_owner, rec->rm_offset, in xfs_rmap_find_left_neighbor_helper()
326 rec->rm_flags); in xfs_rmap_find_left_neighbor_helper()
328 if (rec->rm_owner != info->high.rm_owner) in xfs_rmap_find_left_neighbor_helper()
330 if (!XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) && in xfs_rmap_find_left_neighbor_helper()
331 !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK) && in xfs_rmap_find_left_neighbor_helper()
332 rec->rm_offset + rec->rm_blockcount - 1 != info->high.rm_offset) in xfs_rmap_find_left_neighbor_helper()
335 *info->irec = *rec; in xfs_rmap_find_left_neighbor_helper()
336 return -ECANCELED; in xfs_rmap_find_left_neighbor_helper()
361 info.high.rm_startblock = bno - 1; in xfs_rmap_find_left_neighbor()
367 info.high.rm_offset = offset - 1; in xfs_rmap_find_left_neighbor()
374 trace_xfs_rmap_find_left_neighbor_query(cur->bc_mp, in xfs_rmap_find_left_neighbor()
375 cur->bc_ag.pag->pag_agno, bno, 0, owner, offset, flags); in xfs_rmap_find_left_neighbor()
384 * produce correct results -- if the index contains a record that is an in xfs_rmap_find_left_neighbor()
385 * exact match for the lookup key; and if there are no other records in xfs_rmap_find_left_neighbor()
388 * As an optimization, try a non-overlapped lookup first. This makes in xfs_rmap_find_left_neighbor()
402 if (error != -ECANCELED) in xfs_rmap_find_left_neighbor()
406 trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, in xfs_rmap_find_left_neighbor()
407 cur->bc_ag.pag->pag_agno, irec->rm_startblock, in xfs_rmap_find_left_neighbor()
408 irec->rm_blockcount, irec->rm_owner, irec->rm_offset, in xfs_rmap_find_left_neighbor()
409 irec->rm_flags); in xfs_rmap_find_left_neighbor()
422 trace_xfs_rmap_lookup_le_range_candidate(cur->bc_mp, in xfs_rmap_lookup_le_range_helper()
423 cur->bc_ag.pag->pag_agno, rec->rm_startblock, in xfs_rmap_lookup_le_range_helper()
424 rec->rm_blockcount, rec->rm_owner, rec->rm_offset, in xfs_rmap_lookup_le_range_helper()
425 rec->rm_flags); in xfs_rmap_lookup_le_range_helper()
427 if (rec->rm_owner != info->high.rm_owner) in xfs_rmap_lookup_le_range_helper()
429 if (!XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) && in xfs_rmap_lookup_le_range_helper()
430 !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK) && in xfs_rmap_lookup_le_range_helper()
431 (rec->rm_offset > info->high.rm_offset || in xfs_rmap_lookup_le_range_helper()
432 rec->rm_offset + rec->rm_blockcount <= info->high.rm_offset)) in xfs_rmap_lookup_le_range_helper()
435 *info->irec = *rec; in xfs_rmap_lookup_le_range_helper()
436 return -ECANCELED; in xfs_rmap_lookup_le_range_helper()
442 * block ranges. This is the overlapping-interval version of
470 trace_xfs_rmap_lookup_le_range(cur->bc_mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_lookup_le_range()
480 * produce correct results -- if the index contains a record that is an in xfs_rmap_lookup_le_range()
481 * exact match for the lookup key; and if there are no other records in xfs_rmap_lookup_le_range()
484 * As an optimization, try a non-overlapped lookup first. This makes in xfs_rmap_lookup_le_range()
486 * usually an exact match for rmap records. If we don't find what we in xfs_rmap_lookup_le_range()
498 if (error != -ECANCELED) in xfs_rmap_lookup_le_range()
502 trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, in xfs_rmap_lookup_le_range()
503 cur->bc_ag.pag->pag_agno, irec->rm_startblock, in xfs_rmap_lookup_le_range()
504 irec->rm_blockcount, irec->rm_owner, irec->rm_offset, in xfs_rmap_lookup_le_range()
505 irec->rm_flags); in xfs_rmap_lookup_le_range()
511 * unknown-owner removal then we have no owner information to check.
518 xfs_filblks_t len, in xfs_rmap_free_check_owner() argument
531 (rec->rm_flags & XFS_RMAP_UNWRITTEN))) { in xfs_rmap_free_check_owner()
532 error = -EFSCORRUPTED; in xfs_rmap_free_check_owner()
537 if (XFS_IS_CORRUPT(mp, owner != rec->rm_owner)) { in xfs_rmap_free_check_owner()
538 error = -EFSCORRUPTED; in xfs_rmap_free_check_owner()
548 !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK))) { in xfs_rmap_free_check_owner()
549 error = -EFSCORRUPTED; in xfs_rmap_free_check_owner()
553 if (XFS_IS_CORRUPT(mp, rec->rm_offset > offset)) { in xfs_rmap_free_check_owner()
554 error = -EFSCORRUPTED; in xfs_rmap_free_check_owner()
558 offset + len > ltoff + rec->rm_blockcount)) { in xfs_rmap_free_check_owner()
559 error = -EFSCORRUPTED; in xfs_rmap_free_check_owner()
571 * The record we find should always be an exact match for the extent that we're
578 * extent. We verify that - the extent lookup result in a record that does not
590 xfs_extlen_t len, in xfs_rmap_unmap() argument
594 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_unmap()
609 trace_xfs_rmap_unmap(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_unmap()
621 error = -EFSCORRUPTED; in xfs_rmap_unmap()
625 trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, in xfs_rmap_unmap()
626 cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, in xfs_rmap_unmap()
642 error = -EFSCORRUPTED; in xfs_rmap_unmap()
649 * If we're doing an unknown-owner removal for EFI recovery, we expect in xfs_rmap_unmap()
668 error = -EFSCORRUPTED; in xfs_rmap_unmap()
671 if (rtrec.rm_startblock >= bno + len) in xfs_rmap_unmap()
679 bno + len)) { in xfs_rmap_unmap()
680 error = -EFSCORRUPTED; in xfs_rmap_unmap()
685 error = xfs_rmap_free_check_owner(mp, ltoff, <rec, len, owner, in xfs_rmap_unmap()
690 if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) { in xfs_rmap_unmap()
691 /* exact match, simply remove the record from rmap tree */ in xfs_rmap_unmap()
692 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_unmap()
700 error = -EFSCORRUPTED; in xfs_rmap_unmap()
712 * bno len in xfs_rmap_unmap()
714 ltrec.rm_startblock += len; in xfs_rmap_unmap()
715 ltrec.rm_blockcount -= len; in xfs_rmap_unmap()
717 ltrec.rm_offset += len; in xfs_rmap_unmap()
721 } else if (ltrec.rm_startblock + ltrec.rm_blockcount == bno + len) { in xfs_rmap_unmap()
730 * bno len in xfs_rmap_unmap()
732 ltrec.rm_blockcount -= len; in xfs_rmap_unmap()
740 * record to the length of the new left-extent size, increment in xfs_rmap_unmap()
742 * containing the remaining right-extent space. in xfs_rmap_unmap()
748 * bno len in xfs_rmap_unmap()
752 ltrec.rm_blockcount = bno - ltrec.rm_startblock; in xfs_rmap_unmap()
761 cur->bc_rec.r.rm_startblock = bno + len; in xfs_rmap_unmap()
762 cur->bc_rec.r.rm_blockcount = orig_len - len - in xfs_rmap_unmap()
764 cur->bc_rec.r.rm_owner = ltrec.rm_owner; in xfs_rmap_unmap()
766 cur->bc_rec.r.rm_offset = 0; in xfs_rmap_unmap()
768 cur->bc_rec.r.rm_offset = offset + len; in xfs_rmap_unmap()
769 cur->bc_rec.r.rm_flags = flags; in xfs_rmap_unmap()
770 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_unmap()
771 cur->bc_rec.r.rm_startblock, in xfs_rmap_unmap()
772 cur->bc_rec.r.rm_blockcount, in xfs_rmap_unmap()
773 cur->bc_rec.r.rm_owner, in xfs_rmap_unmap()
774 cur->bc_rec.r.rm_offset, in xfs_rmap_unmap()
775 cur->bc_rec.r.rm_flags); in xfs_rmap_unmap()
782 trace_xfs_rmap_unmap_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_unmap()
786 trace_xfs_rmap_unmap_error(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_unmap()
800 xfs_extlen_t len, in xfs_rmap_free() argument
803 struct xfs_mount *mp = tp->t_mountp; in xfs_rmap_free()
812 error = xfs_rmap_unmap(cur, bno, len, false, oinfo); in xfs_rmap_free()
829 if (irec->rm_owner == XFS_RMAP_OWN_NULL) in xfs_rmap_is_mergeable()
831 if (irec->rm_owner != owner) in xfs_rmap_is_mergeable()
834 (irec->rm_flags & XFS_RMAP_UNWRITTEN)) in xfs_rmap_is_mergeable()
837 (irec->rm_flags & XFS_RMAP_ATTR_FORK)) in xfs_rmap_is_mergeable()
840 (irec->rm_flags & XFS_RMAP_BMBT_BLOCK)) in xfs_rmap_is_mergeable()
855 xfs_extlen_t len, in xfs_rmap_map() argument
859 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_map()
877 trace_xfs_rmap_map(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_map()
882 * For the initial lookup, look for an exact match or the left-adjacent in xfs_rmap_map()
891 trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, in xfs_rmap_map()
892 cur->bc_ag.pag->pag_agno, ltrec.rm_startblock, in xfs_rmap_map()
903 error = -EFSCORRUPTED; in xfs_rmap_map()
908 * Increment the cursor to see if we have a right-adjacent record to our in xfs_rmap_map()
920 error = -EFSCORRUPTED; in xfs_rmap_map()
923 if (XFS_IS_CORRUPT(mp, bno + len > gtrec.rm_startblock)) { in xfs_rmap_map()
924 error = -EFSCORRUPTED; in xfs_rmap_map()
927 trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, in xfs_rmap_map()
928 cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, in xfs_rmap_map()
949 * bno len in xfs_rmap_map()
951 ltrec.rm_blockcount += len; in xfs_rmap_map()
953 bno + len == gtrec.rm_startblock && in xfs_rmap_map()
954 (ignore_off || offset + len == gtrec.rm_offset) && in xfs_rmap_map()
955 (unsigned long)ltrec.rm_blockcount + len + in xfs_rmap_map()
967 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_map()
977 error = -EFSCORRUPTED; in xfs_rmap_map()
990 bno + len == gtrec.rm_startblock && in xfs_rmap_map()
991 (ignore_off || offset + len == gtrec.rm_offset)) { in xfs_rmap_map()
999 * bno len in xfs_rmap_map()
1002 gtrec.rm_blockcount += len; in xfs_rmap_map()
1013 cur->bc_rec.r.rm_startblock = bno; in xfs_rmap_map()
1014 cur->bc_rec.r.rm_blockcount = len; in xfs_rmap_map()
1015 cur->bc_rec.r.rm_owner = owner; in xfs_rmap_map()
1016 cur->bc_rec.r.rm_offset = offset; in xfs_rmap_map()
1017 cur->bc_rec.r.rm_flags = flags; in xfs_rmap_map()
1018 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_map()
1024 error = -EFSCORRUPTED; in xfs_rmap_map()
1029 trace_xfs_rmap_map_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_map()
1033 trace_xfs_rmap_map_error(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_map()
1047 xfs_extlen_t len, in xfs_rmap_alloc() argument
1050 struct xfs_mount *mp = tp->t_mountp; in xfs_rmap_alloc()
1058 error = xfs_rmap_map(cur, bno, len, false, oinfo); in xfs_rmap_alloc()
1084 xfs_extlen_t len, in xfs_rmap_convert() argument
1088 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_convert()
1106 new_endoff = offset + len; in xfs_rmap_convert()
1107 trace_xfs_rmap_convert(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_convert()
1111 * For the initial lookup, look for an exact match or the left-adjacent in xfs_rmap_convert()
1119 error = -EFSCORRUPTED; in xfs_rmap_convert()
1123 trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, in xfs_rmap_convert()
1124 cur->bc_ag.pag->pag_agno, PREV.rm_startblock, in xfs_rmap_convert()
1143 * Decrement the cursor to see if we have a left-adjacent record to our in xfs_rmap_convert()
1156 error = -EFSCORRUPTED; in xfs_rmap_convert()
1162 error = -EFSCORRUPTED; in xfs_rmap_convert()
1165 trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, in xfs_rmap_convert()
1166 cur->bc_ag.pag->pag_agno, LEFT.rm_startblock, in xfs_rmap_convert()
1176 * Increment the cursor to see if we have a right-adjacent record to our in xfs_rmap_convert()
1184 error = -EFSCORRUPTED; in xfs_rmap_convert()
1196 error = -EFSCORRUPTED; in xfs_rmap_convert()
1199 if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { in xfs_rmap_convert()
1200 error = -EFSCORRUPTED; in xfs_rmap_convert()
1203 trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, in xfs_rmap_convert()
1204 cur->bc_ag.pag->pag_agno, RIGHT.rm_startblock, in xfs_rmap_convert()
1207 if (bno + len == RIGHT.rm_startblock && in xfs_rmap_convert()
1208 offset + len == RIGHT.rm_offset && in xfs_rmap_convert()
1218 (unsigned long)LEFT.rm_blockcount + len + in xfs_rmap_convert()
1222 trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state, in xfs_rmap_convert()
1230 error = -EFSCORRUPTED; in xfs_rmap_convert()
1249 error = -EFSCORRUPTED; in xfs_rmap_convert()
1252 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_convert()
1260 error = -EFSCORRUPTED; in xfs_rmap_convert()
1267 error = -EFSCORRUPTED; in xfs_rmap_convert()
1270 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_convert()
1278 error = -EFSCORRUPTED; in xfs_rmap_convert()
1285 error = -EFSCORRUPTED; in xfs_rmap_convert()
1300 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_convert()
1308 error = -EFSCORRUPTED; in xfs_rmap_convert()
1315 error = -EFSCORRUPTED; in xfs_rmap_convert()
1334 error = -EFSCORRUPTED; in xfs_rmap_convert()
1337 trace_xfs_rmap_delete(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_convert()
1345 error = -EFSCORRUPTED; in xfs_rmap_convert()
1352 error = -EFSCORRUPTED; in xfs_rmap_convert()
1356 NEW.rm_blockcount = len + RIGHT.rm_blockcount; in xfs_rmap_convert()
1382 NEW.rm_offset += len; in xfs_rmap_convert()
1383 NEW.rm_startblock += len; in xfs_rmap_convert()
1384 NEW.rm_blockcount -= len; in xfs_rmap_convert()
1392 NEW.rm_blockcount += len; in xfs_rmap_convert()
1404 NEW.rm_startblock += len; in xfs_rmap_convert()
1405 NEW.rm_offset += len; in xfs_rmap_convert()
1406 NEW.rm_blockcount -= len; in xfs_rmap_convert()
1413 NEW.rm_blockcount = len; in xfs_rmap_convert()
1415 cur->bc_rec.r = NEW; in xfs_rmap_convert()
1416 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, in xfs_rmap_convert()
1417 len, owner, offset, newext); in xfs_rmap_convert()
1422 error = -EFSCORRUPTED; in xfs_rmap_convert()
1433 NEW.rm_blockcount -= len; in xfs_rmap_convert()
1443 NEW.rm_blockcount += len; in xfs_rmap_convert()
1455 NEW.rm_blockcount -= len; in xfs_rmap_convert()
1459 error = xfs_rmap_lookup_eq(cur, bno, len, owner, offset, in xfs_rmap_convert()
1464 error = -EFSCORRUPTED; in xfs_rmap_convert()
1470 NEW.rm_blockcount = len; in xfs_rmap_convert()
1472 cur->bc_rec.r = NEW; in xfs_rmap_convert()
1473 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, in xfs_rmap_convert()
1474 len, owner, offset, newext); in xfs_rmap_convert()
1479 error = -EFSCORRUPTED; in xfs_rmap_convert()
1490 /* new right extent - oldext */ in xfs_rmap_convert()
1491 NEW.rm_startblock = bno + len; in xfs_rmap_convert()
1494 NEW.rm_blockcount = PREV.rm_offset + PREV.rm_blockcount - in xfs_rmap_convert()
1500 /* new left extent - oldext */ in xfs_rmap_convert()
1502 NEW.rm_blockcount = offset - PREV.rm_offset; in xfs_rmap_convert()
1503 cur->bc_rec.r = NEW; in xfs_rmap_convert()
1504 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, in xfs_rmap_convert()
1512 error = -EFSCORRUPTED; in xfs_rmap_convert()
1520 error = xfs_rmap_lookup_eq(cur, bno, len, owner, offset, in xfs_rmap_convert()
1525 error = -EFSCORRUPTED; in xfs_rmap_convert()
1528 /* new middle extent - newext */ in xfs_rmap_convert()
1529 cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN; in xfs_rmap_convert()
1530 cur->bc_rec.r.rm_flags |= newext; in xfs_rmap_convert()
1531 trace_xfs_rmap_insert(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_convert()
1537 error = -EFSCORRUPTED; in xfs_rmap_convert()
1555 trace_xfs_rmap_convert_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_convert()
1559 trace_xfs_rmap_convert_error(cur->bc_mp, in xfs_rmap_convert()
1560 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_convert()
1573 xfs_extlen_t len, in xfs_rmap_convert_shared() argument
1577 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_convert_shared()
1595 new_endoff = offset + len; in xfs_rmap_convert_shared()
1596 trace_xfs_rmap_convert(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_convert_shared()
1600 * For the initial lookup, look for and exact match or the left-adjacent in xfs_rmap_convert_shared()
1609 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1637 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1645 error = xfs_rmap_lookup_eq(cur, bno + len, len, owner, offset + len, in xfs_rmap_convert_shared()
1655 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1658 if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { in xfs_rmap_convert_shared()
1659 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1662 trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, in xfs_rmap_convert_shared()
1663 cur->bc_ag.pag->pag_agno, RIGHT.rm_startblock, in xfs_rmap_convert_shared()
1675 (unsigned long)LEFT.rm_blockcount + len + in xfs_rmap_convert_shared()
1679 trace_xfs_rmap_convert_state(mp, cur->bc_ag.pag->pag_agno, state, in xfs_rmap_convert_shared()
1709 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1735 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1761 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1784 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1804 NEW.rm_offset += len; in xfs_rmap_convert_shared()
1805 NEW.rm_startblock += len; in xfs_rmap_convert_shared()
1806 NEW.rm_blockcount -= len; in xfs_rmap_convert_shared()
1819 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1822 NEW.rm_blockcount += len; in xfs_rmap_convert_shared()
1839 NEW.rm_offset += len; in xfs_rmap_convert_shared()
1840 NEW.rm_startblock += len; in xfs_rmap_convert_shared()
1841 NEW.rm_blockcount -= len; in xfs_rmap_convert_shared()
1847 error = xfs_rmap_insert(cur, bno, len, owner, offset, newext); in xfs_rmap_convert_shared()
1864 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1867 NEW.rm_blockcount = offset - NEW.rm_offset; in xfs_rmap_convert_shared()
1879 NEW.rm_blockcount += len; in xfs_rmap_convert_shared()
1899 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1902 NEW.rm_blockcount -= len; in xfs_rmap_convert_shared()
1906 error = xfs_rmap_insert(cur, bno, len, owner, offset, newext); in xfs_rmap_convert_shared()
1917 /* new right extent - oldext */ in xfs_rmap_convert_shared()
1918 NEW.rm_startblock = bno + len; in xfs_rmap_convert_shared()
1921 NEW.rm_blockcount = PREV.rm_offset + PREV.rm_blockcount - in xfs_rmap_convert_shared()
1929 /* new left extent - oldext */ in xfs_rmap_convert_shared()
1937 error = -EFSCORRUPTED; in xfs_rmap_convert_shared()
1940 NEW.rm_blockcount = offset - NEW.rm_offset; in xfs_rmap_convert_shared()
1944 /* new middle extent - newext */ in xfs_rmap_convert_shared()
1946 NEW.rm_blockcount = len; in xfs_rmap_convert_shared()
1970 trace_xfs_rmap_convert_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_convert_shared()
1974 trace_xfs_rmap_convert_error(cur->bc_mp, in xfs_rmap_convert_shared()
1975 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_convert_shared()
1997 xfs_extlen_t len, in xfs_rmap_unmap_shared() argument
2001 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_unmap_shared()
2013 trace_xfs_rmap_unmap(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_unmap_shared()
2026 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2035 bno + len)) { in xfs_rmap_unmap_shared()
2036 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2042 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2050 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2056 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2060 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2064 if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) { in xfs_rmap_unmap_shared()
2065 /* Exact match, simply remove the record from rmap tree. */ in xfs_rmap_unmap_shared()
2080 * bno len in xfs_rmap_unmap_shared()
2091 ltrec.rm_startblock += len; in xfs_rmap_unmap_shared()
2092 ltrec.rm_blockcount -= len; in xfs_rmap_unmap_shared()
2093 ltrec.rm_offset += len; in xfs_rmap_unmap_shared()
2099 } else if (ltrec.rm_startblock + ltrec.rm_blockcount == bno + len) { in xfs_rmap_unmap_shared()
2108 * bno len in xfs_rmap_unmap_shared()
2116 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2119 ltrec.rm_blockcount -= len; in xfs_rmap_unmap_shared()
2126 * record to the length of the new left-extent size, increment in xfs_rmap_unmap_shared()
2128 * containing the remaining right-extent space. in xfs_rmap_unmap_shared()
2134 * bno len in xfs_rmap_unmap_shared()
2145 error = -EFSCORRUPTED; in xfs_rmap_unmap_shared()
2148 ltrec.rm_blockcount = bno - ltrec.rm_startblock; in xfs_rmap_unmap_shared()
2154 error = xfs_rmap_insert(cur, bno + len, in xfs_rmap_unmap_shared()
2155 orig_len - len - ltrec.rm_blockcount, in xfs_rmap_unmap_shared()
2156 ltrec.rm_owner, offset + len, in xfs_rmap_unmap_shared()
2162 trace_xfs_rmap_unmap_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_unmap_shared()
2166 trace_xfs_rmap_unmap_error(cur->bc_mp, in xfs_rmap_unmap_shared()
2167 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_unmap_shared()
2184 xfs_extlen_t len, in xfs_rmap_map_shared() argument
2188 struct xfs_mount *mp = cur->bc_mp; in xfs_rmap_map_shared()
2202 trace_xfs_rmap_map(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_map_shared()
2215 error = xfs_rmap_lookup_eq(cur, bno + len, len, owner, offset + len, in xfs_rmap_map_shared()
2224 error = -EFSCORRUPTED; in xfs_rmap_map_shared()
2227 trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, in xfs_rmap_map_shared()
2228 cur->bc_ag.pag->pag_agno, gtrec.rm_startblock, in xfs_rmap_map_shared()
2246 * bno len in xfs_rmap_map_shared()
2248 ltrec.rm_blockcount += len; in xfs_rmap_map_shared()
2250 bno + len == gtrec.rm_startblock && in xfs_rmap_map_shared()
2251 offset + len == gtrec.rm_offset) { in xfs_rmap_map_shared()
2276 error = -EFSCORRUPTED; in xfs_rmap_map_shared()
2284 bno + len == gtrec.rm_startblock && in xfs_rmap_map_shared()
2285 offset + len == gtrec.rm_offset) { in xfs_rmap_map_shared()
2293 * bno len in xfs_rmap_map_shared()
2302 /* Move the start and re-add it. */ in xfs_rmap_map_shared()
2304 gtrec.rm_blockcount += len; in xfs_rmap_map_shared()
2316 error = xfs_rmap_insert(cur, bno, len, owner, offset, flags); in xfs_rmap_map_shared()
2321 trace_xfs_rmap_map_done(mp, cur->bc_ag.pag->pag_agno, bno, len, in xfs_rmap_map_shared()
2325 trace_xfs_rmap_map_error(cur->bc_mp, in xfs_rmap_map_shared()
2326 cur->bc_ag.pag->pag_agno, error, _RET_IP_); in xfs_rmap_map_shared()
2338 oinfo.oi_owner = rmap->rm_owner; in xfs_rmap_map_raw()
2339 oinfo.oi_offset = rmap->rm_offset; in xfs_rmap_map_raw()
2341 if (rmap->rm_flags & XFS_RMAP_ATTR_FORK) in xfs_rmap_map_raw()
2343 if (rmap->rm_flags & XFS_RMAP_BMBT_BLOCK) in xfs_rmap_map_raw()
2346 if (rmap->rm_flags || XFS_RMAP_NON_INODE_OWNER(rmap->rm_owner)) in xfs_rmap_map_raw()
2347 return xfs_rmap_map(cur, rmap->rm_startblock, in xfs_rmap_map_raw()
2348 rmap->rm_blockcount, in xfs_rmap_map_raw()
2349 rmap->rm_flags & XFS_RMAP_UNWRITTEN, in xfs_rmap_map_raw()
2352 return xfs_rmap_map_shared(cur, rmap->rm_startblock, in xfs_rmap_map_raw()
2353 rmap->rm_blockcount, in xfs_rmap_map_raw()
2354 rmap->rm_flags & XFS_RMAP_UNWRITTEN, in xfs_rmap_map_raw()
2380 return query->fn(cur, &irec, query->priv); in xfs_rmap_query_range_helper()
2425 agbp = rcur->bc_ag.agbp; in xfs_rmap_finish_one_cleanup()
2444 struct xfs_mount *mp = tp->t_mountp; in xfs_rmap_finish_one()
2452 bno = XFS_FSB_TO_AGBNO(mp, ri->ri_bmap.br_startblock); in xfs_rmap_finish_one()
2454 trace_xfs_rmap_deferred(mp, ri->ri_pag->pag_agno, ri->ri_type, bno, in xfs_rmap_finish_one()
2455 ri->ri_owner, ri->ri_whichfork, in xfs_rmap_finish_one()
2456 ri->ri_bmap.br_startoff, ri->ri_bmap.br_blockcount, in xfs_rmap_finish_one()
2457 ri->ri_bmap.br_state); in xfs_rmap_finish_one()
2460 return -EIO; in xfs_rmap_finish_one()
2467 if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) { in xfs_rmap_finish_one()
2478 error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp); in xfs_rmap_finish_one()
2481 if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) in xfs_rmap_finish_one()
2482 return -EFSCORRUPTED; in xfs_rmap_finish_one()
2484 rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag); in xfs_rmap_finish_one()
2488 xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork, in xfs_rmap_finish_one()
2489 ri->ri_bmap.br_startoff); in xfs_rmap_finish_one()
2490 unwritten = ri->ri_bmap.br_state == XFS_EXT_UNWRITTEN; in xfs_rmap_finish_one()
2491 bno = XFS_FSB_TO_AGBNO(rcur->bc_mp, ri->ri_bmap.br_startblock); in xfs_rmap_finish_one()
2493 switch (ri->ri_type) { in xfs_rmap_finish_one()
2496 error = xfs_rmap_map(rcur, bno, ri->ri_bmap.br_blockcount, in xfs_rmap_finish_one()
2501 ri->ri_bmap.br_blockcount, unwritten, &oinfo); in xfs_rmap_finish_one()
2505 error = xfs_rmap_unmap(rcur, bno, ri->ri_bmap.br_blockcount, in xfs_rmap_finish_one()
2510 ri->ri_bmap.br_blockcount, unwritten, &oinfo); in xfs_rmap_finish_one()
2513 error = xfs_rmap_convert(rcur, bno, ri->ri_bmap.br_blockcount, in xfs_rmap_finish_one()
2518 ri->ri_bmap.br_blockcount, !unwritten, &oinfo); in xfs_rmap_finish_one()
2522 error = -EFSCORRUPTED; in xfs_rmap_finish_one()
2553 trace_xfs_rmap_defer(tp->t_mountp, in __xfs_rmap_add()
2554 XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock), in __xfs_rmap_add()
2556 XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock), in __xfs_rmap_add()
2558 bmap->br_startoff, in __xfs_rmap_add()
2559 bmap->br_blockcount, in __xfs_rmap_add()
2560 bmap->br_state); in __xfs_rmap_add()
2563 INIT_LIST_HEAD(&ri->ri_list); in __xfs_rmap_add()
2564 ri->ri_type = type; in __xfs_rmap_add()
2565 ri->ri_owner = owner; in __xfs_rmap_add()
2566 ri->ri_whichfork = whichfork; in __xfs_rmap_add()
2567 ri->ri_bmap = *bmap; in __xfs_rmap_add()
2569 xfs_rmap_update_get_group(tp->t_mountp, ri); in __xfs_rmap_add()
2570 xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type); in __xfs_rmap_add()
2583 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) in xfs_rmap_map_extent()
2589 __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); in xfs_rmap_map_extent()
2602 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) in xfs_rmap_unmap_extent()
2608 __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); in xfs_rmap_unmap_extent()
2633 __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); in xfs_rmap_convert_extent()
2636 /* Schedule the creation of an rmap for non-file data. */
2642 xfs_extlen_t len, in xfs_rmap_alloc_extent() argument
2647 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) in xfs_rmap_alloc_extent()
2650 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); in xfs_rmap_alloc_extent()
2651 bmap.br_blockcount = len; in xfs_rmap_alloc_extent()
2658 /* Schedule the deletion of an rmap for non-file data. */
2664 xfs_extlen_t len, in xfs_rmap_free_extent() argument
2669 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) in xfs_rmap_free_extent()
2672 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); in xfs_rmap_free_extent()
2673 bmap.br_blockcount = len; in xfs_rmap_free_extent()
2680 /* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */
2692 if (a->rm_startblock < b->rm_startblock) in xfs_rmap_compare()
2693 return -1; in xfs_rmap_compare()
2694 else if (a->rm_startblock > b->rm_startblock) in xfs_rmap_compare()
2696 else if (a->rm_owner < b->rm_owner) in xfs_rmap_compare()
2697 return -1; in xfs_rmap_compare()
2698 else if (a->rm_owner > b->rm_owner) in xfs_rmap_compare()
2701 return -1; in xfs_rmap_compare()
2717 xfs_extlen_t len, in xfs_rmap_has_records() argument
2721 .rmap.rm_startblock = cpu_to_be32(-1U), in xfs_rmap_has_records()
2729 high.r.rm_startblock = bno + len - 1; in xfs_rmap_has_records()
2756 if (XFS_RMAP_NON_INODE_OWNER(rmap->rm_owner)) in xfs_rmap_shareable()
2758 if (rmap->rm_flags & (XFS_RMAP_ATTR_FORK | in xfs_rmap_shareable()
2768 xfs_extlen_t len, in xfs_rmap_ownercount_init() argument
2773 roc->results = results; in xfs_rmap_ownercount_init()
2775 roc->low.rm_startblock = bno; in xfs_rmap_ownercount_init()
2776 memset(&roc->high, 0xFF, sizeof(roc->high)); in xfs_rmap_ownercount_init()
2777 roc->high.rm_startblock = bno + len - 1; in xfs_rmap_ownercount_init()
2780 roc->good.rm_startblock = bno; in xfs_rmap_ownercount_init()
2781 roc->good.rm_blockcount = len; in xfs_rmap_ownercount_init()
2782 roc->good.rm_owner = oinfo->oi_owner; in xfs_rmap_ownercount_init()
2783 roc->good.rm_offset = oinfo->oi_offset; in xfs_rmap_ownercount_init()
2784 if (oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK) in xfs_rmap_ownercount_init()
2785 roc->good.rm_flags |= XFS_RMAP_ATTR_FORK; in xfs_rmap_ownercount_init()
2786 if (oinfo->oi_flags & XFS_OWNER_INFO_BMBT_BLOCK) in xfs_rmap_ownercount_init()
2787 roc->good.rm_flags |= XFS_RMAP_BMBT_BLOCK; in xfs_rmap_ownercount_init()
2807 delta = (int64_t)roc->good.rm_startblock - check.rm_startblock; in xfs_rmap_count_owners_helper()
2810 check.rm_blockcount -= delta; in xfs_rmap_count_owners_helper()
2816 delta = (check.rm_startblock + check.rm_blockcount) - in xfs_rmap_count_owners_helper()
2817 (roc->good.rm_startblock + roc->good.rm_blockcount); in xfs_rmap_count_owners_helper()
2819 check.rm_blockcount -= delta; in xfs_rmap_count_owners_helper()
2824 if (check.rm_startblock == roc->good.rm_startblock && in xfs_rmap_count_owners_helper()
2825 check.rm_blockcount == roc->good.rm_blockcount && in xfs_rmap_count_owners_helper()
2826 check.rm_owner == roc->good.rm_owner && in xfs_rmap_count_owners_helper()
2827 check.rm_offset == roc->good.rm_offset && in xfs_rmap_count_owners_helper()
2828 keyflags == roc->good.rm_flags) { in xfs_rmap_count_owners_helper()
2829 roc->results->matches++; in xfs_rmap_count_owners_helper()
2831 roc->results->non_owner_matches++; in xfs_rmap_count_owners_helper()
2832 if (xfs_rmap_shareable(cur->bc_mp, &roc->good) ^ in xfs_rmap_count_owners_helper()
2833 xfs_rmap_shareable(cur->bc_mp, &check)) in xfs_rmap_count_owners_helper()
2834 roc->results->bad_non_owner_matches++; in xfs_rmap_count_owners_helper()
2837 if (roc->results->non_owner_matches && roc->stop_on_nonmatch) in xfs_rmap_count_owners_helper()
2838 return -ECANCELED; in xfs_rmap_count_owners_helper()
2843 /* Count the number of owners and non-owners of this range of blocks. */
2848 xfs_extlen_t len, in xfs_rmap_count_owners() argument
2855 xfs_rmap_ownercount_init(&roc, bno, len, oinfo, results); in xfs_rmap_count_owners()
2862 * There can't be any non-owner rmaps that conflict with the given in xfs_rmap_count_owners()
2865 if (!results->matches) in xfs_rmap_count_owners()
2866 results->bad_non_owner_matches = 0; in xfs_rmap_count_owners()
2879 xfs_extlen_t len, in xfs_rmap_has_other_keys() argument
2887 xfs_rmap_ownercount_init(&roc, bno, len, oinfo, &res); in xfs_rmap_has_other_keys()
2892 if (error == -ECANCELED) { in xfs_rmap_has_other_keys()
2938 return xfs_rmap_intent_cache != NULL ? 0 : -ENOMEM; in xfs_rmap_intent_init_cache()