Lines Matching refs:vol
39 ntfs_volume *vol = ni->vol;
40 struct inode *mft_vi = vol->mft_ino;
52 index = (u64)ni->mft_no << vol->mft_record_size_bits >>
54 ofs = (ni->mft_no << vol->mft_record_size_bits) & ~PAGE_MASK;
63 vol->mft_record_size) {
65 ntfs_error(vol->sb, "Attempt to read mft record 0x%lx, "
82 ntfs_error(vol->sb, "Mft record 0x%lx is corrupt. "
86 NVolSetErrors(vol);
162 ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m));
282 ntfs_error(base_ni->vol->sb, "Found stale extent mft "
288 ntfs_error(base_ni->vol->sb, "Failed to map extent "
293 ni = ntfs_new_extent_inode(base_ni->vol->sb, mft_no);
299 ni->vol = base_ni->vol;
313 ntfs_error(base_ni->vol->sb, "Found stale extent mft "
326 ntfs_error(base_ni->vol->sb, "Failed to allocate "
407 * @vol: ntfs volume on which the mft record to synchronize resides
412 * number @mft_no to the mft mirror ($MFTMirr) of the ntfs volume @vol,
427 static int ntfs_sync_mft_mirror_umount(ntfs_volume *vol,
430 BUG_ON(vol->mftmirr_ino);
431 ntfs_error(vol->sb, "Umount time mft mirror syncing is not "
438 * @vol: ntfs volume on which the mft record to synchronize resides
444 * number @mft_no to the mft mirror ($MFTMirr) of the ntfs volume @vol.
447 * in the ntfs volume @vol.
454 int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
458 unsigned int blocksize = vol->sb->s_blocksize;
459 int max_bhs = vol->mft_record_size / blocksize;
466 unsigned char blocksize_bits = vol->sb->s_blocksize_bits;
472 if (unlikely(!vol->mftmirr_ino)) {
474 err = ntfs_sync_mft_mirror_umount(vol, mft_no, m);
480 page = ntfs_map_page(vol->mftmirr_ino->i_mapping, mft_no >>
481 (PAGE_SHIFT - vol->mft_record_size_bits));
483 ntfs_error(vol->sb, "Failed to map mft mirror page.");
491 page_ofs = (mft_no << vol->mft_record_size_bits) & ~PAGE_MASK;
495 memcpy(kmirr, m, vol->mft_record_size);
515 m_end = m_start + vol->mft_record_size;
529 bh->b_bdev = vol->sb->s_bdev;
531 vcn = ((VCN)mft_no << vol->mft_record_size_bits) +
533 vcn_ofs = vcn & vol->cluster_size_mask;
534 vcn >>= vol->cluster_size_bits;
536 down_read(&NTFS_I(vol->mftmirr_ino)->
538 rl = NTFS_I(vol->mftmirr_ino)->runlist.rl;
553 vol->cluster_size_bits) +
558 ntfs_error(vol->sb, "Cannot write mft mirror "
574 up_read(&NTFS_I(vol->mftmirr_ino)->runlist.lock);
617 ntfs_error(vol->sb, "I/O error while writing mft mirror "
620 ntfs_error(vol->sb, "Failed to synchronize $MFTMirr (error "
624 NVolSetErrors(vol);
662 ntfs_volume *vol = ni->vol;
664 unsigned int blocksize = vol->sb->s_blocksize;
665 unsigned char blocksize_bits = vol->sb->s_blocksize_bits;
666 int max_bhs = vol->mft_record_size / blocksize;
695 m_end = m_start + vol->mft_record_size;
722 bh->b_bdev = vol->sb->s_bdev;
724 vcn = ((VCN)ni->mft_no << vol->mft_record_size_bits) +
726 vcn_ofs = vcn & vol->cluster_size_mask;
727 vcn >>= vol->cluster_size_bits;
729 down_read(&NTFS_I(vol->mft_ino)->runlist.lock);
730 rl = NTFS_I(vol->mft_ino)->runlist.rl;
741 vol->cluster_size_bits) +
746 ntfs_error(vol->sb, "Cannot write mft record "
761 up_read(&NTFS_I(vol->mft_ino)->runlist.lock);
767 err = pre_write_mst_fixup((NTFS_RECORD*)m, vol->mft_record_size);
769 ntfs_error(vol->sb, "Failed to apply mst fixups!");
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);
811 ntfs_error(vol->sb, "I/O error while writing mft record "
832 ntfs_error(vol->sb, "Not enough memory to write mft record. "
837 NVolSetErrors(vol);
843 * @vol: [IN] ntfs volume on which the mft record to check resides
849 * @mft_no belonging to the ntfs volume @vol may be written out. If necessary
920 bool ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
923 struct super_block *sb = vol->sb;
924 struct inode *mft_vi = vol->mft_ino;
1109 * @vol: volume on which to search for a free mft record
1113 * @vol.
1124 * Locking: Caller must hold vol->mftbmp_lock for writing.
1126 static int ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(ntfs_volume *vol,
1139 mftbmp_mapping = vol->mftbmp_ino->i_mapping;
1144 read_lock_irqsave(&NTFS_I(vol->mft_ino)->size_lock, flags);
1145 pass_end = NTFS_I(vol->mft_ino)->allocated_size >>
1146 vol->mft_record_size_bits;
1147 read_unlock_irqrestore(&NTFS_I(vol->mft_ino)->size_lock, flags);
1148 read_lock_irqsave(&NTFS_I(vol->mftbmp_ino)->size_lock, flags);
1149 ll = NTFS_I(vol->mftbmp_ino)->initialized_size << 3;
1150 read_unlock_irqrestore(&NTFS_I(vol->mftbmp_ino)->size_lock, flags);
1155 data_pos = vol->mft_data_pos;
1190 ntfs_error(vol->sb, "Failed to read mft "
1258 * @vol: volume on which to extend the mft bitmap attribute
1260 * Extend the mft bitmap attribute on the ntfs volume @vol by one cluster.
1267 * Locking: - Caller must hold vol->mftbmp_lock for writing.
1268 * - This function takes NTFS_I(vol->mftbmp_ino)->runlist.lock for
1270 * - This function takes vol->lcnbmp_lock for writing and releases it
1273 static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
1294 mft_ni = NTFS_I(vol->mft_ino);
1295 mftbmp_ni = NTFS_I(vol->mftbmp_ino);
1305 (ll - 1) >> vol->cluster_size_bits, NULL);
1308 ntfs_error(vol->sb, "Failed to determine last allocated "
1325 page = ntfs_map_page(vol->lcnbmp_ino->i_mapping,
1329 ntfs_error(vol->sb, "Failed to read from lcn bitmap.");
1334 down_write(&vol->lcnbmp_lock);
1340 up_write(&vol->lcnbmp_lock);
1348 up_write(&vol->lcnbmp_lock);
1351 rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE,
1355 ntfs_error(vol->sb, "Failed to allocate a cluster for "
1362 ntfs_error(vol->sb, "Failed to merge runlists for mft "
1364 if (ntfs_cluster_free_from_rl(vol, rl2)) {
1365 ntfs_error(vol->sb, "Failed to deallocate "
1367 NVolSetErrors(vol);
1385 ntfs_error(vol->sb, "Failed to map mft record.");
1391 ntfs_error(vol->sb, "Failed to get search context.");
1399 ntfs_error(vol->sb, "Failed to find last attribute extent of "
1415 mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1);
1417 ntfs_error(vol->sb, "Get size for mapping pairs failed for "
1430 ntfs_error(vol->sb, "Failed to resize attribute "
1439 ntfs_error(vol->sb, "Not enough space in this mft record to "
1447 ret = ntfs_mapping_pairs_build(vol, (u8*)a +
1451 ntfs_error(vol->sb, "Failed to build mapping pairs array for "
1473 ntfs_error(vol->sb, "Failed to find first attribute "
1480 mftbmp_ni->allocated_size += vol->cluster_size;
1497 ntfs_error(vol->sb, "Failed to find last attribute extent of "
1500 mftbmp_ni->allocated_size += vol->cluster_size;
1509 NVolSetErrors(vol);
1526 down_write(&vol->lcnbmp_lock);
1527 if (ntfs_bitmap_clear_bit(vol->lcnbmp_ino, lcn)) {
1528 ntfs_error(vol->sb, "Failed to free allocated cluster.%s", es);
1529 NVolSetErrors(vol);
1531 up_write(&vol->lcnbmp_lock);
1533 if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
1538 ntfs_error(vol->sb, "Failed to restore mapping pairs "
1540 NVolSetErrors(vol);
1543 ntfs_error(vol->sb, "Failed to restore attribute "
1545 NVolSetErrors(vol);
1560 * @vol: volume on which to extend the mft bitmap attribute
1563 * volume @vol by 8 bytes.
1570 * Locking: Caller must hold vol->mftbmp_lock for writing.
1572 static int ntfs_mft_bitmap_extend_initialized_nolock(ntfs_volume *vol)
1584 mft_ni = NTFS_I(vol->mft_ino);
1585 mftbmp_vi = vol->mftbmp_ino;
1590 ntfs_error(vol->sb, "Failed to map mft record.");
1595 ntfs_error(vol->sb, "Failed to get search context.");
1602 ntfs_error(vol->sb, "Failed to find first attribute extent of "
1638 ntfs_error(vol->sb, "Failed to write to mft bitmap.");
1642 ntfs_error(vol->sb, "Failed to map mft record.%s", es);
1643 NVolSetErrors(vol);
1648 ntfs_error(vol->sb, "Failed to get search context.%s", es);
1649 NVolSetErrors(vol);
1654 ntfs_error(vol->sb, "Failed to find first attribute extent of "
1656 NVolSetErrors(vol);
1692 * @vol: volume on which to extend the mft data attribute
1694 * Extend the mft data attribute on the ntfs volume @vol by 16 mft records
1703 * Locking: - Caller must hold vol->mftbmp_lock for writing.
1704 * - This function takes NTFS_I(vol->mft_ino)->runlist.lock for
1706 * - This function calls functions which take vol->lcnbmp_lock for
1709 static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
1725 mft_ni = NTFS_I(vol->mft_ino);
1736 (ll - 1) >> vol->cluster_size_bits, NULL);
1739 ntfs_error(vol->sb, "Failed to determine last allocated "
1750 min_nr = vol->mft_record_size >> vol->cluster_size_bits;
1754 nr = vol->mft_record_size << 4 >> vol->cluster_size_bits;
1761 if (unlikely((ll + (nr << vol->cluster_size_bits)) >>
1762 vol->mft_record_size_bits >= (1ll << 32))) {
1764 if (unlikely((ll + (nr << vol->cluster_size_bits)) >>
1765 vol->mft_record_size_bits >= (1ll << 32))) {
1766 ntfs_warning(vol->sb, "Cannot allocate mft record "
1777 rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE,
1782 ntfs_error(vol->sb, "Failed to allocate the minimal "
1800 ntfs_error(vol->sb, "Failed to merge runlists for mft data "
1802 if (ntfs_cluster_free_from_rl(vol, rl2)) {
1803 ntfs_error(vol->sb, "Failed to deallocate clusters "
1805 NVolSetErrors(vol);
1818 ntfs_error(vol->sb, "Failed to map mft record.");
1824 ntfs_error(vol->sb, "Failed to get search context.");
1831 ntfs_error(vol->sb, "Failed to find last attribute extent of "
1847 mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1);
1849 ntfs_error(vol->sb, "Get size for mapping pairs failed for "
1862 ntfs_error(vol->sb, "Failed to resize attribute "
1876 ntfs_error(vol->sb, "Not enough space in this mft record to "
1884 ret = ntfs_mapping_pairs_build(vol, (u8*)a +
1888 ntfs_error(vol->sb, "Failed to build mapping pairs array of "
1912 ntfs_error(vol->sb, "Failed to find first attribute "
1919 mft_ni->allocated_size += nr << vol->cluster_size_bits;
1935 ntfs_error(vol->sb, "Failed to find last attribute extent of "
1938 mft_ni->allocated_size += nr << vol->cluster_size_bits;
1947 NVolSetErrors(vol);
1954 ntfs_error(vol->sb, "Failed to free clusters from mft data "
1956 NVolSetErrors(vol);
1959 if (ntfs_rl_truncate_nolock(vol, &mft_ni->runlist, old_last_vcn)) {
1960 ntfs_error(vol->sb, "Failed to truncate mft data attribute "
1962 NVolSetErrors(vol);
1965 if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
1970 ntfs_error(vol->sb, "Failed to restore mapping pairs "
1972 NVolSetErrors(vol);
1975 ntfs_error(vol->sb, "Failed to restore attribute "
1977 NVolSetErrors(vol);
1982 ntfs_error(vol->sb, "Failed to restore attribute search "
1984 NVolSetErrors(vol);
1996 * @vol: volume to which the mft record will belong
1998 * @m: destination buffer of size >= @vol->mft_record_size bytes
2001 * the buffer @m. The volume @vol is needed because the mft record structure
2007 static int ntfs_mft_record_layout(const ntfs_volume *vol, const s64 mft_no,
2014 ntfs_error(vol->sb, "Mft record number 0x%llx exceeds "
2019 memset(m, 0, vol->mft_record_size);
2021 if (vol->major_ver < 3 || (vol->major_ver == 3 && !vol->minor_ver))
2033 if (vol->mft_record_size >= NTFS_BLOCK_SIZE)
2034 m->usa_count = cpu_to_le16(vol->mft_record_size /
2038 ntfs_warning(vol->sb, "Sector size is bigger than mft record "
2064 m->bytes_allocated = cpu_to_le32(vol->mft_record_size);
2077 * @vol: volume on which to format the mft record
2086 static int ntfs_mft_record_format(const ntfs_volume *vol, const s64 mft_no)
2089 struct inode *mft_vi = vol->mft_ino;
2101 index = mft_no << vol->mft_record_size_bits >> PAGE_SHIFT;
2102 ofs = (mft_no << vol->mft_record_size_bits) & ~PAGE_MASK;
2107 if (unlikely(index > end_index || ofs + vol->mft_record_size >=
2109 ntfs_error(vol->sb, "Tried to format non-existing mft "
2117 ntfs_error(vol->sb, "Failed to map page containing mft record "
2125 err = ntfs_mft_record_layout(vol, mft_no, m);
2127 ntfs_error(vol->sb, "Failed to layout mft record 0x%llx.",
2150 * @vol: [IN] volume on which to allocate the mft record
2155 * Allocate an mft record in $MFT/$DATA of an open ntfs volume @vol.
2238 ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
2271 mft_ni = NTFS_I(vol->mft_ino);
2272 mftbmp_ni = NTFS_I(vol->mftbmp_ino);
2273 down_write(&vol->mftbmp_lock);
2274 bit = ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(vol, base_ni);
2281 up_write(&vol->mftbmp_lock);
2293 ll = mft_ni->initialized_size >> vol->mft_record_size_bits;
2321 (long long)i_size_read(vol->mftbmp_ino),
2327 err = ntfs_mft_bitmap_extend_allocation_nolock(vol);
2329 up_write(&vol->mftbmp_lock);
2338 (long long)i_size_read(vol->mftbmp_ino),
2348 err = ntfs_mft_bitmap_extend_initialized_nolock(vol);
2350 up_write(&vol->mftbmp_lock);
2359 (long long)i_size_read(vol->mftbmp_ino),
2367 err = ntfs_bitmap_set_bit(vol->mftbmp_ino, bit);
2369 ntfs_error(vol->sb, "Failed to allocate bit in mft bitmap.");
2370 up_write(&vol->mftbmp_lock);
2383 ll = (bit + 1) << vol->mft_record_size_bits;
2403 (long long)i_size_read(vol->mft_ino),
2407 err = ntfs_mft_data_extend_allocation_nolock(vol);
2409 ntfs_error(vol->sb, "Failed to extend mft data "
2418 (long long)i_size_read(vol->mft_ino),
2431 old_data_size = vol->mft_ino->i_size;
2436 vol->mft_record_size;
2437 mft_no = mft_ni->initialized_size >> vol->mft_record_size_bits;
2438 if (new_initialized_size > i_size_read(vol->mft_ino))
2439 i_size_write(vol->mft_ino, new_initialized_size);
2443 err = ntfs_mft_record_format(vol, mft_no);
2445 ntfs_error(vol->sb, "Failed to format mft record.");
2456 ntfs_error(vol->sb, "Failed to map mft record.");
2462 ntfs_error(vol->sb, "Failed to get search context.");
2470 ntfs_error(vol->sb, "Failed to find first attribute extent of "
2481 cpu_to_sle64(i_size_read(vol->mft_ino));
2493 (long long)i_size_read(vol->mft_ino),
2495 BUG_ON(i_size_read(vol->mft_ino) > mft_ni->allocated_size);
2496 BUG_ON(mft_ni->initialized_size > i_size_read(vol->mft_ino));
2508 up_write(&vol->mftbmp_lock);
2513 index = bit << vol->mft_record_size_bits >> PAGE_SHIFT;
2514 ofs = (bit << vol->mft_record_size_bits) & ~PAGE_MASK;
2516 page = ntfs_map_page(vol->mft_ino->i_mapping, index);
2518 ntfs_error(vol->sb, "Failed to map page containing allocated "
2532 ntfs_error(vol->sb, "Mft record 0x%llx was marked "
2541 NVolSetErrors(vol);
2553 err = ntfs_mft_record_layout(vol, bit, m);
2555 ntfs_error(vol->sb, "Failed to layout allocated mft "
2590 ntfs_error(vol->sb, "Failed to map allocated extent "
2624 vi = new_inode(vol->sb);
2640 vi->i_uid = vol->uid;
2641 vi->i_gid = vol->gid;
2652 vi->i_mode &= ~vol->dmask;
2662 if (vol->cluster_size <= ni->itype.index.block_size) {
2663 ni->itype.index.vcn_size = vol->cluster_size;
2665 vol->cluster_size_bits;
2667 ni->itype.index.vcn_size = vol->sector_size;
2669 vol->sector_size_bits;
2673 vi->i_mode &= ~vol->fmask;
2719 vol->mft_data_pos = bit + 1;
2732 i_size_write(vol->mft_ino, old_data_size);
2736 down_write(&vol->mftbmp_lock);
2738 if (ntfs_bitmap_clear_bit(vol->mftbmp_ino, bit)) {
2739 ntfs_error(vol->sb, "Failed to clear bit in mft bitmap.%s", es);
2740 NVolSetErrors(vol);
2742 up_write(&vol->mftbmp_lock);
2746 ntfs_warning(vol->sb, "Cannot allocate mft record because the maximum "
2748 up_write(&vol->mftbmp_lock);
2776 ntfs_volume *vol = ni->vol;
2799 ntfs_error(vol->sb, "Tried to free busy extent inode 0x%lx, "
2822 ntfs_error(vol->sb, "Extent inode 0x%lx is not attached to "
2853 ntfs_error(vol->sb, "Failed to write mft record 0x%lx, not "
2863 down_write(&vol->mftbmp_lock);
2864 err = ntfs_bitmap_clear_bit(vol->mftbmp_ino, mft_no);
2865 up_write(&vol->mftbmp_lock);
2872 ntfs_error(vol->sb, "Failed to clear bit in mft bitmap.%s", es);
2873 NVolSetErrors(vol);
2885 ntfs_error(vol->sb, "Failed to allocate internal "
2888 NVolSetErrors(vol);