Lines Matching refs:rl

60 static inline runlist_element *ntfs_rl_realloc(runlist_element *rl,  in ntfs_rl_realloc()  argument
65 old_size = PAGE_ALIGN(old_size * sizeof(*rl)); in ntfs_rl_realloc()
66 new_size = PAGE_ALIGN(new_size * sizeof(*rl)); in ntfs_rl_realloc()
68 return rl; in ntfs_rl_realloc()
74 if (likely(rl != NULL)) { in ntfs_rl_realloc()
77 memcpy(new_rl, rl, old_size); in ntfs_rl_realloc()
78 ntfs_free(rl); in ntfs_rl_realloc()
106 static inline runlist_element *ntfs_rl_realloc_nofail(runlist_element *rl, in ntfs_rl_realloc_nofail() argument
111 old_size = PAGE_ALIGN(old_size * sizeof(*rl)); in ntfs_rl_realloc_nofail()
112 new_size = PAGE_ALIGN(new_size * sizeof(*rl)); in ntfs_rl_realloc_nofail()
114 return rl; in ntfs_rl_realloc_nofail()
119 if (likely(rl != NULL)) { in ntfs_rl_realloc_nofail()
122 memcpy(new_rl, rl, old_size); in ntfs_rl_realloc_nofail()
123 ntfs_free(rl); in ntfs_rl_realloc_nofail()
741 runlist_element *rl; /* The output runlist. */ in ntfs_mapping_pairs_decompress() local
774 rl = ntfs_malloc_nofs(rlsize = PAGE_SIZE); in ntfs_mapping_pairs_decompress()
775 if (unlikely(!rl)) in ntfs_mapping_pairs_decompress()
779 rl->vcn = 0; in ntfs_mapping_pairs_decompress()
780 rl->lcn = LCN_RL_NOT_MAPPED; in ntfs_mapping_pairs_decompress()
781 rl->length = vcn; in ntfs_mapping_pairs_decompress()
795 ntfs_free(rl); in ntfs_mapping_pairs_decompress()
798 memcpy(rl2, rl, rlsize); in ntfs_mapping_pairs_decompress()
799 ntfs_free(rl); in ntfs_mapping_pairs_decompress()
800 rl = rl2; in ntfs_mapping_pairs_decompress()
804 rl[rlpos].vcn = vcn; in ntfs_mapping_pairs_decompress()
836 rl[rlpos].length = deltaxcn; in ntfs_mapping_pairs_decompress()
845 rl[rlpos].lcn = LCN_HOLE; in ntfs_mapping_pairs_decompress()
878 rl[rlpos].lcn = lcn; in ntfs_mapping_pairs_decompress()
924 rl[rlpos].vcn = vcn; in ntfs_mapping_pairs_decompress()
925 vcn += rl[rlpos].length = max_cluster - in ntfs_mapping_pairs_decompress()
927 rl[rlpos].lcn = LCN_RL_NOT_MAPPED; in ntfs_mapping_pairs_decompress()
939 rl[rlpos].lcn = LCN_ENOENT; in ntfs_mapping_pairs_decompress()
941 rl[rlpos].lcn = LCN_RL_NOT_MAPPED; in ntfs_mapping_pairs_decompress()
944 rl[rlpos].vcn = vcn; in ntfs_mapping_pairs_decompress()
945 rl[rlpos].length = (s64)0; in ntfs_mapping_pairs_decompress()
949 ntfs_debug_dump_runlist(rl); in ntfs_mapping_pairs_decompress()
950 return rl; in ntfs_mapping_pairs_decompress()
953 old_rl = ntfs_runlists_merge(old_rl, rl); in ntfs_mapping_pairs_decompress()
956 ntfs_free(rl); in ntfs_mapping_pairs_decompress()
962 ntfs_free(rl); in ntfs_mapping_pairs_decompress()
990 LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn) in ntfs_rl_vcn_to_lcn() argument
1000 if (unlikely(!rl)) in ntfs_rl_vcn_to_lcn()
1004 if (unlikely(vcn < rl[0].vcn)) in ntfs_rl_vcn_to_lcn()
1007 for (i = 0; likely(rl[i].length); i++) { in ntfs_rl_vcn_to_lcn()
1008 if (unlikely(vcn < rl[i+1].vcn)) { in ntfs_rl_vcn_to_lcn()
1009 if (likely(rl[i].lcn >= (LCN)0)) in ntfs_rl_vcn_to_lcn()
1010 return rl[i].lcn + (vcn - rl[i].vcn); in ntfs_rl_vcn_to_lcn()
1011 return rl[i].lcn; in ntfs_rl_vcn_to_lcn()
1018 if (likely(rl[i].lcn < (LCN)0)) in ntfs_rl_vcn_to_lcn()
1019 return rl[i].lcn; in ntfs_rl_vcn_to_lcn()
1039 runlist_element *ntfs_rl_find_vcn_nolock(runlist_element *rl, const VCN vcn) in ntfs_rl_find_vcn_nolock() argument
1042 if (unlikely(!rl || vcn < rl[0].vcn)) in ntfs_rl_find_vcn_nolock()
1044 while (likely(rl->length)) { in ntfs_rl_find_vcn_nolock()
1045 if (unlikely(vcn < rl[1].vcn)) { in ntfs_rl_find_vcn_nolock()
1046 if (likely(rl->lcn >= LCN_HOLE)) in ntfs_rl_find_vcn_nolock()
1047 return rl; in ntfs_rl_find_vcn_nolock()
1050 rl++; in ntfs_rl_find_vcn_nolock()
1052 if (likely(rl->lcn == LCN_ENOENT)) in ntfs_rl_find_vcn_nolock()
1053 return rl; in ntfs_rl_find_vcn_nolock()
1118 const runlist_element *rl, const VCN first_vcn, in ntfs_get_size_for_mapping_pairs() argument
1128 if (!rl) { in ntfs_get_size_for_mapping_pairs()
1134 while (rl->length && first_vcn >= rl[1].vcn) in ntfs_get_size_for_mapping_pairs()
1135 rl++; in ntfs_get_size_for_mapping_pairs()
1136 if (unlikely((!rl->length && first_vcn > rl->vcn) || in ntfs_get_size_for_mapping_pairs()
1137 first_vcn < rl->vcn)) in ntfs_get_size_for_mapping_pairs()
1143 if (first_vcn > rl->vcn) { in ntfs_get_size_for_mapping_pairs()
1144 s64 delta, length = rl->length; in ntfs_get_size_for_mapping_pairs()
1147 if (unlikely(length < 0 || rl->lcn < LCN_HOLE)) in ntfs_get_size_for_mapping_pairs()
1153 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) { in ntfs_get_size_for_mapping_pairs()
1155 if (unlikely(rl[1].vcn > s1)) in ntfs_get_size_for_mapping_pairs()
1156 length = s1 - rl->vcn; in ntfs_get_size_for_mapping_pairs()
1159 delta = first_vcn - rl->vcn; in ntfs_get_size_for_mapping_pairs()
1169 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) { in ntfs_get_size_for_mapping_pairs()
1170 prev_lcn = rl->lcn; in ntfs_get_size_for_mapping_pairs()
1171 if (likely(rl->lcn >= 0)) in ntfs_get_size_for_mapping_pairs()
1177 rl++; in ntfs_get_size_for_mapping_pairs()
1180 for (; rl->length && !the_end; rl++) { in ntfs_get_size_for_mapping_pairs()
1181 s64 length = rl->length; in ntfs_get_size_for_mapping_pairs()
1183 if (unlikely(length < 0 || rl->lcn < LCN_HOLE)) in ntfs_get_size_for_mapping_pairs()
1189 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) { in ntfs_get_size_for_mapping_pairs()
1191 if (unlikely(rl[1].vcn > s1)) in ntfs_get_size_for_mapping_pairs()
1192 length = s1 - rl->vcn; in ntfs_get_size_for_mapping_pairs()
1204 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) { in ntfs_get_size_for_mapping_pairs()
1206 rls += ntfs_get_nr_significant_bytes(rl->lcn - in ntfs_get_size_for_mapping_pairs()
1208 prev_lcn = rl->lcn; in ntfs_get_size_for_mapping_pairs()
1213 if (rl->lcn == LCN_RL_NOT_MAPPED) in ntfs_get_size_for_mapping_pairs()
1310 const int dst_len, const runlist_element *rl, in ntfs_mapping_pairs_build() argument
1323 if (!rl) { in ntfs_mapping_pairs_build()
1333 while (rl->length && first_vcn >= rl[1].vcn) in ntfs_mapping_pairs_build()
1334 rl++; in ntfs_mapping_pairs_build()
1335 if (unlikely((!rl->length && first_vcn > rl->vcn) || in ntfs_mapping_pairs_build()
1336 first_vcn < rl->vcn)) in ntfs_mapping_pairs_build()
1345 if (first_vcn > rl->vcn) { in ntfs_mapping_pairs_build()
1346 s64 delta, length = rl->length; in ntfs_mapping_pairs_build()
1349 if (unlikely(length < 0 || rl->lcn < LCN_HOLE)) in ntfs_mapping_pairs_build()
1355 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) { in ntfs_mapping_pairs_build()
1357 if (unlikely(rl[1].vcn > s1)) in ntfs_mapping_pairs_build()
1358 length = s1 - rl->vcn; in ntfs_mapping_pairs_build()
1361 delta = first_vcn - rl->vcn; in ntfs_mapping_pairs_build()
1376 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) { in ntfs_mapping_pairs_build()
1377 prev_lcn = rl->lcn; in ntfs_mapping_pairs_build()
1378 if (likely(rl->lcn >= 0)) in ntfs_mapping_pairs_build()
1395 rl++; in ntfs_mapping_pairs_build()
1398 for (; rl->length && !the_end; rl++) { in ntfs_mapping_pairs_build()
1399 s64 length = rl->length; in ntfs_mapping_pairs_build()
1401 if (unlikely(length < 0 || rl->lcn < LCN_HOLE)) in ntfs_mapping_pairs_build()
1407 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) { in ntfs_mapping_pairs_build()
1409 if (unlikely(rl[1].vcn > s1)) in ntfs_mapping_pairs_build()
1410 length = s1 - rl->vcn; in ntfs_mapping_pairs_build()
1427 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) { in ntfs_mapping_pairs_build()
1430 len_len, dst_max, rl->lcn - prev_lcn); in ntfs_mapping_pairs_build()
1433 prev_lcn = rl->lcn; in ntfs_mapping_pairs_build()
1449 *stop_vcn = rl->vcn; in ntfs_mapping_pairs_build()
1454 if (rl->lcn == LCN_RL_NOT_MAPPED) in ntfs_mapping_pairs_build()
1488 runlist_element *rl; in ntfs_rl_truncate_nolock() local
1494 rl = runlist->rl; in ntfs_rl_truncate_nolock()
1497 runlist->rl = NULL; in ntfs_rl_truncate_nolock()
1498 if (rl) in ntfs_rl_truncate_nolock()
1499 ntfs_free(rl); in ntfs_rl_truncate_nolock()
1502 if (unlikely(!rl)) { in ntfs_rl_truncate_nolock()
1507 rl = ntfs_malloc_nofs(PAGE_SIZE); in ntfs_rl_truncate_nolock()
1508 if (unlikely(!rl)) { in ntfs_rl_truncate_nolock()
1513 runlist->rl = rl; in ntfs_rl_truncate_nolock()
1514 rl[1].length = rl->vcn = 0; in ntfs_rl_truncate_nolock()
1515 rl->lcn = LCN_HOLE; in ntfs_rl_truncate_nolock()
1516 rl[1].vcn = rl->length = new_length; in ntfs_rl_truncate_nolock()
1517 rl[1].lcn = LCN_ENOENT; in ntfs_rl_truncate_nolock()
1520 BUG_ON(new_length < rl->vcn); in ntfs_rl_truncate_nolock()
1522 while (likely(rl->length && new_length >= rl[1].vcn)) in ntfs_rl_truncate_nolock()
1523 rl++; in ntfs_rl_truncate_nolock()
1528 if (rl->length) { in ntfs_rl_truncate_nolock()
1534 trl = rl + 1; in ntfs_rl_truncate_nolock()
1537 old_size = trl - runlist->rl + 1; in ntfs_rl_truncate_nolock()
1539 rl->length = new_length - rl->vcn; in ntfs_rl_truncate_nolock()
1545 if (rl->length) { in ntfs_rl_truncate_nolock()
1546 rl++; in ntfs_rl_truncate_nolock()
1547 if (!rl->length) in ntfs_rl_truncate_nolock()
1549 rl->vcn = new_length; in ntfs_rl_truncate_nolock()
1550 rl->length = 0; in ntfs_rl_truncate_nolock()
1552 rl->lcn = LCN_ENOENT; in ntfs_rl_truncate_nolock()
1555 int new_size = rl - runlist->rl + 1; in ntfs_rl_truncate_nolock()
1556 rl = ntfs_rl_realloc(runlist->rl, old_size, new_size); in ntfs_rl_truncate_nolock()
1557 if (IS_ERR(rl)) in ntfs_rl_truncate_nolock()
1564 runlist->rl = rl; in ntfs_rl_truncate_nolock()
1566 } else if (likely(/* !rl->length && */ new_length > rl->vcn)) { in ntfs_rl_truncate_nolock()
1573 if ((rl > runlist->rl) && ((rl - 1)->lcn == LCN_HOLE)) in ntfs_rl_truncate_nolock()
1574 (rl - 1)->length = new_length - (rl - 1)->vcn; in ntfs_rl_truncate_nolock()
1577 old_size = rl - runlist->rl + 1; in ntfs_rl_truncate_nolock()
1579 rl = ntfs_rl_realloc(runlist->rl, old_size, in ntfs_rl_truncate_nolock()
1581 if (IS_ERR(rl)) { in ntfs_rl_truncate_nolock()
1584 return PTR_ERR(rl); in ntfs_rl_truncate_nolock()
1586 runlist->rl = rl; in ntfs_rl_truncate_nolock()
1591 rl += old_size - 1; in ntfs_rl_truncate_nolock()
1593 rl->lcn = LCN_HOLE; in ntfs_rl_truncate_nolock()
1594 rl->length = new_length - rl->vcn; in ntfs_rl_truncate_nolock()
1596 rl++; in ntfs_rl_truncate_nolock()
1597 rl->length = 0; in ntfs_rl_truncate_nolock()
1599 rl->vcn = new_length; in ntfs_rl_truncate_nolock()
1600 rl->lcn = LCN_ENOENT; in ntfs_rl_truncate_nolock()
1603 rl->lcn = LCN_ENOENT; in ntfs_rl_truncate_nolock()
1635 runlist_element *rl, *rl_end, *rl_real_end, *trl; in ntfs_rl_punch_nolock() local
1645 rl = runlist->rl; in ntfs_rl_punch_nolock()
1646 if (unlikely(!rl)) { in ntfs_rl_punch_nolock()
1652 while (likely(rl->length && start >= rl[1].vcn)) in ntfs_rl_punch_nolock()
1653 rl++; in ntfs_rl_punch_nolock()
1654 rl_end = rl; in ntfs_rl_punch_nolock()
1670 if (!rl->length) in ntfs_rl_punch_nolock()
1676 old_size = rl_real_end - runlist->rl + 1; in ntfs_rl_punch_nolock()
1678 if (rl->lcn == LCN_HOLE) { in ntfs_rl_punch_nolock()
1683 if (end <= rl[1].vcn) { in ntfs_rl_punch_nolock()
1689 rl->length = end - rl->vcn; in ntfs_rl_punch_nolock()
1693 rl->length = rl_end->vcn - rl->vcn; in ntfs_rl_punch_nolock()
1696 rl++; in ntfs_rl_punch_nolock()
1698 if (rl < rl_end) in ntfs_rl_punch_nolock()
1699 memmove(rl, rl_end, (rl_real_end - rl_end + 1) * in ntfs_rl_punch_nolock()
1700 sizeof(*rl)); in ntfs_rl_punch_nolock()
1702 if (end > rl->vcn) { in ntfs_rl_punch_nolock()
1703 delta = end - rl->vcn; in ntfs_rl_punch_nolock()
1704 rl->vcn = end; in ntfs_rl_punch_nolock()
1705 rl->length -= delta; in ntfs_rl_punch_nolock()
1707 if (rl->lcn >= 0) in ntfs_rl_punch_nolock()
1708 rl->lcn += delta; in ntfs_rl_punch_nolock()
1712 if (rl < rl_end) { in ntfs_rl_punch_nolock()
1713 rl = ntfs_rl_realloc(runlist->rl, old_size, in ntfs_rl_punch_nolock()
1714 old_size - (rl_end - rl)); in ntfs_rl_punch_nolock()
1715 if (IS_ERR(rl)) in ntfs_rl_punch_nolock()
1722 runlist->rl = rl; in ntfs_rl_punch_nolock()
1731 if (start == rl->vcn) { in ntfs_rl_punch_nolock()
1743 if (rl > runlist->rl && (rl - 1)->lcn == LCN_HOLE) { in ntfs_rl_punch_nolock()
1744 rl--; in ntfs_rl_punch_nolock()
1747 if (end >= rl[1].vcn) { in ntfs_rl_punch_nolock()
1748 rl->lcn = LCN_HOLE; in ntfs_rl_punch_nolock()
1758 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1); in ntfs_rl_punch_nolock()
1762 if (runlist->rl != trl) { in ntfs_rl_punch_nolock()
1763 rl = trl + (rl - runlist->rl); in ntfs_rl_punch_nolock()
1764 rl_end = trl + (rl_end - runlist->rl); in ntfs_rl_punch_nolock()
1765 rl_real_end = trl + (rl_real_end - runlist->rl); in ntfs_rl_punch_nolock()
1766 runlist->rl = trl; in ntfs_rl_punch_nolock()
1770 memmove(rl + 1, rl, (rl_real_end - rl + 1) * sizeof(*rl)); in ntfs_rl_punch_nolock()
1772 rl->lcn = LCN_HOLE; in ntfs_rl_punch_nolock()
1773 rl->length = length; in ntfs_rl_punch_nolock()
1774 rl++; in ntfs_rl_punch_nolock()
1775 rl->vcn += length; in ntfs_rl_punch_nolock()
1777 if (rl->lcn >= 0 || lcn_fixup) in ntfs_rl_punch_nolock()
1778 rl->lcn += length; in ntfs_rl_punch_nolock()
1779 rl->length -= length; in ntfs_rl_punch_nolock()
1793 rl->length = start - rl->vcn; in ntfs_rl_punch_nolock()
1794 rl++; in ntfs_rl_punch_nolock()
1796 if (rl < rl_end) in ntfs_rl_punch_nolock()
1797 memmove(rl, rl_end, (rl_real_end - rl_end + 1) * in ntfs_rl_punch_nolock()
1798 sizeof(*rl)); in ntfs_rl_punch_nolock()
1800 rl->vcn = start; in ntfs_rl_punch_nolock()
1801 rl->length = rl[1].vcn - start; in ntfs_rl_punch_nolock()
1815 if (end >= rl[1].vcn) { in ntfs_rl_punch_nolock()
1820 if (rl[1].length && end >= rl[2].vcn) { in ntfs_rl_punch_nolock()
1822 rl->length = start - rl->vcn; in ntfs_rl_punch_nolock()
1823 rl++; in ntfs_rl_punch_nolock()
1824 rl->vcn = start; in ntfs_rl_punch_nolock()
1825 rl->lcn = LCN_HOLE; in ntfs_rl_punch_nolock()
1828 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1); in ntfs_rl_punch_nolock()
1832 if (runlist->rl != trl) { in ntfs_rl_punch_nolock()
1833 rl = trl + (rl - runlist->rl); in ntfs_rl_punch_nolock()
1834 rl_end = trl + (rl_end - runlist->rl); in ntfs_rl_punch_nolock()
1835 rl_real_end = trl + (rl_real_end - runlist->rl); in ntfs_rl_punch_nolock()
1836 runlist->rl = trl; in ntfs_rl_punch_nolock()
1839 rl->length = start - rl->vcn; in ntfs_rl_punch_nolock()
1840 rl++; in ntfs_rl_punch_nolock()
1846 delta = rl->vcn - start; in ntfs_rl_punch_nolock()
1847 rl->vcn = start; in ntfs_rl_punch_nolock()
1848 if (rl->lcn >= 0) { in ntfs_rl_punch_nolock()
1849 rl->lcn -= delta; in ntfs_rl_punch_nolock()
1853 rl->length += delta; in ntfs_rl_punch_nolock()
1863 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 2); in ntfs_rl_punch_nolock()
1867 if (runlist->rl != trl) { in ntfs_rl_punch_nolock()
1868 rl = trl + (rl - runlist->rl); in ntfs_rl_punch_nolock()
1869 rl_end = trl + (rl_end - runlist->rl); in ntfs_rl_punch_nolock()
1870 rl_real_end = trl + (rl_real_end - runlist->rl); in ntfs_rl_punch_nolock()
1871 runlist->rl = trl; in ntfs_rl_punch_nolock()
1874 memmove(rl + 2, rl, (rl_real_end - rl + 1) * sizeof(*rl)); in ntfs_rl_punch_nolock()
1876 rl->length = start - rl->vcn; in ntfs_rl_punch_nolock()
1877 rl++; in ntfs_rl_punch_nolock()
1878 rl->vcn = start; in ntfs_rl_punch_nolock()
1879 rl->lcn = LCN_HOLE; in ntfs_rl_punch_nolock()
1880 rl->length = length; in ntfs_rl_punch_nolock()
1881 rl++; in ntfs_rl_punch_nolock()
1882 delta = end - rl->vcn; in ntfs_rl_punch_nolock()
1883 rl->vcn = end; in ntfs_rl_punch_nolock()
1884 rl->lcn += delta; in ntfs_rl_punch_nolock()
1885 rl->length -= delta; in ntfs_rl_punch_nolock()