Lines Matching refs:rl

58  * @rl:		original runlist
59 * @old_size: number of runlist elements in the original runlist @rl
66 * It is up to the caller to serialize access to the runlist @rl.
74 struct runlist_element *ntfs_rl_realloc(struct runlist_element *rl,
79 old_size = old_size * sizeof(*rl);
80 new_size = new_size * sizeof(*rl);
82 return rl;
88 if (likely(rl != NULL)) {
91 memcpy(new_rl, rl, old_size);
92 kvfree(rl);
99 * @rl: original runlist
100 * @old_size: number of runlist elements in the original runlist @rl
110 * It is up to the caller to serialize access to the runlist @rl.
118 static inline struct runlist_element *ntfs_rl_realloc_nofail(struct runlist_element *rl,
123 old_size = old_size * sizeof(*rl);
124 new_size = new_size * sizeof(*rl);
126 return rl;
129 if (likely(rl != NULL)) {
132 memcpy(new_rl, rl, old_size);
133 kvfree(rl);
522 int di, si; /* Current index into @[ds]rl. */
525 int dend, send; /* Last index into @[ds]rl. */
526 int dfinal, sfinal; /* The last index into @[ds]rl with lcn >= LCN_HOLE. */
529 struct runlist_element *drl = d_runlist->rl, *rl;
591 rl = __ntfs_attr_find_vcn_nolock(d_runlist, srl[sstart].vcn);
592 if (IS_ERR(rl))
595 di = (int)(rl - d_runlist->rl);
738 struct runlist_element *rl, *new_rl; /* The output runlist. */
774 rl = kvzalloc(rlsize = PAGE_SIZE, GFP_NOFS);
775 if (unlikely(!rl))
779 rl->vcn = 0;
780 rl->lcn = LCN_RL_NOT_MAPPED;
781 rl->length = vcn;
790 if (((rlpos + 3) * sizeof(*rl)) > rlsize) {
795 kvfree(rl);
798 memcpy(rl2, rl, rlsize);
799 kvfree(rl);
800 rl = rl2;
804 rl[rlpos].vcn = vcn;
834 rl[rlpos].length = deltaxcn;
852 rl[rlpos].lcn = LCN_HOLE;
890 if ((lcn != -1) && !rl[rlpos].length) {
898 rl[rlpos].lcn = lcn;
901 if (rl[rlpos].length)
939 rl[rlpos].vcn = vcn;
940 vcn += rl[rlpos].length = max_cluster -
942 rl[rlpos].lcn = LCN_RL_NOT_MAPPED;
951 rl[rlpos].lcn = LCN_ENOENT;
953 rl[rlpos].lcn = LCN_RL_NOT_MAPPED;
956 rl[rlpos].vcn = vcn;
957 rl[rlpos].length = (s64)0;
959 if (!old_runlist || !old_runlist->rl) {
962 ntfs_debug_dump_runlist(rl);
963 return rl;
966 new_rl = ntfs_runlists_merge(old_runlist, rl, rlpos + 1, new_rl_count);
969 kvfree(rl);
975 kvfree(rl);
981 * @rl: runlist to use for conversion
985 * cluster number (lcn) of a device using the runlist @rl to map vcns to their
988 * It is up to the caller to serialize access to the runlist @rl.
1003 s64 ntfs_rl_vcn_to_lcn(const struct runlist_element *rl, const s64 vcn)
1008 * If rl is NULL, assume that we have found an unmapped runlist. The
1012 if (unlikely(!rl))
1016 if (unlikely(vcn < rl[0].vcn))
1019 for (i = 0; likely(rl[i].length); i++) {
1020 if (vcn < rl[i+1].vcn) {
1021 if (likely(rl[i].lcn >= 0))
1022 return rl[i].lcn + (vcn - rl[i].vcn);
1023 return rl[i].lcn;
1030 if (likely(rl[i].lcn < 0))
1031 return rl[i].lcn;
1038 * @rl: runlist to search
1041 * Find the virtual cluster number @vcn in the runlist @rl and return the
1044 * Return NULL if @rl is NULL or @vcn is in an unmapped part/out of bounds of
1049 struct runlist_element *ntfs_rl_find_vcn_nolock(struct runlist_element *rl, const s64 vcn)
1051 if (unlikely(!rl || vcn < rl[0].vcn))
1053 while (likely(rl->length)) {
1054 if (unlikely(vcn < rl[1].vcn)) {
1055 if (likely(rl->lcn >= LCN_HOLE))
1056 return rl;
1059 rl++;
1061 if (likely(rl->lcn == LCN_ENOENT))
1062 return rl;
1100 * @rl: runlist to calculate the mapping pairs array size for
1105 * Walk the locked runlist @rl and calculate the size in bytes of the mapping
1106 * pairs array corresponding to the runlist @rl, starting at vcn @first_vcn and
1116 * If @rl is NULL, just return 1 (for the single terminator byte).
1121 const struct runlist_element *rl, const s64 first_vcn,
1134 if (!rl) {
1142 while (rl->length && first_vcn >= rl[1].vcn)
1143 rl++;
1144 if (unlikely((!rl->length && first_vcn > rl->vcn) ||
1145 first_vcn < rl->vcn))
1151 if (first_vcn > rl->vcn) {
1152 s64 delta, length = rl->length;
1154 /* We know rl->length != 0 already. */
1155 if (unlikely(length < 0 || rl->lcn < LCN_HOLE))
1161 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) {
1164 if (unlikely(rl[1].vcn > s1))
1165 length = s1 - rl->vcn;
1168 delta = first_vcn - rl->vcn;
1178 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) {
1179 prev_lcn = rl->lcn;
1180 if (likely(rl->lcn >= 0))
1186 rl++;
1189 for (; rl->length && !the_end; rl++) {
1190 s64 length = rl->length;
1192 if (unlikely(length < 0 || rl->lcn < LCN_HOLE))
1198 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) {
1201 if (unlikely(rl[1].vcn > s1))
1202 length = s1 - rl->vcn;
1214 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) {
1216 rls += ntfs_get_nr_significant_bytes(rl->lcn -
1218 prev_lcn = rl->lcn;
1226 if (rl->lcn == LCN_RL_NOT_MAPPED)
1289 * @rl: runlist to build the mapping pairs array from
1296 * Create the mapping pairs array from the locked runlist @rl, starting at vcn
1305 * If @rl is NULL, just write a single terminator byte to @dst.
1321 * Locking: @rl must be locked on entry (either for reading or writing), it
1325 const int dst_len, const struct runlist_element *rl,
1341 if (!rl) {
1350 while (rl->length && first_vcn >= rl[1].vcn)
1351 rl++;
1352 if (unlikely((!rl->length && first_vcn > rl->vcn) ||
1353 first_vcn < rl->vcn))
1362 if (first_vcn > rl->vcn) {
1363 s64 delta, length = rl->length;
1365 /* We know rl->length != 0 already. */
1366 if (unlikely(length < 0 || rl->lcn < LCN_HOLE))
1372 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) {
1375 if (unlikely(rl[1].vcn > s1))
1376 length = s1 - rl->vcn;
1379 delta = first_vcn - rl->vcn;
1391 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) {
1392 prev_lcn = rl->lcn;
1393 if (likely(rl->lcn >= 0))
1410 rl++;
1413 for (; rl->length && !the_end; rl++) {
1414 s64 length = rl->length;
1416 if (unlikely(length < 0 || rl->lcn < LCN_HOLE))
1422 if (unlikely(last_vcn >= 0 && rl[1].vcn > last_vcn)) {
1425 if (unlikely(rl[1].vcn > s1))
1426 length = s1 - rl->vcn;
1440 if (likely(rl->lcn >= 0 || vol->major_ver < 3)) {
1443 len_len, dst_max, rl->lcn - prev_lcn);
1446 prev_lcn = rl->lcn;
1448 if (rl->lcn == LCN_DELALLOC)
1449 de_cnt += rl->length;
1467 *stop_vcn = rl->vcn;
1469 *stop_rl = (struct runlist_element *)rl;
1474 if (rl->lcn == LCN_RL_NOT_MAPPED)
1508 struct runlist_element *rl;
1516 rl = runlist->rl;
1517 if (new_length < rl->vcn)
1521 while (likely(rl->length && new_length >= rl[1].vcn))
1522 rl++;
1527 if (rl->length) {
1533 trl = rl + 1;
1536 old_size = trl - runlist->rl + 1;
1538 rl->length = new_length - rl->vcn;
1544 if (rl->length) {
1545 rl++;
1546 if (!rl->length)
1548 rl->vcn = new_length;
1549 rl->length = 0;
1551 rl->lcn = LCN_ENOENT;
1552 runlist->count = rl - runlist->rl + 1;
1555 int new_size = rl - runlist->rl + 1;
1557 rl = ntfs_rl_realloc(runlist->rl, old_size, new_size);
1558 if (IS_ERR(rl))
1562 runlist->rl = rl;
1564 } else if (likely(/* !rl->length && */ new_length > rl->vcn)) {
1571 if ((rl > runlist->rl) && ((rl - 1)->lcn == LCN_HOLE))
1572 (rl - 1)->length = new_length - (rl - 1)->vcn;
1575 old_size = rl - runlist->rl + 1;
1577 rl = ntfs_rl_realloc(runlist->rl, old_size,
1579 if (IS_ERR(rl)) {
1581 return PTR_ERR(rl);
1583 runlist->rl = rl;
1585 * Set @rl to the same runlist element in the new
1588 rl += old_size - 1;
1590 rl->lcn = LCN_HOLE;
1591 rl->length = new_length - rl->vcn;
1593 rl++;
1594 rl->length = 0;
1597 rl->vcn = new_length;
1598 rl->lcn = LCN_ENOENT;
1599 } else /* if (unlikely(!rl->length && new_length == rl->vcn)) */ {
1601 rl->lcn = LCN_ENOENT;
1609 * @rl: runlist to check
1613 int ntfs_rl_sparse(struct runlist_element *rl)
1617 if (!rl)
1620 for (rlc = rl; rlc->length; rlc++)
1634 * @rl: runlist to calculate for
1638 s64 ntfs_rl_get_compressed_size(struct ntfs_volume *vol, struct runlist_element *rl)
1643 if (!rl)
1646 for (rlc = rl; rlc->length; rlc++) {
1769 struct runlist_element *rl, *rl_3rd;
1780 rl = &new_rl[new_1st_cnt + new_2nd_cnt];
1783 rl = &new_rl[new_1st_cnt + new_2nd_cnt - 1];
1786 rl_3rd->vcn = rl->vcn + rl->length;
1789 rl = rl_3rd;