Lines Matching refs:ni
26 * @ni: ntfs inode for which to map (part of) a runlist
30 * Map the part of a runlist containing the @vcn of the ntfs inode @ni.
32 * If @ctx is specified, it is an active search context of @ni and its base mft
63 * Locking: - The runlist described by @ni must be locked for writing on entry
65 * - If @ctx is NULL, the base mft record of @ni must not be mapped on
70 int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx)
85 if (!NInoAttr(ni))
86 base_ni = ni;
88 base_ni = ni->ext.base_ntfs_ino;
107 read_lock_irqsave(&ni->size_lock, flags);
108 allocated_size_vcn = ni->allocated_size >>
109 ni->vol->cluster_size_bits;
110 read_unlock_irqrestore(&ni->size_lock, flags);
120 if (vcn >= allocated_size_vcn || (a->type == ni->type &&
121 a->name_length == ni->name_len &&
123 ni->name, ni->name_len) &&
152 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
173 rl = ntfs_mapping_pairs_decompress(ni->vol, a, ni->runlist.rl);
177 ni->runlist.rl = rl;
271 * @ni: ntfs inode for which to map (part of) a runlist
274 * Map the part of a runlist containing the @vcn of the ntfs inode @ni.
284 int ntfs_map_runlist(ntfs_inode *ni, VCN vcn)
288 down_write(&ni->runlist.lock);
290 if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <=
292 err = ntfs_map_runlist_nolock(ni, vcn, NULL);
293 up_write(&ni->runlist.lock);
299 * @ni: ntfs inode of the attribute whose runlist to search
304 * described by the ntfs inode @ni and return the corresponding logical cluster
327 LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn,
334 BUG_ON(!ni);
336 ni->mft_no, (unsigned long long)vcn,
338 BUG_ON(!NInoNonResident(ni));
340 if (!ni->runlist.rl) {
341 read_lock_irqsave(&ni->size_lock, flags);
342 if (!ni->allocated_size) {
343 read_unlock_irqrestore(&ni->size_lock, flags);
346 read_unlock_irqrestore(&ni->size_lock, flags);
350 lcn = ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn);
362 up_read(&ni->runlist.lock);
363 down_write(&ni->runlist.lock);
364 if (unlikely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) !=
366 up_write(&ni->runlist.lock);
367 down_read(&ni->runlist.lock);
371 err = ntfs_map_runlist_nolock(ni, vcn, NULL);
373 up_write(&ni->runlist.lock);
374 down_read(&ni->runlist.lock);
388 ntfs_error(ni->vol->sb, "Failed with error code %lli.",
395 * @ni: ntfs inode describing the runlist to search
400 * inode @ni and return the address of the runlist element containing the @vcn.
405 * If @ctx is specified, it is an active search context of @ni and its base mft
442 * Locking: - The runlist described by @ni must be locked for writing on entry
445 * - If @ctx is NULL, the base mft record of @ni must not be mapped on
450 runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn,
458 BUG_ON(!ni);
460 ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out");
461 BUG_ON(!NInoNonResident(ni));
463 if (!ni->runlist.rl) {
464 read_lock_irqsave(&ni->size_lock, flags);
465 if (!ni->allocated_size) {
466 read_unlock_irqrestore(&ni->size_lock, flags);
469 read_unlock_irqrestore(&ni->size_lock, flags);
472 rl = ni->runlist.rl;
503 err = ntfs_map_runlist_nolock(ni, vcn, ctx);
514 ntfs_error(ni->vol->sb, "Failed with error code %i.", err);
872 ntfs_inode *base_ni, *ni;
882 ni = ctx->ntfs_ino;
884 ntfs_debug("Entering for inode 0x%lx, type 0x%x.", ni->mft_no, type);
890 if (ni == base_ni)
991 if (MREF_LE(al_entry->mft_reference) == ni->mft_no) {
992 if (MSEQNO_LE(al_entry->mft_reference) != ni->seq_no) {
1002 if (ni != base_ni)
1003 unmap_extent_mft_record(ni);
1007 ni = ctx->ntfs_ino = base_ni;
1013 al_entry->mft_reference), &ni);
1026 ni = NULL;
1029 ctx->ntfs_ino = ni;
1100 if (ni != base_ni) {
1101 if (ni)
1102 unmap_extent_mft_record(ni);
1133 if (ni != base_ni)
1134 unmap_extent_mft_record(ni);
1222 * @ni: ntfs inode with which to initialize the search context
1225 * Initialize the attribute search context @ctx with @ni and @mrec.
1228 ntfs_inode *ni, MFT_RECORD *mrec)
1236 .ntfs_ino = ni,
1273 * @ni: ntfs inode with which to initialize the search context
1276 * Allocate a new attribute search context, initialize it with @ni and @mrec,
1279 ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
1285 ntfs_attr_init_search_ctx(ctx, ni, mrec);
1513 * @ni: ntfs inode describing the attribute to convert
1516 * Convert the resident ntfs attribute described by the ntfs inode @ni to a
1545 int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1548 struct inode *vi = VFS_I(ni);
1549 ntfs_volume *vol = ni->vol;
1563 err = ntfs_attr_can_be_non_resident(vol, ni->type);
1577 BUG_ON(NInoCompressed(ni));
1578 BUG_ON(NInoEncrypted(ni));
1617 down_write(&ni->runlist.lock);
1618 if (!NInoAttr(ni))
1619 base_ni = ni;
1621 base_ni = ni->ext.base_ntfs_ino;
1634 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
1643 BUG_ON(NInoNonResident(ni));
1648 if (NInoSparse(ni) || NInoCompressed(ni))
1705 if (NInoSparse(ni) || NInoCompressed(ni)) {
1707 if (NInoCompressed(ni) || vol->major_ver < 3)
1722 ni->runlist.rl = rl;
1723 write_lock_irqsave(&ni->size_lock, flags);
1724 ni->allocated_size = new_size;
1725 if (NInoSparse(ni) || NInoCompressed(ni)) {
1726 ni->itype.compressed.size = ni->allocated_size;
1728 ni->itype.compressed.block_size = 1U << (a->data.
1731 ni->itype.compressed.block_size_bits =
1732 ffs(ni->itype.compressed.block_size) -
1734 ni->itype.compressed.block_clusters = 1U <<
1737 ni->itype.compressed.block_size = 0;
1738 ni->itype.compressed.block_size_bits = 0;
1739 ni->itype.compressed.block_clusters = 0;
1741 vi->i_blocks = ni->itype.compressed.size >> 9;
1743 vi->i_blocks = ni->allocated_size >> 9;
1744 write_unlock_irqrestore(&ni->size_lock, flags);
1751 NInoSetNonResident(ni);
1757 up_write(&ni->runlist.lock);
1800 (unsigned)le32_to_cpu(ni->type),
1802 ((ni->type == AT_DATA) &&
1803 !ni->name_len) ? "FILE": "ATTRIBUTE");
1804 write_lock_irqsave(&ni->size_lock, flags);
1805 ni->initialized_size = attr_size;
1807 write_unlock_irqrestore(&ni->size_lock, flags);
1823 write_lock_irqsave(&ni->size_lock, flags);
1824 ni->allocated_size = arec_size - mp_ofs;
1825 write_unlock_irqrestore(&ni->size_lock, flags);
1834 ni->runlist.rl = NULL;
1835 up_write(&ni->runlist.lock);
1857 * @ni: ntfs inode of the attribute whose allocation to extend
1862 * Extend the allocated space of an attribute described by the ntfs inode @ni
1865 * inode @ni have sparse support enabled). If @data_start is >= 0, then the
1903 * Locking: This function takes the runlist lock of @ni for writing as well as
1914 s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size,
1919 struct inode *vi = VFS_I(ni);
1920 ntfs_volume *vol = ni->vol;
1932 read_lock_irqsave(&ni->size_lock, flags);
1933 allocated_size = ni->allocated_size;
1934 read_unlock_irqrestore(&ni->size_lock, flags);
1939 (unsigned)le32_to_cpu(ni->type),
1950 if (NInoNonResident(ni)) {
1958 err = ntfs_attr_size_bounds_check(vol, ni->type, new_alloc_size);
1961 read_lock_irqsave(&ni->size_lock, flags);
1962 allocated_size = ni->allocated_size;
1963 read_unlock_irqrestore(&ni->size_lock, flags);
1973 le32_to_cpu(ni->type));
1983 le32_to_cpu(ni->type));
1993 if (!NInoAttr(ni))
1994 base_ni = ni;
1996 base_ni = ni->ext.base_ntfs_ino;
2001 down_write(&ni->runlist.lock);
2014 read_lock_irqsave(&ni->size_lock, flags);
2015 allocated_size = ni->allocated_size;
2016 read_unlock_irqrestore(&ni->size_lock, flags);
2021 vcn = NInoNonResident(ni) ? allocated_size >> vol->cluster_size_bits :
2040 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
2052 BUG_ON(NInoNonResident(ni));
2065 write_lock_irqsave(&ni->size_lock, flags);
2066 ni->allocated_size = le32_to_cpu(a->length) -
2068 write_unlock_irqrestore(&ni->size_lock, flags);
2086 up_write(&ni->runlist.lock);
2091 err = ntfs_attr_make_non_resident(ni, attr_len);
2101 read_lock_irqsave(&ni->size_lock, flags);
2102 allocated_size = ni->allocated_size;
2103 read_unlock_irqrestore(&ni->size_lock, flags);
2110 (unsigned)le32_to_cpu(ni->type), err);
2116 read_lock_irqsave(&ni->size_lock, flags);
2117 allocated_size = ni->allocated_size;
2118 read_unlock_irqrestore(&ni->size_lock, flags);
2142 if (ni->type == AT_ATTRIBUTE_LIST ||
2143 ni->type == AT_STANDARD_INFORMATION) {
2161 BUG_ON(!NInoNonResident(ni));
2174 if ((start >= 0 && start <= allocated_size) || ni->type != AT_DATA ||
2175 !NVolSparseEnabled(vol) || NInoSparseDisabled(ni))
2182 rl = ni->runlist.rl;
2190 (rl->lcn == LCN_ENOENT && rl > ni->runlist.rl &&
2194 rl = ntfs_mapping_pairs_decompress(vol, a, ni->runlist.rl);
2204 (unsigned)le32_to_cpu(ni->type),
2210 ni->runlist.rl = rl;
2223 while (rl->lcn < 0 && rl > ni->runlist.rl)
2240 (unsigned)le32_to_cpu(ni->type), err);
2245 rl = ntfs_runlists_merge(ni->runlist.rl, rl2);
2253 (unsigned)le32_to_cpu(ni->type), err);
2266 ni->runlist.rl = rl;
2286 (unsigned)le32_to_cpu(ni->type), err);
2321 (unsigned)le32_to_cpu(ni->type), err);
2340 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
2347 write_lock_irqsave(&ni->size_lock, flags);
2348 ni->allocated_size = new_alloc_size;
2351 * FIXME: This would fail if @ni is a directory, $MFT, or an index,
2360 if (NInoSparse(ni) || NInoCompressed(ni)) {
2361 ni->itype.compressed.size += new_alloc_size - allocated_size;
2363 cpu_to_sle64(ni->itype.compressed.size);
2364 vi->i_blocks = ni->itype.compressed.size >> 9;
2367 write_unlock_irqrestore(&ni->size_lock, flags);
2381 up_write(&ni->runlist.lock);
2391 (unsigned)le32_to_cpu(ni->type), err);
2395 if (ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE,
2401 write_lock_irqsave(&ni->size_lock, flags);
2402 ni->allocated_size = new_alloc_size;
2404 * FIXME: This would fail if @ni is a directory... See above.
2408 if (NInoSparse(ni) || NInoCompressed(ni)) {
2409 ni->itype.compressed.size += new_alloc_size -
2411 vi->i_blocks = ni->itype.compressed.size >> 9;
2414 write_unlock_irqrestore(&ni->size_lock, flags);
2417 up_write(&ni->runlist.lock);
2429 if (ntfs_cluster_free(ni, ll, -1, ctx) < 0) {
2443 if (ntfs_rl_truncate_nolock(vol, &ni->runlist, ll) || IS_ERR(m)) {
2477 up_write(&ni->runlist.lock);
2485 * @ni: ntfs inode describing the attribute to fill
2490 * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
2503 int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val)
2505 ntfs_volume *vol = ni->vol;
2522 BUG_ON(NInoCompressed(ni));
2523 BUG_ON(NInoEncrypted(ni));
2524 mapping = VFS_I(ni)->i_mapping;
2532 if (unlikely(end > i_size_read(VFS_I(ni)))) {