Document directory
- Why?
- How can I enable lastaccesstime update?
- References
In win7, I noticed that the "Access time" and "modification time" in the file attributes are inconsistent, for example:
This file was created at, and I fixed it at and saved it. According to common sense,Access timeAndModification timeYes. This is a strange phenomenon because it is earlier than the modification time.
According to the getfiletime API, there are three file-related times:
BOOL WINAPI GetFileTime( __in HANDLE hFile, __out_opt LPFILETIME lpCreationTime, __out_opt LPFILETIME lpLastAccessTime, __out_opt LPFILETIME lpLastWriteTime);
Creationtime: Creation time. This is the time when the file was created.
Lastaccesstime:The last access time, which indicates the last time the file was read, written, copied, or executed.
Lastwritetime: The last time when the file was written.
From this definition, lastaccesstime should be greater than or equal to lastwritetime. However, from the usage perspective, this is not the case.
Why?
After reading the old New thing today,Originally, lastaccesstime was disabled for performance from 2003 SP1..
I am using Windows 7, which is disabled by default.
Why does it affect performance?
Lastaccesstime is saved in two places:
- File Attribute, as a record in MFT
- The Directory Index to which the file belongs.
The main reason for the impact on performance is that if a file is only read, a write operation is required to update the time and write the information to the file attributes and directory indexes, in this way, a read operation becomes a read + write operation. Since the hard disks are very large today, it is common to have hundreds of thousands of files. if you add a write operation to the read operation, this does affect the performance. (For details, refer to the description of disablelastaccess in fsutil: behavior. The address is attached ).
The following documents are supported by various file systems for file time:
Feature |
NTFS |
Exfat |
UDF |
FAT32 |
Creation Time Stamps (Creation Time) |
Yes |
Yes |
Yes |
Yes |
Last access time stamps (last access time) |
No * |
Yes |
Yes |
Yes (update date only) |
Last change time stamps (last change time) |
Yes |
Yes |
Yes |
Yes |
Last archive time stamps (last archive time) |
No |
No |
No |
No |
Note:
1. NTFS supports lastaccesstime update. It is enabled by default in Windows 2000, XP, and 2003, and must be enabled separately after Vista.
How can I enable lastaccesstime update?
Run the following command to check whether lastaccesstime is disabled:
fsutil behavior query disablelastaccess
1 indicates disabled, 0 indicates Enabled
Disable lastaccesstime updates:
fsutil behavior set disablelastaccess 1
Note: restart required.
Open the update of lastaccesstime:
fsutil behavior set disablelastaccess 0
Note: restart required.
In fact, all the above modifications are the modified registry.
Key: [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ FileSystem]
Value Name: Ntfsdisablelastaccessupdate
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = Disable, 1 = Enable)
References
File_basic_info Structure
The http://msdn.microsoft.com/zh-cn/library/aa364217 (vs.85). aspx
Setfiletime Function
The http://msdn.microsoft.com/en-us/library/ms724933 (vs.85). aspx
Getfiletime Function
Http://msdn.microsoft.com/en-us/library/ms724320 (V = vs.85). aspx
File System functionality comparison
The http://msdn.microsoft.com/en-us/library/ee681827 (vs.85). aspx
What's the difference between lastwritetime and changetime in file_basic_info?
Http://blogs.msdn.com/ B /oldnewthing/archive/2010/07/09/10036162.aspx
Disabling last access time in Windows Vista to improve NTFS Performance
Http://blogs.technet.com/ B /filecab/archive/2006/11/07/disabling-last-access-time-in-windows-vista-to-improve-ntfs-performance.aspx
Enable last access time stamp to files in Windows 7 [how-to]
Http://www.groovypost.com/howto/microsoft/enable-last-access-time-stamp-to-files-folder-windows-7/
Kb894372: support for Windows Server 2003 SP1 on Windows Storage Server 2003-based server appliances
Http://support.microsoft.com /? SCID = KB; en-US; 894372 & X = 9 & Y = 15
Ntfsdisablelastaccessupdate
Http://technet.microsoft.com/en-us/library/cc758569 (ws.10). aspx
Fsutil: Behavior
Http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fsutil_behavior.mspx? MFR = true