Lines Matching refs:vol

125 	struct ntfs_volume *vol = fc->s_fs_info;
135 vol->uid = make_kuid(current_user_ns(), result.uint_32);
138 vol->gid = make_kgid(current_user_ns(), result.uint_32);
141 vol->fmask = vol->dmask = result.uint_32;
144 vol->dmask = result.uint_32;
147 vol->fmask = result.uint_32;
150 vol->on_errors = result.uint_32;
154 if (vol->nls_map)
155 unload_nls(vol->nls_map);
156 vol->nls_map = load_nls(param->string);
157 if (!vol->nls_map) {
158 ntfs_error(vol->sb, "Failed to load NLS table '%s'.",
164 if (vol->mft_zone_multiplier && vol->mft_zone_multiplier !=
166 ntfs_error(vol->sb, "Cannot change mft_zone_multiplier on remount.");
170 ntfs_error(vol->sb,
172 vol->mft_zone_multiplier = 1;
174 vol->mft_zone_multiplier = result.int_32;
179 NVolSetShowSystemFiles(vol);
181 NVolClearShowSystemFiles(vol);
185 NVolSetCaseSensitive(vol);
187 NVolClearCaseSensitive(vol);
191 NVolClearCaseSensitive(vol);
193 NVolSetCaseSensitive(vol);
196 vol->preallocated_size = (loff_t)result.uint_64;
200 NVolSetSysImmutable(vol);
202 NVolClearSysImmutable(vol);
206 NVolClearShowHiddenFiles(vol);
208 NVolSetShowHiddenFiles(vol);
212 NVolSetHideDotFiles(vol);
214 NVolClearHideDotFiles(vol);
218 NVolSetCheckWindowsNames(vol);
220 NVolClearCheckWindowsNames(vol);
234 NVolSetDiscard(vol);
236 NVolClearDiscard(vol);
240 NVolSetDisableSparse(vol);
242 NVolClearDisableSparse(vol);
246 NVolSetNativeSymlinkRel(vol);
248 NVolClearNativeSymlinkRel(vol);
252 NVolSetSymlinkNative(vol);
254 NVolClearSymlinkNative(vol);
268 struct ntfs_volume *vol = NTFS_SB(sb);
289 if (NVolErrors(vol)) {
294 if (vol->vol_flags & VOLUME_IS_DIRTY) {
298 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
302 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
304 le16_to_cpu(vol->vol_flags), es);
307 if (vol->logfile_ino && !ntfs_empty_logfile(vol->logfile_ino)) {
310 NVolSetErrors(vol);
315 if (!NVolErrors(vol)) {
316 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY))
335 struct ntfs_volume *vol = NTFS_SB(sb);
340 if (vol->on_errors == ON_ERRORS_REMOUNT_RO) {
344 } else if (vol->on_errors == ON_ERRORS_PANIC) {
347 } else if (vol->on_errors == ON_ERRORS_CONTINUE) {
348 if (errseq_check(&sb->s_wb_err, vol->wb_err) == -ENODEV) {
349 NVolSetShutdown(vol);
350 vol->wb_err = sb->s_wb_err;
357 * @vol: ntfs volume on which to modify the flags
363 * Replace the volume information flags on the volume @vol with the value
370 static int ntfs_write_volume_flags(struct ntfs_volume *vol, const __le16 flags)
372 struct ntfs_inode *ni = NTFS_I(vol->vol_ino);
378 le16_to_cpu(vol->vol_flags), le16_to_cpu(flags));
380 if (vol->vol_flags == flags)
396 vol->vol_flags = vi->flags = flags;
407 ntfs_error(vol->sb, "Failed with error code %i.", -err);
413 * @vol: ntfs volume on which to modify the flags
416 * Set the bits in @flags in the volume information flags on the volume @vol.
420 int ntfs_set_volume_flags(struct ntfs_volume *vol, __le16 flags)
423 return ntfs_write_volume_flags(vol, vol->vol_flags | flags);
428 * @vol: ntfs volume on which to modify the flags
431 * Clear the bits in @flags in the volume information flags on the volume @vol.
435 int ntfs_clear_volume_flags(struct ntfs_volume *vol, __le16 flags)
438 flags = vol->vol_flags & cpu_to_le16(~le16_to_cpu(flags));
439 return ntfs_write_volume_flags(vol, flags);
442 int ntfs_write_volume_label(struct ntfs_volume *vol, char *label)
444 struct ntfs_inode *vol_ni = NTFS_I(vol->vol_ino);
450 uname_len = ntfs_nlstoucs(vol, label, strlen(label),
453 ntfs_error(vol->sb,
460 ntfs_error(vol->sb,
501 mutex_lock(&vol->volume_label_lock);
502 old_label = vol->volume_label;
503 vol->volume_label = new_label;
504 mutex_unlock(&vol->volume_label_lock);
507 mark_inode_dirty_sync(vol->vol_ino);
636 * parse_ntfs_boot_sector - parse the boot sector and store the data in @vol
637 * @vol: volume structure to initialise with data from boot sector
641 * the ntfs super block @vol. Return 'true' on success and 'false' on error.
643 static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
650 vol->sector_size = le16_to_cpu(b->bpb.bytes_per_sector);
651 vol->sector_size_bits = ffs(vol->sector_size) - 1;
652 ntfs_debug("vol->sector_size = %i (0x%x)", vol->sector_size,
653 vol->sector_size);
654 ntfs_debug("vol->sector_size_bits = %i (0x%x)", vol->sector_size_bits,
655 vol->sector_size_bits);
656 if (vol->sector_size < vol->sb->s_blocksize) {
657 ntfs_error(vol->sb,
659 vol->sector_size, vol->sb->s_blocksize);
673 vol->cluster_size = vol->sector_size << sectors_per_cluster_bits;
674 vol->cluster_size_mask = vol->cluster_size - 1;
675 vol->cluster_size_bits = ffs(vol->cluster_size) - 1;
676 ntfs_debug("vol->cluster_size = %i (0x%x)", vol->cluster_size,
677 vol->cluster_size);
678 ntfs_debug("vol->cluster_size_mask = 0x%x", vol->cluster_size_mask);
679 ntfs_debug("vol->cluster_size_bits = %i", vol->cluster_size_bits);
680 if (vol->cluster_size < vol->sector_size) {
681 ntfs_error(vol->sb,
683 vol->cluster_size, vol->sector_size);
690 vol->mft_record_size = vol->cluster_size <<
698 vol->mft_record_size = 1 << -clusters_per_mft_record;
699 vol->mft_record_size_mask = vol->mft_record_size - 1;
700 vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1;
701 ntfs_debug("vol->mft_record_size = %i (0x%x)", vol->mft_record_size,
702 vol->mft_record_size);
703 ntfs_debug("vol->mft_record_size_mask = 0x%x",
704 vol->mft_record_size_mask);
705 ntfs_debug("vol->mft_record_size_bits = %i (0x%x)",
706 vol->mft_record_size_bits, vol->mft_record_size_bits);
711 if (vol->mft_record_size > PAGE_SIZE) {
712 ntfs_error(vol->sb,
714 vol->mft_record_size, PAGE_SIZE);
718 if (vol->mft_record_size < vol->sector_size) {
719 ntfs_warning(vol->sb, "Mft record size (%i) is smaller than the sector size (%i).",
720 vol->mft_record_size, vol->sector_size);
726 vol->index_record_size = vol->cluster_size <<
735 vol->index_record_size = 1 << -clusters_per_index_record;
736 vol->index_record_size_mask = vol->index_record_size - 1;
737 vol->index_record_size_bits = ffs(vol->index_record_size) - 1;
738 ntfs_debug("vol->index_record_size = %i (0x%x)",
739 vol->index_record_size, vol->index_record_size);
740 ntfs_debug("vol->index_record_size_mask = 0x%x",
741 vol->index_record_size_mask);
742 ntfs_debug("vol->index_record_size_bits = %i (0x%x)",
743 vol->index_record_size_bits,
744 vol->index_record_size_bits);
746 if (vol->index_record_size < vol->sector_size) {
747 ntfs_error(vol->sb,
749 vol->index_record_size, vol->sector_size);
759 ntfs_error(vol->sb, "Cannot handle 64-bit clusters.");
762 vol->nr_clusters = ll;
763 ntfs_debug("vol->nr_clusters = 0x%llx", vol->nr_clusters);
765 if (ll >= vol->nr_clusters) {
766 ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of volume. Weird.",
770 vol->mft_lcn = ll;
771 ntfs_debug("vol->mft_lcn = 0x%llx", vol->mft_lcn);
773 if (ll >= vol->nr_clusters) {
774 ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end of volume. Weird.",
778 vol->mftmirr_lcn = ll;
779 ntfs_debug("vol->mftmirr_lcn = 0x%llx", vol->mftmirr_lcn);
788 if (vol->cluster_size <= (4 << vol->mft_record_size_bits))
789 vol->mftmirr_size = 4;
791 vol->mftmirr_size = vol->cluster_size >>
792 vol->mft_record_size_bits;
793 ntfs_debug("vol->mftmirr_size = %i", vol->mftmirr_size);
794 vol->serial_no = le64_to_cpu(b->volume_serial_number);
795 ntfs_debug("vol->serial_no = 0x%llx", vol->serial_no);
797 vol->sparse_compression_unit = 4;
798 if (vol->cluster_size > 4096) {
799 switch (vol->cluster_size) {
801 vol->sparse_compression_unit = 0;
804 vol->sparse_compression_unit = 1;
807 vol->sparse_compression_unit = 2;
810 vol->sparse_compression_unit = 3;
820 * @vol: volume structure for which to setup the allocators
824 static void ntfs_setup_allocators(struct ntfs_volume *vol)
828 ntfs_debug("vol->mft_zone_multiplier = 0x%x",
829 vol->mft_zone_multiplier);
831 mft_zone_size = vol->nr_clusters;
832 switch (vol->mft_zone_multiplier) { /* % of volume size in clusters */
849 vol->mft_zone_start = vol->mft_zone_pos = vol->mft_lcn;
850 ntfs_debug("vol->mft_zone_pos = 0x%llx", vol->mft_zone_pos);
860 mft_lcn = NTFS_B_TO_CLU(vol, 8192 + 2 * vol->cluster_size - 1);
861 if (mft_lcn * vol->cluster_size < 16 * 1024)
862 mft_lcn = (16 * 1024 + vol->cluster_size - 1) >>
863 vol->cluster_size_bits;
864 if (vol->mft_zone_start <= mft_lcn)
865 vol->mft_zone_start = 0;
866 ntfs_debug("vol->mft_zone_start = 0x%llx", vol->mft_zone_start);
872 vol->mft_zone_end = vol->mft_lcn + mft_zone_size;
873 while (vol->mft_zone_end >= vol->nr_clusters) {
875 vol->mft_zone_end = vol->mft_lcn + mft_zone_size;
877 ntfs_debug("vol->mft_zone_end = 0x%llx", vol->mft_zone_end);
882 vol->data1_zone_pos = vol->mft_zone_end;
883 ntfs_debug("vol->data1_zone_pos = 0x%llx", vol->data1_zone_pos);
884 vol->data2_zone_pos = 0;
885 ntfs_debug("vol->data2_zone_pos = 0x%llx", vol->data2_zone_pos);
888 vol->mft_data_pos = 24;
889 ntfs_debug("vol->mft_data_pos = 0x%llx", vol->mft_data_pos);
896 * @vol: ntfs super block describing device whose mft mirror to load
900 static bool load_and_init_mft_mirror(struct ntfs_volume *vol)
907 tmp_ino = ntfs_iget(vol->sb, FILE_MFTMirr);
940 tmp_ni->itype.index.block_size = vol->mft_record_size;
941 tmp_ni->itype.index.block_size_bits = vol->mft_record_size_bits;
942 vol->mftmirr_ino = tmp_ino;
949 * @vol: ntfs super block describing device whose mft mirror to check
957 static bool check_mft_mirror(struct ntfs_volume *vol)
959 struct super_block *sb = vol->sb;
969 mrecs_per_page = PAGE_SIZE / vol->mft_record_size;
983 mft_folio = read_mapping_folio(vol->mft_ino->i_mapping,
991 mirr_folio = read_mapping_folio(vol->mftmirr_ino->i_mapping,
1029 bytes > vol->mft_record_size ||
1033 bytes > vol->mft_record_size ||
1035 bytes = vol->mft_record_size;
1044 kmft += vol->mft_record_size;
1045 kmirr += vol->mft_record_size;
1046 } while (++i < vol->mftmirr_size);
1055 rl2[0].lcn = vol->mftmirr_lcn;
1056 rl2[0].length = NTFS_B_TO_CLU(vol, vol->mftmirr_size * vol->mft_record_size +
1057 vol->cluster_size - 1);
1065 mirr_ni = NTFS_I(vol->mftmirr_ino);
1085 * @vol: ntfs volume to load the logfile for
1090 static int load_and_check_logfile(struct ntfs_volume *vol,
1097 tmp_ino = ntfs_iget(vol->sb, FILE_LogFile);
1107 vol->logfile_ino = tmp_ino;
1116 * @vol: ntfs super block of device to check
1118 * Check if Windows is hibernated on the ntfs volume @vol. This is done by
1138 static int check_windows_hibernation_status(struct ntfs_volume *vol)
1159 inode_lock(vol->root_ino);
1160 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12,
1162 inode_unlock(vol->root_ino);
1172 ntfs_error(vol->sb, "Failed to find inode number for hiberfil.sys.");
1176 vi = ntfs_iget(vol->sb, MREF(mref));
1180 ntfs_error(vol->sb, "Failed to load hiberfil.sys.");
1191 ntfs_error(vol->sb, "Failed to read from hiberfil.sys.");
1221 * @vol: ntfs super block describing device whose attrdef to load
1225 static bool load_and_init_attrdef(struct ntfs_volume *vol)
1228 struct super_block *sb = vol->sb;
1236 /* Read attrdef table and setup vol->attrdef and vol->attrdef_size. */
1248 vol->attrdef = kvzalloc(i_size, GFP_NOFS);
1249 if (!vol->attrdef)
1261 memcpy((u8 *)vol->attrdef + (index++ << PAGE_SHIFT),
1271 vol->attrdef_size = i_size;
1276 kvfree(vol->attrdef);
1277 vol->attrdef = NULL;
1287 * @vol: ntfs super block describing device whose upcase to load
1291 static bool load_and_init_upcase(struct ntfs_volume *vol)
1294 struct super_block *sb = vol->sb;
1302 /* Read upcase table and setup vol->upcase and vol->upcase_len. */
1317 vol->upcase = kvzalloc(i_size, GFP_NOFS);
1318 if (!vol->upcase)
1330 memcpy((char *)vol->upcase + (index++ << PAGE_SHIFT),
1340 vol->upcase_len = i_size >> sizeof(unsigned char);
1350 if (default_upcase_len == vol->upcase_len &&
1351 !memcmp(vol->upcase, default_upcase,
1353 kvfree(vol->upcase);
1354 vol->upcase = default_upcase;
1365 kvfree(vol->upcase);
1366 vol->upcase = NULL;
1370 vol->upcase = default_upcase;
1371 vol->upcase_len = default_upcase_len;
1392 * @vol: ntfs super block describing device whose system files to load
1395 * the ntfs super block @vol.
1399 static bool load_system_files(struct ntfs_volume *vol)
1401 struct super_block *sb = vol->sb;
1410 if (!load_and_init_mft_mirror(vol) || !check_mft_mirror(vol)) {
1412 if (!sb_rdonly(sb) && vol->on_errors == ON_ERRORS_REMOUNT_RO) {
1419 !vol->mftmirr_ino ? es1 : es2, es3);
1421 NVolSetErrors(vol);
1424 vol->mftbmp_ino = ntfs_attr_iget(vol->mft_ino, AT_BITMAP, NULL, 0);
1425 if (IS_ERR(vol->mftbmp_ino)) {
1429 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->runlist.lock,
1431 lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->mrec_lock,
1433 /* Read upcase table and setup @vol->upcase and @vol->upcase_len. */
1434 if (!load_and_init_upcase(vol))
1437 * Read attribute definitions table and setup @vol->attrdef and
1438 * @vol->attrdef_size.
1440 if (!load_and_init_attrdef(vol))
1447 vol->lcnbmp_ino = ntfs_iget(sb, FILE_Bitmap);
1448 if (IS_ERR(vol->lcnbmp_ino)) {
1449 if (!IS_ERR(vol->lcnbmp_ino))
1450 iput(vol->lcnbmp_ino);
1453 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->runlist.lock,
1455 lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->mrec_lock,
1458 NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino));
1459 if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) {
1460 iput(vol->lcnbmp_ino);
1469 vol->vol_ino = ntfs_iget(sb, FILE_Volume);
1470 if (IS_ERR(vol->vol_ino)) {
1471 if (!IS_ERR(vol->vol_ino))
1472 iput(vol->vol_ino);
1477 m = map_mft_record(NTFS_I(vol->vol_ino));
1480 iput(vol->vol_ino);
1484 ctx = ntfs_attr_get_search_ctx(NTFS_I(vol->vol_ino), m);
1494 err = ntfs_ucstonls(vol, (__le16 *)((u8 *)ctx->attr +
1497 &vol->volume_label, NTFS_MAX_LABEL_LEN);
1499 vol->volume_label = NULL;
1507 unmap_mft_record(NTFS_I(vol->vol_ino));
1513 vol->vol_flags = vi->flags;
1514 vol->major_ver = vi->major_ver;
1515 vol->minor_ver = vi->minor_ver;
1517 unmap_mft_record(NTFS_I(vol->vol_ino));
1519 vol->major_ver, vol->minor_ver, sb->s_id, vol->cluster_size);
1522 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
1531 if (vol->vol_flags & VOLUME_IS_DIRTY)
1533 else if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
1539 (unsigned int)le16_to_cpu(vol->vol_flags));
1542 if (!sb_rdonly(sb) && vol->on_errors == ON_ERRORS_REMOUNT_RO) {
1556 err = load_and_check_logfile(vol, &rp);
1559 if (!sb_rdonly(sb) && vol->on_errors == ON_ERRORS_REMOUNT_RO) {
1563 NVolSetErrors(vol);
1568 vol->root_ino = ntfs_iget(sb, FILE_root);
1569 if (IS_ERR(vol->root_ino)) {
1570 if (!IS_ERR(vol->root_ino))
1571 iput(vol->root_ino);
1582 err = check_windows_hibernation_status(vol);
1591 if (!sb_rdonly(sb) && vol->on_errors == ON_ERRORS_REMOUNT_RO) {
1595 NVolSetErrors(vol);
1600 vol->logfile_ino && !ntfs_empty_logfile(vol->logfile_ino) &&
1601 vol->on_errors == ON_ERRORS_REMOUNT_RO) {
1608 NVolSetErrors(vol);
1611 if (unlikely(vol->major_ver < 3))
1615 vol->secure_ino = ntfs_iget(sb, FILE_Secure);
1616 if (IS_ERR(vol->secure_ino)) {
1617 if (!IS_ERR(vol->secure_ino))
1618 iput(vol->secure_ino);
1623 vol->extend_ino = ntfs_iget(sb, FILE_Extend);
1624 if (IS_ERR(vol->extend_ino) ||
1625 !S_ISDIR(vol->extend_ino->i_mode)) {
1626 if (!IS_ERR(vol->extend_ino))
1627 iput(vol->extend_ino);
1634 iput(vol->secure_ino);
1636 iput(vol->root_ino);
1638 if (vol->logfile_ino)
1639 iput(vol->logfile_ino);
1640 iput(vol->vol_ino);
1642 iput(vol->lcnbmp_ino);
1644 vol->attrdef_size = 0;
1645 if (vol->attrdef) {
1646 kvfree(vol->attrdef);
1647 vol->attrdef = NULL;
1650 vol->upcase_len = 0;
1652 if (vol->upcase && vol->upcase == default_upcase) {
1654 vol->upcase = NULL;
1657 if (vol->upcase) {
1658 kvfree(vol->upcase);
1659 vol->upcase = NULL;
1662 iput(vol->mftbmp_ino);
1664 iput(vol->mftmirr_ino);
1668 static void ntfs_volume_free(struct ntfs_volume *vol)
1671 vol->attrdef_size = 0;
1672 if (vol->attrdef) {
1673 kvfree(vol->attrdef);
1674 vol->attrdef = NULL;
1676 vol->upcase_len = 0;
1682 if (vol->upcase && vol->upcase == default_upcase) {
1684 vol->upcase = NULL;
1695 if (vol->upcase) {
1696 kvfree(vol->upcase);
1697 vol->upcase = NULL;
1700 unload_nls(vol->nls_map);
1702 kvfree(vol->lcn_empty_bits_per_page);
1703 kfree(vol->volume_label);
1704 kfree(vol);
1713 struct ntfs_volume *vol = NTFS_SB(sb);
1717 cancel_work_sync(&vol->precalc_work);
1723 ntfs_commit_inode(vol->vol_ino);
1726 if (vol->major_ver >= 3) {
1727 if (vol->extend_ino)
1728 ntfs_commit_inode(vol->extend_ino);
1729 if (vol->secure_ino)
1730 ntfs_commit_inode(vol->secure_ino);
1733 ntfs_commit_inode(vol->root_ino);
1735 ntfs_commit_inode(vol->lcnbmp_ino);
1741 ntfs_commit_inode(vol->mftbmp_ino);
1743 if (vol->logfile_ino)
1744 ntfs_commit_inode(vol->logfile_ino);
1746 if (vol->mftmirr_ino)
1747 ntfs_commit_inode(vol->mftmirr_ino);
1748 ntfs_commit_inode(vol->mft_ino);
1755 if (!NVolErrors(vol)) {
1756 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY))
1759 ntfs_commit_inode(vol->vol_ino);
1760 ntfs_commit_inode(vol->root_ino);
1761 if (vol->mftmirr_ino)
1762 ntfs_commit_inode(vol->mftmirr_ino);
1763 ntfs_commit_inode(vol->mft_ino);
1770 iput(vol->vol_ino);
1771 vol->vol_ino = NULL;
1774 if (vol->major_ver >= 3) {
1775 if (vol->extend_ino) {
1776 iput(vol->extend_ino);
1777 vol->extend_ino = NULL;
1779 if (vol->secure_ino) {
1780 iput(vol->secure_ino);
1781 vol->secure_ino = NULL;
1785 iput(vol->root_ino);
1786 vol->root_ino = NULL;
1788 iput(vol->lcnbmp_ino);
1789 vol->lcnbmp_ino = NULL;
1791 iput(vol->mftbmp_ino);
1792 vol->mftbmp_ino = NULL;
1794 if (vol->logfile_ino) {
1795 iput(vol->logfile_ino);
1796 vol->logfile_ino = NULL;
1798 if (vol->mftmirr_ino) {
1800 ntfs_commit_inode(vol->mftmirr_ino);
1801 ntfs_commit_inode(vol->mft_ino);
1802 iput(vol->mftmirr_ino);
1803 vol->mftmirr_ino = NULL;
1810 ntfs_commit_inode(vol->mft_ino);
1811 write_inode_now(vol->mft_ino, 1);
1813 iput(vol->mft_ino);
1814 vol->mft_ino = NULL;
1817 ntfs_volume_free(vol);
1822 struct ntfs_volume *vol = NTFS_SB(sb);
1825 if (NVolShutdown(vol))
1835 NVolSetShutdown(vol);
1838 NVolSetShutdown(vol);
1855 struct ntfs_volume *vol = NTFS_SB(sb);
1858 if (NVolShutdown(vol))
1865 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) {
1877 * @vol: ntfs volume for which to obtain free cluster count
1879 * Calculate the number of free clusters on the mounted NTFS volume @vol. We
1894 s64 get_nr_free_clusters(struct ntfs_volume *vol)
1896 s64 nr_free = vol->nr_clusters;
1898 struct address_space *mapping = vol->lcnbmp_ino->i_mapping;
1906 if (NVolFreeClusterKnown(vol))
1907 return atomic64_read(&vol->free_clusters);
1916 max_index = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >>
1934 vol->lcn_empty_bits_per_page[index] = 0;
1948 vol->lcn_empty_bits_per_page[index] = PAGE_SIZE * BITS_PER_BYTE - nr_used;
1958 if (vol->nr_clusters & 63)
1959 nr_free += 64 - (vol->nr_clusters & 63);
1965 atomic64_set(&vol->free_clusters, nr_free);
1967 NVolSetFreeClusterKnown(vol);
1968 wake_up_all(&vol->free_waitq);
1980 s64 ntfs_available_clusters_count(struct ntfs_volume *vol, s64 nr_clusters)
1985 if (!NVolFreeClusterKnown(vol))
1986 wait_event(vol->free_waitq, NVolFreeClusterKnown(vol));
1988 free_clusters = atomic64_read(&vol->free_clusters) -
1989 atomic64_read(&vol->dirty_clusters);
2000 * @vol: ntfs volume for which to obtain free inode count
2005 * volume @vol. We actually calculate the number of mft records in use instead
2015 static unsigned long __get_nr_free_mft_records(struct ntfs_volume *vol,
2018 struct address_space *mapping = vol->mftbmp_ino->i_mapping;
2067 atomic64_set(&vol->free_mft_records, nr_free);
2095 struct ntfs_volume *vol = NTFS_SB(sb);
2096 struct ntfs_inode *mft_ni = NTFS_I(vol->mft_ino);
2103 sfs->f_bsize = vol->cluster_size;
2105 sfs->f_frsize = vol->cluster_size;
2112 sfs->f_blocks = vol->nr_clusters;
2115 if (!NVolFreeClusterKnown(vol))
2116 wait_event(vol->free_waitq, NVolFreeClusterKnown(vol));
2119 size = atomic64_read(&vol->free_clusters) -
2120 atomic64_read(&vol->dirty_clusters);
2129 sfs->f_files = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits;
2133 sfs->f_ffree = atomic64_read(&vol->free_mft_records);
2145 sfs->f_fsid = u64_to_fsid(vol->serial_no);
2175 struct ntfs_volume *vol = container_of(work, struct ntfs_volume, precalc_work);
2178 nr_free = get_nr_free_clusters(vol);
2207 struct ntfs_volume *vol = NTFS_SB(sb);
2210 vol->sb = sb;
2225 if (vol->nls_map && !strcmp(vol->nls_map->charset, "utf8"))
2226 vol->nls_utf8 = true;
2227 if (NVolDisableSparse(vol))
2228 vol->preallocated_size = 0;
2230 if (NVolDiscard(vol) && !bdev_max_discard_sectors(sb->s_bdev)) {
2234 NVolClearDiscard(vol);
2266 vol->nr_blocks = bdev_nr_bytes(sb->s_bdev) >>
2279 result = parse_ntfs_boot_sector(vol, (struct ntfs_boot_sector *)boot);
2287 if (vol->sector_size > blocksize) {
2288 blocksize = sb_set_blocksize(sb, vol->sector_size);
2289 if (blocksize != vol->sector_size) {
2293 vol->sector_size);
2296 vol->nr_blocks = bdev_nr_bytes(sb->s_bdev) >>
2302 ntfs_setup_allocators(vol);
2355 lcn_bit_pages = (((vol->nr_clusters + 7) >> 3) + PAGE_SIZE - 1) >> PAGE_SHIFT;
2356 vol->lcn_empty_bits_per_page = kvmalloc_array(lcn_bit_pages, sizeof(unsigned int),
2358 if (!vol->lcn_empty_bits_per_page) {
2372 if (!load_system_files(vol)) {
2378 ihold(vol->root_ino);
2379 sb->s_root = d_make_root(vol->root_ino);
2395 nr_records = __get_nr_free_mft_records(vol,
2396 i_size_read(vol->mft_ino) >> vol->mft_record_size_bits,
2397 ((((NTFS_I(vol->mft_ino)->initialized_size >>
2398 vol->mft_record_size_bits) +
2402 init_waitqueue_head(&vol->free_waitq);
2403 INIT_WORK(&vol->precalc_work, precalc_free_clusters);
2404 queue_work(ntfs_wq, &vol->precalc_work);
2409 iput(vol->vol_ino);
2410 vol->vol_ino = NULL;
2412 if (vol->major_ver >= 3) {
2413 if (vol->extend_ino) {
2414 iput(vol->extend_ino);
2415 vol->extend_ino = NULL;
2417 if (vol->secure_ino) {
2418 iput(vol->secure_ino);
2419 vol->secure_ino = NULL;
2422 iput(vol->root_ino);
2423 vol->root_ino = NULL;
2424 iput(vol->lcnbmp_ino);
2425 vol->lcnbmp_ino = NULL;
2426 iput(vol->mftbmp_ino);
2427 vol->mftbmp_ino = NULL;
2428 if (vol->logfile_ino) {
2429 iput(vol->logfile_ino);
2430 vol->logfile_ino = NULL;
2432 if (vol->mftmirr_ino) {
2433 iput(vol->mftmirr_ino);
2434 vol->mftmirr_ino = NULL;
2437 vol->attrdef_size = 0;
2438 if (vol->attrdef) {
2439 kvfree(vol->attrdef);
2440 vol->attrdef = NULL;
2442 vol->upcase_len = 0;
2444 if (vol->upcase && vol->upcase == default_upcase) {
2446 vol->upcase = NULL;
2449 if (vol->upcase) {
2450 kvfree(vol->upcase);
2451 vol->upcase = NULL;
2453 if (vol->nls_map) {
2454 unload_nls(vol->nls_map);
2455 vol->nls_map = NULL;
2472 if (vol->mft_ino && vol->mft_ino != tmp_ino)
2473 iput(vol->mft_ino);
2474 vol->mft_ino = NULL;
2478 kvfree(vol->lcn_empty_bits_per_page);
2479 kfree(vol->volume_label);
2480 unload_nls(vol->nls_map);
2481 kfree(vol);
2523 struct ntfs_volume *vol = fc->s_fs_info;
2525 if (vol)
2526 ntfs_volume_free(vol);
2538 struct ntfs_volume *vol;
2541 vol = kmalloc(sizeof(struct ntfs_volume), GFP_NOFS);
2542 if (!vol)
2546 *vol = (struct ntfs_volume) {
2557 NVolSetShowHiddenFiles(vol);
2558 NVolSetCaseSensitive(vol);
2559 init_rwsem(&vol->mftbmp_lock);
2560 init_rwsem(&vol->lcnbmp_lock);
2561 mutex_init(&vol->volume_label_lock);
2563 fc->s_fs_info = vol;