Lines Matching refs:ni
36 static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni) in map_mft_record_page() argument
39 ntfs_volume *vol = ni->vol; in map_mft_record_page()
45 BUG_ON(ni->page); in map_mft_record_page()
52 index = (u64)ni->mft_no << vol->mft_record_size_bits >> in map_mft_record_page()
54 ofs = (ni->mft_no << vol->mft_record_size_bits) & ~PAGE_MASK; in map_mft_record_page()
68 "driver.", ni->mft_no); in map_mft_record_page()
78 ni->page = page; in map_mft_record_page()
79 ni->page_ofs = ofs; in map_mft_record_page()
83 "Run chkdsk.", ni->mft_no); in map_mft_record_page()
89 ni->page = NULL; in map_mft_record_page()
90 ni->page_ofs = 0; in map_mft_record_page()
144 MFT_RECORD *map_mft_record(ntfs_inode *ni) in map_mft_record() argument
148 ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no); in map_mft_record()
151 atomic_inc(&ni->count); in map_mft_record()
154 mutex_lock(&ni->mrec_lock); in map_mft_record()
156 m = map_mft_record_page(ni); in map_mft_record()
160 mutex_unlock(&ni->mrec_lock); in map_mft_record()
161 atomic_dec(&ni->count); in map_mft_record()
162 ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m)); in map_mft_record()
180 static inline void unmap_mft_record_page(ntfs_inode *ni) in unmap_mft_record_page() argument
182 BUG_ON(!ni->page); in unmap_mft_record_page()
185 ntfs_unmap_page(ni->page); in unmap_mft_record_page()
186 ni->page = NULL; in unmap_mft_record_page()
187 ni->page_ofs = 0; in unmap_mft_record_page()
202 void unmap_mft_record(ntfs_inode *ni) in unmap_mft_record() argument
204 struct page *page = ni->page; in unmap_mft_record()
208 ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no); in unmap_mft_record()
210 unmap_mft_record_page(ni); in unmap_mft_record()
211 mutex_unlock(&ni->mrec_lock); in unmap_mft_record()
212 atomic_dec(&ni->count); in unmap_mft_record()
239 ntfs_inode *ni = NULL; in map_extent_mft_record() local
261 ni = extent_nis[i]; in map_extent_mft_record()
263 atomic_inc(&ni->count); in map_extent_mft_record()
267 if (likely(ni != NULL)) { in map_extent_mft_record()
271 m = map_mft_record(ni); in map_extent_mft_record()
273 atomic_dec(&ni->count); in map_extent_mft_record()
278 *ntfs_ino = ni; in map_extent_mft_record()
281 unmap_mft_record(ni); in map_extent_mft_record()
293 ni = ntfs_new_extent_inode(base_ni->vol->sb, mft_no); in map_extent_mft_record()
294 if (unlikely(!ni)) { in map_extent_mft_record()
299 ni->vol = base_ni->vol; in map_extent_mft_record()
300 ni->seq_no = seq_no; in map_extent_mft_record()
301 ni->nr_extents = -1; in map_extent_mft_record()
302 ni->ext.base_ntfs_ino = base_ni; in map_extent_mft_record()
304 m = map_mft_record(ni); in map_extent_mft_record()
308 ntfs_clear_extent_inode(ni); in map_extent_mft_record()
340 base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni; in map_extent_mft_record()
344 *ntfs_ino = ni; in map_extent_mft_record()
347 unmap_mft_record(ni); in map_extent_mft_record()
355 ntfs_clear_extent_inode(ni); in map_extent_mft_record()
384 void __mark_mft_record_dirty(ntfs_inode *ni) in __mark_mft_record_dirty() argument
388 ntfs_debug("Entering for inode 0x%lx.", ni->mft_no); in __mark_mft_record_dirty()
389 BUG_ON(NInoAttr(ni)); in __mark_mft_record_dirty()
390 mark_ntfs_record_dirty(ni->page, ni->page_ofs); in __mark_mft_record_dirty()
392 mutex_lock(&ni->extent_lock); in __mark_mft_record_dirty()
393 if (likely(ni->nr_extents >= 0)) in __mark_mft_record_dirty()
394 base_ni = ni; in __mark_mft_record_dirty()
396 base_ni = ni->ext.base_ntfs_ino; in __mark_mft_record_dirty()
397 mutex_unlock(&ni->extent_lock); in __mark_mft_record_dirty()
660 int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) in write_mft_record_nolock() argument
662 ntfs_volume *vol = ni->vol; in write_mft_record_nolock()
663 struct page *page = ni->page; in write_mft_record_nolock()
673 ntfs_debug("Entering for inode 0x%lx.", ni->mft_no); in write_mft_record_nolock()
674 BUG_ON(NInoAttr(ni)); in write_mft_record_nolock()
687 if (!NInoTestClearDirty(ni)) in write_mft_record_nolock()
694 m_start = ni->page_ofs; in write_mft_record_nolock()
724 vcn = ((VCN)ni->mft_no << vol->mft_record_size_bits) + in write_mft_record_nolock()
750 ni->mft_no, (long long)lcn); in write_mft_record_nolock()
772 flush_dcache_mft_record_page(ni); in write_mft_record_nolock()
786 if (!sync && ni->mft_no < vol->mftmirr_size) in write_mft_record_nolock()
787 ntfs_sync_mft_mirror(vol, ni->mft_no, m, sync); in write_mft_record_nolock()
804 if (sync && ni->mft_no < vol->mftmirr_size) in write_mft_record_nolock()
805 ntfs_sync_mft_mirror(vol, ni->mft_no, m, sync); in write_mft_record_nolock()
808 flush_dcache_mft_record_page(ni); in write_mft_record_nolock()
814 ni->mft_no); in write_mft_record_nolock()
834 mark_mft_record_dirty(ni); in write_mft_record_nolock()
926 ntfs_inode *ni, *eni, **extent_nis; in ntfs_may_write_mft_record() local
966 ni = NTFS_I(vi); in ntfs_may_write_mft_record()
968 atomic_inc(&ni->count); in ntfs_may_write_mft_record()
970 if (NInoDirty(ni)) { in ntfs_may_write_mft_record()
973 atomic_dec(&ni->count); in ntfs_may_write_mft_record()
979 if (unlikely(!mutex_trylock(&ni->mrec_lock))) { in ntfs_may_write_mft_record()
982 atomic_dec(&ni->count); in ntfs_may_write_mft_record()
992 *locked_ni = ni; in ntfs_may_write_mft_record()
1038 ni = NTFS_I(vi); in ntfs_may_write_mft_record()
1039 mutex_lock(&ni->extent_lock); in ntfs_may_write_mft_record()
1040 if (ni->nr_extents <= 0) { in ntfs_may_write_mft_record()
1045 mutex_unlock(&ni->extent_lock); in ntfs_may_write_mft_record()
1052 extent_nis = ni->ext.extent_ntfs_inos; in ntfs_may_write_mft_record()
1053 for (eni = NULL, i = 0; i < ni->nr_extents; ++i) { in ntfs_may_write_mft_record()
1068 mutex_unlock(&ni->extent_lock); in ntfs_may_write_mft_record()
1079 mutex_unlock(&ni->extent_lock); in ntfs_may_write_mft_record()
2245 ntfs_inode *mft_ni, *mftbmp_ni, *ni; in ntfs_mft_record_alloc() local
2588 m_tmp = map_extent_mft_record(base_ni, bit, &ni); in ntfs_mft_record_alloc()
2645 ni = NTFS_I(vi); in ntfs_mft_record_alloc()
2654 NInoSetMstProtected(ni); in ntfs_mft_record_alloc()
2655 ni->type = AT_INDEX_ALLOCATION; in ntfs_mft_record_alloc()
2656 ni->name = I30; in ntfs_mft_record_alloc()
2657 ni->name_len = 4; in ntfs_mft_record_alloc()
2659 ni->itype.index.block_size = 4096; in ntfs_mft_record_alloc()
2660 ni->itype.index.block_size_bits = ntfs_ffs(4096) - 1; in ntfs_mft_record_alloc()
2661 ni->itype.index.collation_rule = COLLATION_FILE_NAME; in ntfs_mft_record_alloc()
2662 if (vol->cluster_size <= ni->itype.index.block_size) { in ntfs_mft_record_alloc()
2663 ni->itype.index.vcn_size = vol->cluster_size; in ntfs_mft_record_alloc()
2664 ni->itype.index.vcn_size_bits = in ntfs_mft_record_alloc()
2667 ni->itype.index.vcn_size = vol->sector_size; in ntfs_mft_record_alloc()
2668 ni->itype.index.vcn_size_bits = in ntfs_mft_record_alloc()
2675 ni->type = AT_DATA; in ntfs_mft_record_alloc()
2676 ni->name = NULL; in ntfs_mft_record_alloc()
2677 ni->name_len = 0; in ntfs_mft_record_alloc()
2693 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number); in ntfs_mft_record_alloc()
2698 atomic_inc(&ni->count); in ntfs_mft_record_alloc()
2699 mutex_lock(&ni->mrec_lock); in ntfs_mft_record_alloc()
2700 ni->page = page; in ntfs_mft_record_alloc()
2701 ni->page_ofs = ofs; in ntfs_mft_record_alloc()
2728 return ni; in ntfs_mft_record_alloc()
2773 int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m) in ntfs_extent_mft_record_free() argument
2775 unsigned long mft_no = ni->mft_no; in ntfs_extent_mft_record_free()
2776 ntfs_volume *vol = ni->vol; in ntfs_extent_mft_record_free()
2783 BUG_ON(NInoAttr(ni)); in ntfs_extent_mft_record_free()
2784 BUG_ON(ni->nr_extents != -1); in ntfs_extent_mft_record_free()
2786 mutex_lock(&ni->extent_lock); in ntfs_extent_mft_record_free()
2787 base_ni = ni->ext.base_ntfs_ino; in ntfs_extent_mft_record_free()
2788 mutex_unlock(&ni->extent_lock); in ntfs_extent_mft_record_free()
2798 if (atomic_read(&ni->count) > 2) { in ntfs_extent_mft_record_free()
2809 if (ni != extent_nis[i]) in ntfs_extent_mft_record_free()
2850 NInoSetDirty(ni); in ntfs_extent_mft_record_free()
2851 err = write_mft_record(ni, m, 0); in ntfs_extent_mft_record_free()
2859 unmap_extent_mft_record(ni); in ntfs_extent_mft_record_free()
2860 ntfs_clear_extent_inode(ni); in ntfs_extent_mft_record_free()
2901 extent_nis[base_ni->nr_extents++] = ni; in ntfs_extent_mft_record_free()
2903 mark_mft_record_dirty(ni); in ntfs_extent_mft_record_free()