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 if (!IS_ERR(vol->extend_ino)) in load_system_files()
2097 iput(vol->extend_ino); in load_system_files()
2103 if (!load_and_init_quota(vol)) { in load_system_files()
2109 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2123 NVolSetErrors(vol); in load_system_files()
2126 if (!sb_rdonly(sb) && !ntfs_mark_quotas_out_of_date(vol)) { in load_system_files()
2131 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2140 NVolSetErrors(vol); in load_system_files()
2146 if (!load_and_init_usnjrnl(vol)) { in load_system_files()
2152 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2166 NVolSetErrors(vol); in load_system_files()
2169 if (!sb_rdonly(sb) && !ntfs_stamp_usnjrnl(vol)) { in load_system_files()
2175 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | in load_system_files()
2184 NVolSetErrors(vol); in load_system_files()
2190 iput(vol->usnjrnl_j_ino); in load_system_files()
2191 iput(vol->usnjrnl_max_ino); in load_system_files()
2192 iput(vol->usnjrnl_ino); in load_system_files()
2194 iput(vol->quota_q_ino); in load_system_files()
2195 iput(vol->quota_ino); in load_system_files()
2196 iput(vol->extend_ino); in load_system_files()
2199 iput(vol->secure_ino); in load_system_files()
2201 iput(vol->root_ino); in load_system_files()
2204 iput(vol->logfile_ino); in load_system_files()
2207 iput(vol->vol_ino); in load_system_files()
2209 iput(vol->lcnbmp_ino); in load_system_files()
2211 vol->attrdef_size = 0; in load_system_files()
2212 if (vol->attrdef) { in load_system_files()
2213 ntfs_free(vol->attrdef); in load_system_files()
2214 vol->attrdef = NULL; in load_system_files()
2219 vol->upcase_len = 0; in load_system_files()
2221 if (vol->upcase == default_upcase) { in load_system_files()
2223 vol->upcase = NULL; in load_system_files()
2226 if (vol->upcase) { in load_system_files()
2227 ntfs_free(vol->upcase); in load_system_files()
2228 vol->upcase = NULL; in load_system_files()
2231 iput(vol->mftbmp_ino); in load_system_files()
2234 iput(vol->mftmirr_ino); in load_system_files()
2250 ntfs_volume *vol = NTFS_SB(sb); in ntfs_put_super() local
2259 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2262 if (vol->major_ver >= 3) { in ntfs_put_super()
2263 if (vol->usnjrnl_j_ino) in ntfs_put_super()
2264 ntfs_commit_inode(vol->usnjrnl_j_ino); in ntfs_put_super()
2265 if (vol->usnjrnl_max_ino) in ntfs_put_super()
2266 ntfs_commit_inode(vol->usnjrnl_max_ino); in ntfs_put_super()
2267 if (vol->usnjrnl_ino) in ntfs_put_super()
2268 ntfs_commit_inode(vol->usnjrnl_ino); in ntfs_put_super()
2269 if (vol->quota_q_ino) in ntfs_put_super()
2270 ntfs_commit_inode(vol->quota_q_ino); in ntfs_put_super()
2271 if (vol->quota_ino) in ntfs_put_super()
2272 ntfs_commit_inode(vol->quota_ino); in ntfs_put_super()
2273 if (vol->extend_ino) in ntfs_put_super()
2274 ntfs_commit_inode(vol->extend_ino); in ntfs_put_super()
2275 if (vol->secure_ino) in ntfs_put_super()
2276 ntfs_commit_inode(vol->secure_ino); in ntfs_put_super()
2279 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2281 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2282 ntfs_commit_inode(vol->lcnbmp_ino); in ntfs_put_super()
2283 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2285 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2286 ntfs_commit_inode(vol->mftbmp_ino); in ntfs_put_super()
2287 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2289 if (vol->logfile_ino) in ntfs_put_super()
2290 ntfs_commit_inode(vol->logfile_ino); in ntfs_put_super()
2292 if (vol->mftmirr_ino) in ntfs_put_super()
2293 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2294 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2301 if (!NVolErrors(vol)) { in ntfs_put_super()
2302 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) in ntfs_put_super()
2306 ntfs_commit_inode(vol->vol_ino); in ntfs_put_super()
2307 ntfs_commit_inode(vol->root_ino); in ntfs_put_super()
2308 if (vol->mftmirr_ino) in ntfs_put_super()
2309 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2310 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2318 iput(vol->vol_ino); in ntfs_put_super()
2319 vol->vol_ino = NULL; in ntfs_put_super()
2322 if (vol->major_ver >= 3) { in ntfs_put_super()
2324 if (vol->usnjrnl_j_ino) { in ntfs_put_super()
2325 iput(vol->usnjrnl_j_ino); in ntfs_put_super()
2326 vol->usnjrnl_j_ino = NULL; in ntfs_put_super()
2328 if (vol->usnjrnl_max_ino) { in ntfs_put_super()
2329 iput(vol->usnjrnl_max_ino); in ntfs_put_super()
2330 vol->usnjrnl_max_ino = NULL; in ntfs_put_super()
2332 if (vol->usnjrnl_ino) { in ntfs_put_super()
2333 iput(vol->usnjrnl_ino); in ntfs_put_super()
2334 vol->usnjrnl_ino = NULL; in ntfs_put_super()
2336 if (vol->quota_q_ino) { in ntfs_put_super()
2337 iput(vol->quota_q_ino); in ntfs_put_super()
2338 vol->quota_q_ino = NULL; in ntfs_put_super()
2340 if (vol->quota_ino) { in ntfs_put_super()
2341 iput(vol->quota_ino); in ntfs_put_super()
2342 vol->quota_ino = NULL; in ntfs_put_super()
2345 if (vol->extend_ino) { in ntfs_put_super()
2346 iput(vol->extend_ino); in ntfs_put_super()
2347 vol->extend_ino = NULL; in ntfs_put_super()
2349 if (vol->secure_ino) { in ntfs_put_super()
2350 iput(vol->secure_ino); in ntfs_put_super()
2351 vol->secure_ino = NULL; in ntfs_put_super()
2355 iput(vol->root_ino); in ntfs_put_super()
2356 vol->root_ino = NULL; in ntfs_put_super()
2358 down_write(&vol->lcnbmp_lock); in ntfs_put_super()
2359 iput(vol->lcnbmp_ino); in ntfs_put_super()
2360 vol->lcnbmp_ino = NULL; in ntfs_put_super()
2361 up_write(&vol->lcnbmp_lock); in ntfs_put_super()
2363 down_write(&vol->mftbmp_lock); in ntfs_put_super()
2364 iput(vol->mftbmp_ino); in ntfs_put_super()
2365 vol->mftbmp_ino = NULL; in ntfs_put_super()
2366 up_write(&vol->mftbmp_lock); in ntfs_put_super()
2369 if (vol->logfile_ino) { in ntfs_put_super()
2370 iput(vol->logfile_ino); in ntfs_put_super()
2371 vol->logfile_ino = NULL; in ntfs_put_super()
2373 if (vol->mftmirr_ino) { in ntfs_put_super()
2375 ntfs_commit_inode(vol->mftmirr_ino); in ntfs_put_super()
2376 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2377 iput(vol->mftmirr_ino); in ntfs_put_super()
2378 vol->mftmirr_ino = NULL; in ntfs_put_super()
2385 ntfs_commit_inode(vol->mft_ino); in ntfs_put_super()
2386 write_inode_now(vol->mft_ino, 1); in ntfs_put_super()
2389 iput(vol->mft_ino); in ntfs_put_super()
2390 vol->mft_ino = NULL; in ntfs_put_super()
2393 vol->attrdef_size = 0; in ntfs_put_super()
2394 if (vol->attrdef) { in ntfs_put_super()
2395 ntfs_free(vol->attrdef); in ntfs_put_super()
2396 vol->attrdef = NULL; in ntfs_put_super()
2398 vol->upcase_len = 0; in ntfs_put_super()
2404 if (vol->upcase == default_upcase) { in ntfs_put_super()
2406 vol->upcase = NULL; in ntfs_put_super()
2412 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_put_super()
2415 if (vol->upcase) { in ntfs_put_super()
2416 ntfs_free(vol->upcase); in ntfs_put_super()
2417 vol->upcase = NULL; in ntfs_put_super()
2420 unload_nls(vol->nls_map); in ntfs_put_super()
2423 kfree(vol); in ntfs_put_super()
2445 static s64 get_nr_free_clusters(ntfs_volume *vol) in get_nr_free_clusters() argument
2447 s64 nr_free = vol->nr_clusters; in get_nr_free_clusters()
2448 struct address_space *mapping = vol->lcnbmp_ino->i_mapping; in get_nr_free_clusters()
2454 down_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2460 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >> in get_nr_free_clusters()
2498 if (vol->nr_clusters & 63) in get_nr_free_clusters()
2499 nr_free += 64 - (vol->nr_clusters & 63); in get_nr_free_clusters()
2500 up_read(&vol->lcnbmp_lock); in get_nr_free_clusters()
2525 static unsigned long __get_nr_free_mft_records(ntfs_volume *vol, in __get_nr_free_mft_records() argument
2528 struct address_space *mapping = vol->mftbmp_ino->i_mapping; in __get_nr_free_mft_records()
2595 ntfs_volume *vol = NTFS_SB(sb); in ntfs_statfs() local
2596 ntfs_inode *mft_ni = NTFS_I(vol->mft_ino); in ntfs_statfs()
2610 sfs->f_blocks = vol->nr_clusters << vol->cluster_size_bits >> in ntfs_statfs()
2613 size = get_nr_free_clusters(vol) << vol->cluster_size_bits >> in ntfs_statfs()
2620 down_read(&vol->mftbmp_lock); in ntfs_statfs()
2622 size = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits; in ntfs_statfs()
2628 max_index = ((((mft_ni->initialized_size >> vol->mft_record_size_bits) in ntfs_statfs()
2634 sfs->f_ffree = __get_nr_free_mft_records(vol, size, max_index); in ntfs_statfs()
2635 up_read(&vol->mftbmp_lock); in ntfs_statfs()
2646 sfs->f_fsid = u64_to_fsid(vol->serial_no); in ntfs_statfs()
2698 ntfs_volume *vol; in ntfs_fill_super() local
2720 vol = NTFS_SB(sb); in ntfs_fill_super()
2721 if (!vol) { in ntfs_fill_super()
2729 *vol = (ntfs_volume) { in ntfs_fill_super()
2740 init_rwsem(&vol->mftbmp_lock); in ntfs_fill_super()
2741 init_rwsem(&vol->lcnbmp_lock); in ntfs_fill_super()
2744 NVolSetSparseEnabled(vol); in ntfs_fill_super()
2747 if (!parse_options(vol, (char*)opt)) in ntfs_fill_super()
2775 vol->nr_blocks = sb_bdev_nr_blocks(sb); in ntfs_fill_super()
2776 if (!vol->nr_blocks) { in ntfs_fill_super()
2791 result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data); in ntfs_fill_super()
2808 if (vol->sector_size > blocksize) { in ntfs_fill_super()
2809 blocksize = sb_set_blocksize(sb, vol->sector_size); in ntfs_fill_super()
2810 if (blocksize != vol->sector_size) { in ntfs_fill_super()
2814 vol->sector_size); in ntfs_fill_super()
2818 vol->nr_blocks = sb_bdev_nr_blocks(sb); in ntfs_fill_super()
2824 ntfs_setup_allocators(vol); in ntfs_fill_super()
2864 if (vol->cluster_size <= 4096 && !ntfs_nr_compression_users++) { in ntfs_fill_super()
2891 if (!load_system_files(vol)) { in ntfs_fill_super()
2897 ihold(vol->root_ino); in ntfs_fill_super()
2898 if ((sb->s_root = d_make_root(vol->root_ino))) { in ntfs_fill_super()
2916 iput(vol->vol_ino); in ntfs_fill_super()
2917 vol->vol_ino = NULL; in ntfs_fill_super()
2919 if (vol->major_ver >= 3) { in ntfs_fill_super()
2921 if (vol->usnjrnl_j_ino) { in ntfs_fill_super()
2922 iput(vol->usnjrnl_j_ino); in ntfs_fill_super()
2923 vol->usnjrnl_j_ino = NULL; in ntfs_fill_super()
2925 if (vol->usnjrnl_max_ino) { in ntfs_fill_super()
2926 iput(vol->usnjrnl_max_ino); in ntfs_fill_super()
2927 vol->usnjrnl_max_ino = NULL; in ntfs_fill_super()
2929 if (vol->usnjrnl_ino) { in ntfs_fill_super()
2930 iput(vol->usnjrnl_ino); in ntfs_fill_super()
2931 vol->usnjrnl_ino = NULL; in ntfs_fill_super()
2933 if (vol->quota_q_ino) { in ntfs_fill_super()
2934 iput(vol->quota_q_ino); in ntfs_fill_super()
2935 vol->quota_q_ino = NULL; in ntfs_fill_super()
2937 if (vol->quota_ino) { in ntfs_fill_super()
2938 iput(vol->quota_ino); in ntfs_fill_super()
2939 vol->quota_ino = NULL; in ntfs_fill_super()
2942 if (vol->extend_ino) { in ntfs_fill_super()
2943 iput(vol->extend_ino); in ntfs_fill_super()
2944 vol->extend_ino = NULL; in ntfs_fill_super()
2946 if (vol->secure_ino) { in ntfs_fill_super()
2947 iput(vol->secure_ino); in ntfs_fill_super()
2948 vol->secure_ino = NULL; in ntfs_fill_super()
2951 iput(vol->root_ino); in ntfs_fill_super()
2952 vol->root_ino = NULL; in ntfs_fill_super()
2953 iput(vol->lcnbmp_ino); in ntfs_fill_super()
2954 vol->lcnbmp_ino = NULL; in ntfs_fill_super()
2955 iput(vol->mftbmp_ino); in ntfs_fill_super()
2956 vol->mftbmp_ino = NULL; in ntfs_fill_super()
2958 if (vol->logfile_ino) { in ntfs_fill_super()
2959 iput(vol->logfile_ino); in ntfs_fill_super()
2960 vol->logfile_ino = NULL; in ntfs_fill_super()
2962 if (vol->mftmirr_ino) { in ntfs_fill_super()
2963 iput(vol->mftmirr_ino); in ntfs_fill_super()
2964 vol->mftmirr_ino = NULL; in ntfs_fill_super()
2968 vol->attrdef_size = 0; in ntfs_fill_super()
2969 if (vol->attrdef) { in ntfs_fill_super()
2970 ntfs_free(vol->attrdef); in ntfs_fill_super()
2971 vol->attrdef = NULL; in ntfs_fill_super()
2973 vol->upcase_len = 0; in ntfs_fill_super()
2975 if (vol->upcase == default_upcase) { in ntfs_fill_super()
2977 vol->upcase = NULL; in ntfs_fill_super()
2980 if (vol->upcase) { in ntfs_fill_super()
2981 ntfs_free(vol->upcase); in ntfs_fill_super()
2982 vol->upcase = NULL; in ntfs_fill_super()
2984 if (vol->nls_map) { in ntfs_fill_super()
2985 unload_nls(vol->nls_map); in ntfs_fill_super()
2986 vol->nls_map = NULL; in ntfs_fill_super()
2999 if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) in ntfs_fill_super()
3004 if (vol->mft_ino && vol->mft_ino != tmp_ino) in ntfs_fill_super()
3005 iput(vol->mft_ino); in ntfs_fill_super()
3006 vol->mft_ino = NULL; in ntfs_fill_super()
3010 kfree(vol); in ntfs_fill_super()