Lines Matching full:record

3  * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project.
27 * map_mft_record_page - map the page in which a specific mft record resides
28 * @ni: ntfs inode whose mft record page to map
30 * This maps the page in which the mft record of the ntfs inode @ni is situated
31 * and returns a pointer to the mft record within the mapped page.
48 * page of the wanted mft record. FIXME: We need to check for in map_mft_record_page()
60 /* If the wanted index is out of bounds the mft record doesn't exist. */ in map_mft_record_page()
65 ntfs_error(vol->sb, "Attempt to read mft record 0x%lx, " in map_mft_record_page()
82 ntfs_error(vol->sb, "Mft record 0x%lx is corrupt. " in map_mft_record_page()
95 * map_mft_record - map, pin and lock an mft record
96 * @ni: ntfs inode whose MFT record to map
101 * The page of the record is mapped using map_mft_record_page() before being
105 * record (it in turn calls read_cache_page() which reads it in from disk if
111 * and the post-read mst fixups on each mft record in the page have been
133 * The mft record is now ours and we return a pointer to it. You need to check
137 * NOTE: Caller is responsible for setting the mft record dirty before calling
139 * modified the mft record...
141 * A: No, the inode ones mean we want to change the mft record, not we want to
153 /* Serialize access to this mft record. */ in map_mft_record()
167 * unmap_mft_record_page - unmap the page in which a specific mft record resides
168 * @ni: ntfs inode whose mft record page to unmap
170 * This unmaps the page in which the mft record of the ntfs inode @ni is
192 * unmap_mft_record - release a mapped mft record
193 * @ni: ntfs inode whose MFT record to unmap
196 * record and releases it for others to get hold of. We also release the ntfs
199 * NOTE: If caller has modified the mft record, it is imperative to set the mft
200 * record dirty BEFORE calling unmap_mft_record().
228 * Load the extent mft record @mref and attach it to its base inode @base_ni.
229 * Return the mapped extent mft record if IS_ERR(result) is false. Otherwise
246 ntfs_debug("Mapping extent mft record 0x%lx (base mft record 0x%lx).", in map_extent_mft_record()
270 /* We found the record; just have to map and return it. */ in map_extent_mft_record()
289 "mft record, error code %ld.", -PTR_ERR(m)); in map_extent_mft_record()
292 /* Record wasn't there. Get a new ntfs inode and initialize it. */ in map_extent_mft_record()
303 /* Now map the record. */ in map_extent_mft_record()
362 * __mark_mft_record_dirty - set the mft record and the page containing it dirty
363 * @ni: ntfs inode describing the mapped mft record
367 * Set the mapped (extent) mft record of the (base or extent) ntfs inode @ni,
368 * as well as the page containing the mft record, dirty. Also, mark the base
369 * vfs inode dirty. This ensures that any changes to the mft record are
406 * ntfs_sync_mft_mirror_umount - synchronise an mft record to the mft mirror
407 * @vol: ntfs volume on which the mft record to synchronize resides
408 * @mft_no: mft record number of mft record to synchronize
409 * @m: mapped, mst protected (extent) mft record to synchronize
411 * Write the mapped, mst protected (extent) mft record @m with mft record
437 * ntfs_sync_mft_mirror - synchronize an mft record to the mft mirror
438 * @vol: ntfs volume on which the mft record to synchronize resides
439 * @mft_no: mft record number of mft record to synchronize
440 * @m: mapped, mst protected (extent) mft record to synchronize
443 * Write the mapped, mst protected (extent) mft record @m with mft record
479 /* Get the page containing the mirror copy of the mft record @m. */ in ntfs_sync_mft_mirror()
490 /* Offset of the mft mirror record inside the page. */ in ntfs_sync_mft_mirror()
492 /* The address in the page of the mirror copy of the mft record @m. */ in ntfs_sync_mft_mirror()
494 /* Copy the mst protected mft record to the mirror. */ in ntfs_sync_mft_mirror()
518 /* If the buffer is outside the mft record, skip it. */ in ntfs_sync_mft_mirror()
559 "record 0x%lx because its " in ntfs_sync_mft_mirror()
618 "record 0x%lx!", mft_no); in ntfs_sync_mft_mirror()
630 * write_mft_record_nolock - write out a mapped (extent) mft record
631 * @ni: ntfs inode describing the mapped (extent) mft record
632 * @m: mapped (extent) mft record to write
635 * Write the mapped (extent) mft record @m described by the (regular or extent)
636 * ntfs inode @ni to backing store. If the mft record @m has a counterpart in
639 * We only write the mft record if the ntfs inode @ni is dirty and the first
640 * buffer belonging to its mft record is dirty, too. We ignore the dirty state
644 * On success, clean the mft record and return 0. On error, leave the mft
645 * record dirty and return -errno.
648 * However, if the mft record has a counterpart in the mft mirror and @sync is
649 * true, we write the mft record, wait for i/o completion, and only then write
651 * or the mft mirror will contain a self-consistent mft record @m. If @sync is
654 * up with a self-consistent mft record in the case of a crash but if you asked
685 * for the mft record @m and the page it is in. in write_mft_record_nolock()
698 /* If the buffer is outside the mft record, skip it. */ in write_mft_record_nolock()
704 * If this block is not the first one in the record, we ignore in write_mft_record_nolock()
709 /* This block is the first one in the record. */ in write_mft_record_nolock()
746 ntfs_error(vol->sb, "Cannot write mft record " in write_mft_record_nolock()
811 ntfs_error(vol->sb, "I/O error while writing mft record " in write_mft_record_nolock()
832 ntfs_error(vol->sb, "Not enough memory to write mft record. " in write_mft_record_nolock()
842 * ntfs_may_write_mft_record - check if an mft record may be written out
843 * @vol: [IN] ntfs volume on which the mft record to check resides
844 * @mft_no: [IN] mft record number of the mft record to check
845 * @m: [IN] mapped mft record to check
848 * Check if the mapped (base or extent) mft record @m with mft record number
850 * and possible the ntfs inode of the mft record is locked and the base vfs
855 * Return 'true' if the mft record may be written out and 'false' if not.
861 * record in read_cache_page() until we are finished with the write out.
865 * If the inode is found in icache we know the mft record must be a base mft
866 * record. If it is dirty, we do not write it and return 'false' as the vfs
868 * cause the base mft record to be redirtied and written out again. (We know
869 * the access time update will modify the base mft record because Windows
871 * mft record.)
873 * If the inode is in icache and not dirty, we attempt to lock the mft record
875 * record and we return 'false'.
877 * If we manage to obtain the lock we have exclusive access to the mft record,
878 * which also allows us safe writeout of the mft record. We then set
881 * Note we cannot just lock the mft record and sleep while waiting for the lock
882 * because this would deadlock due to lock reversal (normally the mft record is
884 * when we try to lock the mft record).
888 * If the mft record is not a FILE record or it is a base mft record, we can
891 * We now know the mft record is an extent mft record. We check if the inode
892 * corresponding to its base mft record is in icache and obtain a reference to
895 * We now have the base inode for the extent mft record. We check if it has an
896 * ntfs inode for the extent mft record attached and if not it is safe to write
897 * the extent mft record and we return 'true'.
899 * The ntfs inode for the extent mft record is attached to the base inode so we
900 * attempt to lock the extent mft record and if we find the lock was already
901 * taken, it is not safe to write the extent mft record and we return 'false'.
904 * record, which also allows us safe writeout of the extent mft record. We
905 * set the ntfs inode of the extent mft record clean and then set @locked_ni to
917 * appear if the mft record is reused for a new inode before it got written
937 * Check if the inode corresponding to this mft record is in the VFS in ntfs_may_write_mft_record()
969 /* If the inode is dirty, do not write this record. */ in ntfs_may_write_mft_record()
978 /* The inode is not dirty, try to take the mft record lock. */ in ntfs_may_write_mft_record()
980 ntfs_debug("Mft record 0x%lx is already locked, do " in ntfs_may_write_mft_record()
986 ntfs_debug("Managed to lock mft record 0x%lx, write it.", in ntfs_may_write_mft_record()
989 * The write has to occur while we hold the mft record lock so in ntfs_may_write_mft_record()
997 /* Write the record if it is not a mft record (type "FILE"). */ in ntfs_may_write_mft_record()
999 ntfs_debug("Mft record 0x%lx is not a FILE record, write it.", in ntfs_may_write_mft_record()
1003 /* Write the mft record if it is a base inode. */ in ntfs_may_write_mft_record()
1005 ntfs_debug("Mft record 0x%lx is a base record, write it.", in ntfs_may_write_mft_record()
1010 * This is an extent mft record. Check if the inode corresponding to in ntfs_may_write_mft_record()
1011 * its base mft record is in icache and obtain a reference to it if it in ntfs_may_write_mft_record()
1015 ntfs_debug("Mft record 0x%lx is an extent record. Looking for base " in ntfs_may_write_mft_record()
1027 * record. in ntfs_may_write_mft_record()
1030 "extent record.", na.mft_no); in ntfs_may_write_mft_record()
1036 * corresponding to this extent mft record attached. in ntfs_may_write_mft_record()
1043 * extent mft record. in ntfs_may_write_mft_record()
1048 "write the extent record.", na.mft_no); in ntfs_may_write_mft_record()
1057 * mft record. in ntfs_may_write_mft_record()
1065 * extent mft record. in ntfs_may_write_mft_record()
1071 "inode 0x%lx, write the extent record.", in ntfs_may_write_mft_record()
1081 * Found the extent inode coresponding to this extent mft record. in ntfs_may_write_mft_record()
1082 * Try to take the mft record lock. in ntfs_may_write_mft_record()
1087 ntfs_debug("Extent mft record 0x%lx is already locked, do " in ntfs_may_write_mft_record()
1091 ntfs_debug("Managed to lock extent mft record 0x%lx, write it.", in ntfs_may_write_mft_record()
1097 * The write has to occur while we hold the mft record lock so return in ntfs_may_write_mft_record()
1109 * @vol: volume on which to search for a free mft record
1110 * @base_ni: open base inode if allocating an extent mft record or NULL
1112 * Search for a free mft record in the mft bitmap attribute on the ntfs volume
1117 * If @base_ni is not NULL start the search at the mft record after the base
1118 * mft record @base_ni.
1120 * Return the free mft record on success and -errno on error. An error code of
1137 ntfs_debug("Searching for free mft record in the currently " in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1172 /* Loop until a free mft record is found. */ in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1217 "allocated mft record " in ntfs_mft_bitmap_find_and_alloc_free_rec_nolock()
1380 * Update the attribute record as well. Note: @rl is the last in ntfs_mft_bitmap_extend_allocation_nolock()
1385 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_bitmap_extend_allocation_nolock()
1424 /* Expand the attribute record if necessary. */ in ntfs_mft_bitmap_extend_allocation_nolock()
1431 "record for mft bitmap attribute."); in ntfs_mft_bitmap_extend_allocation_nolock()
1435 // record or by starting a new extent in a new mft record or by in ntfs_mft_bitmap_extend_allocation_nolock()
1436 // moving other attributes out of this mft record. in ntfs_mft_bitmap_extend_allocation_nolock()
1437 // Note: It will need to be a special mft record and if none of in ntfs_mft_bitmap_extend_allocation_nolock()
1439 ntfs_error(vol->sb, "Not enough space in this mft record to " in ntfs_mft_bitmap_extend_allocation_nolock()
1446 /* Generate the mapping pairs array directly into the attr record. */ in ntfs_mft_bitmap_extend_allocation_nolock()
1459 * Reflect this in the ntfs_inode structure and the attribute record. in ntfs_mft_bitmap_extend_allocation_nolock()
1544 "record.%s", es); in ntfs_mft_bitmap_extend_allocation_nolock()
1587 /* Get the attribute record. */ in ntfs_mft_bitmap_extend_initialized_nolock()
1590 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_bitmap_extend_initialized_nolock()
1642 ntfs_error(vol->sb, "Failed to map mft record.%s", es); in ntfs_mft_bitmap_extend_initialized_nolock()
1695 * worth of clusters or if not enough space for this by one mft record worth
1749 /* Minimum allocation is one mft record worth of clusters. */ in ntfs_mft_data_extend_allocation_nolock()
1766 ntfs_warning(vol->sb, "Cannot allocate mft record " in ntfs_mft_data_extend_allocation_nolock()
1815 /* Update the attribute record as well. */ in ntfs_mft_data_extend_allocation_nolock()
1818 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_data_extend_allocation_nolock()
1856 /* Expand the attribute record if necessary. */ in ntfs_mft_data_extend_allocation_nolock()
1863 "record for mft data attribute."); in ntfs_mft_data_extend_allocation_nolock()
1867 // record or by starting a new extent in a new mft record or by in ntfs_mft_data_extend_allocation_nolock()
1868 // moving other attributes out of this mft record. in ntfs_mft_data_extend_allocation_nolock()
1870 // this extent is not required to find the mft record in in ntfs_mft_data_extend_allocation_nolock()
1872 // move an existing record away, insert ours in its place, and in ntfs_mft_data_extend_allocation_nolock()
1873 // then place the moved record into the newly allocated space in ntfs_mft_data_extend_allocation_nolock()
1875 // record appropriately. This is rather complicated... in ntfs_mft_data_extend_allocation_nolock()
1876 ntfs_error(vol->sb, "Not enough space in this mft record to " in ntfs_mft_data_extend_allocation_nolock()
1883 /* Generate the mapping pairs array directly into the attr record. */ in ntfs_mft_data_extend_allocation_nolock()
1896 * Reflect this in the ntfs_inode structure and the attribute record. in ntfs_mft_data_extend_allocation_nolock()
1976 "record.%s", es); in ntfs_mft_data_extend_allocation_nolock()
1995 * ntfs_mft_record_layout - layout an mft record into a memory buffer
1996 * @vol: volume to which the mft record will belong
1997 * @mft_no: mft reference specifying the mft record number
2000 * Layout an empty, unused mft record with the mft record number @mft_no into
2001 * the buffer @m. The volume @vol is needed because the mft record structure
2003 * record will be used on.
2012 ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no); in ntfs_mft_record_layout()
2014 ntfs_error(vol->sb, "Mft record number 0x%llx exceeds " in ntfs_mft_record_layout()
2018 /* Start by clearing the whole mft record to gives us a clean slate. */ in ntfs_mft_record_layout()
2038 ntfs_warning(vol->sb, "Sector size is bigger than mft record " in ntfs_mft_record_layout()
2076 * ntfs_mft_record_format - format an mft record on an ntfs volume
2077 * @vol: volume on which to format the mft record
2078 * @mft_no: mft record number to format
2080 * Format the mft record @mft_no in $MFT/$DATA, i.e. lay out an empty, unused
2081 * mft record into the appropriate place of the mft data attribute. This is
2096 ntfs_debug("Entering for mft record 0x%llx.", (long long)mft_no); in ntfs_mft_record_format()
2099 * page of the wanted mft record. in ntfs_mft_record_format()
2110 "record 0x%llx.", (long long)mft_no); in ntfs_mft_record_format()
2114 /* Read, map, and pin the page containing the mft record. */ in ntfs_mft_record_format()
2117 ntfs_error(vol->sb, "Failed to map page containing mft record " in ntfs_mft_record_format()
2127 ntfs_error(vol->sb, "Failed to layout mft record 0x%llx.", in ntfs_mft_record_format()
2138 * Make sure the mft record is written out to disk. We could use in ntfs_mft_record_format()
2140 * unnecessary as ntfs_writepage() will write the dirty record anyway. in ntfs_mft_record_format()
2149 * ntfs_mft_record_alloc - allocate an mft record on an ntfs volume
2150 * @vol: [IN] volume on which to allocate the mft record
2152 * @base_ni: [IN] open base inode if allocating an extent mft record or NULL
2153 * @mrec: [OUT] on successful return this is the mapped mft record
2155 * Allocate an mft record in $MFT/$DATA of an open ntfs volume @vol.
2157 * If @base_ni is NULL make the mft record a base mft record, i.e. a file or
2163 * If @base_ni is not NULL make the allocated mft record an extent record,
2164 * allocate it starting at the mft record after the base mft record and attach
2170 * allocated mft record. *@mrec is then set to the allocated, mapped, pinned,
2171 * and locked mft record. If IS_ERR() is true, the function failed and the
2177 * To find a free mft record, we scan the mft bitmap for a zero bit. To
2192 * record. If there are no free records left in the range 24 to number of
2196 * is not sufficient space to do this, we try to extend by a single mft record
2197 * or one cluster, if cluster size is above the mft record size.
2200 * allocated mft record, incrementing mft data size and initialized size
2203 * mft records until we reach record 24 which we consider as the first free mft
2204 * record for use by normal files.
2215 * - set the bit corresponding to the mft record being allocated in the
2217 * - opened an ntfs_inode for the allocated mft record, and we will have
2219 * locked mft record.
2221 * On error, the volume will be left in a consistent state and no record will
2228 * the base mft record and an attribute list is used, it is very important that
2256 ntfs_debug("Entering (allocating an extent mft record for " in ntfs_mft_record_alloc()
2257 "base mft record 0x%llx).", in ntfs_mft_record_alloc()
2262 ntfs_debug("Entering (allocating a base mft record)."); in ntfs_mft_record_alloc()
2276 ntfs_debug("Found and allocated free record (#1), bit 0x%llx.", in ntfs_mft_record_alloc()
2287 * so we can simply allocate the first unused mft record. in ntfs_mft_record_alloc()
2304 ntfs_debug("Found free record (#2), bit 0x%llx.", in ntfs_mft_record_alloc()
2310 * mft record that we can allocate. in ntfs_mft_record_alloc()
2311 * Note: The smallest mft record we allocate is mft record 24. in ntfs_mft_record_alloc()
2363 ntfs_debug("Found free record (#3), bit 0x%llx.", (long long)bit); in ntfs_mft_record_alloc()
2365 /* @bit is the found free mft record, allocate it in the mft bitmap. */ in ntfs_mft_record_alloc()
2379 * will impact decisions for mft bitmap and mft record allocation done in ntfs_mft_record_alloc()
2381 * parallel allocation could allocate the same mft record as this one. in ntfs_mft_record_alloc()
2388 ntfs_debug("Allocated mft record already initialized."); in ntfs_mft_record_alloc()
2391 ntfs_debug("Initializing allocated mft record."); in ntfs_mft_record_alloc()
2393 * The mft record is outside the initialized data. Extend the mft data in ntfs_mft_record_alloc()
2394 * attribute until it covers the allocated record. The loop is only in ntfs_mft_record_alloc()
2424 * the allocated mft record, formatting the mft records allong the way. in ntfs_mft_record_alloc()
2427 * record itself in one fell swoop later on. in ntfs_mft_record_alloc()
2441 ntfs_debug("Initializing mft record 0x%llx.", in ntfs_mft_record_alloc()
2445 ntfs_error(vol->sb, "Failed to format mft record."); in ntfs_mft_record_alloc()
2453 /* Update the mft data attribute record to reflect the new sizes. */ in ntfs_mft_record_alloc()
2456 ntfs_error(vol->sb, "Failed to map mft record."); in ntfs_mft_record_alloc()
2489 ntfs_debug("Status of mft data after mft record initialization: " in ntfs_mft_record_alloc()
2502 * allocated mft record still needs to be marked as in use to match the in ntfs_mft_record_alloc()
2504 * this mft record is not referenced from anywhere yet and the fact in ntfs_mft_record_alloc()
2510 * We now have allocated and initialized the mft record. Calculate the in ntfs_mft_record_alloc()
2511 * index of and the offset within the page cache page the record is in. in ntfs_mft_record_alloc()
2515 /* Read, map, and pin the page containing the mft record. */ in ntfs_mft_record_alloc()
2519 "mft record 0x%llx.", (long long)bit); in ntfs_mft_record_alloc()
2527 /* If we just formatted the mft record no need to do it again. */ in ntfs_mft_record_alloc()
2529 /* Sanity check that the mft record is really not in use. */ in ntfs_mft_record_alloc()
2532 ntfs_error(vol->sb, "Mft record 0x%llx was marked " in ntfs_mft_record_alloc()
2545 * We need to (re-)format the mft record, preserving the in ntfs_mft_record_alloc()
2549 * wrong with the previous mft record. in ntfs_mft_record_alloc()
2556 "record 0x%llx.", (long long)bit); in ntfs_mft_record_alloc()
2567 /* Set the mft record itself in use. */ in ntfs_mft_record_alloc()
2577 * Setup the base mft record in the extent mft record. This in ntfs_mft_record_alloc()
2578 * completes initialization of the allocated extent mft record in ntfs_mft_record_alloc()
2584 * Allocate an extent inode structure for the new mft record, in ntfs_mft_record_alloc()
2586 * its, i.e. the allocated, mft record. in ntfs_mft_record_alloc()
2591 "mft record 0x%llx.", (long long)bit); in ntfs_mft_record_alloc()
2593 /* Set the mft record itself not in use. */ in ntfs_mft_record_alloc()
2597 /* Make sure the mft record is written out to disk. */ in ntfs_mft_record_alloc()
2605 * Make sure the allocated mft record is written out to disk. in ntfs_mft_record_alloc()
2608 * record (e.g. at a minimum a new attribute will be added to in ntfs_mft_record_alloc()
2609 * the mft record. in ntfs_mft_record_alloc()
2621 * is set to 1 but the mft record->link_count is 0. The caller in ntfs_mft_record_alloc()
2627 /* Set the mft record itself not in use. */ in ntfs_mft_record_alloc()
2631 /* Make sure the mft record is written out to disk. */ in ntfs_mft_record_alloc()
2695 * Manually map, pin, and lock the mft record as we already in ntfs_mft_record_alloc()
2703 * Make sure the allocated mft record is written out to disk. in ntfs_mft_record_alloc()
2708 * that anyway after finishing with the new mft record (e.g. at in ntfs_mft_record_alloc()
2710 * record. in ntfs_mft_record_alloc()
2722 * Return the opened, allocated inode of the allocated mft record as in ntfs_mft_record_alloc()
2723 * well as the mapped, pinned, and locked mft record. in ntfs_mft_record_alloc()
2746 ntfs_warning(vol->sb, "Cannot allocate mft record because the maximum " in ntfs_mft_record_alloc()
2753 * ntfs_extent_mft_record_free - free an extent mft record on an ntfs volume
2754 * @ni: ntfs inode of the mapped extent mft record to free
2755 * @m: mapped extent mft record of the ntfs inode @ni
2757 * Free the mapped extent mft record @m of the extent ntfs inode @ni.
2759 * Note that this function unmaps the mft record and closes and destroys @ni
2769 * caller no longer wants to reference this mft record so it does not matter to
2833 /* Mark the mft record as not in use. */ in ntfs_extent_mft_record_free()
2848 * record to be freed is guaranteed to do it already. in ntfs_extent_mft_record_free()
2853 ntfs_error(vol->sb, "Failed to write mft record 0x%lx, not " in ntfs_extent_mft_record_free()
2862 /* Clear the bit in the $MFT/$BITMAP corresponding to this record. */ in ntfs_extent_mft_record_free()