Lines Matching full:record
3 * NTFS kernel mft record operations.
21 * ntfs_mft_record_check - Check the consistency of an MFT record
35 ntfs_error(sb, "Record %llu has no FILE magic (0x%x)\n", in ntfs_mft_record_check()
43 ntfs_error(sb, "Record %llu has corrupt fix-up values fields\n", in ntfs_mft_record_check()
49 ntfs_error(sb, "Record %llu has corrupt allocation size (%u <> %u)\n", in ntfs_mft_record_check()
56 ntfs_error(sb, "Record %llu has corrupt in-use size (%u > %u)\n", in ntfs_mft_record_check()
63 ntfs_error(sb, "Attributes badly aligned in record %llu\n", in ntfs_mft_record_check()
70 ntfs_error(sb, "Record %llu is corrupt\n", mft_no); in ntfs_mft_record_check()
81 * map_mft_record_folio - map the folio in which a specific mft record resides
82 * @ni: ntfs inode whose mft record page to map
84 * This maps the folio in which the mft record of the ntfs inode @ni is
87 * This allocates a new buffer (@ni->mrec), copies the MFT record data from
94 * Return: A pointer to the allocated and fixed-up mft record (@ni->mrec).
110 * page of the wanted mft record. in map_mft_record_folio()
119 /* If the wanted index is out of bounds the mft record doesn't exist. */ in map_mft_record_folio()
125 …"Attempt to read mft record 0x%llx, which is beyond the end of the mft. This is probably a bug in … in map_mft_record_folio()
168 * map_mft_record - map and pin an mft record
169 * @ni: ntfs inode whose MFT record to map
171 * This function ensures the MFT record for the given inode is mapped and
174 * It increments the reference count of the ntfs inode. If the record is
175 * already mapped (@ni->folio is set), it returns the cached record
180 * record data.
182 * Return: A pointer to the mft record. You need to check the returned
210 * unmap_mft_record - release a reference to a mapped mft record
211 * @ni: ntfs inode whose MFT record to unmap
220 * NOTE: If caller has modified the mft record, it is imperative to set the mft
221 * record dirty BEFORE calling unmap_mft_record().
244 * Load the extent mft record @mref and attach it to its base inode @base_ni.
245 * Return the mapped extent mft record if IS_ERR(result) is false. Otherwise
262 ntfs_debug("Mapping extent mft record 0x%llx (base mft record 0x%llx).", in map_extent_mft_record()
287 /* We found the record; just have to map and return it. */ in map_extent_mft_record()
305 "Failed to map extent mft record, error code %ld.", in map_extent_mft_record()
311 /* Record wasn't there. Get a new ntfs inode and initialize it. */ in map_extent_mft_record()
321 /* Now map the record. */ in map_extent_mft_record()
387 * @ni: ntfs inode describing the mapped mft record
421 * ntfs_bio_end_io - bio completion callback for MFT record writes
436 * ntfs_sync_mft_mirror - synchronize an mft record to the mft mirror
437 * @vol: ntfs volume on which the mft record to synchronize resides
438 * @mft_no: mft record number of mft record to synchronize
439 * @m: mapped, mst protected (extent) mft record to synchronize
441 * Write the mapped, mst protected (extent) mft record @m with mft record
465 /* Get the page containing the mirror copy of the mft record @m. */ in ntfs_sync_mft_mirror()
476 /* Offset of the mft mirror record inside the page. */ in ntfs_sync_mft_mirror()
478 /* The address in the page of the mirror copy of the mft record @m. */ in ntfs_sync_mft_mirror()
480 /* Copy the mst protected mft record to the mirror. */ in ntfs_sync_mft_mirror()
511 ntfs_error(vol->sb, "I/O error while writing mft mirror record 0x%llx!", mft_no); in ntfs_sync_mft_mirror()
522 * write_mft_record_nolock - write out a mapped (extent) mft record
523 * @ni: ntfs inode describing the mapped (extent) mft record
524 * @m: mapped (extent) mft record to write
527 * Write the mapped (extent) mft record @m described by the (regular or extent)
528 * ntfs inode @ni to backing store. If the mft record @m has a counterpart in
531 * We only write the mft record if the ntfs inode @ni is dirty.
533 * On success, clean the mft record and return 0.
534 * On error (specifically ENOMEM), we redirty the record so it can be retried.
556 * for the mft record @m and the page it is in. in write_mft_record_nolock()
609 …"I/O error while writing mft record 0x%llx! Marking base inode as bad. You should unmount the vo… in write_mft_record_nolock()
627 "Not enough memory to write mft record. Redirtying so the write is retried later."); in write_mft_record_nolock()
669 * ntfs_may_write_mft_record - check if an mft record may be written out
670 * @vol: [IN] ntfs volume on which the mft record to check resides
671 * @mft_no: [IN] mft record number of the mft record to check
672 * @m: [IN] mapped mft record to check
676 * Check if the mapped (base or extent) mft record @m with mft record number
678 * and possible the ntfs inode of the mft record is locked and the base vfs
688 * Return 'true' if the mft record may be written out and 'false' if not.
696 * If the inode is found in icache we know the mft record must be a base mft
697 * record. If it is dirty, we do not write it and return 'false' as the vfs
699 * cause the base mft record to be redirtied and written out again.
701 * If the inode is in icache and not dirty, we attempt to lock the mft record
703 * record and we return 'false'.
705 * If we manage to obtain the lock we have exclusive access to the mft record,
706 * which also allows us safe writeout of the mft record. We then set
709 * Note we cannot just lock the mft record and sleep while waiting for the lock
714 * If the mft record is not a FILE record or it is a base mft record, we can
717 * We now know the mft record is an extent mft record. We check if the inode
718 * corresponding to its base mft record is in icache. If it is not, we cannot
721 * We now have the base inode for the extent mft record. We check if it has an
722 * ntfs inode for the extent mft record attached. If not, it is safe to write
723 * the extent mft record and we return 'true'.
728 * If it is not dirty, we attempt to lock the extent mft record. If the lock
732 * record. We set @locked_ni to the now locked ntfs inode and return 'true'.
753 * Check if the inode corresponding to this mft record is in the VFS in ntfs_may_write_mft_record()
783 /* If the inode is dirty, do not write this record. */ in ntfs_may_write_mft_record()
792 /* The inode is not dirty, try to take the mft record lock. */ in ntfs_may_write_mft_record()
794 ntfs_debug("Mft record 0x%llx is already locked, do not write it.", mft_no); in ntfs_may_write_mft_record()
799 ntfs_debug("Managed to lock mft record 0x%llx, write it.", in ntfs_may_write_mft_record()
802 * The write has to occur while we hold the mft record lock so in ntfs_may_write_mft_record()
810 /* Write the record if it is not a mft record (type "FILE"). */ in ntfs_may_write_mft_record()
812 ntfs_debug("Mft record 0x%llx is not a FILE record, write it.", in ntfs_may_write_mft_record()
816 /* Write the mft record if it is a base inode. */ in ntfs_may_write_mft_record()
818 ntfs_debug("Mft record 0x%llx is a base record, write it.", in ntfs_may_write_mft_record()
823 * This is an extent mft record. Check if the inode corresponding to in ntfs_may_write_mft_record()
824 * its base mft record is in icache and obtain a reference to it if it in ntfs_may_write_mft_record()
829 ntfs_debug("Mft record 0x%llx is an extent record. Looking for base inode 0x%llx in icache.", in ntfs_may_write_mft_record()
846 * corresponding to this extent mft record attached. in ntfs_may_write_mft_record()
853 * extent mft record. in ntfs_may_write_mft_record()
857 ntfs_debug("Base inode 0x%llx has no attached extent inodes, write the extent record.", in ntfs_may_write_mft_record()
867 * mft record. in ntfs_may_write_mft_record()
875 * extent mft record. in ntfs_may_write_mft_record()
880 …ntfs_debug("Extent inode 0x%llx is not attached to its base inode 0x%llx, write the extent record.… in ntfs_may_write_mft_record()
898 * Found the extent inode coresponding to this extent mft record. in ntfs_may_write_mft_record()
899 * Try to take the mft record lock. in ntfs_may_write_mft_record()
904 ntfs_debug("Extent mft record 0x%llx is already locked, do not write it.", in ntfs_may_write_mft_record()
908 ntfs_debug("Managed to lock extent mft record 0x%llx, write it.", in ntfs_may_write_mft_record()
911 * The write has to occur while we hold the mft record lock so return in ntfs_may_write_mft_record()
924 * @vol: volume on which to search for a free mft record
925 * @base_ni: open base inode if allocating an extent mft record or NULL
927 * Search for a free mft record in the mft bitmap attribute on the ntfs volume
932 * If @base_ni is not NULL start the search at the mft record after the base
933 * mft record @base_ni.
935 * Return the free mft record on success and -errno on error. An error code of
952 ntfs_debug("Searching for free mft record in the currently initialized mft bitmap."); in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
990 /* Loop until a free mft record is found. */ in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1021 * mft record (base record) then give up searching since in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1022 * no guarantee that the found record will be accessible. in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1048 ntfs_debug("Done. (Found and allocated mft record 0x%llx.)", in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1245 * Update the attribute record as well. Note: @rl is the last in ntfs_mft_bitmap_extend_allocation_nolock()
1250 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_bitmap_extend_allocation_nolock()
1289 /* Expand the attribute record if necessary. */ in ntfs_mft_bitmap_extend_allocation_nolock()
1302 /* Generate the mapping pairs array directly into the attr record. */ in ntfs_mft_bitmap_extend_allocation_nolock()
1315 * Reflect this in the struct ntfs_inode structure and the attribute record. in ntfs_mft_bitmap_extend_allocation_nolock()
1401 ntfs_error(vol->sb, "Failed to restore attribute record.%s", es); in ntfs_mft_bitmap_extend_allocation_nolock()
1446 /* Get the attribute record. */ in ntfs_mft_bitmap_extend_initialized_nolock()
1449 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_bitmap_extend_initialized_nolock()
1500 ntfs_error(vol->sb, "Failed to map mft record.%s", es); in ntfs_mft_bitmap_extend_initialized_nolock()
1550 * worth of clusters or if not enough space for this by one mft record worth
1605 /* Minimum allocation is one mft record worth of clusters. */ in ntfs_mft_data_extend_allocation_nolock()
1623 …"Cannot allocate mft record because the maximum number of inodes (2^32) has already been reached."… in ntfs_mft_data_extend_allocation_nolock()
1681 /* Update the attribute record as well. */ in ntfs_mft_data_extend_allocation_nolock()
1684 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_data_extend_allocation_nolock()
1727 /* Expand the attribute record if necessary. */ in ntfs_mft_data_extend_allocation_nolock()
1740 /* Generate the mapping pairs array directly into the attr record. */ in ntfs_mft_data_extend_allocation_nolock()
1752 * Reflect this in the struct ntfs_inode structure and the attribute record. in ntfs_mft_data_extend_allocation_nolock()
1834 ntfs_error(vol->sb, "Failed to restore attribute record.%s", es); in ntfs_mft_data_extend_allocation_nolock()
1850 * ntfs_mft_record_layout - layout an mft record into a memory buffer
1851 * @vol: volume to which the mft record will belong
1852 * @mft_no: mft reference specifying the mft record number
1855 * Layout an empty, unused mft record with the mft record number @mft_no into
1856 * the buffer @m. The volume @vol is needed because the mft record structure
1858 * record will be used on.
1867 ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no); in ntfs_mft_record_layout()
1869 ntfs_error(vol->sb, "Mft record number 0x%llx exceeds maximum of 2^32.", in ntfs_mft_record_layout()
1873 /* Start by clearing the whole mft record to gives us a clean slate. */ in ntfs_mft_record_layout()
1894 …"Sector size is bigger than mft record size. Setting usa_count to 1. If chkdsk reports this as c… in ntfs_mft_record_layout()
1926 * ntfs_mft_record_format - format an mft record on an ntfs volume
1927 * @vol: volume on which to format the mft record
1928 * @mft_no: mft record number to format
1930 * Format the mft record @mft_no in $MFT/$DATA, i.e. lay out an empty, unused
1931 * mft record into the appropriate place of the mft data attribute. This is
1946 ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no); in ntfs_mft_record_format()
1949 * page of the wanted mft record. in ntfs_mft_record_format()
1959 ntfs_error(vol->sb, "Tried to format non-existing mft record 0x%llx.", in ntfs_mft_record_format()
1965 /* Read, map, and pin the folio containing the mft record. */ in ntfs_mft_record_format()
1968 ntfs_error(vol->sb, "Failed to map page containing mft record to format 0x%llx.", in ntfs_mft_record_format()
1977 ntfs_error(vol->sb, "Failed to layout mft record 0x%llx.", in ntfs_mft_record_format()
1988 * Make sure the mft record is written out to disk. We could use in ntfs_mft_record_format()
1990 * unnecessary as ntfs_writepage() will write the dirty record anyway. in ntfs_mft_record_format()
2001 * ntfs_mft_record_alloc - allocate an mft record on an ntfs volume
2002 * @vol: [IN] volume on which to allocate the mft record
2005 * @base_ni: [IN] open base inode if allocating an extent mft record or NULL
2006 * @ni_mrec: [OUT] on successful return this is the mapped mft record
2008 * Allocate an mft record in $MFT/$DATA of an open ntfs volume @vol.
2010 * If @base_ni is NULL make the mft record a base mft record, i.e. a file or
2016 * If @base_ni is not NULL make the allocated mft record an extent record,
2017 * allocate it starting at the mft record after the base mft record and attach
2023 * allocated mft record. *@mrec is then set to the allocated, mapped, pinned,
2024 * and locked mft record. If IS_ERR() is true, the function failed and the
2030 * To find a free mft record, we scan the mft bitmap for a zero bit. To
2045 * record. If there are no free records left in the range 64 to number of
2049 * is not sufficient space to do this, we try to extend by a single mft record
2050 * or one cluster, if cluster size is above the mft record size.
2053 * allocated mft record, incrementing mft data size and initialized size
2056 * mft records until we reach record 64 which we consider as the first free mft
2057 * record for use by normal files.
2068 * - set the bit corresponding to the mft record being allocated in the
2070 * - opened an struct ntfs_inode for the allocated mft record, and we will have
2072 * locked mft record.
2074 * On error, the volume will be left in a consistent state and no record will
2081 * the base mft record and an attribute list is used, it is very important that
2117 ntfs_debug("Entering (allocating an extent mft record for base mft record 0x%llx).", in ntfs_mft_record_alloc()
2120 ntfs_debug("Entering (allocating a base mft record)."); in ntfs_mft_record_alloc()
2133 ntfs_debug("Found and allocated free record (#1), bit 0x%llx.", in ntfs_mft_record_alloc()
2154 * so we can simply allocate the first unused mft record. in ntfs_mft_record_alloc()
2172 ntfs_debug("Found free record (#2), bit 0x%llx.", in ntfs_mft_record_alloc()
2178 * mft record that we can allocate. in ntfs_mft_record_alloc()
2179 * Note: The smallest mft record we allocate is mft record 24. in ntfs_mft_record_alloc()
2230 ntfs_debug("Found free record (#3), bit 0x%llx.", (long long)bit); in ntfs_mft_record_alloc()
2232 /* @bit is the found free mft record, allocate it in the mft bitmap. */ in ntfs_mft_record_alloc()
2247 * will impact decisions for mft bitmap and mft record allocation done in ntfs_mft_record_alloc()
2249 * parallel allocation could allocate the same mft record as this one. in ntfs_mft_record_alloc()
2256 ntfs_debug("Allocated mft record already initialized."); in ntfs_mft_record_alloc()
2259 ntfs_debug("Initializing allocated mft record."); in ntfs_mft_record_alloc()
2261 * The mft record is outside the initialized data. Extend the mft data in ntfs_mft_record_alloc()
2262 * attribute until it covers the allocated record. The loop is only in ntfs_mft_record_alloc()
2293 * the allocated mft record, formatting the mft records allong the way. in ntfs_mft_record_alloc()
2296 * record itself in one fell swoop later on. in ntfs_mft_record_alloc()
2310 ntfs_debug("Initializing mft record 0x%llx.", in ntfs_mft_record_alloc()
2314 ntfs_error(vol->sb, "Failed to format mft record."); in ntfs_mft_record_alloc()
2322 /* Update the mft data attribute record to reflect the new sizes. */ in ntfs_mft_record_alloc()
2325 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_record_alloc()
2356 …ntfs_debug("Status of mft data after mft record initialization: allocated_size 0x%llx, data_size 0… in ntfs_mft_record_alloc()
2366 * allocated mft record still needs to be marked as in use to match the in ntfs_mft_record_alloc()
2368 * this mft record is not referenced from anywhere yet and the fact in ntfs_mft_record_alloc()
2375 * We now have allocated and initialized the mft record. Calculate the in ntfs_mft_record_alloc()
2376 * index of and the offset within the page cache page the record is in. in ntfs_mft_record_alloc()
2380 /* Read, map, and pin the folio containing the mft record. */ in ntfs_mft_record_alloc()
2383 ntfs_error(vol->sb, "Failed to map page containing allocated mft record 0x%llx.", in ntfs_mft_record_alloc()
2391 /* If we just formatted the mft record no need to do it again. */ in ntfs_mft_record_alloc()
2393 /* Sanity check that the mft record is really not in use. */ in ntfs_mft_record_alloc()
2397 …"Mft record 0x%llx was marked free in mft bitmap but is marked used itself. Unmount and run chkdsk… in ntfs_mft_record_alloc()
2407 * We need to (re-)format the mft record, preserving the in ntfs_mft_record_alloc()
2411 * wrong with the previous mft record. in ntfs_mft_record_alloc()
2417 ntfs_error(vol->sb, "Failed to layout allocated mft record 0x%llx.", in ntfs_mft_record_alloc()
2431 /* Set the mft record itself in use. */ in ntfs_mft_record_alloc()
2440 * Setup the base mft record in the extent mft record. This in ntfs_mft_record_alloc()
2441 * completes initialization of the allocated extent mft record in ntfs_mft_record_alloc()
2447 * Allocate an extent inode structure for the new mft record, in ntfs_mft_record_alloc()
2449 * its, i.e. the allocated, mft record. in ntfs_mft_record_alloc()
2455 ntfs_error(vol->sb, "Failed to map allocated extent mft record 0x%llx.", in ntfs_mft_record_alloc()
2458 /* Set the mft record itself not in use. */ in ntfs_mft_record_alloc()
2461 /* Make sure the mft record is written out to disk. */ in ntfs_mft_record_alloc()
2470 * Make sure the allocated mft record is written out to disk. in ntfs_mft_record_alloc()
2473 * record (e.g. at a minimum a new attribute will be added to in ntfs_mft_record_alloc()
2474 * the mft record. in ntfs_mft_record_alloc()
2486 * Manually map, pin, and lock the mft record as we already in ntfs_mft_record_alloc()
2491 * Make sure the allocated mft record is written out to disk. in ntfs_mft_record_alloc()
2496 * that anyway after finishing with the new mft record (e.g. at in ntfs_mft_record_alloc()
2498 * record. in ntfs_mft_record_alloc()
2525 * Return the opened, allocated inode of the allocated mft record as in ntfs_mft_record_alloc()
2526 * well as the mapped, pinned, and locked mft record. in ntfs_mft_record_alloc()
2558 …"Cannot allocate mft record because the maximum number of inodes (2^32) has already been reached."… in ntfs_mft_record_alloc()
2568 * ntfs_mft_record_free - free an mft record on an ntfs volume
2569 * @vol: volume on which to free the mft record
2570 * @ni: open ntfs inode of the mft record to free
2572 * Free the mft record of the open inode @ni on the mounted ntfs volume @vol.
2600 /* Mark the mft record as not in use. */ in ntfs_mft_record_free()
2623 * record to be freed is guaranteed to do it already. in ntfs_mft_record_free()
2635 /* Clear the bit in the $MFT/$BITMAP corresponding to this record. */ in ntfs_mft_record_free()
2749 /* Get the mft record number. */ in ntfs_write_mft_block()
2753 /* Check whether to write this mft record. */ in ntfs_write_mft_block()
2775 * The record should be written. If a locked ntfs in ntfs_write_mft_block()