Lines Matching refs:runlist

3  * runlist.c - NTFS runlist handling code.  Part of the Linux-NTFS project.
16 * ntfs_rl_mm - runlist memmove
18 * It is up to the caller to serialize access to the runlist @base.
28 * ntfs_rl_mc - runlist memory copy
42 * @rl: original runlist
43 * @old_size: number of runlist elements in the original runlist @rl
44 * @new_size: number of runlist elements we need space for
50 * It is up to the caller to serialize access to the runlist @rl.
57 * -ENOMEM - Not enough memory to allocate runlist array.
85 * @rl: original runlist
86 * @old_size: number of runlist elements in the original runlist @rl
87 * @new_size: number of runlist elements we need space for
96 * It is up to the caller to serialize access to the runlist @rl.
103 * -ENOMEM - Not enough memory to allocate runlist array.
130 * @dst: original runlist
131 * @src: new runlist to test for mergeability with @dst
166 * @dst: original, destination runlist
167 * @src: new runlist to merge with @dst
169 * Merge the two runlists, writing into the destination runlist @dst. The
171 * destination runlist.
181 * ntfs_rl_append - append a runlist after a given element
182 * @dst: original runlist to be worked on
184 * @src: runlist to be inserted into @dst
186 * @loc: append the new runlist @src after this element in @dst
188 * Append the runlist @src after element @loc in @dst. Merge the right end of
189 * the new runlist, if necessary. Adjust the size of the hole before the
190 * appended runlist.
194 * On success, return a pointer to the new, combined, runlist. Note, both
196 * the pointers for anything any more. (Strictly speaking the returned runlist
201 * -ENOMEM - Not enough memory to allocate runlist array.
248 * ntfs_rl_insert - insert a runlist into another
249 * @dst: original runlist to be worked on
251 * @src: new runlist to be inserted
253 * @loc: insert the new runlist @src before this element in @dst
255 * Insert the runlist @src before element @loc in the runlist @dst. Merge the
256 * left end of the new runlist, if necessary. Adjust the size of the hole
257 * after the inserted runlist.
261 * On success, return a pointer to the new, combined, runlist. Note, both
263 * the pointers for anything any more. (Strictly speaking the returned runlist
268 * -ENOMEM - Not enough memory to allocate runlist array.
307 * original runlist.
345 * ntfs_rl_replace - overwrite a runlist element with another runlist
346 * @dst: original runlist to be worked on
348 * @src: new runlist to be inserted
350 * @loc: index in runlist @dst to overwrite with @src
352 * Replace the runlist element @dst at @loc with @src. Merge the left and
353 * right ends of the inserted runlist, if necessary.
357 * On success, return a pointer to the new, combined, runlist. Note, both
359 * the pointers for anything any more. (Strictly speaking the returned runlist
364 * -ENOMEM - Not enough memory to allocate runlist array.
433 * ntfs_rl_split - insert a runlist into the centre of a hole
434 * @dst: original runlist to be worked on
436 * @src: new runlist to be inserted
438 * @loc: index in runlist @dst at which to split and insert @src
440 * Split the runlist @dst at @loc into two and insert @new in between the two
446 * On success, return a pointer to the new, combined, runlist. Note, both
448 * the pointers for anything any more. (Strictly speaking the returned runlist
453 * -ENOMEM - Not enough memory to allocate runlist array.
485 * @drl: original runlist to be worked on
486 * @srl: new runlist to be merged into @drl
489 * are sensible and can be merged. The runlist @srl must be either after the
490 * runlist @drl or completely within a hole (or unmapped region) in @drl.
503 * It can also be appended to the end of the runlist, which is just a variant
506 * On success, return a pointer to the new, combined, runlist. Note, both
508 * the pointers for anything any more. (Strictly speaking the returned runlist
513 * -ENOMEM - Not enough memory to allocate runlist array.
545 /* Complete the source runlist if necessary. */
547 /* Scan to the end of the source runlist. */
554 /* Insert start element at the front of the runlist. */
565 /* Skip any unmapped start element(s) in the source runlist. */
569 /* Can't have an entirely unmapped source runlist. */
664 * We need to create an unmapped runlist element in
673 /* Add an unmapped runlist element. */
702 ntfs_debug("Merged runlist:");
708 * ntfs_mapping_pairs_decompress - convert mapping pairs array to runlist
711 * @old_rl: optional runlist in which to insert @attr's runlist
713 * It is up to the caller to serialize access to the runlist @old_rl.
715 * Decompress the attribute @attr's mapping pairs array into a runlist. On
716 * success, return the decompressed runlist.
718 * If @old_rl is not NULL, decompressed runlist is inserted into the
719 * appropriate place in @old_rl and the resultant, combined runlist is
725 * -ENOMEM - Not enough memory to allocate runlist array.
726 * -EIO - Corrupt runlist.
731 * new runlist disregarding the already existing one and then splicing the
733 * runlist if overlap present before returning ERR_PTR(-ERANGE)).
741 runlist_element *rl; /* The output runlist. */
744 int rlsize; /* Size of runlist buffer. */
745 u16 rlpos; /* Current runlist position in units of
771 /* Current position in runlist array. */
773 /* Allocate first page and set current runlist size to one page. */
803 /* Enter the current vcn into the current runlist element. */
833 * Enter the current run length into the current runlist
877 /* Enter the current lcn into the runlist element. */
880 /* Get to the next runlist element. */
889 * vcn in the runlist - 1, or something has gone badly wrong.
898 /* Setup not mapped runlist element if this is the base extent. */
908 * attribute so simply terminate the runlist with LCN_ENOENT).
913 * the highest cluster, the runlist is either corrupt
943 /* Setup terminating runlist element. */
946 /* If no existing runlist was specified, we are done. */
967 * ntfs_rl_vcn_to_lcn - convert a vcn into a lcn given a runlist
968 * @rl: runlist to use for conversion
972 * cluster number (lcn) of a device using the runlist @rl to map vcns to their
975 * It is up to the caller to serialize access to the runlist @rl.
982 * LCN_RL_NOT_MAPPED This is part of the runlist which has not been
983 * inserted into the runlist yet.
986 * Locking: - The caller must have locked the runlist (for reading or writing).
988 * runlist.
996 * If rl is NULL, assume that we have found an unmapped runlist. The
1027 * ntfs_rl_find_vcn_nolock - find a vcn in a runlist
1028 * @rl: runlist to search
1031 * Find the virtual cluster number @vcn in the runlist @rl and return the
1032 * address of the runlist element containing the @vcn on success.
1035 * the runlist.
1037 * Locking: The runlist must be locked on entry.
1091 * @rl: locked runlist to determine the size of the mapping pairs of
1095 * Walk the locked runlist @rl and calculate the size in bytes of the mapping
1096 * pairs array corresponding to the runlist @rl, starting at vcn @first_vcn and
1099 * A @last_vcn of -1 means end of runlist and in that case the size of the
1100 * mapping pairs array corresponding to the runlist starting at vcn @first_vcn
1101 * and finishing at the end of the runlist is determined.
1112 * -EIO - The runlist is corrupt.
1133 /* Skip to runlist element containing @first_vcn. */
1176 /* Go to next runlist element. */
1231 * This is used when building the mapping pairs array of a runlist to compress
1272 * ntfs_mapping_pairs_build - build the mapping pairs array from a runlist
1276 * @rl: locked runlist for which to build the mapping pairs array
1281 * Create the mapping pairs array from the locked runlist @rl, starting at vcn
1286 * A @last_vcn of -1 means end of runlist and in that case the mapping pairs
1287 * array corresponding to the runlist starting at vcn @first_vcn and finishing
1288 * at the end of the runlist is created.
1303 * -EIO - The runlist is corrupt.
1332 /* Skip to runlist element containing @first_vcn. */
1394 /* Go to next runlist element. */
1462 * ntfs_rl_truncate_nolock - truncate a runlist starting at a specified vcn
1464 * @runlist: runlist to truncate
1465 * @new_length: the new length of the runlist in VCNs
1467 * Truncate the runlist described by @runlist as well as the memory buffer
1468 * holding the runlist elements to a length of @new_length VCNs.
1470 * If @new_length lies within the runlist, the runlist elements with VCNs of
1472 * zero, the runlist is discarded and set to NULL.
1474 * If @new_length lies beyond the runlist, a sparse runlist element is added to
1475 * the end of the runlist @runlist or if the last runlist element is a sparse
1478 * Note, no checking is done for unmapped runlist elements. It is assumed that
1483 * Locking: The caller must hold @runlist->lock for writing.
1485 int ntfs_rl_truncate_nolock(const ntfs_volume *vol, runlist *const runlist,
1492 BUG_ON(!runlist);
1494 rl = runlist->rl;
1496 ntfs_debug("Freeing runlist.");
1497 runlist->rl = NULL;
1504 * Create a runlist consisting of a sparse runlist element of
1505 * length @new_length followed by a terminator runlist element.
1510 "runlist element buffer.");
1513 runlist->rl = rl;
1521 /* Find @new_length in the runlist. */
1525 * If not at the end of the runlist we need to shrink it.
1526 * If at the end of the runlist we need to expand it.
1532 ntfs_debug("Shrinking runlist.");
1533 /* Determine the runlist size. */
1537 old_size = trl - runlist->rl + 1;
1541 * If a run was partially truncated, make the following runlist
1555 int new_size = rl - runlist->rl + 1;
1556 rl = ntfs_rl_realloc(runlist->rl, old_size, new_size);
1559 "runlist buffer. This just "
1564 runlist->rl = rl;
1567 ntfs_debug("Expanding runlist.");
1569 * If there is a previous runlist element and it is a sparse
1570 * one, extend it. Otherwise need to add a new, sparse runlist
1573 if ((rl > runlist->rl) && ((rl - 1)->lcn == LCN_HOLE))
1576 /* Determine the runlist size. */
1577 old_size = rl - runlist->rl + 1;
1579 rl = ntfs_rl_realloc(runlist->rl, old_size,
1582 ntfs_error(vol->sb, "Failed to expand runlist "
1586 runlist->rl = rl;
1588 * Set @rl to the same runlist element in the new
1589 * runlist as before in the old runlist.
1592 /* Add a new, sparse runlist element. */
1595 /* Add a new terminator runlist element. */
1610 * ntfs_rl_punch_nolock - punch a hole into a runlist
1612 * @runlist: runlist to punch a hole into
1616 * Punch a hole into the runlist @runlist starting at VCN @start and of size
1619 * Return 0 on success and -errno on error, in which case @runlist has not been
1622 * If @start and/or @start + @length are outside the runlist return error code
1625 * If the runlist contains unmapped or error elements between @start and @start
1628 * Locking: The caller must hold @runlist->lock for writing.
1630 int ntfs_rl_punch_nolock(const ntfs_volume *vol, runlist *const runlist,
1641 BUG_ON(!runlist);
1645 rl = runlist->rl;
1651 /* Find @start in the runlist. */
1655 /* Find @end in the runlist. */
1673 /* Determine the runlist size. */
1676 old_size = rl_real_end - runlist->rl + 1;
1697 /* Cut out all runlist elements up to @end. */
1713 rl = ntfs_rl_realloc(runlist->rl, old_size,
1717 "runlist buffer. This just "
1722 runlist->rl = rl;
1743 if (rl > runlist->rl && (rl - 1)->lcn == LCN_HOLE) {
1758 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1);
1762 if (runlist->rl != trl) {
1763 rl = trl + (rl - runlist->rl);
1764 rl_end = trl + (rl_end - runlist->rl);
1765 rl_real_end = trl + (rl_real_end - runlist->rl);
1766 runlist->rl = trl;
1795 /* Cut out all runlist elements up to @end. */
1828 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 1);
1832 if (runlist->rl != trl) {
1833 rl = trl + (rl - runlist->rl);
1834 rl_end = trl + (rl_end - runlist->rl);
1835 rl_real_end = trl + (rl_real_end - runlist->rl);
1836 runlist->rl = trl;
1863 trl = ntfs_rl_realloc(runlist->rl, old_size, old_size + 2);
1867 if (runlist->rl != trl) {
1868 rl = trl + (rl - runlist->rl);
1869 rl_end = trl + (rl_end - runlist->rl);
1870 rl_real_end = trl + (rl_real_end - runlist->rl);
1871 runlist->rl = trl;
1889 ntfs_error(vol->sb, "Not enough memory to extend runlist buffer.");