Lines Matching full:ni
20 static struct mft_inode *ni_ins_mi(struct ntfs_inode *ni, struct rb_root *tree, in ni_ins_mi() argument
50 static struct mft_inode *ni_find_mi(struct ntfs_inode *ni, CLST rno) in ni_find_mi() argument
52 return ni_ins_mi(ni, &ni->mi_tree, rno, NULL); in ni_find_mi()
58 static void ni_add_mi(struct ntfs_inode *ni, struct mft_inode *mi) in ni_add_mi() argument
60 ni_ins_mi(ni, &ni->mi_tree, mi->rno, &mi->node); in ni_add_mi()
66 void ni_remove_mi(struct ntfs_inode *ni, struct mft_inode *mi) in ni_remove_mi() argument
68 rb_erase(&mi->node, &ni->mi_tree); in ni_remove_mi()
74 struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni) in ni_std() argument
78 attr = mi_find_attr(&ni->mi, NULL, ATTR_STD, NULL, 0, NULL); in ni_std()
88 struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni) in ni_std5() argument
92 attr = mi_find_attr(&ni->mi, NULL, ATTR_STD, NULL, 0, NULL); in ni_std5()
101 void ni_clear(struct ntfs_inode *ni) in ni_clear() argument
105 if (!ni->vfs_inode.i_nlink && ni->mi.mrec && in ni_clear()
106 is_rec_inuse(ni->mi.mrec) && in ni_clear()
107 !(ni->mi.sbi->flags & NTFS_FLAGS_LOG_REPLAYING)) in ni_clear()
108 ni_delete_all(ni); in ni_clear()
110 al_destroy(ni); in ni_clear()
112 for (node = rb_first(&ni->mi_tree); node;) { in ni_clear()
116 rb_erase(node, &ni->mi_tree); in ni_clear()
122 if (ni->ni_flags & NI_FLAG_DIR) in ni_clear()
123 indx_clear(&ni->dir); in ni_clear()
125 run_close(&ni->file.run); in ni_clear()
127 if (ni->file.offs_folio) { in ni_clear()
129 folio_put(ni->file.offs_folio); in ni_clear()
130 ni->file.offs_folio = NULL; in ni_clear()
135 mi_clear(&ni->mi); in ni_clear()
141 int ni_load_mi_ex(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi) in ni_load_mi_ex() argument
146 r = ni_find_mi(ni, rno); in ni_load_mi_ex()
150 err = mi_get(ni->mi.sbi, rno, &r); in ni_load_mi_ex()
154 ni_add_mi(ni, r); in ni_load_mi_ex()
165 int ni_load_mi(struct ntfs_inode *ni, const struct ATTR_LIST_ENTRY *le, in ni_load_mi() argument
171 *mi = &ni->mi; in ni_load_mi()
176 if (rno == ni->mi.rno) { in ni_load_mi()
177 *mi = &ni->mi; in ni_load_mi()
180 return ni_load_mi_ex(ni, rno, mi); in ni_load_mi()
188 struct ATTRIB *ni_find_attr(struct ntfs_inode *ni, struct ATTRIB *attr, in ni_find_attr() argument
196 if (!ni->attr_list.size || in ni_find_attr()
201 *mi = &ni->mi; in ni_find_attr()
204 return mi_find_attr(&ni->mi, attr, type, name, name_len, NULL); in ni_find_attr()
208 le = al_find_ex(ni, le_o ? *le_o : NULL, type, name, name_len, vcn); in ni_find_attr()
216 if (ni_load_mi(ni, le, &m)) in ni_find_attr()
241 ntfs_inode_err(&ni->vfs_inode, "failed to parse mft record"); in ni_find_attr()
242 ntfs_set_state(ni->mi.sbi, NTFS_DIRTY_ERROR); in ni_find_attr()
249 struct ATTRIB *ni_enum_attr_ex(struct ntfs_inode *ni, struct ATTRIB *attr, in ni_enum_attr_ex() argument
257 if (!ni->attr_list.size) { in ni_enum_attr_ex()
260 *mi = &ni->mi; in ni_enum_attr_ex()
262 return mi_enum_attr(&ni->mi, attr); in ni_enum_attr_ex()
266 le2 = *le = al_enumerate(ni, attr ? *le : NULL); in ni_enum_attr_ex()
271 if (ni_load_mi(ni, le2, &mi2)) in ni_enum_attr_ex()
284 struct ATTRIB *ni_load_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, in ni_load_attr() argument
293 if (!ni->attr_list.size) { in ni_load_attr()
295 *pmi = &ni->mi; in ni_load_attr()
296 return mi_find_attr(&ni->mi, NULL, type, name, name_len, NULL); in ni_load_attr()
299 le = al_find_ex(ni, NULL, type, name, name_len, NULL); in ni_load_attr()
310 next = al_find_ex(ni, le, type, name, name_len, NULL); in ni_load_attr()
316 if (ni_load_mi(ni, le, &mi)) in ni_load_attr()
339 int ni_load_all_mi(struct ntfs_inode *ni) in ni_load_all_mi() argument
344 if (!ni->attr_list.size) in ni_load_all_mi()
349 while ((le = al_enumerate(ni, le))) { in ni_load_all_mi()
352 if (rno == ni->mi.rno) in ni_load_all_mi()
355 err = ni_load_mi_ex(ni, rno, NULL); in ni_load_all_mi()
366 bool ni_add_subrecord(struct ntfs_inode *ni, CLST rno, struct mft_inode **mi) in ni_add_subrecord() argument
374 if (mi_format_new(m, ni->mi.sbi, rno, 0, ni->mi.rno == MFT_REC_MFT)) { in ni_add_subrecord()
379 mi_get_ref(&ni->mi, &m->mrec->parent_ref); in ni_add_subrecord()
381 ni_add_mi(ni, m); in ni_add_subrecord()
389 int ni_remove_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, in ni_remove_attr() argument
400 if (base_only || type == ATTR_LIST || !ni->attr_list.size) { in ni_remove_attr()
401 attr = mi_find_attr(&ni->mi, NULL, type, name, name_len, id); in ni_remove_attr()
405 mi_remove_attr(ni, &ni->mi, attr); in ni_remove_attr()
413 le = al_enumerate(ni, le); in ni_remove_attr()
434 err = ni_load_mi(ni, le, &mi); in ni_remove_attr()
438 al_remove_le(ni, le); in ni_remove_attr()
444 mi_remove_attr(ni, mi, attr); in ni_remove_attr()
446 if (PtrOffset(ni->attr_list.le, le) >= ni->attr_list.size) in ni_remove_attr()
458 ni_ins_new_attr(struct ntfs_inode *ni, struct mft_inode *mi, in ni_ins_new_attr() argument
470 if (type != ATTR_LIST && !le && ni->attr_list.size) { in ni_ins_new_attr()
471 err = al_add_le(ni, type, name, name_len, svcn, cpu_to_le16(-1), in ni_ins_new_attr()
491 al_remove_le(ni, le); in ni_ins_new_attr()
505 ni->attr_list.dirty = true; in ni_ins_new_attr()
521 static int ni_repack(struct ntfs_inode *ni) in ni_repack() argument
527 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_repack()
539 while ((attr = ni_enum_attr_ex(ni, attr, &le, &mi))) { in ni_repack()
583 err = run_unpack(&run, sbi, ni->mi.rno, svcn, evcn, svcn, in ni_repack()
611 al_remove_le(ni, le); in ni_repack()
619 ni->attr_list.dirty = true; in ni_repack()
638 ntfs_inode_warn(&ni->vfs_inode, "repack problem"); in ni_repack()
657 static int ni_try_remove_attr_list(struct ntfs_inode *ni) in ni_try_remove_attr_list() argument
660 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_try_remove_attr_list()
669 if (!ni->attr_list.dirty) in ni_try_remove_attr_list()
672 err = ni_repack(ni); in ni_try_remove_attr_list()
676 attr_list = mi_find_attr(&ni->mi, NULL, ATTR_LIST, NULL, 0, NULL); in ni_try_remove_attr_list()
683 free = sbi->record_size - le32_to_cpu(ni->mi.mrec->used) + asize; in ni_try_remove_attr_list()
684 mi_get_ref(&ni->mi, &ref); in ni_try_remove_attr_list()
687 while ((le = al_enumerate(ni, le))) { in ni_try_remove_attr_list()
694 mi = ni_find_mi(ni, ino_get(&le->ref)); in ni_try_remove_attr_list()
711 mrec = kmemdup(ni->mi.mrec, sbi->record_size, GFP_NOFS); in ni_try_remove_attr_list()
716 mi_remove_attr(NULL, &ni->mi, attr_list); in ni_try_remove_attr_list()
724 while ((le = al_enumerate(ni, le))) { in ni_try_remove_attr_list()
728 mi = ni_find_mi(ni, ino_get(&le->ref)); in ni_try_remove_attr_list()
743 attr_ins = mi_insert_attr(&ni->mi, le->type, le_name(le), in ni_try_remove_attr_list()
763 while ((le = al_enumerate(ni, le))) { in ni_try_remove_attr_list()
767 mi = ni_find_mi(ni, ino_get(&le->ref)); in ni_try_remove_attr_list()
780 run_deallocate(sbi, &ni->attr_list.run, true); in ni_try_remove_attr_list()
781 run_close(&ni->attr_list.run); in ni_try_remove_attr_list()
782 ni->attr_list.size = 0; in ni_try_remove_attr_list()
783 kvfree(ni->attr_list.le); in ni_try_remove_attr_list()
784 ni->attr_list.le = NULL; in ni_try_remove_attr_list()
785 ni->attr_list.dirty = false; in ni_try_remove_attr_list()
791 swap(mrec, ni->mi.mrec); in ni_try_remove_attr_list()
799 int ni_create_attr_list(struct ntfs_inode *ni) in ni_create_attr_list() argument
801 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_create_attr_list()
814 is_mft = ni->mi.rno == MFT_REC_MFT; in ni_create_attr_list()
815 rec = ni->mi.mrec; in ni_create_attr_list()
826 mi_get_ref(&ni->mi, &le->ref); in ni_create_attr_list()
827 ni->attr_list.le = le; in ni_create_attr_list()
834 for (; (attr = mi_enum_attr(&ni->mi, attr)); le = Add2Ptr(le, sz)) { in ni_create_attr_list()
841 if (le != ni->attr_list.le) in ni_create_attr_list()
842 le->ref = ni->attr_list.le->ref; in ni_create_attr_list()
862 lsize = PtrOffset(ni->attr_list.le, le); in ni_create_attr_list()
863 ni->attr_list.size = lsize; in ni_create_attr_list()
878 err = ntfs_look_free_mft(sbi, &rno, is_mft, ni, &mi); in ni_create_attr_list()
902 if (!mi_remove_attr(NULL, &ni->mi, b)) in ni_create_attr_list()
912 attr = mi_insert_attr(&ni->mi, ATTR_LIST, NULL, 0, in ni_create_attr_list()
924 memcpy(resident_data_ex(attr, lsize), ni->attr_list.le, lsize); in ni_create_attr_list()
926 ni->attr_list.dirty = false; in ni_create_attr_list()
928 mark_inode_dirty(&ni->vfs_inode); in ni_create_attr_list()
932 kvfree(ni->attr_list.le); in ni_create_attr_list()
933 ni->attr_list.le = NULL; in ni_create_attr_list()
934 ni->attr_list.size = 0; in ni_create_attr_list()
941 static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le, in ni_ins_attr_ext() argument
954 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_ins_attr_ext()
956 is_mft = ni->mi.rno == MFT_REC_MFT; in ni_ins_attr_ext()
969 ni->mi.rno == MFT_REC_LOG) { in ni_ins_attr_ext()
975 if (!ni->attr_list.size) { in ni_ins_attr_ext()
976 err = ni_create_attr_list(ni); in ni_ins_attr_ext()
987 err = ni_load_all_mi(ni); in ni_ins_attr_ext()
992 for (node = rb_first(&ni->mi_tree); node; node = rb_next(node)) { in ni_ins_attr_ext()
1024 attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize, in ni_ins_attr_ext()
1040 err = ntfs_look_free_mft(sbi, &rno, is_mft_data, ni, &mi); in ni_ins_attr_ext()
1049 attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize, in ni_ins_attr_ext()
1069 ni_remove_mi(ni, mi); in ni_ins_attr_ext()
1092 static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, in ni_insert_attr() argument
1098 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_insert_attr()
1108 is_mft = ni->mi.rno == MFT_REC_MFT; in ni_insert_attr()
1109 rec = ni->mi.mrec; in ni_insert_attr()
1124 attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len, in ni_insert_attr()
1135 *ins_mi = &ni->mi; in ni_insert_attr()
1143 err = ni_ins_attr_ext(ni, NULL, type, name, name_len, asize, in ni_insert_attr()
1160 while ((attr = mi_enum_attr(&ni->mi, attr))) { in ni_insert_attr()
1178 attr = mi_enum_attr(&ni->mi, attr); in ni_insert_attr()
1190 if (ni->attr_list.size) { in ni_insert_attr()
1191 le = al_find_le(ni, NULL, attr); in ni_insert_attr()
1201 err = ni_ins_attr_ext(ni, le, attr->type, Add2Ptr(attr, t16), in ni_insert_attr()
1212 mi_remove_attr(NULL, &ni->mi, attr); in ni_insert_attr()
1221 attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len, asize, in ni_insert_attr()
1236 *ins_mi = &ni->mi; in ni_insert_attr()
1243 static int ni_expand_mft_list(struct ntfs_inode *ni) in ni_expand_mft_list() argument
1246 struct runs_tree *run = &ni->file.run; in ni_expand_mft_list()
1252 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_expand_mft_list()
1259 for (node = rb_first(&ni->mi_tree); node; node = rb_next(node)) { in ni_expand_mft_list()
1271 if (ntfs_look_free_mft(sbi, &mft_new, true, ni, &mi_new)) { in ni_expand_mft_list()
1280 ni_remove_mi(ni, mi_new); in ni_expand_mft_list()
1283 attr = mi_find_attr(&ni->mi, NULL, ATTR_DATA, NULL, 0, NULL); in ni_expand_mft_list()
1320 le32_sub_cpu(&ni->mi.mrec->used, done); in ni_expand_mft_list()
1340 attr = ni_ins_new_attr(ni, mi_min, NULL, ATTR_DATA, NULL, 0, in ni_expand_mft_list()
1368 ni_remove_mi(ni, mi_new); in ni_expand_mft_list()
1377 int ni_expand_list(struct ntfs_inode *ni) in ni_expand_list() argument
1383 bool is_mft = ni->mi.rno == MFT_REC_MFT; in ni_expand_list()
1386 mi_get_ref(&ni->mi, &ref); in ni_expand_list()
1389 while ((le = al_enumerate(ni, le))) { in ni_expand_list()
1400 attr = rec_find_attr_le(&ni->mi, le); in ni_expand_list()
1409 err = ni_ins_attr_ext(ni, le, attr->type, attr_name(attr), in ni_expand_list()
1420 mi_remove_attr(NULL, &ni->mi, attr); in ni_expand_list()
1432 err = ni_expand_mft_list(ni); in ni_expand_list()
1441 int ni_insert_nonresident(struct ntfs_inode *ni, enum ATTR_TYPE type, in ni_insert_nonresident() argument
1456 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_insert_nonresident()
1478 err = ni_insert_attr(ni, type, name, name_len, asize, name_off, svcn, in ni_insert_nonresident()
1500 svcn ? 0 : cpu_to_le64((u64)len << ni->mi.sbi->cluster_bits); in ni_insert_nonresident()
1517 int ni_insert_resident(struct ntfs_inode *ni, u32 data_size, in ni_insert_resident() argument
1527 err = ni_insert_attr(ni, type, name, name_len, asize, SIZEOF_RESIDENT, in ni_insert_resident()
1541 le16_add_cpu(&ni->mi.mrec->hard_links, 1); in ni_insert_resident()
1542 ni->mi.dirty = true; in ni_insert_resident()
1555 void ni_remove_attr_le(struct ntfs_inode *ni, struct ATTRIB *attr, in ni_remove_attr_le() argument
1558 mi_remove_attr(ni, mi, attr); in ni_remove_attr_le()
1561 al_remove_le(ni, le); in ni_remove_attr_le()
1569 int ni_delete_all(struct ntfs_inode *ni) in ni_delete_all() argument
1578 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_delete_all()
1582 while ((attr = ni_enum_attr_ex(ni, attr, &le, NULL))) { in ni_delete_all()
1586 mi_get_ref(&ni->mi, &ref); in ni_delete_all()
1607 _ntfs_bad_inode(&ni->vfs_inode); in ni_delete_all()
1612 run_unpack_ex(RUN_DEALLOCATE, sbi, ni->mi.rno, svcn, evcn, svcn, in ni_delete_all()
1616 if (ni->attr_list.size) { in ni_delete_all()
1617 run_deallocate(ni->mi.sbi, &ni->attr_list.run, true); in ni_delete_all()
1618 al_destroy(ni); in ni_delete_all()
1622 for (node = rb_first(&ni->mi_tree); node;) { in ni_delete_all()
1631 ni_remove_mi(ni, mi); in ni_delete_all()
1637 clear_rec_inuse(ni->mi.mrec); in ni_delete_all()
1638 ni->mi.dirty = true; in ni_delete_all()
1639 err = mi_write(&ni->mi, 0); in ni_delete_all()
1641 ntfs_mark_rec_free(sbi, ni->mi.rno, false); in ni_delete_all()
1650 struct ATTR_FILE_NAME *ni_fname_name(struct ntfs_inode *ni, in ni_fname_name() argument
1664 attr = ni_find_attr(ni, attr, le, ATTR_NAME, NULL, 0, NULL, mi); in ni_fname_name()
1692 struct ATTR_FILE_NAME *ni_fname_type(struct ntfs_inode *ni, u8 name_type, in ni_fname_type() argument
1706 attr = ni_find_attr(ni, attr, le, ATTR_NAME, NULL, 0, NULL, mi); in ni_fname_type()
1720 * NOTE: You need to set ni->std_fa = new_fa
1723 int ni_new_attr_flags(struct ntfs_inode *ni, enum FILE_ATTRIBUTE new_fa) in ni_new_attr_flags() argument
1730 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, &mi); in ni_new_attr_flags()
1751 ntfs_inode_warn(&ni->vfs_inode, in ni_new_attr_flags()
1761 &ni->vfs_inode, in ni_new_attr_flags()
1778 ni->vfs_inode.i_mapping->a_ops = &ntfs_aops; in ni_new_attr_flags()
1783 ni->vfs_inode.i_mapping->a_ops = &ntfs_aops_cmpr; in ni_new_attr_flags()
1788 ni->vfs_inode.i_mapping->a_ops = &ntfs_aops; in ni_new_attr_flags()
1803 enum REPARSE_SIGN ni_parse_reparse(struct ntfs_inode *ni, struct ATTRIB *attr, in ni_parse_reparse() argument
1820 if (!attr_load_runs_vcn(ni, ATTR_REPARSE, NULL, 0, &run, 0) && in ni_parse_reparse()
1821 !ntfs_read_run_nb(ni->mi.sbi, &run, 0, buffer, in ni_parse_reparse()
1882 ni_set_ext_compress_bits(ni, bits); in ni_parse_reparse()
1886 ni->ni_flags |= NI_FLAG_DEDUPLICATED; in ni_parse_reparse()
1949 int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, in ni_fiemap() argument
1954 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_fiemap()
1961 u64 valid = ni->i_valid; in ni_fiemap()
1968 if (S_ISDIR(ni->vfs_inode.i_mode)) { in ni_fiemap()
1969 run = &ni->dir.alloc_run; in ni_fiemap()
1970 attr = ni_find_attr(ni, NULL, NULL, ATTR_ALLOC, I30_NAME, in ni_fiemap()
1972 run_lock = &ni->dir.run_lock; in ni_fiemap()
1974 run = &ni->file.run; in ni_fiemap()
1975 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, in ni_fiemap()
1985 &ni->vfs_inode, in ni_fiemap()
1989 run_lock = &ni->file.run_lock; in ni_fiemap()
2035 err = attr_load_runs_vcn(ni, attr->type, in ni_fiemap()
2065 if (S_ISDIR(ni->vfs_inode.i_mode)) { in ni_fiemap()
2071 ni, attr, vcn >> attr->nres.c_unit, &clst_data); in ni_fiemap()
2156 int ni_readpage_cmpr(struct ntfs_inode *ni, struct folio *folio) in ni_readpage_cmpr() argument
2159 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_readpage_cmpr()
2170 if (vbo >= i_size_read(&ni->vfs_inode)) { in ni_readpage_cmpr()
2177 if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { in ni_readpage_cmpr()
2179 frame_bits = ni_ext_compress_bits(ni); in ni_readpage_cmpr()
2212 err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame); in ni_readpage_cmpr()
2238 int ni_decompress_file(struct ntfs_inode *ni) in ni_decompress_file() argument
2240 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_decompress_file()
2241 struct inode *inode = &ni->vfs_inode; in ni_decompress_file()
2268 frame_bits = ni_ext_compress_bits(ni); in ni_decompress_file()
2296 err = attr_data_get_block(ni, vcn, cend - vcn, &lcn, in ni_decompress_file()
2317 err = ni_read_frame(ni, vbo, pages, pages_per_frame); in ni_decompress_file()
2320 down_read(&ni->file.run_lock); in ni_decompress_file()
2321 err = ntfs_bio_pages(sbi, &ni->file.run, pages, in ni_decompress_file()
2324 up_read(&ni->file.run_lock); in ni_decompress_file()
2345 while ((attr = ni_enum_attr_ex(ni, attr, &le, NULL))) { in ni_decompress_file()
2352 mi_get_ref(&ni->mi, &ref); in ni_decompress_file()
2380 run_unpack_ex(RUN_DEALLOCATE, sbi, ni->mi.rno, svcn, evcn, svcn, in ni_decompress_file()
2387 err = ni_remove_attr(ni, ATTR_DATA, WOF_NAME, ARRAY_SIZE(WOF_NAME), in ni_decompress_file()
2395 err = ni_remove_attr(ni, ATTR_REPARSE, NULL, 0, false, NULL); in ni_decompress_file()
2402 attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, &mi); in ni_decompress_file()
2423 ni->std_fa &= ~(FILE_ATTRIBUTE_SPARSE_FILE | in ni_decompress_file()
2430 ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK; in ni_decompress_file()
2431 if (ni->file.offs_folio) { in ni_decompress_file()
2432 folio_put(ni->file.offs_folio); in ni_decompress_file()
2433 ni->file.offs_folio = NULL; in ni_decompress_file()
2514 int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, in ni_read_frame() argument
2518 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_read_frame()
2524 struct runs_tree *run = &ni->file.run; in ni_read_frame()
2525 u64 valid_size = ni->i_valid; in ni_read_frame()
2547 attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, NULL); in ni_read_frame()
2572 if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { in ni_read_frame()
2577 loff_t i_size = i_size_read(&ni->vfs_inode); in ni_read_frame()
2578 u32 frame_bits = ni_ext_compress_bits(ni); in ni_read_frame()
2598 attr = ni_find_attr(ni, attr, &le, ATTR_DATA, WOF_NAME, in ni_read_frame()
2602 &ni->vfs_inode, in ni_read_frame()
2620 err = attr_wof_frame_info(ni, attr, run, frame64, frames, in ni_read_frame()
2651 err = attr_load_runs_range(ni, ATTR_DATA, WOF_NAME, in ni_read_frame()
2672 down_write(&ni->file.run_lock); in ni_read_frame()
2675 err = attr_is_frame_compressed(ni, attr, frame, &clst_data); in ni_read_frame()
2676 up_write(&ni->file.run_lock); in ni_read_frame()
2690 down_read(&ni->file.run_lock); in ni_read_frame()
2694 up_read(&ni->file.run_lock); in ni_read_frame()
2723 down_read(&ni->file.run_lock); in ni_read_frame()
2726 up_read(&ni->file.run_lock); in ni_read_frame()
2741 if (run != &ni->file.run) { in ni_read_frame()
2778 if (run != &ni->file.run) in ni_read_frame()
2798 int ni_write_frame(struct ntfs_inode *ni, struct page **pages, in ni_write_frame() argument
2802 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_write_frame()
2818 attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, &mi); in ni_write_frame()
2835 down_write(&ni->file.run_lock); in ni_write_frame()
2836 err = attr_make_nonresident(ni, attr, le, mi, in ni_write_frame()
2838 &ni->file.run, &attr, pages[0]); in ni_write_frame()
2839 up_write(&ni->file.run_lock); in ni_write_frame()
2922 down_write(&ni->file.run_lock); in ni_write_frame()
2923 run_truncate_around(&ni->file.run, le64_to_cpu(attr->nres.svcn)); in ni_write_frame()
2924 err = attr_allocate_frame(ni, frame, compr_size, ni->i_valid); in ni_write_frame()
2925 up_write(&ni->file.run_lock); in ni_write_frame()
2932 down_read(&ni->file.run_lock); in ni_write_frame()
2933 err = ntfs_bio_pages(sbi, &ni->file.run, in ni_write_frame()
2937 up_read(&ni->file.run_lock); in ni_write_frame()
2965 int ni_remove_name(struct ntfs_inode *dir_ni, struct ntfs_inode *ni, in ni_remove_name() argument
2969 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_remove_name()
2982 fname = ni_fname_name(ni, (struct le_str *)&de_name->name_len, in ni_remove_name()
2999 ni_remove_attr_le(ni, attr_from_name(fname), mi, le); in ni_remove_name()
3004 fname = ni_fname_type(ni, name_type, &mi, &le); in ni_remove_name()
3020 ni_remove_attr_le(ni, attr_from_name(fname), mi, le); in ni_remove_name()
3032 bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni, in ni_remove_name_undo() argument
3035 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_remove_name_undo()
3042 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0, in ni_remove_name_undo()
3047 mi_get_ref(&ni->mi, &de2->ref); in ni_remove_name_undo()
3060 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0, in ni_remove_name_undo()
3065 mi_get_ref(&ni->mi, &de->ref); in ni_remove_name_undo()
3077 int ni_add_name(struct ntfs_inode *dir_ni, struct ntfs_inode *ni, in ni_add_name() argument
3081 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_add_name()
3094 if (ni->mi.sbi->options->hide_dot_files) { in ni_add_name()
3097 ni->std_fa |= FILE_ATTRIBUTE_HIDDEN; in ni_add_name()
3099 ni->std_fa &= ~FILE_ATTRIBUTE_HIDDEN; in ni_add_name()
3102 mi_get_ref(&ni->mi, &de->ref); in ni_add_name()
3106 fname = ni_fname_name(ni, NULL, NULL, NULL, NULL); in ni_add_name()
3109 de_name->dup.fa = ni->std_fa; in ni_add_name()
3112 err = ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0, &attr, in ni_add_name()
3122 ni_remove_attr_le(ni, attr, mi, le); in ni_add_name()
3131 struct ntfs_inode *ni, struct NTFS_DE *de, struct NTFS_DE *new_de, in ni_rename() argument
3152 err = ni_add_name(new_dir_ni, ni, new_de); in ni_rename()
3154 err = ni_remove_name(dir_ni, ni, de, &de2, &undo); in ni_rename()
3155 if (err && ni_remove_name(new_dir_ni, ni, new_de, &de2, &undo)) in ni_rename()
3163 * err = ni_remove_name(dir_ni, ni, de, &de2, &undo); in ni_rename()
3165 * err = ni_add_name(new_dir_ni, ni, new_de); in ni_rename()
3166 * if (err && !ni_remove_name_undo(dir_ni, ni, de, de2, undo)) in ni_rename()
3175 * ni_is_dirty - Return: True if 'ni' requires ni_write_inode.
3179 struct ntfs_inode *ni = ntfs_i(inode); in ni_is_dirty() local
3182 if (ni->mi.dirty || ni->attr_list.dirty || in ni_is_dirty()
3183 (ni->ni_flags & NI_FLAG_UPDATE_PARENT)) in ni_is_dirty()
3186 for (node = rb_first(&ni->mi_tree); node; node = rb_next(node)) { in ni_is_dirty()
3199 static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup, in ni_update_parent() argument
3205 struct ntfs_sb_info *sbi = ni->mi.sbi; in ni_update_parent()
3209 if (ni->mi.mrec->flags & RECORD_FLAG_DIR) { in ni_update_parent()
3217 attr = ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0, NULL, in ni_update_parent()
3227 u64 new_valid = ni->i_valid; in ni_update_parent()
3251 if (ni->ni_flags & NI_FLAG_EA) { in ni_update_parent()
3252 attr = ni_find_attr(ni, attr, &le, ATTR_EA_INFO, NULL, 0, NULL, in ni_update_parent()
3267 while ((attr = ni_find_attr(ni, attr, &le, ATTR_NAME, NULL, 0, NULL, in ni_update_parent()
3277 if (ino_get(&fname->home) == ni->vfs_inode.i_ino) { in ni_update_parent()
3286 &ni->vfs_inode, in ni_update_parent()
3316 struct ntfs_inode *ni = ntfs_i(inode); in ni_write_inode() local
3330 if (!ni_trylock(ni)) { in ni_write_inode()
3331 /* 'ni' is under modification, skip for now. */ in ni_write_inode()
3336 if (!ni->mi.mrec) in ni_write_inode()
3339 if (is_rec_inuse(ni->mi.mrec) && in ni_write_inode()
3345 std = ni_std(ni); in ni_write_inode()
3373 dup.fa = ni->std_fa; in ni_write_inode()
3381 ni->mi.dirty = true; in ni_write_inode()
3384 (modified || (ni->ni_flags & NI_FLAG_UPDATE_PARENT)) in ni_write_inode()
3389 re_dirty = ni_update_parent(ni, &dup, sync); in ni_write_inode()
3392 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in ni_write_inode()
3394 ni->ni_flags &= ~NI_FLAG_UPDATE_PARENT; in ni_write_inode()
3398 if (ni->attr_list.size && ni->attr_list.dirty) { in ni_write_inode()
3400 err = ni_try_remove_attr_list(ni); in ni_write_inode()
3405 err = al_update(ni, sync); in ni_write_inode()
3411 for (node = rb_first(&ni->mi_tree); node; node = next) { in ni_write_inode()
3431 rb_erase(node, &ni->mi_tree); in ni_write_inode()
3436 if (ni->mi.dirty) { in ni_write_inode()
3437 err2 = mi_write(&ni->mi, sync); in ni_write_inode()
3442 ni_unlock(ni); in ni_write_inode()
3465 struct ntfs_inode *ni = ntfs_i(inode); in ni_set_compress() local
3469 if (is_compressed(ni) == !!compr) in ni_set_compress()
3472 if (is_sparsed(ni)) { in ni_set_compress()
3484 ni_lock(ni); in ni_set_compress()
3486 std = ni_std(ni); in ni_set_compress()
3493 err = attr_set_compress(ni, compr); in ni_set_compress()
3504 ni->std_fa = std->fa; in ni_set_compress()
3510 if (ni->std_fa != std->fa) { in ni_set_compress()
3511 ni->std_fa = std->fa; in ni_set_compress()
3512 ni->mi.dirty = true; in ni_set_compress()
3515 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; in ni_set_compress()
3519 ni_unlock(ni); in ni_set_compress()