Lines Matching refs:runlist
41 * ntfs_map_runlist_nolock - map (a part of) a runlist of an ntfs inode
42 * @ni: ntfs inode for which to map (part of) a runlist
43 * @vcn: map runlist part containing this vcn
46 * Map the part of a runlist containing the @vcn of the ntfs inode @ni.
50 * runlist fragments and allows their mapping. If you do not have the mft
67 * of bounds of the runlist.
69 * Note the runlist can be NULL after this function returns if @vcn is zero and
70 * the attribute has zero allocated size, i.e. there simply is no runlist.
79 * Locking: - The runlist described by @ni must be locked for writing on entry
80 * and is locked on return. Note the runlist will be modified.
100 ntfs_debug("Mapping runlist part containing vcn 0x%llx.",
136 * map the runlist below, so there is definitely no need to get
184 * we then try to map the already mapped runlist fragment and
192 rl = ntfs_mapping_pairs_decompress(ni->vol, a, &ni->runlist, &new_rl_count);
196 ni->runlist.rl = rl;
197 ni->runlist.count = new_rl_count;
287 * ntfs_map_runlist - map (a part of) a runlist of an ntfs inode
288 * @ni: ntfs inode for which to map (part of) a runlist
289 * @vcn: map runlist part containing this vcn
291 * Map the part of a runlist containing the @vcn of the ntfs inode @ni.
295 * of bounds of the runlist.
297 * Locking: - The runlist must be unlocked on entry and is unlocked on return.
298 * - This function takes the runlist lock for writing and may modify
299 * the runlist.
305 down_write(&ni->runlist.lock);
307 if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <=
310 up_write(&ni->runlist.lock);
316 struct runlist_element *rl = ni->runlist.rl;
324 rl = ni->runlist.rl;
336 rl = ni->runlist.rl;
346 * @ni: ntfs inode of the attribute whose runlist to search
348 * @write_locked: true if the runlist is locked for writing
350 * Find the virtual cluster number @vcn in the runlist of the ntfs attribute
357 * If @write_locked is true the caller has locked the runlist for writing and
365 * LCN_ENOENT There is no such vcn in the runlist, i.e. @vcn is out of bounds.
366 * LCN_ENOMEM Not enough memory to map runlist.
367 * LCN_EIO Critical error (runlist/file is corrupt, i/o error, etc).
369 * Locking: - The runlist must be locked on entry and is left locked on return.
370 * - If @write_locked is 'false', i.e. the runlist is locked for reading,
372 * the runlist still being the same when this function returns.
384 if (!ni->runlist.rl) {
393 /* Convert vcn to lcn. If that fails map the runlist and retry once. */
394 lcn = ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn);
406 up_read(&ni->runlist.lock);
407 down_write(&ni->runlist.lock);
408 if (unlikely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) !=
410 up_write(&ni->runlist.lock);
411 down_read(&ni->runlist.lock);
417 up_write(&ni->runlist.lock);
418 down_read(&ni->runlist.lock);
437 struct runlist_element *__ntfs_attr_find_vcn_nolock(struct runlist *runlist, const s64 vcn)
441 int rh = runlist->rl_hint;
443 if (runlist->count <= 1)
446 if (runlist->count - 1 > rh && runlist->rl[rh].vcn <= vcn) {
447 if (vcn < runlist->rl[rh].vcn + runlist->rl[rh].length)
448 return &runlist->rl[rh];
449 if (runlist->count - 2 == rh)
454 run = &runlist->rl[0];
458 runlist->rl_hint = 0;
465 run = &runlist->rl[runlist->count - 2];
467 runlist->rl_hint = runlist->count - 2;
473 upper_idx = runlist->count - 2;
477 run = &runlist->rl[idx];
484 runlist->rl_hint = idx;
493 * ntfs_attr_find_vcn_nolock - find a vcn in the runlist of an ntfs inode
494 * @ni: ntfs inode describing the runlist to search
498 * Find the virtual cluster number @vcn in the runlist described by the ntfs
499 * inode @ni and return the address of the runlist element containing the @vcn.
506 * runlist fragments and allows their mapping. If you do not have the mft
520 * Note you need to distinguish between the lcn of the returned runlist element
534 if (!ni->runlist.rl) {
544 rl = ni->runlist.rl;
546 rl = __ntfs_attr_find_vcn_nolock(&ni->runlist, vcn);
563 * The @vcn is in an unmapped region, map the runlist
2012 down_write(&ni->runlist.lock);
2102 ni->runlist.rl = rl;
2104 for (ni->runlist.count = 1; rl->length != 0; rl++)
2105 ni->runlist.count++;
2107 ni->runlist.count = 0;
2142 up_write(&ni->runlist.lock);
2204 up_write(&ni->runlist.lock);
2221 ni->runlist.rl = NULL;
2704 ntfs_debug("Couldn't decompress attribute list runlist. Succeed anyway.\n");
2708 ntfs_debug("Leaking clusters! Run chkdsk. Couldn't free clusters from attribute list runlist.\n");
2994 ni->runlist.rl = NULL;
3225 if (NInoNonResident(ni) && ni->runlist.rl)
3226 kvfree(ni->runlist.rl);
3233 * ntfs_attr_map_whole_runlist - map the whole runlist of an ntfs attribute
3234 * @ni: ntfs inode for which to map the runlist
3236 * Map the whole runlist of the ntfs attribute @na. For an attribute made up
3239 * will map the runlist fragments from each of the extents thus giving access
3257 if (NInoFullyMapped(ni) && ni->runlist.rl)
3278 if (ntfs_rl_vcn_to_lcn(ni->runlist.rl, next_vcn) == LCN_RL_NOT_MAPPED)
3289 /* Decode the runlist. */
3290 rl = ntfs_mapping_pairs_decompress(ni->vol, a, &ni->runlist,
3296 ni->runlist.rl = rl;
3297 ni->runlist.count = new_rl_count;
3333 ntfs_error(sb, "Couldn't find attribute for runlist mapping");
3339 "Failed to load full runlist: inode: %llu highest_vcn: 0x%llx last_vcn: 0x%llx",
3561 sparse = ntfs_rl_sparse(ni->runlist.rl);
3642 new_compr_size = ntfs_rl_get_compressed_size(ni->vol, ni->runlist.rl);
3670 * @from_vcn: update runlist starting this VCN
3676 * @na->allocated_size should be set to correct value for the new runlist before
3695 if (!ni || !ni->runlist.rl)
3721 start_rl = ni->runlist.rl;
3732 * If runlist is updating not from the beginning, then set
3744 * the last run in runlist, if so, then deallocate
3747 first_lcn = ntfs_rl_vcn_to_lcn(ni->runlist.rl, stop_vcn);
3750 ntfs_error(sb, "Bad runlist");
4085 /* Read and cache the whole runlist if not already done. */
4124 * Deallocate clusters from the runlist.
4136 /* Throw away the now unused runlist. */
4137 kvfree(ni->runlist.rl);
4138 ni->runlist.rl = NULL;
4139 ni->runlist.count = 0;
4238 /* Truncate the runlist itself. */
4239 if (ntfs_rl_truncate_nolock(vol, &ni->runlist, first_free_vcn)) {
4241 * Failed to truncate the runlist, so just throw it
4244 kvfree(ni->runlist.rl);
4245 ni->runlist.rl = NULL;
4262 /* Write mapping pairs for new runlist. */
4404 while (ni->runlist.rl[last].length)
4407 rl = ntfs_rl_realloc(ni->runlist.rl, last + 1,
4430 ni->runlist.rl = rl;
4431 ni->runlist.count += more_entries;
4456 if (ni->runlist.rl->length) {
4458 for (rl = ni->runlist.rl; (rl + 1)->length; rl++)
4464 while (rl->lcn < 0 && rl != ni->runlist.rl)
4487 /* Append new clusters to attribute runlist. */
4488 rln = ntfs_runlists_merge(&ni->runlist, rl, 0, &new_rl_count);
4496 ni->runlist.rl = rln;
4497 ni->runlist.count = new_rl_count;
4545 /* Now, truncate the runlist itself. */
4547 down_write(&ni->runlist.lock);
4548 err2 = ntfs_rl_truncate_nolock(vol, &ni->runlist,
4551 up_write(&ni->runlist.lock);
4554 * Failed to truncate the runlist, so just throw it away, it
4557 kvfree(ni->runlist.rl);
4558 ni->runlist.rl = NULL;
4559 ntfs_error(sb, "Couldn't truncate runlist. Rollback failed");
4565 down_read(&ni->runlist.lock);
4569 up_read(&ni->runlist.lock);
4847 down_write(&ni->runlist.lock);
4852 up_write(&ni->runlist.lock);
5006 ntfs_error(vol->sb, "Failed to find run after mapping runlist.");
5074 rl = ntfs_runlists_merge(&ni->runlist, rlc, 0, &new_rl_count);
5083 ni->runlist.rl = rl;
5084 ni->runlist.count = new_rl_count;
5324 down_write(&ni->runlist.lock);
5327 up_write(&ni->runlist.lock);
5331 rl = ntfs_rl_find_vcn_nolock(ni->runlist.rl, start_vcn);
5333 up_write(&ni->runlist.lock);
5338 rl = ntfs_rl_insert_range(ni->runlist.rl, (int)ni->runlist.count,
5341 up_write(&ni->runlist.lock);
5345 ni->runlist.rl = rl;
5346 ni->runlist.count = new_rl_count;
5353 up_write(&ni->runlist.lock);
5396 down_write(&ni->runlist.lock);
5399 up_write(&ni->runlist.lock);
5404 for (rl = ni->runlist.rl, dst_cnt = 0; rl && rl->length; rl++)
5406 rl = ntfs_rl_find_vcn_nolock(ni->runlist.rl, start_vcn);
5408 up_write(&ni->runlist.lock);
5412 rl = ntfs_rl_collapse_range(ni->runlist.rl, dst_cnt + 1,
5415 up_write(&ni->runlist.lock);
5418 ni->runlist.rl = rl;
5419 ni->runlist.count = new_rl_cnt;
5439 up_write(&ni->runlist.lock);
5443 up_write(&ni->runlist.lock);
5490 down_write(&ni->runlist.lock);
5493 up_write(&ni->runlist.lock);
5498 for (rl = ni->runlist.rl, dst_cnt = 0; rl && rl->length; rl++)
5500 rl = ntfs_rl_find_vcn_nolock(ni->runlist.rl, start_vcn);
5502 up_write(&ni->runlist.lock);
5506 rl = ntfs_rl_punch_hole(ni->runlist.rl, dst_cnt + 1,
5509 up_write(&ni->runlist.lock);
5512 ni->runlist.rl = rl;
5513 ni->runlist.count = new_rl_count;
5516 up_write(&ni->runlist.lock);
5547 down_write(&ni->runlist.lock);
5549 up_write(&ni->runlist.lock);
5616 down_read(&ni->runlist.lock);
5618 up_read(&ni->runlist.lock);
5637 down_write(&ni->runlist.lock);
5640 up_write(&ni->runlist.lock);
5667 down_write(&ni->runlist.lock);
5670 up_write(&ni->runlist.lock);
5682 down_write(&ni->runlist.lock);
5688 up_write(&ni->runlist.lock);