Lines Matching full:ni

28  * @ni:		ntfs inode whose mft record page to map
30 * This maps the page in which the mft record of the ntfs inode @ni is situated
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()
96 * @ni: ntfs inode whose MFT record to map
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()
168 * @ni: ntfs inode whose mft record page to unmap
170 * This unmaps the page in which the mft record of the ntfs inode @ni is
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()
193 * @ni: ntfs inode whose MFT record to unmap
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()
363 * @ni: ntfs inode describing the mapped mft record
367 * Set the mapped (extent) mft record of the (base or extent) ntfs inode @ni,
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()
631 * @ni: ntfs inode describing the mapped (extent) mft record
636 * ntfs inode @ni to backing store. If the mft record @m has a counterpart in
639 * We only write the mft record if the ntfs inode @ni is dirty and the first
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()
2247 ntfs_inode *mft_ni, *mftbmp_ni, *ni; in ntfs_mft_record_alloc() local
2590 m_tmp = map_extent_mft_record(base_ni, bit, &ni); in ntfs_mft_record_alloc()
2647 ni = NTFS_I(vi); in ntfs_mft_record_alloc()
2656 NInoSetMstProtected(ni); in ntfs_mft_record_alloc()
2657 ni->type = AT_INDEX_ALLOCATION; in ntfs_mft_record_alloc()
2658 ni->name = I30; in ntfs_mft_record_alloc()
2659 ni->name_len = 4; in ntfs_mft_record_alloc()
2661 ni->itype.index.block_size = 4096; in ntfs_mft_record_alloc()
2662 ni->itype.index.block_size_bits = ntfs_ffs(4096) - 1; in ntfs_mft_record_alloc()
2663 ni->itype.index.collation_rule = COLLATION_FILE_NAME; in ntfs_mft_record_alloc()
2664 if (vol->cluster_size <= ni->itype.index.block_size) { in ntfs_mft_record_alloc()
2665 ni->itype.index.vcn_size = vol->cluster_size; in ntfs_mft_record_alloc()
2666 ni->itype.index.vcn_size_bits = in ntfs_mft_record_alloc()
2669 ni->itype.index.vcn_size = vol->sector_size; in ntfs_mft_record_alloc()
2670 ni->itype.index.vcn_size_bits = in ntfs_mft_record_alloc()
2677 ni->type = AT_DATA; in ntfs_mft_record_alloc()
2678 ni->name = NULL; in ntfs_mft_record_alloc()
2679 ni->name_len = 0; in ntfs_mft_record_alloc()
2694 vi->i_generation = ni->seq_no = le16_to_cpu(m->sequence_number); in ntfs_mft_record_alloc()
2699 atomic_inc(&ni->count); in ntfs_mft_record_alloc()
2700 mutex_lock(&ni->mrec_lock); in ntfs_mft_record_alloc()
2701 ni->page = page; in ntfs_mft_record_alloc()
2702 ni->page_ofs = ofs; in ntfs_mft_record_alloc()
2729 return ni; in ntfs_mft_record_alloc()
2755 * @ni: ntfs inode of the mapped extent mft record to free
2756 * @m: mapped extent mft record of the ntfs inode @ni
2758 * Free the mapped extent mft record @m of the extent ntfs inode @ni.
2760 * Note that this function unmaps the mft record and closes and destroys @ni
2761 * internally and hence you cannot use either @ni nor @m any more after this
2764 * On success return 0 and on error return -errno. @ni and @m are still valid
2774 int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m) in ntfs_extent_mft_record_free() argument
2776 unsigned long mft_no = ni->mft_no; in ntfs_extent_mft_record_free()
2777 ntfs_volume *vol = ni->vol; in ntfs_extent_mft_record_free()
2784 BUG_ON(NInoAttr(ni)); in ntfs_extent_mft_record_free()
2785 BUG_ON(ni->nr_extents != -1); in ntfs_extent_mft_record_free()
2787 mutex_lock(&ni->extent_lock); in ntfs_extent_mft_record_free()
2788 base_ni = ni->ext.base_ntfs_ino; in ntfs_extent_mft_record_free()
2789 mutex_unlock(&ni->extent_lock); in ntfs_extent_mft_record_free()
2799 if (atomic_read(&ni->count) > 2) { in ntfs_extent_mft_record_free()
2810 if (ni != extent_nis[i]) in ntfs_extent_mft_record_free()
2851 NInoSetDirty(ni); in ntfs_extent_mft_record_free()
2852 err = write_mft_record(ni, m, 0); in ntfs_extent_mft_record_free()
2860 unmap_extent_mft_record(ni); in ntfs_extent_mft_record_free()
2861 ntfs_clear_extent_inode(ni); in ntfs_extent_mft_record_free()
2902 extent_nis[base_ni->nr_extents++] = ni; in ntfs_extent_mft_record_free()
2904 mark_mft_record_dirty(ni); in ntfs_extent_mft_record_free()