Lines Matching refs:vol
87 static bool parse_options(ntfs_volume *vol, char *opt) in parse_options() argument
192 ntfs_warning(vol->sb, "Ignoring obsolete option %s.", in parse_options()
196 ntfs_warning(vol->sb, "Option iocharset is " in parse_options()
207 ntfs_error(vol->sb, "NLS character set " in parse_options()
211 ntfs_error(vol->sb, "NLS character set %s not " in parse_options()
220 ntfs_warning(vol->sb, "Option utf8 is no longer " in parse_options()
234 ntfs_error(vol->sb, "Unrecognized mount option %s.", p); in parse_options()
247 ntfs_warning(vol->sb, "Sloppy option given. Ignoring " in parse_options()
252 ntfs_error(vol->sb, "Invalid errors option argument " in parse_options()
258 if (vol->nls_map && vol->nls_map != nls_map) { in parse_options()
259 ntfs_error(vol->sb, "Cannot change NLS character set " in parse_options()
264 vol->nls_map = nls_map; in parse_options()
266 if (!vol->nls_map) { in parse_options()
267 vol->nls_map = load_nls_default(); in parse_options()
268 if (!vol->nls_map) { in parse_options()
269 ntfs_error(vol->sb, "Failed to load default " in parse_options()
274 vol->nls_map->charset); in parse_options()
278 if (vol->mft_zone_multiplier && vol->mft_zone_multiplier != in parse_options()
280 ntfs_error(vol->sb, "Cannot change mft_zone_multiplier " in parse_options()
285 ntfs_error(vol->sb, "Invalid mft_zone_multiplier. " in parse_options()
289 vol->mft_zone_multiplier = mft_zone_multiplier; in parse_options()
291 if (!vol->mft_zone_multiplier) in parse_options()
292 vol->mft_zone_multiplier = 1; in parse_options()
294 vol->on_errors = on_errors; in parse_options()
295 if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER) in parse_options()
296 vol->on_errors |= ON_ERRORS_CONTINUE; in parse_options()
298 vol->uid = uid; in parse_options()
300 vol->gid = gid; in parse_options()
302 vol->fmask = fmask; in parse_options()
304 vol->dmask = dmask; in parse_options()
307 NVolSetShowSystemFiles(vol); in parse_options()
309 NVolClearShowSystemFiles(vol); in parse_options()
313 NVolSetCaseSensitive(vol); in parse_options()
315 NVolClearCaseSensitive(vol); in parse_options()
319 NVolClearSparseEnabled(vol); in parse_options()
321 if (!NVolSparseEnabled(vol) && in parse_options()
322 vol->major_ver && vol->major_ver < 3) in parse_options()
323 ntfs_warning(vol->sb, "Not enabling sparse " in parse_options()
326 "version 3.0).", vol->major_ver, in parse_options()
327 vol->minor_ver); in parse_options()
329 NVolSetSparseEnabled(vol); in parse_options()
334 ntfs_error(vol->sb, "The %s option requires an argument.", p); in parse_options()
337 ntfs_error(vol->sb, "The %s option requires a boolean argument.", p); in parse_options()
340 ntfs_error(vol->sb, "Invalid %s option argument: %s", p, ov); in parse_options()
361 static int ntfs_write_volume_flags(ntfs_volume *vol, const VOLUME_FLAGS flags) in ntfs_write_volume_flags() argument
363 ntfs_inode *ni = NTFS_I(vol->vol_ino); in ntfs_write_volume_flags()
370 le16_to_cpu(vol->vol_flags), le16_to_cpu(flags)); in ntfs_write_volume_flags()
371 if (vol->vol_flags == flags) in ntfs_write_volume_flags()
390 vol->vol_flags = vi->flags = flags; in ntfs_write_volume_flags()
403 ntfs_error(vol->sb, "Failed with error code %i.", -err); in ntfs_write_volume_flags()
416 static inline int ntfs_set_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) in ntfs_set_volume_flags() argument
419 return ntfs_write_volume_flags(vol, vol->vol_flags | flags); in ntfs_set_volume_flags()
431 static inline int ntfs_clear_volume_flags(ntfs_volume *vol, VOLUME_FLAGS flags) in ntfs_clear_volume_flags() argument
434 flags = vol->vol_flags & cpu_to_le16(~le16_to_cpu(flags)); in ntfs_clear_volume_flags()
435 return ntfs_write_volume_flags(vol, flags); in ntfs_clear_volume_flags()
454 ntfs_volume *vol = NTFS_SB(sb); in ntfs_remount() local
480 if (NVolErrors(vol)) { in ntfs_remount()
485 if (vol->vol_flags & VOLUME_IS_DIRTY) { in ntfs_remount()
489 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { in ntfs_remount()
494 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { in ntfs_remount()
497 (unsigned)le16_to_cpu(vol->vol_flags), in ntfs_remount()
501 if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { in ntfs_remount()
510 if ((vol->major_ver > 1)) { in ntfs_remount()
511 if (ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) { in ntfs_remount()
514 NVolSetErrors(vol); in ntfs_remount()
519 if (!ntfs_empty_logfile(vol->logfile_ino)) { in ntfs_remount()
522 NVolSetErrors(vol); in ntfs_remount()
525 if (!ntfs_mark_quotas_out_of_date(vol)) { in ntfs_remount()
528 NVolSetErrors(vol); in ntfs_remount()
531 if (!ntfs_stamp_usnjrnl(vol)) { in ntfs_remount()
534 NVolSetErrors(vol); in ntfs_remount()
539 if (!NVolErrors(vol)) { in ntfs_remount()
540 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) in ntfs_remount()
550 if (!parse_options(vol, opt)) in ntfs_remount()
752 static bool parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b) in parse_ntfs_boot_sector() argument
758 vol->sector_size = le16_to_cpu(b->bpb.bytes_per_sector); in parse_ntfs_boot_sector()
759 vol->sector_size_bits = ffs(vol->sector_size) - 1; in parse_ntfs_boot_sector()
760 ntfs_debug("vol->sector_size = %i (0x%x)", vol->sector_size, in parse_ntfs_boot_sector()
761 vol->sector_size); in parse_ntfs_boot_sector()
762 ntfs_debug("vol->sector_size_bits = %i (0x%x)", vol->sector_size_bits, in parse_ntfs_boot_sector()
763 vol->sector_size_bits); in parse_ntfs_boot_sector()
764 if (vol->sector_size < vol->sb->s_blocksize) { in parse_ntfs_boot_sector()
765 ntfs_error(vol->sb, "Sector size (%i) is smaller than the " in parse_ntfs_boot_sector()
767 "supported. Sorry.", vol->sector_size, in parse_ntfs_boot_sector()
768 vol->sb->s_blocksize); in parse_ntfs_boot_sector()
777 vol->cluster_size = vol->sector_size << sectors_per_cluster_bits; in parse_ntfs_boot_sector()
778 vol->cluster_size_mask = vol->cluster_size - 1; in parse_ntfs_boot_sector()
779 vol->cluster_size_bits = ffs(vol->cluster_size) - 1; in parse_ntfs_boot_sector()
780 ntfs_debug("vol->cluster_size = %i (0x%x)", vol->cluster_size, in parse_ntfs_boot_sector()
781 vol->cluster_size); in parse_ntfs_boot_sector()
782 ntfs_debug("vol->cluster_size_mask = 0x%x", vol->cluster_size_mask); in parse_ntfs_boot_sector()
783 ntfs_debug("vol->cluster_size_bits = %i", vol->cluster_size_bits); in parse_ntfs_boot_sector()
784 if (vol->cluster_size < vol->sector_size) { in parse_ntfs_boot_sector()
785 ntfs_error(vol->sb, "Cluster size (%i) is smaller than the " in parse_ntfs_boot_sector()
787 "Sorry.", vol->cluster_size, vol->sector_size); in parse_ntfs_boot_sector()
794 vol->mft_record_size = vol->cluster_size << in parse_ntfs_boot_sector()
802 vol->mft_record_size = 1 << -clusters_per_mft_record; in parse_ntfs_boot_sector()
803 vol->mft_record_size_mask = vol->mft_record_size - 1; in parse_ntfs_boot_sector()
804 vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1; in parse_ntfs_boot_sector()
805 ntfs_debug("vol->mft_record_size = %i (0x%x)", vol->mft_record_size, in parse_ntfs_boot_sector()
806 vol->mft_record_size); in parse_ntfs_boot_sector()
808 vol->mft_record_size_mask); in parse_ntfs_boot_sector()
810 vol->mft_record_size_bits, vol->mft_record_size_bits); in parse_ntfs_boot_sector()
815 if (vol->mft_record_size > PAGE_SIZE) { in parse_ntfs_boot_sector()
816 ntfs_error(vol->sb, "Mft record size (%i) exceeds the " in parse_ntfs_boot_sector()
819 vol->mft_record_size, PAGE_SIZE); in parse_ntfs_boot_sector()
823 if (vol->mft_record_size < vol->sector_size) { in parse_ntfs_boot_sector()
824 ntfs_error(vol->sb, "Mft record size (%i) is smaller than the " in parse_ntfs_boot_sector()
826 "Sorry.", vol->mft_record_size, in parse_ntfs_boot_sector()
827 vol->sector_size); in parse_ntfs_boot_sector()
834 vol->index_record_size = vol->cluster_size << in parse_ntfs_boot_sector()
843 vol->index_record_size = 1 << -clusters_per_index_record; in parse_ntfs_boot_sector()
844 vol->index_record_size_mask = vol->index_record_size - 1; in parse_ntfs_boot_sector()
845 vol->index_record_size_bits = ffs(vol->index_record_size) - 1; in parse_ntfs_boot_sector()
847 vol->index_record_size, vol->index_record_size); in parse_ntfs_boot_sector()
849 vol->index_record_size_mask); in parse_ntfs_boot_sector()
851 vol->index_record_size_bits, in parse_ntfs_boot_sector()
852 vol->index_record_size_bits); in parse_ntfs_boot_sector()
854 if (vol->index_record_size < vol->sector_size) { in parse_ntfs_boot_sector()
855 ntfs_error(vol->sb, "Index record size (%i) is smaller than " in parse_ntfs_boot_sector()
857 "supported. Sorry.", vol->index_record_size, in parse_ntfs_boot_sector()
858 vol->sector_size); in parse_ntfs_boot_sector()
868 ntfs_error(vol->sb, "Cannot handle 64-bit clusters. Sorry."); in parse_ntfs_boot_sector()
871 vol->nr_clusters = ll; in parse_ntfs_boot_sector()
872 ntfs_debug("vol->nr_clusters = 0x%llx", (long long)vol->nr_clusters); in parse_ntfs_boot_sector()
879 if ((ll << vol->cluster_size_bits) >= (1ULL << 41)) { in parse_ntfs_boot_sector()
880 ntfs_error(vol->sb, "Volume size (%lluTiB) is too " in parse_ntfs_boot_sector()
884 vol->cluster_size_bits)); in parse_ntfs_boot_sector()
889 if (ll >= vol->nr_clusters) { in parse_ntfs_boot_sector()
890 ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of " in parse_ntfs_boot_sector()
895 vol->mft_lcn = ll; in parse_ntfs_boot_sector()
896 ntfs_debug("vol->mft_lcn = 0x%llx", (long long)vol->mft_lcn); in parse_ntfs_boot_sector()
898 if (ll >= vol->nr_clusters) { in parse_ntfs_boot_sector()
899 ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end " in parse_ntfs_boot_sector()
904 vol->mftmirr_lcn = ll; in parse_ntfs_boot_sector()
905 ntfs_debug("vol->mftmirr_lcn = 0x%llx", (long long)vol->mftmirr_lcn); in parse_ntfs_boot_sector()
915 if (vol->cluster_size <= (4 << vol->mft_record_size_bits)) in parse_ntfs_boot_sector()
916 vol->mftmirr_size = 4; in parse_ntfs_boot_sector()
918 vol->mftmirr_size = vol->cluster_size >> in parse_ntfs_boot_sector()
919 vol->mft_record_size_bits; in parse_ntfs_boot_sector()
920 ntfs_debug("vol->mftmirr_size = %i", vol->mftmirr_size); in parse_ntfs_boot_sector()
922 vol->serial_no = le64_to_cpu(b->volume_serial_number); in parse_ntfs_boot_sector()
924 (unsigned long long)vol->serial_no); in parse_ntfs_boot_sector()
934 static void ntfs_setup_allocators(ntfs_volume *vol) in ntfs_setup_allocators() argument
941 vol->mft_zone_multiplier); in ntfs_setup_allocators()
944 mft_zone_size = vol->nr_clusters; in ntfs_setup_allocators()
945 switch (vol->mft_zone_multiplier) { /* % of volume size in clusters */ in ntfs_setup_allocators()
962 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn; in ntfs_setup_allocators()
964 (unsigned long long)vol->mft_zone_pos); in ntfs_setup_allocators()
974 mft_lcn = (8192 + 2 * vol->cluster_size - 1) / vol->cluster_size; in ntfs_setup_allocators()
975 if (mft_lcn * vol->cluster_size < 16 * 1024) in ntfs_setup_allocators()
976 mft_lcn = (16 * 1024 + vol->cluster_size - 1) / in ntfs_setup_allocators()
977 vol->cluster_size; in ntfs_setup_allocators()
978 if (vol->mft_zone_start <= mft_lcn) in ntfs_setup_allocators()
979 vol->mft_zone_start = 0; in ntfs_setup_allocators()
981 (unsigned long long)vol->mft_zone_start); in ntfs_setup_allocators()
987 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_setup_allocators()
988 while (vol->mft_zone_end >= vol->nr_clusters) { in ntfs_setup_allocators()
990 vol->mft_zone_end = vol->mft_lcn + mft_zone_size; in ntfs_setup_allocators()
993 (unsigned long long)vol->mft_zone_end); in ntfs_setup_allocators()
998 vol->data1_zone_pos = vol->mft_zone_end; in ntfs_setup_allocators()
1000 (unsigned long long)vol->data1_zone_pos); in ntfs_setup_allocators()
1001 vol->data2_zone_pos = 0; in ntfs_setup_allocators()
1003 (unsigned long long)vol->data2_zone_pos); in ntfs_setup_allocators()
1006 vol->mft_data_pos = 24; in ntfs_setup_allocators()
1008 (unsigned long long)vol->mft_data_pos); in ntfs_setup_allocators()
1020 static bool load_and_init_mft_mirror(ntfs_volume *vol) in load_and_init_mft_mirror() argument
1027 tmp_ino = ntfs_iget(vol->sb, FILE_MFTMirr); in load_and_init_mft_mirror()
1056 tmp_ni->itype.index.block_size = vol->mft_record_size; in load_and_init_mft_mirror()
1057 tmp_ni->itype.index.block_size_bits = vol->mft_record_size_bits; in load_and_init_mft_mirror()
1058 vol->mftmirr_ino = tmp_ino; in load_and_init_mft_mirror()
1073 static bool check_mft_mirror(ntfs_volume *vol) in check_mft_mirror() argument
1075 struct super_block *sb = vol->sb; in check_mft_mirror()
1085 mrecs_per_page = PAGE_SIZE / vol->mft_record_size; in check_mft_mirror()
1087 BUG_ON(!vol->mftmirr_size); in check_mft_mirror()
1101 mft_page = ntfs_map_page(vol->mft_ino->i_mapping, in check_mft_mirror()
1109 mirr_page = ntfs_map_page(vol->mftmirr_ino->i_mapping, in check_mft_mirror()
1144 bytes > vol->mft_record_size || in check_mft_mirror()
1148 bytes > vol->mft_record_size || in check_mft_mirror()
1150 bytes = vol->mft_record_size; in check_mft_mirror()
1158 kmft += vol->mft_record_size; in check_mft_mirror()
1159 kmirr += vol->mft_record_size; in check_mft_mirror()
1160 } while (++i < vol->mftmirr_size); in check_mft_mirror()
1167 rl2[0].lcn = vol->mftmirr_lcn; in check_mft_mirror()
1168 rl2[0].length = (vol->mftmirr_size * vol->mft_record_size + in check_mft_mirror()
1169 vol->cluster_size - 1) / vol->cluster_size; in check_mft_mirror()
1177 mirr_ni = NTFS_I(vol->mftmirr_ino); in check_mft_mirror()
1202 static bool load_and_check_logfile(ntfs_volume *vol, in load_and_check_logfile() argument
1208 tmp_ino = ntfs_iget(vol->sb, FILE_LogFile); in load_and_check_logfile()
1221 vol->logfile_ino = tmp_ino; in load_and_check_logfile()
1252 static int check_windows_hibernation_status(ntfs_volume *vol) in check_windows_hibernation_status() argument
1273 inode_lock(vol->root_ino); in check_windows_hibernation_status()
1274 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12, in check_windows_hibernation_status()
1276 inode_unlock(vol->root_ino); in check_windows_hibernation_status()
1286 ntfs_error(vol->sb, "Failed to find inode number for " in check_windows_hibernation_status()
1293 vi = ntfs_iget(vol->sb, MREF(mref)); in check_windows_hibernation_status()
1297 ntfs_error(vol->sb, "Failed to load hiberfil.sys."); in check_windows_hibernation_status()
1308 ntfs_error(vol->sb, "Failed to read from hiberfil.sys."); in check_windows_hibernation_status()
1349 static bool load_and_init_quota(ntfs_volume *vol) in load_and_init_quota() argument
1366 inode_lock(vol->extend_ino); in load_and_init_quota()
1367 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6, in load_and_init_quota()
1369 inode_unlock(vol->extend_ino); in load_and_init_quota()
1382 NVolSetQuotaOutOfDate(vol); in load_and_init_quota()
1386 ntfs_error(vol->sb, "Failed to find inode number for $Quota."); in load_and_init_quota()
1392 tmp_ino = ntfs_iget(vol->sb, MREF(mref)); in load_and_init_quota()
1396 ntfs_error(vol->sb, "Failed to load $Quota."); in load_and_init_quota()
1399 vol->quota_ino = tmp_ino; in load_and_init_quota()
1401 tmp_ino = ntfs_index_iget(vol->quota_ino, Q, 2); in load_and_init_quota()
1403 ntfs_error(vol->sb, "Failed to load $Quota/$Q index."); in load_and_init_quota()
1406 vol->quota_q_ino = tmp_ino; in load_and_init_quota()
1425 static bool load_and_init_usnjrnl(ntfs_volume *vol) in load_and_init_usnjrnl() argument
1449 inode_lock(vol->extend_ino); in load_and_init_usnjrnl()
1450 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8, in load_and_init_usnjrnl()
1452 inode_unlock(vol->extend_ino); in load_and_init_usnjrnl()
1466 NVolSetUsnJrnlStamped(vol); in load_and_init_usnjrnl()
1470 ntfs_error(vol->sb, "Failed to find inode number for " in load_and_init_usnjrnl()
1477 tmp_ino = ntfs_iget(vol->sb, MREF(mref)); in load_and_init_usnjrnl()
1481 ntfs_error(vol->sb, "Failed to load $UsnJrnl."); in load_and_init_usnjrnl()
1484 vol->usnjrnl_ino = tmp_ino; in load_and_init_usnjrnl()
1489 if (unlikely(vol->vol_flags & VOLUME_DELETE_USN_UNDERWAY)) { in load_and_init_usnjrnl()
1496 tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, Max, 4); in load_and_init_usnjrnl()
1498 ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1502 vol->usnjrnl_max_ino = tmp_ino; in load_and_init_usnjrnl()
1504 ntfs_error(vol->sb, "Found corrupt $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1511 tmp_ino = ntfs_attr_iget(vol->usnjrnl_ino, AT_DATA, J, 2); in load_and_init_usnjrnl()
1513 ntfs_error(vol->sb, "Failed to load $UsnJrnl/$DATA/$J " in load_and_init_usnjrnl()
1517 vol->usnjrnl_j_ino = tmp_ino; in load_and_init_usnjrnl()
1519 tmp_ni = NTFS_I(vol->usnjrnl_j_ino); in load_and_init_usnjrnl()
1521 ntfs_error(vol->sb, "$UsnJrnl/$DATA/$J attribute is resident " in load_and_init_usnjrnl()
1526 page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0); in load_and_init_usnjrnl()
1528 ntfs_error(vol->sb, "Failed to read from $UsnJrnl/$DATA/$Max " in load_and_init_usnjrnl()
1536 ntfs_error(vol->sb, "Allocation delta (0x%llx) exceeds " in load_and_init_usnjrnl()
1548 i_size_read(vol->usnjrnl_j_ino))) { in load_and_init_usnjrnl()
1550 i_size_read(vol->usnjrnl_j_ino))) { in load_and_init_usnjrnl()
1559 ntfs_error(vol->sb, "$UsnJrnl has lowest valid usn (0x%llx) " in load_and_init_usnjrnl()
1563 i_size_read(vol->usnjrnl_j_ino)); in load_and_init_usnjrnl()
1578 static bool load_and_init_attrdef(ntfs_volume *vol) in load_and_init_attrdef() argument
1581 struct super_block *sb = vol->sb; in load_and_init_attrdef()
1600 vol->attrdef = (ATTR_DEF*)ntfs_malloc_nofs(i_size); in load_and_init_attrdef()
1601 if (!vol->attrdef) in load_and_init_attrdef()
1612 memcpy((u8*)vol->attrdef + (index++ << PAGE_SHIFT), in load_and_init_attrdef()
1621 vol->attrdef_size = i_size; in load_and_init_attrdef()
1626 ntfs_free(vol->attrdef); in load_and_init_attrdef()
1627 vol->attrdef = NULL; in load_and_init_attrdef()
1643 static bool load_and_init_upcase(ntfs_volume *vol) in load_and_init_upcase() argument
1646 struct super_block *sb = vol->sb; in load_and_init_upcase()
1669 vol->upcase = (ntfschar*)ntfs_malloc_nofs(i_size); in load_and_init_upcase()
1670 if (!vol->upcase) in load_and_init_upcase()
1681 memcpy((char*)vol->upcase + (index++ << PAGE_SHIFT), in load_and_init_upcase()
1690 vol->upcase_len = i_size >> UCHAR_T_SIZE_BITS; in load_and_init_upcase()
1702 if (max > vol->upcase_len) in load_and_init_upcase()
1703 max = vol->upcase_len; in load_and_init_upcase()
1705 if (vol->upcase[i] != default_upcase[i]) in load_and_init_upcase()
1708 ntfs_free(vol->upcase); in load_and_init_upcase()
1709 vol->upcase = default_upcase; in load_and_init_upcase()
1710 vol->upcase_len = max; in load_and_init_upcase()
1723 ntfs_free(vol->upcase); in load_and_init_upcase()
1724 vol->upcase = NULL; in load_and_init_upcase()
1728 vol->upcase = default_upcase; in load_and_init_upcase()
1729 vol->upcase_len = default_upcase_len; in load_and_init_upcase()
1758 static bool load_system_files(ntfs_volume *vol) in load_system_files() argument
1760 struct super_block *sb = vol->sb; in load_system_files()
1772 if (!load_and_init_mft_mirror(vol) || !check_mft_mirror(vol)) { in load_system_files()
1779 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1784 !vol->mftmirr_ino ? es1 : es2, in load_system_files()
1790 !vol->mftmirr_ino ? es1 : es2, es3); in load_system_files()
1794 !vol->mftmirr_ino ? es1 : es2, es3); in load_system_files()
1796 NVolSetErrors(vol); in load_system_files()
1800 vol->mftbmp_ino = ntfs_attr_iget(vol->mft_ino, AT_BITMAP, NULL, 0); in load_system_files()
1801 if (IS_ERR(vol->mftbmp_ino)) { in load_system_files()
1805 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->runlist.lock, in load_system_files()
1807 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->mrec_lock, in load_system_files()
1810 if (!load_and_init_upcase(vol)) in load_system_files()
1817 if (!load_and_init_attrdef(vol)) in load_system_files()
1825 vol->lcnbmp_ino = ntfs_iget(sb, FILE_Bitmap); in load_system_files()
1826 if (IS_ERR(vol->lcnbmp_ino) || is_bad_inode(vol->lcnbmp_ino)) { in load_system_files()
1827 if (!IS_ERR(vol->lcnbmp_ino)) in load_system_files()
1828 iput(vol->lcnbmp_ino); in load_system_files()
1831 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->runlist.lock, in load_system_files()
1833 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->mrec_lock, in load_system_files()
1836 NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino)); in load_system_files()
1837 if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) { in load_system_files()
1838 iput(vol->lcnbmp_ino); in load_system_files()
1847 vol->vol_ino = ntfs_iget(sb, FILE_Volume); in load_system_files()
1848 if (IS_ERR(vol->vol_ino) || is_bad_inode(vol->vol_ino)) { in load_system_files()
1849 if (!IS_ERR(vol->vol_ino)) in load_system_files()
1850 iput(vol->vol_ino); in load_system_files()
1855 m = map_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1858 iput(vol->vol_ino); in load_system_files()
1861 if (!(ctx = ntfs_attr_get_search_ctx(NTFS_I(vol->vol_ino), m))) { in load_system_files()
1870 unmap_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1881 vol->vol_flags = vi->flags; in load_system_files()
1882 vol->major_ver = vi->major_ver; in load_system_files()
1883 vol->minor_ver = vi->minor_ver; in load_system_files()
1885 unmap_mft_record(NTFS_I(vol->vol_ino)); in load_system_files()
1886 pr_info("volume version %i.%i.\n", vol->major_ver, in load_system_files()
1887 vol->minor_ver); in load_system_files()
1888 if (vol->major_ver < 3 && NVolSparseEnabled(vol)) { in load_system_files()
1889 ntfs_warning(vol->sb, "Disabling sparse support due to NTFS " in load_system_files()
1891 "3.0).", vol->major_ver, vol->minor_ver); in load_system_files()
1892 NVolClearSparseEnabled(vol); in load_system_files()
1896 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { in load_system_files()
1905 if (vol->vol_flags & VOLUME_IS_DIRTY) in load_system_files()
1907 else if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { in load_system_files()
1914 (unsigned)le16_to_cpu(vol->vol_flags)); in load_system_files()
1918 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1941 if (!load_and_check_logfile(vol, &rp) || in load_system_files()
1942 !ntfs_is_logfile_clean(vol->logfile_ino, rp)) { in load_system_files()
1948 es1 = !vol->logfile_ino ? es1a : es1b; in load_system_files()
1951 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
1957 if (vol->logfile_ino) { in load_system_files()
1969 NVolSetErrors(vol); in load_system_files()
1974 vol->root_ino = ntfs_iget(sb, FILE_root); in load_system_files()
1975 if (IS_ERR(vol->root_ino) || is_bad_inode(vol->root_ino)) { in load_system_files()
1976 if (!IS_ERR(vol->root_ino)) in load_system_files()
1977 iput(vol->root_ino); in load_system_files()
1989 err = check_windows_hibernation_status(vol); in load_system_files()
2000 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2014 NVolSetErrors(vol); in load_system_files()
2017 if (!sb_rdonly(sb) && ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { in load_system_files()
2023 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2044 if (!(sb->s_flags & SB_RDONLY) && (vol->major_ver > 1) && in load_system_files()
2045 ntfs_set_volume_flags(vol, VOLUME_MOUNTED_ON_NT4)) { in load_system_files()
2050 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2059 NVolSetErrors(vol); in load_system_files()
2063 if (!sb_rdonly(sb) && !ntfs_empty_logfile(vol->logfile_ino)) { in load_system_files()
2068 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2077 NVolSetErrors(vol); in load_system_files()
2081 if (unlikely(vol->major_ver < 3)) in load_system_files()
2085 vol->secure_ino = ntfs_iget(sb, FILE_Secure); in load_system_files()
2086 if (IS_ERR(vol->secure_ino) || is_bad_inode(vol->secure_ino)) { in load_system_files()
2087 if (!IS_ERR(vol->secure_ino)) in load_system_files()
2088 iput(vol->secure_ino); in load_system_files()
2094 vol->extend_ino = ntfs_iget(sb, FILE_Extend); in load_system_files()
2095 if (IS_ERR(vol->extend_ino) || is_bad_inode(vol->extend_ino) || in load_system_files()
2096 !S_ISDIR(vol->extend_ino->i_mode)) { in load_system_files()
2097 if (!IS_ERR(vol->extend_ino)) in load_system_files()
2098 iput(vol->extend_ino); in load_system_files()
2104 if (!load_and_init_quota(vol)) { in load_system_files()
2110 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2124 NVolSetErrors(vol); in load_system_files()
2127 if (!sb_rdonly(sb) && !ntfs_mark_quotas_out_of_date(vol)) { in load_system_files()
2132 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2141 NVolSetErrors(vol); in load_system_files()
2147 if (!load_and_init_usnjrnl(vol)) { in load_system_files()
2153 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2167 NVolSetErrors(vol); in load_system_files()
2170 if (!sb_rdonly(sb) && !ntfs_stamp_usnjrnl(vol)) { in load_system_files()
2176 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2185 NVolSetErrors(vol); in load_system_files()
2191 iput(vol->usnjrnl_j_ino); in load_system_files()
2192 iput(vol->usnjrnl_max_ino); in load_system_files()
2193 iput(vol->usnjrnl_ino); in load_system_files()
2195 iput(vol->quota_q_ino); in load_system_files()
2196 iput(vol->quota_ino); in load_system_files()
2197 iput(vol->extend_ino); in load_system_files()
2200 iput(vol->secure_ino); in load_system_files()
2202 iput(vol->root_ino); in load_system_files()
2205 iput(vol->logfile_ino); in load_system_files()
2208 iput(vol->vol_ino); in load_system_files()
2210 iput(vol->lcnbmp_ino); in load_system_files()
2212 vol->attrdef_size = 0; in load_system_files()
2213 if (vol->attrdef) { in load_system_files()
2214 ntfs_free(vol->attrdef); in load_system_files()
2215 vol->attrdef = NULL; in load_system_files()
2220 vol->upcase_len = 0; in load_system_files()
2222 if (vol->upcase == default_upcase) { in load_system_files()
2224 vol->upcase = NULL; in load_system_files()
2227 if (vol->upcase) { in load_system_files()
2228 ntfs_free(vol->upcase); in load_system_files()
2229 vol->upcase = NULL; in load_system_files()
2232 iput(vol->mftbmp_ino); in load_system_files()
2235 iput(vol->mftmirr_ino); in load_system_files()
2251 ntfs_volume *vol = NTFS_SB(sb); in ntfs_put_super() local
2260 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2263 if (vol->major_ver >= 3) { in ntfs_put_super()
2264 if (vol->usnjrnl_j_ino) in ntfs_put_super()
2265 ntfs_commit_inode(vol->usnjrnl_j_ino); in ntfs_put_super()
2266 if (vol->usnjrnl_max_ino) in ntfs_put_super()
2267 ntfs_commit_inode(vol->usnjrnl_max_ino); in ntfs_put_super()
2268 if (vol->usnjrnl_ino) in ntfs_put_super()
2269 ntfs_commit_inode(vol->usnjrnl_ino); in ntfs_put_super()
2270 if (vol->quota_q_ino) in ntfs_put_super()
2271 ntfs_commit_inode(vol->quota_q_ino); in ntfs_put_super()
2272 if (vol->quota_ino) in ntfs_put_super()
2273 ntfs_commit_inode(vol->quota_ino); in ntfs_put_super()
2274 if (vol->extend_ino) in ntfs_put_super()
2275 ntfs_commit_inode(vol->extend_ino); in ntfs_put_super()
2276 if (vol->secure_ino) in ntfs_put_super()
2277 ntfs_commit_inode(vol->secure_ino); in ntfs_put_super()
2280 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2282 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2283 ntfs_commit_inode(vol->lcnbmp_ino); in ntfs_put_super()
2284 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2286 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2287 ntfs_commit_inode(vol->mftbmp_ino); in ntfs_put_super()
2288 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2290 if (vol->logfile_ino) in ntfs_put_super()
2291 ntfs_commit_inode(vol->logfile_ino); in ntfs_put_super()
2293 if (vol->mftmirr_ino) in ntfs_put_super()
2294 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2295 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2302 if (!NVolErrors(vol)) { in ntfs_put_super()
2303 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) in ntfs_put_super()
2307 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2308 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2309 if (vol->mftmirr_ino) in ntfs_put_super()
2310 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2311 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2319 iput(vol->vol_ino); in ntfs_put_super()
2320 vol->vol_ino = NULL; in ntfs_put_super()
2323 if (vol->major_ver >= 3) { in ntfs_put_super()
2325 if (vol->usnjrnl_j_ino) { in ntfs_put_super()
2326 iput(vol->usnjrnl_j_ino); in ntfs_put_super()
2327 vol->usnjrnl_j_ino = NULL; in ntfs_put_super()
2329 if (vol->usnjrnl_max_ino) { in ntfs_put_super()
2330 iput(vol->usnjrnl_max_ino); in ntfs_put_super()
2331 vol->usnjrnl_max_ino = NULL; in ntfs_put_super()
2333 if (vol->usnjrnl_ino) { in ntfs_put_super()
2334 iput(vol->usnjrnl_ino); in ntfs_put_super()
2335 vol->usnjrnl_ino = NULL; in ntfs_put_super()
2337 if (vol->quota_q_ino) { in ntfs_put_super()
2338 iput(vol->quota_q_ino); in ntfs_put_super()
2339 vol->quota_q_ino = NULL; in ntfs_put_super()
2341 if (vol->quota_ino) { in ntfs_put_super()
2342 iput(vol->quota_ino); in ntfs_put_super()
2343 vol->quota_ino = NULL; in ntfs_put_super()
2346 if (vol->extend_ino) { in ntfs_put_super()
2347 iput(vol->extend_ino); in ntfs_put_super()
2348 vol->extend_ino = NULL; in ntfs_put_super()
2350 if (vol->secure_ino) { in ntfs_put_super()
2351 iput(vol->secure_ino); in ntfs_put_super()
2352 vol->secure_ino = NULL; in ntfs_put_super()
2356 iput(vol->root_ino); in ntfs_put_super()
2357 vol->root_ino = NULL; in ntfs_put_super()
2359 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2360 iput(vol->lcnbmp_ino); in ntfs_put_super()
2361 vol->lcnbmp_ino = NULL; in ntfs_put_super()
2362 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2364 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2365 iput(vol->mftbmp_ino); in ntfs_put_super()
2366 vol->mftbmp_ino = NULL; in ntfs_put_super()
2367 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2370 if (vol->logfile_ino) { in ntfs_put_super()
2371 iput(vol->logfile_ino); in ntfs_put_super()
2372 vol->logfile_ino = NULL; in ntfs_put_super()
2374 if (vol->mftmirr_ino) { in ntfs_put_super()
2376 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2377 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2378 iput(vol->mftmirr_ino); in ntfs_put_super()
2379 vol->mftmirr_ino = NULL; in ntfs_put_super()
2386 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2387 write_inode_now(vol->mft_ino, 1); in ntfs_put_super()
2390 iput(vol->mft_ino); in ntfs_put_super()
2391 vol->mft_ino = NULL; in ntfs_put_super()
2394 vol->attrdef_size = 0; in ntfs_put_super()
2395 if (vol->attrdef) { in ntfs_put_super()
2396 ntfs_free(vol->attrdef); in ntfs_put_super()
2397 vol->attrdef = NULL; in ntfs_put_super()
2399 vol->upcase_len = 0; in ntfs_put_super()
2405 if (vol->upcase == default_upcase) { in ntfs_put_super()
2407 vol->upcase = NULL; in ntfs_put_super()
2413 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_put_super()
2416 if (vol->upcase) { in ntfs_put_super()
2417 ntfs_free(vol->upcase); in ntfs_put_super()
2418 vol->upcase = NULL; in ntfs_put_super()
2421 unload_nls(vol->nls_map); in ntfs_put_super()
2424 kfree(vol); in ntfs_put_super()
2446 static s64 get_nr_free_clusters(ntfs_volume *vol) in get_nr_free_clusters() argument
2448 s64 nr_free = vol->nr_clusters; in get_nr_free_clusters()
2449 struct address_space *mapping = vol->lcnbmp_ino->i_mapping; in get_nr_free_clusters()
2455 down_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2461 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >> in get_nr_free_clusters()
2499 if (vol->nr_clusters & 63) in get_nr_free_clusters()
2500 nr_free += 64 - (vol->nr_clusters & 63); in get_nr_free_clusters()
2501 up_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2526 static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, in __get_nr_free_mft_records() argument
2529 struct address_space *mapping = vol->mftbmp_ino->i_mapping; in __get_nr_free_mft_records()
2596 ntfs_volume *vol = NTFS_SB(sb); in ntfs_statfs() local
2597 ntfs_inode *mft_ni = NTFS_I(vol->mft_ino); in ntfs_statfs()
2611 sfs->f_blocks = vol->nr_clusters << vol->cluster_size_bits >> in ntfs_statfs()
2614 size = get_nr_free_clusters(vol) << vol->cluster_size_bits >> in ntfs_statfs()
2621 down_read(&vol->mftbmp_lock); in ntfs_statfs()
2623 size = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits; in ntfs_statfs()
2629 max_index = ((((mft_ni->initialized_size >> vol->mft_record_size_bits) in ntfs_statfs()
2635 sfs->f_ffree = __get_nr_free_mft_records(vol, size, max_index); in ntfs_statfs()
2636 up_read(&vol->mftbmp_lock); in ntfs_statfs()
2647 sfs->f_fsid = u64_to_fsid(vol->serial_no); in ntfs_statfs()
2699 ntfs_volume *vol; in ntfs_fill_super() local
2721 vol = NTFS_SB(sb); in ntfs_fill_super()
2722 if (!vol) { in ntfs_fill_super()
2730 *vol = (ntfs_volume) { in ntfs_fill_super()
2741 init_rwsem(&vol->mftbmp_lock); in ntfs_fill_super()
2742 init_rwsem(&vol->lcnbmp_lock); in ntfs_fill_super()
2745 NVolSetSparseEnabled(vol); in ntfs_fill_super()
2748 if (!parse_options(vol, (char*)opt)) in ntfs_fill_super()
2781 vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> in ntfs_fill_super()
2793 result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data); in ntfs_fill_super()
2810 if (vol->sector_size > blocksize) { in ntfs_fill_super()
2811 blocksize = sb_set_blocksize(sb, vol->sector_size); in ntfs_fill_super()
2812 if (blocksize != vol->sector_size) { in ntfs_fill_super()
2816 vol->sector_size); in ntfs_fill_super()
2820 vol->nr_blocks = i_size_read(sb->s_bdev->bd_inode) >> in ntfs_fill_super()
2827 ntfs_setup_allocators(vol); in ntfs_fill_super()
2867 if (vol->cluster_size <= 4096 && !ntfs_nr_compression_users++) { in ntfs_fill_super()
2894 if (!load_system_files(vol)) { in ntfs_fill_super()
2900 ihold(vol->root_ino); in ntfs_fill_super()
2901 if ((sb->s_root = d_make_root(vol->root_ino))) { in ntfs_fill_super()
2919 iput(vol->vol_ino); in ntfs_fill_super()
2920 vol->vol_ino = NULL; in ntfs_fill_super()
2922 if (vol->major_ver >= 3) { in ntfs_fill_super()
2924 if (vol->usnjrnl_j_ino) { in ntfs_fill_super()
2925 iput(vol->usnjrnl_j_ino); in ntfs_fill_super()
2926 vol->usnjrnl_j_ino = NULL; in ntfs_fill_super()
2928 if (vol->usnjrnl_max_ino) { in ntfs_fill_super()
2929 iput(vol->usnjrnl_max_ino); in ntfs_fill_super()
2930 vol->usnjrnl_max_ino = NULL; in ntfs_fill_super()
2932 if (vol->usnjrnl_ino) { in ntfs_fill_super()
2933 iput(vol->usnjrnl_ino); in ntfs_fill_super()
2934 vol->usnjrnl_ino = NULL; in ntfs_fill_super()
2936 if (vol->quota_q_ino) { in ntfs_fill_super()
2937 iput(vol->quota_q_ino); in ntfs_fill_super()
2938 vol->quota_q_ino = NULL; in ntfs_fill_super()
2940 if (vol->quota_ino) { in ntfs_fill_super()
2941 iput(vol->quota_ino); in ntfs_fill_super()
2942 vol->quota_ino = NULL; in ntfs_fill_super()
2945 if (vol->extend_ino) { in ntfs_fill_super()
2946 iput(vol->extend_ino); in ntfs_fill_super()
2947 vol->extend_ino = NULL; in ntfs_fill_super()
2949 if (vol->secure_ino) { in ntfs_fill_super()
2950 iput(vol->secure_ino); in ntfs_fill_super()
2951 vol->secure_ino = NULL; in ntfs_fill_super()
2954 iput(vol->root_ino); in ntfs_fill_super()
2955 vol->root_ino = NULL; in ntfs_fill_super()
2956 iput(vol->lcnbmp_ino); in ntfs_fill_super()
2957 vol->lcnbmp_ino = NULL; in ntfs_fill_super()
2958 iput(vol->mftbmp_ino); in ntfs_fill_super()
2959 vol->mftbmp_ino = NULL; in ntfs_fill_super()
2961 if (vol->logfile_ino) { in ntfs_fill_super()
2962 iput(vol->logfile_ino); in ntfs_fill_super()
2963 vol->logfile_ino = NULL; in ntfs_fill_super()
2965 if (vol->mftmirr_ino) { in ntfs_fill_super()
2966 iput(vol->mftmirr_ino); in ntfs_fill_super()
2967 vol->mftmirr_ino = NULL; in ntfs_fill_super()
2971 vol->attrdef_size = 0; in ntfs_fill_super()
2972 if (vol->attrdef) { in ntfs_fill_super()
2973 ntfs_free(vol->attrdef); in ntfs_fill_super()
2974 vol->attrdef = NULL; in ntfs_fill_super()
2976 vol->upcase_len = 0; in ntfs_fill_super()
2978 if (vol->upcase == default_upcase) { in ntfs_fill_super()
2980 vol->upcase = NULL; in ntfs_fill_super()
2983 if (vol->upcase) { in ntfs_fill_super()
2984 ntfs_free(vol->upcase); in ntfs_fill_super()
2985 vol->upcase = NULL; in ntfs_fill_super()
2987 if (vol->nls_map) { in ntfs_fill_super()
2988 unload_nls(vol->nls_map); in ntfs_fill_super()
2989 vol->nls_map = NULL; in ntfs_fill_super()
3002 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_fill_super()
3007 if (vol->mft_ino && vol->mft_ino != tmp_ino) in ntfs_fill_super()
3008 iput(vol->mft_ino); in ntfs_fill_super()
3009 vol->mft_ino = NULL; in ntfs_fill_super()
3013 kfree(vol); in ntfs_fill_super()