Lines Matching full:ni

60 static int attr_load_runs(struct ATTRIB *attr, struct ntfs_inode *ni,  in attr_load_runs()  argument
81 err = run_unpack_ex(run, ni->mi.sbi, ni->mi.rno, svcn, evcn, in attr_load_runs()
226 int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr, in attr_make_nonresident() argument
291 struct address_space *mapping = ni->vfs_inode.i_mapping; in attr_make_nonresident()
315 al_remove_le(ni, le); in attr_make_nonresident()
317 err = ni_insert_nonresident(ni, attr_s->type, attr_name(attr_s), in attr_make_nonresident()
330 ni->ni_flags &= ~NI_FLAG_RESIDENT; in attr_make_nonresident()
354 static int attr_set_size_res(struct ntfs_inode *ni, struct ATTRIB *attr, in attr_set_size_res() argument
373 return attr_make_nonresident(ni, attr, le, mi, new_size, in attr_set_size_res()
402 int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, in attr_set_size() argument
408 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_set_size()
410 bool is_mft = ni->mi.rno == MFT_REC_MFT && type == ATTR_DATA && in attr_set_size()
426 attr_b = ni_find_attr(ni, NULL, &le_b, type, name, name_len, NULL, in attr_set_size()
434 err = attr_set_size_res(ni, attr_b, le_b, mi_b, new_size, run, in attr_set_size()
484 attr = ni_find_attr(ni, attr_b, &le, type, name, name_len, &vcn, in attr_set_size()
502 err = attr_load_runs(attr, ni, run, NULL); in attr_set_size()
629 err = ni_expand_list(ni); in attr_set_size()
639 if (!ni->attr_list.size) { in attr_set_size()
640 err = ni_create_attr_list(ni); in attr_set_size()
653 err = ni_insert_nonresident(ni, type, name, name_len, run, in attr_set_size()
662 attr_b = ni_find_attr(ni, NULL, &le_b, type, name, name_len, in attr_set_size()
676 if (ni->mi.rno != MFT_REC_MFT) in attr_set_size()
723 if (!al_remove_le(ni, le)) { in attr_set_size()
786 err = ni_load_mi(ni, le, &mi); in attr_set_size()
817 if (inode_get_bytes(&ni->vfs_inode) != new_alloc) { in attr_set_size()
818 inode_set_bytes(&ni->vfs_inode, new_alloc); in attr_set_size()
825 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_set_size()
826 mark_inode_dirty(&ni->vfs_inode); in attr_set_size()
852 attr = ni_find_attr(ni, attr_b, &le, type, name, name_len, in attr_set_size()
869 _ntfs_bad_inode(&ni->vfs_inode); in attr_set_size()
885 int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, in attr_data_get_block() argument
889 struct runs_tree *run = &ni->file.run; in attr_data_get_block()
905 down_read(&ni->file.run_lock); in attr_data_get_block()
908 up_read(&ni->file.run_lock); in attr_data_get_block()
914 sbi = ni->mi.sbi; in attr_data_get_block()
917 ni_lock(ni); in attr_data_get_block()
918 down_write(&ni->file.run_lock); in attr_data_get_block()
932 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); in attr_data_get_block()
963 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_data_get_block()
974 err = attr_load_runs(attr, ni, run, NULL); in attr_data_get_block()
979 err = attr_is_frame_compressed(ni, attr_b, vcn >> NTFS_LZNT_CUNIT, in attr_data_get_block()
1034 attr2 = ni_find_attr(ni, attr_b, &le_b, ATTR_DATA, NULL, in attr_data_get_block()
1041 err = attr_load_runs(attr2, ni, run, NULL); in attr_data_get_block()
1099 inode_set_bytes(&ni->vfs_inode, total_size); in attr_data_get_block()
1100 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_data_get_block()
1103 mark_inode_dirty(&ni->vfs_inode); in attr_data_get_block()
1114 if (!ni->attr_list.size) { in attr_data_get_block()
1115 err = ni_create_attr_list(ni); in attr_data_get_block()
1120 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, in attr_data_get_block()
1151 attr = ni_find_attr(ni, attr, &le, ATTR_DATA, NULL, 0, &svcn, &mi); in attr_data_get_block()
1168 if (!al_remove_le(ni, le)) { in attr_data_get_block()
1179 if (ni_load_mi(ni, le, &mi)) { in attr_data_get_block()
1196 err = attr_load_runs(attr, ni, run, &end); in attr_data_get_block()
1207 ni->attr_list.dirty = true; in attr_data_get_block()
1213 err = ni_insert_nonresident(ni, ATTR_DATA, NULL, 0, run, in attr_data_get_block()
1224 _ntfs_bad_inode(&ni->vfs_inode); in attr_data_get_block()
1226 up_write(&ni->file.run_lock); in attr_data_get_block()
1227 ni_unlock(ni); in attr_data_get_block()
1234 inode_set_bytes(&ni->vfs_inode, total_size0); in attr_data_get_block()
1239 _ntfs_bad_inode(&ni->vfs_inode); in attr_data_get_block()
1244 int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio) in attr_data_read_resident() argument
1251 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL); in attr_data_read_resident()
1271 int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio) in attr_data_write_resident() argument
1278 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, &mi); in attr_data_write_resident()
1296 ni->i_valid = data_size; in attr_data_write_resident()
1304 int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type, in attr_load_runs_vcn() argument
1313 if (!ni) { in attr_load_runs_vcn()
1318 attr = ni_find_attr(ni, NULL, NULL, type, name, name_len, &vcn, NULL); in attr_load_runs_vcn()
1337 err = run_unpack_ex(run, ni->mi.sbi, ni->mi.rno, svcn, evcn, svcn, in attr_load_runs_vcn()
1347 int attr_load_runs_range(struct ntfs_inode *ni, enum ATTR_TYPE type, in attr_load_runs_range() argument
1351 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_load_runs_range()
1360 err = attr_load_runs_vcn(ni, type, name, name_len, run, in attr_load_runs_range()
1377 int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, in attr_wof_frame_info() argument
1381 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_wof_frame_info()
1391 if (ni->vfs_inode.i_size < 0x100000000ull) { in attr_wof_frame_info()
1409 ntfs_inode_err(&ni->vfs_inode, "is corrupted"); in attr_wof_frame_info()
1430 down_write(&ni->file.run_lock); in attr_wof_frame_info()
1431 folio = ni->file.offs_folio; in attr_wof_frame_info()
1439 ni->file.offs_folio = folio; in attr_wof_frame_info()
1463 err = attr_load_runs_range(ni, ATTR_DATA, WOF_NAME, in attr_wof_frame_info()
1515 up_write(&ni->file.run_lock); in attr_wof_frame_info()
1526 int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr, in attr_is_frame_compressed() argument
1545 run = &ni->file.run; in attr_is_frame_compressed()
1548 err = attr_load_runs_vcn(ni, attr->type, attr_name(attr), in attr_is_frame_compressed()
1571 alen = bytes_to_cluster(ni->mi.sbi, le64_to_cpu(attr->nres.alloc_size)); in attr_is_frame_compressed()
1584 err = attr_load_runs_vcn(ni, attr->type, in attr_is_frame_compressed()
1628 * Assumed: down_write(&ni->file.run_lock);
1630 int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size, in attr_allocate_frame() argument
1634 struct runs_tree *run = &ni->file.run; in attr_allocate_frame()
1635 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_allocate_frame()
1644 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); in attr_allocate_frame()
1667 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_allocate_frame()
1677 err = attr_load_runs(attr, ni, run, NULL); in attr_allocate_frame()
1681 err = attr_is_frame_compressed(ni, attr_b, frame, &clst_data); in attr_allocate_frame()
1733 inode_set_bytes(&ni->vfs_inode, total_size); in attr_allocate_frame()
1734 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_allocate_frame()
1737 mark_inode_dirty(&ni->vfs_inode); in attr_allocate_frame()
1748 if (!ni->attr_list.size) { in attr_allocate_frame()
1749 err = ni_create_attr_list(ni); in attr_allocate_frame()
1754 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, in attr_allocate_frame()
1771 attr = ni_find_attr(ni, attr, &le, ATTR_DATA, NULL, 0, &svcn, &mi); in attr_allocate_frame()
1784 if (!al_remove_le(ni, le)) { in attr_allocate_frame()
1795 if (ni_load_mi(ni, le, &mi)) { in attr_allocate_frame()
1813 err = attr_load_runs(attr, ni, run, &end); in attr_allocate_frame()
1824 ni->attr_list.dirty = true; in attr_allocate_frame()
1831 err = ni_insert_nonresident(ni, ATTR_DATA, NULL, 0, run, in attr_allocate_frame()
1857 int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) in attr_collapse_range() argument
1860 struct runs_tree *run = &ni->file.run; in attr_collapse_range()
1861 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_collapse_range()
1875 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); in attr_collapse_range()
1904 down_write(&ni->file.run_lock); in attr_collapse_range()
1907 u64 new_valid = min(ni->i_valid, vbo); in attr_collapse_range()
1910 truncate_setsize(&ni->vfs_inode, vbo); in attr_collapse_range()
1911 err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, vbo, in attr_collapse_range()
1914 if (!err && new_valid < ni->i_valid) in attr_collapse_range()
1915 ni->i_valid = new_valid; in attr_collapse_range()
1941 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_collapse_range()
1959 ni->attr_list.dirty = true; in attr_collapse_range()
1966 err = attr_load_runs(attr, ni, run, &svcn); in attr_collapse_range()
1987 ni->attr_list.dirty = true; in attr_collapse_range()
1998 ni, ATTR_DATA, NULL, 0, run, next_svcn, in attr_collapse_range()
2019 run_unpack_ex(RUN_DEALLOCATE, sbi, ni->mi.rno, svcn, in attr_collapse_range()
2029 if (!al_remove_le(ni, le)) { in attr_collapse_range()
2039 if (ni_load_mi(ni, le, &mi)) { in attr_collapse_range()
2059 attr = ni_enum_attr_ex(ni, attr, &le, &mi); in attr_collapse_range()
2072 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, in attr_collapse_range()
2081 valid_size = ni->i_valid; in attr_collapse_range()
2096 ni->i_valid = valid_size; in attr_collapse_range()
2097 i_size_write(&ni->vfs_inode, data_size); in attr_collapse_range()
2098 inode_set_bytes(&ni->vfs_inode, total_size); in attr_collapse_range()
2099 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_collapse_range()
2100 mark_inode_dirty(&ni->vfs_inode); in attr_collapse_range()
2103 up_write(&ni->file.run_lock); in attr_collapse_range()
2105 _ntfs_bad_inode(&ni->vfs_inode); in attr_collapse_range()
2115 int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32 *frame_size) in attr_punch_hole() argument
2118 struct runs_tree *run = &ni->file.run; in attr_punch_hole()
2119 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_punch_hole()
2133 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); in attr_punch_hole()
2178 down_write(&ni->file.run_lock); in attr_punch_hole()
2204 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_punch_hole()
2218 err = attr_load_runs(attr, ni, run, &svcn); in attr_punch_hole()
2255 err = ni_insert_nonresident(ni, ATTR_DATA, NULL, 0, run, in attr_punch_hole()
2277 attr = ni_enum_attr_ex(ni, attr, &le, &mi); in attr_punch_hole()
2292 attr_b = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, in attr_punch_hole()
2305 inode_set_bytes(&ni->vfs_inode, total_size); in attr_punch_hole()
2306 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_punch_hole()
2307 mark_inode_dirty(&ni->vfs_inode); in attr_punch_hole()
2311 up_write(&ni->file.run_lock); in attr_punch_hole()
2315 _ntfs_bad_inode(&ni->vfs_inode); in attr_punch_hole()
2333 int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) in attr_insert_range() argument
2336 struct runs_tree *run = &ni->file.run; in attr_insert_range()
2337 struct ntfs_sb_info *sbi = ni->mi.sbi; in attr_insert_range()
2350 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b); in attr_insert_range()
2394 down_write(&ni->file.run_lock); in attr_insert_range()
2397 err = attr_set_size(ni, ATTR_DATA, NULL, 0, run, in attr_insert_range()
2401 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, in attr_insert_range()
2442 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_insert_range()
2454 err = attr_load_runs(attr, ni, run, NULL); in attr_insert_range()
2470 while ((attr = ni_enum_attr_ex(ni, attr, &le, &mi)) && in attr_insert_range()
2476 ni->attr_list.dirty = true; in attr_insert_range()
2482 err = ni_insert_nonresident(ni, ATTR_DATA, NULL, 0, run, in attr_insert_range()
2487 attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, in attr_insert_range()
2503 if (vbo <= ni->i_valid) in attr_insert_range()
2504 ni->i_valid += bytes; in attr_insert_range()
2509 /* ni->valid may be not equal valid_size (temporary). */ in attr_insert_range()
2510 if (ni->i_valid > data_size + bytes) in attr_insert_range()
2513 attr_b->nres.valid_size = cpu_to_le64(ni->i_valid); in attr_insert_range()
2517 i_size_write(&ni->vfs_inode, ni->vfs_inode.i_size + bytes); in attr_insert_range()
2518 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in attr_insert_range()
2519 mark_inode_dirty(&ni->vfs_inode); in attr_insert_range()
2524 up_write(&ni->file.run_lock); in attr_insert_range()
2529 _ntfs_bad_inode(&ni->vfs_inode); in attr_insert_range()
2544 attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0, &vcn, in attr_insert_range()
2554 if (attr_load_runs(attr, ni, run, NULL)) in attr_insert_range()
2563 while ((attr = ni_enum_attr_ex(ni, attr, &le, &mi)) && in attr_insert_range()
2569 ni->attr_list.dirty = true; in attr_insert_range()
2582 int attr_force_nonresident(struct ntfs_inode *ni) in attr_force_nonresident() argument
2589 attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, &mi); in attr_force_nonresident()
2591 ntfs_bad_inode(&ni->vfs_inode, "no data attribute"); in attr_force_nonresident()
2600 down_write(&ni->file.run_lock); in attr_force_nonresident()
2601 err = attr_make_nonresident(ni, attr, le, mi, in attr_force_nonresident()
2603 &ni->file.run, &attr, NULL); in attr_force_nonresident()
2604 up_write(&ni->file.run_lock); in attr_force_nonresident()
2612 int attr_set_compress(struct ntfs_inode *ni, bool compr) in attr_set_compress() argument
2617 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, &mi); in attr_set_compress()