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