Lines Matching full: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) in ntfs_map_runlist_nolock() argument
85 if (!NInoAttr(ni)) in ntfs_map_runlist_nolock()
86 base_ni = ni; in ntfs_map_runlist_nolock()
88 base_ni = ni->ext.base_ntfs_ino; in ntfs_map_runlist_nolock()
107 read_lock_irqsave(&ni->size_lock, flags); in ntfs_map_runlist_nolock()
108 allocated_size_vcn = ni->allocated_size >> in ntfs_map_runlist_nolock()
109 ni->vol->cluster_size_bits; in ntfs_map_runlist_nolock()
110 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_map_runlist_nolock()
120 if (vcn >= allocated_size_vcn || (a->type == ni->type && in ntfs_map_runlist_nolock()
121 a->name_length == ni->name_len && in ntfs_map_runlist_nolock()
123 ni->name, ni->name_len) && in ntfs_map_runlist_nolock()
152 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, in ntfs_map_runlist_nolock()
173 rl = ntfs_mapping_pairs_decompress(ni->vol, a, ni->runlist.rl); in ntfs_map_runlist_nolock()
177 ni->runlist.rl = rl; in ntfs_map_runlist_nolock()
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) in ntfs_map_runlist() argument
288 down_write(&ni->runlist.lock); in ntfs_map_runlist()
290 if (likely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) <= in ntfs_map_runlist()
292 err = ntfs_map_runlist_nolock(ni, vcn, NULL); in ntfs_map_runlist()
293 up_write(&ni->runlist.lock); in ntfs_map_runlist()
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, in ntfs_attr_vcn_to_lcn_nolock() argument
334 BUG_ON(!ni); in ntfs_attr_vcn_to_lcn_nolock()
336 ni->mft_no, (unsigned long long)vcn, in ntfs_attr_vcn_to_lcn_nolock()
338 BUG_ON(!NInoNonResident(ni)); in ntfs_attr_vcn_to_lcn_nolock()
340 if (!ni->runlist.rl) { in ntfs_attr_vcn_to_lcn_nolock()
341 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_vcn_to_lcn_nolock()
342 if (!ni->allocated_size) { in ntfs_attr_vcn_to_lcn_nolock()
343 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_vcn_to_lcn_nolock()
346 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_vcn_to_lcn_nolock()
350 lcn = ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn); in ntfs_attr_vcn_to_lcn_nolock()
362 up_read(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
363 down_write(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
364 if (unlikely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) != in ntfs_attr_vcn_to_lcn_nolock()
366 up_write(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
367 down_read(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
371 err = ntfs_map_runlist_nolock(ni, vcn, NULL); in ntfs_attr_vcn_to_lcn_nolock()
373 up_write(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
374 down_read(&ni->runlist.lock); in ntfs_attr_vcn_to_lcn_nolock()
388 ntfs_error(ni->vol->sb, "Failed with error code %lli.", in ntfs_attr_vcn_to_lcn_nolock()
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, in ntfs_attr_find_vcn_nolock() argument
458 BUG_ON(!ni); in ntfs_attr_find_vcn_nolock()
460 ni->mft_no, (unsigned long long)vcn, ctx ? "" : "out"); in ntfs_attr_find_vcn_nolock()
461 BUG_ON(!NInoNonResident(ni)); in ntfs_attr_find_vcn_nolock()
463 if (!ni->runlist.rl) { in ntfs_attr_find_vcn_nolock()
464 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_find_vcn_nolock()
465 if (!ni->allocated_size) { in ntfs_attr_find_vcn_nolock()
466 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_find_vcn_nolock()
469 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_find_vcn_nolock()
472 rl = ni->runlist.rl; in ntfs_attr_find_vcn_nolock()
503 err = ntfs_map_runlist_nolock(ni, vcn, ctx); in ntfs_attr_find_vcn_nolock()
514 ntfs_error(ni->vol->sb, "Failed with error code %i.", err); in ntfs_attr_find_vcn_nolock()
848 ntfs_inode *base_ni, *ni; in ntfs_external_attr_find() local
858 ni = ctx->ntfs_ino; in ntfs_external_attr_find()
860 ntfs_debug("Entering for inode 0x%lx, type 0x%x.", ni->mft_no, type); in ntfs_external_attr_find()
866 if (ni == base_ni) in ntfs_external_attr_find()
967 if (MREF_LE(al_entry->mft_reference) == ni->mft_no) { in ntfs_external_attr_find()
968 if (MSEQNO_LE(al_entry->mft_reference) != ni->seq_no) { in ntfs_external_attr_find()
978 if (ni != base_ni) in ntfs_external_attr_find()
979 unmap_extent_mft_record(ni); in ntfs_external_attr_find()
983 ni = ctx->ntfs_ino = base_ni; in ntfs_external_attr_find()
989 al_entry->mft_reference), &ni); in ntfs_external_attr_find()
1002 ni = NULL; in ntfs_external_attr_find()
1005 ctx->ntfs_ino = ni; in ntfs_external_attr_find()
1076 if (ni != base_ni) { in ntfs_external_attr_find()
1077 if (ni) in ntfs_external_attr_find()
1078 unmap_extent_mft_record(ni); in ntfs_external_attr_find()
1109 if (ni != base_ni) in ntfs_external_attr_find()
1110 unmap_extent_mft_record(ni); in ntfs_external_attr_find()
1198 * @ni: ntfs inode with which to initialize the search context
1201 * Initialize the attribute search context @ctx with @ni and @mrec.
1204 ntfs_inode *ni, MFT_RECORD *mrec) in ntfs_attr_init_search_ctx() argument
1212 .ntfs_ino = ni, in ntfs_attr_init_search_ctx()
1249 * @ni: ntfs inode with which to initialize the search context
1252 * Allocate a new attribute search context, initialize it with @ni and @mrec,
1255 ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec) in ntfs_attr_get_search_ctx() argument
1261 ntfs_attr_init_search_ctx(ctx, ni, mrec); in ntfs_attr_get_search_ctx()
1489 * @ni: ntfs inode describing the attribute to convert
1492 * Convert the resident ntfs attribute described by the ntfs inode @ni to a
1521 int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) in ntfs_attr_make_non_resident() argument
1524 struct inode *vi = VFS_I(ni); in ntfs_attr_make_non_resident()
1525 ntfs_volume *vol = ni->vol; in ntfs_attr_make_non_resident()
1539 err = ntfs_attr_can_be_non_resident(vol, ni->type); in ntfs_attr_make_non_resident()
1553 BUG_ON(NInoCompressed(ni)); in ntfs_attr_make_non_resident()
1554 BUG_ON(NInoEncrypted(ni)); in ntfs_attr_make_non_resident()
1593 down_write(&ni->runlist.lock); in ntfs_attr_make_non_resident()
1594 if (!NInoAttr(ni)) in ntfs_attr_make_non_resident()
1595 base_ni = ni; in ntfs_attr_make_non_resident()
1597 base_ni = ni->ext.base_ntfs_ino; in ntfs_attr_make_non_resident()
1610 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, in ntfs_attr_make_non_resident()
1619 BUG_ON(NInoNonResident(ni)); in ntfs_attr_make_non_resident()
1624 if (NInoSparse(ni) || NInoCompressed(ni)) in ntfs_attr_make_non_resident()
1681 if (NInoSparse(ni) || NInoCompressed(ni)) { in ntfs_attr_make_non_resident()
1683 if (NInoCompressed(ni) || vol->major_ver < 3) in ntfs_attr_make_non_resident()
1698 ni->runlist.rl = rl; in ntfs_attr_make_non_resident()
1699 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1700 ni->allocated_size = new_size; in ntfs_attr_make_non_resident()
1701 if (NInoSparse(ni) || NInoCompressed(ni)) { in ntfs_attr_make_non_resident()
1702 ni->itype.compressed.size = ni->allocated_size; in ntfs_attr_make_non_resident()
1704 ni->itype.compressed.block_size = 1U << (a->data. in ntfs_attr_make_non_resident()
1707 ni->itype.compressed.block_size_bits = in ntfs_attr_make_non_resident()
1708 ffs(ni->itype.compressed.block_size) - in ntfs_attr_make_non_resident()
1710 ni->itype.compressed.block_clusters = 1U << in ntfs_attr_make_non_resident()
1713 ni->itype.compressed.block_size = 0; in ntfs_attr_make_non_resident()
1714 ni->itype.compressed.block_size_bits = 0; in ntfs_attr_make_non_resident()
1715 ni->itype.compressed.block_clusters = 0; in ntfs_attr_make_non_resident()
1717 vi->i_blocks = ni->itype.compressed.size >> 9; in ntfs_attr_make_non_resident()
1719 vi->i_blocks = ni->allocated_size >> 9; in ntfs_attr_make_non_resident()
1720 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1727 NInoSetNonResident(ni); in ntfs_attr_make_non_resident()
1733 up_write(&ni->runlist.lock); in ntfs_attr_make_non_resident()
1776 (unsigned)le32_to_cpu(ni->type), in ntfs_attr_make_non_resident()
1778 ((ni->type == AT_DATA) && in ntfs_attr_make_non_resident()
1779 !ni->name_len) ? "FILE": "ATTRIBUTE"); in ntfs_attr_make_non_resident()
1780 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1781 ni->initialized_size = attr_size; in ntfs_attr_make_non_resident()
1783 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1799 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1800 ni->allocated_size = arec_size - mp_ofs; in ntfs_attr_make_non_resident()
1801 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_make_non_resident()
1810 ni->runlist.rl = NULL; in ntfs_attr_make_non_resident()
1811 up_write(&ni->runlist.lock); in ntfs_attr_make_non_resident()
1833 * @ni: ntfs inode of the attribute whose allocation to extend
1838 * Extend the allocated space of an attribute described by the ntfs inode @ni
1841 * inode @ni have sparse support enabled). If @data_start is >= 0, then the
1879 * Locking: This function takes the runlist lock of @ni for writing as well as
1890 s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size, in ntfs_attr_extend_allocation() argument
1895 struct inode *vi = VFS_I(ni); in ntfs_attr_extend_allocation()
1896 ntfs_volume *vol = ni->vol; in ntfs_attr_extend_allocation()
1908 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1909 allocated_size = ni->allocated_size; in ntfs_attr_extend_allocation()
1910 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1915 (unsigned)le32_to_cpu(ni->type), in ntfs_attr_extend_allocation()
1926 if (NInoNonResident(ni)) { in ntfs_attr_extend_allocation()
1934 err = ntfs_attr_size_bounds_check(vol, ni->type, new_alloc_size); in ntfs_attr_extend_allocation()
1937 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1938 allocated_size = ni->allocated_size; in ntfs_attr_extend_allocation()
1939 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1949 le32_to_cpu(ni->type)); in ntfs_attr_extend_allocation()
1959 le32_to_cpu(ni->type)); in ntfs_attr_extend_allocation()
1969 if (!NInoAttr(ni)) in ntfs_attr_extend_allocation()
1970 base_ni = ni; in ntfs_attr_extend_allocation()
1972 base_ni = ni->ext.base_ntfs_ino; in ntfs_attr_extend_allocation()
1977 down_write(&ni->runlist.lock); in ntfs_attr_extend_allocation()
1990 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1991 allocated_size = ni->allocated_size; in ntfs_attr_extend_allocation()
1992 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
1997 vcn = NInoNonResident(ni) ? allocated_size >> vol->cluster_size_bits : in ntfs_attr_extend_allocation()
2016 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, in ntfs_attr_extend_allocation()
2028 BUG_ON(NInoNonResident(ni)); in ntfs_attr_extend_allocation()
2041 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2042 ni->allocated_size = le32_to_cpu(a->length) - in ntfs_attr_extend_allocation()
2044 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2062 up_write(&ni->runlist.lock); in ntfs_attr_extend_allocation()
2067 err = ntfs_attr_make_non_resident(ni, attr_len); in ntfs_attr_extend_allocation()
2077 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2078 allocated_size = ni->allocated_size; in ntfs_attr_extend_allocation()
2079 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2086 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2092 read_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2093 allocated_size = ni->allocated_size; in ntfs_attr_extend_allocation()
2094 read_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2118 if (ni->type == AT_ATTRIBUTE_LIST || in ntfs_attr_extend_allocation()
2119 ni->type == AT_STANDARD_INFORMATION) { in ntfs_attr_extend_allocation()
2137 BUG_ON(!NInoNonResident(ni)); in ntfs_attr_extend_allocation()
2150 if ((start >= 0 && start <= allocated_size) || ni->type != AT_DATA || in ntfs_attr_extend_allocation()
2151 !NVolSparseEnabled(vol) || NInoSparseDisabled(ni)) in ntfs_attr_extend_allocation()
2158 rl = ni->runlist.rl; in ntfs_attr_extend_allocation()
2166 (rl->lcn == LCN_ENOENT && rl > ni->runlist.rl && in ntfs_attr_extend_allocation()
2170 rl = ntfs_mapping_pairs_decompress(vol, a, ni->runlist.rl); in ntfs_attr_extend_allocation()
2180 (unsigned)le32_to_cpu(ni->type), in ntfs_attr_extend_allocation()
2186 ni->runlist.rl = rl; in ntfs_attr_extend_allocation()
2199 while (rl->lcn < 0 && rl > ni->runlist.rl) in ntfs_attr_extend_allocation()
2216 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2221 rl = ntfs_runlists_merge(ni->runlist.rl, rl2); in ntfs_attr_extend_allocation()
2229 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2242 ni->runlist.rl = rl; in ntfs_attr_extend_allocation()
2262 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2297 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2316 err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len, in ntfs_attr_extend_allocation()
2323 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2324 ni->allocated_size = new_alloc_size; in ntfs_attr_extend_allocation()
2327 * FIXME: This would fail if @ni is a directory, $MFT, or an index, in ntfs_attr_extend_allocation()
2336 if (NInoSparse(ni) || NInoCompressed(ni)) { in ntfs_attr_extend_allocation()
2337 ni->itype.compressed.size += new_alloc_size - allocated_size; in ntfs_attr_extend_allocation()
2339 cpu_to_sle64(ni->itype.compressed.size); in ntfs_attr_extend_allocation()
2340 vi->i_blocks = ni->itype.compressed.size >> 9; in ntfs_attr_extend_allocation()
2343 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2357 up_write(&ni->runlist.lock); in ntfs_attr_extend_allocation()
2367 (unsigned)le32_to_cpu(ni->type), err); in ntfs_attr_extend_allocation()
2371 if (ntfs_attr_lookup(ni->type, ni->name, ni->name_len, CASE_SENSITIVE, in ntfs_attr_extend_allocation()
2377 write_lock_irqsave(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2378 ni->allocated_size = new_alloc_size; in ntfs_attr_extend_allocation()
2380 * FIXME: This would fail if @ni is a directory... See above. in ntfs_attr_extend_allocation()
2384 if (NInoSparse(ni) || NInoCompressed(ni)) { in ntfs_attr_extend_allocation()
2385 ni->itype.compressed.size += new_alloc_size - in ntfs_attr_extend_allocation()
2387 vi->i_blocks = ni->itype.compressed.size >> 9; in ntfs_attr_extend_allocation()
2390 write_unlock_irqrestore(&ni->size_lock, flags); in ntfs_attr_extend_allocation()
2393 up_write(&ni->runlist.lock); in ntfs_attr_extend_allocation()
2405 if (ntfs_cluster_free(ni, ll, -1, ctx) < 0) { in ntfs_attr_extend_allocation()
2419 if (ntfs_rl_truncate_nolock(vol, &ni->runlist, ll) || IS_ERR(m)) { in ntfs_attr_extend_allocation()
2453 up_write(&ni->runlist.lock); in ntfs_attr_extend_allocation()
2461 * @ni: ntfs inode describing the attribute to fill
2466 * Fill @cnt bytes of the attribute described by the ntfs inode @ni starting at
2479 int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val) in ntfs_attr_set() argument
2481 ntfs_volume *vol = ni->vol; in ntfs_attr_set()
2498 BUG_ON(NInoCompressed(ni)); in ntfs_attr_set()
2499 BUG_ON(NInoEncrypted(ni)); in ntfs_attr_set()
2500 mapping = VFS_I(ni)->i_mapping; in ntfs_attr_set()
2508 if (unlikely(end > i_size_read(VFS_I(ni)))) { in ntfs_attr_set()