aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/mft.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ntfs/mft.c')
-rw-r--r--fs/ntfs/mft.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 584260fd6848..2ad5c8b104b9 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -251,7 +251,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
251 int i; 251 int i;
252 unsigned long mft_no = MREF(mref); 252 unsigned long mft_no = MREF(mref);
253 u16 seq_no = MSEQNO(mref); 253 u16 seq_no = MSEQNO(mref);
254 BOOL destroy_ni = FALSE; 254 bool destroy_ni = false;
255 255
256 ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).", 256 ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).",
257 mft_no, base_ni->mft_no); 257 mft_no, base_ni->mft_no);
@@ -322,7 +322,7 @@ map_err_out:
322 if (seq_no && (le16_to_cpu(m->sequence_number) != seq_no)) { 322 if (seq_no && (le16_to_cpu(m->sequence_number) != seq_no)) {
323 ntfs_error(base_ni->vol->sb, "Found stale extent mft " 323 ntfs_error(base_ni->vol->sb, "Found stale extent mft "
324 "reference! Corrupt filesystem. Run chkdsk."); 324 "reference! Corrupt filesystem. Run chkdsk.");
325 destroy_ni = TRUE; 325 destroy_ni = true;
326 m = ERR_PTR(-EIO); 326 m = ERR_PTR(-EIO);
327 goto unm_err_out; 327 goto unm_err_out;
328 } 328 }
@@ -335,7 +335,7 @@ map_err_out:
335 if (unlikely(!tmp)) { 335 if (unlikely(!tmp)) {
336 ntfs_error(base_ni->vol->sb, "Failed to allocate " 336 ntfs_error(base_ni->vol->sb, "Failed to allocate "
337 "internal buffer."); 337 "internal buffer.");
338 destroy_ni = TRUE; 338 destroy_ni = true;
339 m = ERR_PTR(-ENOMEM); 339 m = ERR_PTR(-ENOMEM);
340 goto unm_err_out; 340 goto unm_err_out;
341 } 341 }
@@ -857,7 +857,7 @@ err_out:
857 * caller is responsible for unlocking the ntfs inode and unpinning the base 857 * caller is responsible for unlocking the ntfs inode and unpinning the base
858 * vfs inode. 858 * vfs inode.
859 * 859 *
860 * Return TRUE if the mft record may be written out and FALSE if not. 860 * Return 'true' if the mft record may be written out and 'false' if not.
861 * 861 *
862 * The caller has locked the page and cleared the uptodate flag on it which 862 * The caller has locked the page and cleared the uptodate flag on it which
863 * means that we can safely write out any dirty mft records that do not have 863 * means that we can safely write out any dirty mft records that do not have
@@ -868,7 +868,7 @@ err_out:
868 * Here is a description of the tests we perform: 868 * Here is a description of the tests we perform:
869 * 869 *
870 * If the inode is found in icache we know the mft record must be a base mft 870 * If the inode is found in icache we know the mft record must be a base mft
871 * record. If it is dirty, we do not write it and return FALSE as the vfs 871 * record. If it is dirty, we do not write it and return 'false' as the vfs
872 * inode write paths will result in the access times being updated which would 872 * inode write paths will result in the access times being updated which would
873 * cause the base mft record to be redirtied and written out again. (We know 873 * cause the base mft record to be redirtied and written out again. (We know
874 * the access time update will modify the base mft record because Windows 874 * the access time update will modify the base mft record because Windows
@@ -877,11 +877,11 @@ err_out:
877 * 877 *
878 * If the inode is in icache and not dirty, we attempt to lock the mft record 878 * If the inode is in icache and not dirty, we attempt to lock the mft record
879 * and if we find the lock was already taken, it is not safe to write the mft 879 * and if we find the lock was already taken, it is not safe to write the mft
880 * record and we return FALSE. 880 * record and we return 'false'.
881 * 881 *
882 * If we manage to obtain the lock we have exclusive access to the mft record, 882 * If we manage to obtain the lock we have exclusive access to the mft record,
883 * which also allows us safe writeout of the mft record. We then set 883 * which also allows us safe writeout of the mft record. We then set
884 * @locked_ni to the locked ntfs inode and return TRUE. 884 * @locked_ni to the locked ntfs inode and return 'true'.
885 * 885 *
886 * Note we cannot just lock the mft record and sleep while waiting for the lock 886 * Note we cannot just lock the mft record and sleep while waiting for the lock
887 * because this would deadlock due to lock reversal (normally the mft record is 887 * because this would deadlock due to lock reversal (normally the mft record is
@@ -891,24 +891,24 @@ err_out:
891 * If the inode is not in icache we need to perform further checks. 891 * If the inode is not in icache we need to perform further checks.
892 * 892 *
893 * If the mft record is not a FILE record or it is a base mft record, we can 893 * If the mft record is not a FILE record or it is a base mft record, we can
894 * safely write it and return TRUE. 894 * safely write it and return 'true'.
895 * 895 *
896 * We now know the mft record is an extent mft record. We check if the inode 896 * We now know the mft record is an extent mft record. We check if the inode
897 * corresponding to its base mft record is in icache and obtain a reference to 897 * corresponding to its base mft record is in icache and obtain a reference to
898 * it if it is. If it is not, we can safely write it and return TRUE. 898 * it if it is. If it is not, we can safely write it and return 'true'.
899 * 899 *
900 * We now have the base inode for the extent mft record. We check if it has an 900 * We now have the base inode for the extent mft record. We check if it has an
901 * ntfs inode for the extent mft record attached and if not it is safe to write 901 * ntfs inode for the extent mft record attached and if not it is safe to write
902 * the extent mft record and we return TRUE. 902 * the extent mft record and we return 'true'.
903 * 903 *
904 * The ntfs inode for the extent mft record is attached to the base inode so we 904 * The ntfs inode for the extent mft record is attached to the base inode so we
905 * attempt to lock the extent mft record and if we find the lock was already 905 * attempt to lock the extent mft record and if we find the lock was already
906 * taken, it is not safe to write the extent mft record and we return FALSE. 906 * taken, it is not safe to write the extent mft record and we return 'false'.
907 * 907 *
908 * If we manage to obtain the lock we have exclusive access to the extent mft 908 * If we manage to obtain the lock we have exclusive access to the extent mft
909 * record, which also allows us safe writeout of the extent mft record. We 909 * record, which also allows us safe writeout of the extent mft record. We
910 * set the ntfs inode of the extent mft record clean and then set @locked_ni to 910 * set the ntfs inode of the extent mft record clean and then set @locked_ni to
911 * the now locked ntfs inode and return TRUE. 911 * the now locked ntfs inode and return 'true'.
912 * 912 *
913 * Note, the reason for actually writing dirty mft records here and not just 913 * Note, the reason for actually writing dirty mft records here and not just
914 * relying on the vfs inode dirty code paths is that we can have mft records 914 * relying on the vfs inode dirty code paths is that we can have mft records
@@ -922,7 +922,7 @@ err_out:
922 * appear if the mft record is reused for a new inode before it got written 922 * appear if the mft record is reused for a new inode before it got written
923 * out. 923 * out.
924 */ 924 */
925BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, 925bool ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
926 const MFT_RECORD *m, ntfs_inode **locked_ni) 926 const MFT_RECORD *m, ntfs_inode **locked_ni)
927{ 927{
928 struct super_block *sb = vol->sb; 928 struct super_block *sb = vol->sb;
@@ -977,7 +977,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
977 mft_no); 977 mft_no);
978 atomic_dec(&ni->count); 978 atomic_dec(&ni->count);
979 iput(vi); 979 iput(vi);
980 return FALSE; 980 return false;
981 } 981 }
982 ntfs_debug("Inode 0x%lx is not dirty.", mft_no); 982 ntfs_debug("Inode 0x%lx is not dirty.", mft_no);
983 /* The inode is not dirty, try to take the mft record lock. */ 983 /* The inode is not dirty, try to take the mft record lock. */
@@ -986,7 +986,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
986 "not write it.", mft_no); 986 "not write it.", mft_no);
987 atomic_dec(&ni->count); 987 atomic_dec(&ni->count);
988 iput(vi); 988 iput(vi);
989 return FALSE; 989 return false;
990 } 990 }
991 ntfs_debug("Managed to lock mft record 0x%lx, write it.", 991 ntfs_debug("Managed to lock mft record 0x%lx, write it.",
992 mft_no); 992 mft_no);
@@ -995,7 +995,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
995 * return the locked ntfs inode. 995 * return the locked ntfs inode.
996 */ 996 */
997 *locked_ni = ni; 997 *locked_ni = ni;
998 return TRUE; 998 return true;
999 } 999 }
1000 ntfs_debug("Inode 0x%lx is not in icache.", mft_no); 1000 ntfs_debug("Inode 0x%lx is not in icache.", mft_no);
1001 /* The inode is not in icache. */ 1001 /* The inode is not in icache. */
@@ -1003,13 +1003,13 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1003 if (!ntfs_is_mft_record(m->magic)) { 1003 if (!ntfs_is_mft_record(m->magic)) {
1004 ntfs_debug("Mft record 0x%lx is not a FILE record, write it.", 1004 ntfs_debug("Mft record 0x%lx is not a FILE record, write it.",
1005 mft_no); 1005 mft_no);
1006 return TRUE; 1006 return true;
1007 } 1007 }
1008 /* Write the mft record if it is a base inode. */ 1008 /* Write the mft record if it is a base inode. */
1009 if (!m->base_mft_record) { 1009 if (!m->base_mft_record) {
1010 ntfs_debug("Mft record 0x%lx is a base record, write it.", 1010 ntfs_debug("Mft record 0x%lx is a base record, write it.",
1011 mft_no); 1011 mft_no);
1012 return TRUE; 1012 return true;
1013 } 1013 }
1014 /* 1014 /*
1015 * This is an extent mft record. Check if the inode corresponding to 1015 * This is an extent mft record. Check if the inode corresponding to
@@ -1033,7 +1033,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1033 */ 1033 */
1034 ntfs_debug("Base inode 0x%lx is not in icache, write the " 1034 ntfs_debug("Base inode 0x%lx is not in icache, write the "
1035 "extent record.", na.mft_no); 1035 "extent record.", na.mft_no);
1036 return TRUE; 1036 return true;
1037 } 1037 }
1038 ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no); 1038 ntfs_debug("Base inode 0x%lx is in icache.", na.mft_no);
1039 /* 1039 /*
@@ -1051,7 +1051,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1051 iput(vi); 1051 iput(vi);
1052 ntfs_debug("Base inode 0x%lx has no attached extent inodes, " 1052 ntfs_debug("Base inode 0x%lx has no attached extent inodes, "
1053 "write the extent record.", na.mft_no); 1053 "write the extent record.", na.mft_no);
1054 return TRUE; 1054 return true;
1055 } 1055 }
1056 /* Iterate over the attached extent inodes. */ 1056 /* Iterate over the attached extent inodes. */
1057 extent_nis = ni->ext.extent_ntfs_inos; 1057 extent_nis = ni->ext.extent_ntfs_inos;
@@ -1075,7 +1075,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1075 ntfs_debug("Extent inode 0x%lx is not attached to its base " 1075 ntfs_debug("Extent inode 0x%lx is not attached to its base "
1076 "inode 0x%lx, write the extent record.", 1076 "inode 0x%lx, write the extent record.",
1077 mft_no, na.mft_no); 1077 mft_no, na.mft_no);
1078 return TRUE; 1078 return true;
1079 } 1079 }
1080 ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.", 1080 ntfs_debug("Extent inode 0x%lx is attached to its base inode 0x%lx.",
1081 mft_no, na.mft_no); 1081 mft_no, na.mft_no);
@@ -1091,7 +1091,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1091 iput(vi); 1091 iput(vi);
1092 ntfs_debug("Extent mft record 0x%lx is already locked, do " 1092 ntfs_debug("Extent mft record 0x%lx is already locked, do "
1093 "not write it.", mft_no); 1093 "not write it.", mft_no);
1094 return FALSE; 1094 return false;
1095 } 1095 }
1096 ntfs_debug("Managed to lock extent mft record 0x%lx, write it.", 1096 ntfs_debug("Managed to lock extent mft record 0x%lx, write it.",
1097 mft_no); 1097 mft_no);
@@ -1103,7 +1103,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
1103 * the locked extent ntfs inode. 1103 * the locked extent ntfs inode.
1104 */ 1104 */
1105 *locked_ni = eni; 1105 *locked_ni = eni;
1106 return TRUE; 1106 return true;
1107} 1107}
1108 1108
1109static const char *es = " Leaving inconsistent metadata. Unmount and run " 1109static const char *es = " Leaving inconsistent metadata. Unmount and run "
@@ -1354,7 +1354,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
1354 ntfs_unmap_page(page); 1354 ntfs_unmap_page(page);
1355 /* Allocate a cluster from the DATA_ZONE. */ 1355 /* Allocate a cluster from the DATA_ZONE. */
1356 rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE, 1356 rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE,
1357 TRUE); 1357 true);
1358 if (IS_ERR(rl2)) { 1358 if (IS_ERR(rl2)) {
1359 up_write(&mftbmp_ni->runlist.lock); 1359 up_write(&mftbmp_ni->runlist.lock);
1360 ntfs_error(vol->sb, "Failed to allocate a cluster for " 1360 ntfs_error(vol->sb, "Failed to allocate a cluster for "
@@ -1724,7 +1724,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
1724 ATTR_RECORD *a = NULL; 1724 ATTR_RECORD *a = NULL;
1725 int ret, mp_size; 1725 int ret, mp_size;
1726 u32 old_alen = 0; 1726 u32 old_alen = 0;
1727 BOOL mp_rebuilt = FALSE; 1727 bool mp_rebuilt = false;
1728 1728
1729 ntfs_debug("Extending mft data allocation."); 1729 ntfs_debug("Extending mft data allocation.");
1730 mft_ni = NTFS_I(vol->mft_ino); 1730 mft_ni = NTFS_I(vol->mft_ino);
@@ -1780,7 +1780,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
1780 old_last_vcn = rl[1].vcn; 1780 old_last_vcn = rl[1].vcn;
1781 do { 1781 do {
1782 rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE, 1782 rl2 = ntfs_cluster_alloc(vol, old_last_vcn, nr, lcn, MFT_ZONE,
1783 TRUE); 1783 true);
1784 if (likely(!IS_ERR(rl2))) 1784 if (likely(!IS_ERR(rl2)))
1785 break; 1785 break;
1786 if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) { 1786 if (PTR_ERR(rl2) != -ENOSPC || nr == min_nr) {
@@ -1884,7 +1884,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
1884 ret = -EOPNOTSUPP; 1884 ret = -EOPNOTSUPP;
1885 goto undo_alloc; 1885 goto undo_alloc;
1886 } 1886 }
1887 mp_rebuilt = TRUE; 1887 mp_rebuilt = true;
1888 /* Generate the mapping pairs array directly into the attr record. */ 1888 /* Generate the mapping pairs array directly into the attr record. */
1889 ret = ntfs_mapping_pairs_build(vol, (u8*)a + 1889 ret = ntfs_mapping_pairs_build(vol, (u8*)a +
1890 le16_to_cpu(a->data.non_resident.mapping_pairs_offset), 1890 le16_to_cpu(a->data.non_resident.mapping_pairs_offset),
@@ -2255,7 +2255,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
2255 unsigned int ofs; 2255 unsigned int ofs;
2256 int err; 2256 int err;
2257 le16 seq_no, usn; 2257 le16 seq_no, usn;
2258 BOOL record_formatted = FALSE; 2258 bool record_formatted = false;
2259 2259
2260 if (base_ni) { 2260 if (base_ni) {
2261 ntfs_debug("Entering (allocating an extent mft record for " 2261 ntfs_debug("Entering (allocating an extent mft record for "
@@ -2454,7 +2454,7 @@ have_alloc_rec:
2454 mft_ni->initialized_size = new_initialized_size; 2454 mft_ni->initialized_size = new_initialized_size;
2455 } 2455 }
2456 write_unlock_irqrestore(&mft_ni->size_lock, flags); 2456 write_unlock_irqrestore(&mft_ni->size_lock, flags);
2457 record_formatted = TRUE; 2457 record_formatted = true;
2458 /* Update the mft data attribute record to reflect the new sizes. */ 2458 /* Update the mft data attribute record to reflect the new sizes. */
2459 m = map_mft_record(mft_ni); 2459 m = map_mft_record(mft_ni);
2460 if (IS_ERR(m)) { 2460 if (IS_ERR(m)) {