€•[NŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ-/translations/zh_CN/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/zh_TW/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/it_IT/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ja_JP/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ko_KR/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/sp_SP/filesystems/multigrain-ts”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒG/var/lib/git/docbuild/linux/Documentation/filesystems/multigrain-ts.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒMultigrain Timestamps”h]”hŒMultigrain Timestamps”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h Kubhµ)”}”(hhh]”(hº)”}”(hŒ Introduction”h]”hŒ Introduction”…””}”(hhÌhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hhÉhžhhŸh³h KubhŒ paragraph”“”)”}”(hŒÁHistorically, the kernel has always used coarse time values to stamp inodes. This value is updated every jiffy, so any change that happens within that jiffy will end up with the same timestamp.”h]”hŒÁHistorically, the kernel has always used coarse time values to stamp inodes. This value is updated every jiffy, so any change that happens within that jiffy will end up with the same timestamp.”…””}”(hhÜhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K hhÉhžhubhÛ)”}”(hŒûWhen the kernel goes to stamp an inode (due to a read or write), it first gets the current time and then compares it to the existing timestamp(s) to see whether anything will change. If nothing changed, then it can avoid updating the inode's metadata.”h]”hŒýWhen the kernel goes to stamp an inode (due to a read or write), it first gets the current time and then compares it to the existing timestamp(s) to see whether anything will change. If nothing changed, then it can avoid updating the inode’s metadata.”…””}”(hhêhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K hhÉhžhubhÛ)”}”(hŒêCoarse timestamps are therefore good from a performance standpoint, since they reduce the need for metadata updates, but bad from the standpoint of determining whether anything has changed, since a lot of things can happen in a jiffy.”h]”hŒêCoarse timestamps are therefore good from a performance standpoint, since they reduce the need for metadata updates, but bad from the standpoint of determining whether anything has changed, since a lot of things can happen in a jiffy.”…””}”(hhøhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KhhÉhžhubhÛ)”}”(hXJThey are particularly troublesome with NFSv3, where unchanging timestamps can make it difficult to tell whether to invalidate caches. NFSv4 provides a dedicated change attribute that should always show a visible change, but not all filesystems implement this properly, causing the NFS server to substitute the ctime in many cases.”h]”hXJThey are particularly troublesome with NFSv3, where unchanging timestamps can make it difficult to tell whether to invalidate caches. NFSv4 provides a dedicated change attribute that should always show a visible change, but not all filesystems implement this properly, causing the NFS server to substitute the ctime in many cases.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KhhÉhžhubhÛ)”}”(hŒÇMultigrain timestamps aim to remedy this by selectively using fine-grained timestamps when a file has had its timestamps queried recently, and the current coarse-grained time does not cause a change.”h]”hŒÇMultigrain timestamps aim to remedy this by selectively using fine-grained timestamps when a file has had its timestamps queried recently, and the current coarse-grained time does not cause a change.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KhhÉhžhubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1h´hh¶hžhhŸh³h Kubhµ)”}”(hhh]”(hº)”}”(hŒInode Timestamps”h]”hŒInode Timestamps”…””}”(hj-hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hj*hžhhŸh³h K"ubhÛ)”}”(hŒsThere are currently 3 timestamps in the inode that are updated to the current wallclock time on different activity:”h]”hŒsThere are currently 3 timestamps in the inode that are updated to the current wallclock time on different activity:”…””}”(hj;hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K#hj*hžhubhŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hŒ¢ctime: The inode change time. This is stamped with the current time whenever the inode's metadata is changed. Note that this value is not settable from userland. ”h]”(hŒterm”“”)”}”(hŒctime:”h]”hŒctime:”…””}”(hjVhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jThŸh³h K)hjPubhŒ definition”“”)”}”(hhh]”hÛ)”}”(hŒšThe inode change time. This is stamped with the current time whenever the inode's metadata is changed. Note that this value is not settable from userland.”h]”hŒœThe inode change time. This is stamped with the current time whenever the inode’s metadata is changed. Note that this value is not settable from userland.”…””}”(hjihžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K'hjfubah}”(h]”h ]”h"]”h$]”h&]”uh1jdhjPubeh}”(h]”h ]”h"]”h$]”h&]”uh1jNhŸh³h K)hjKubjO)”}”(hŒmmtime: The inode modification time. This is stamped with the current time any time a file's contents change. ”h]”(jU)”}”(hŒmtime:”h]”hŒmtime:”…””}”(hj‡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jThŸh³h K-hjƒubje)”}”(hhh]”hÛ)”}”(hŒeThe inode modification time. This is stamped with the current time any time a file's contents change.”h]”hŒgThe inode modification time. This is stamped with the current time any time a file’s contents change.”…””}”(hj˜hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K,hj•ubah}”(h]”h ]”h"]”h$]”h&]”uh1jdhjƒubeh}”(h]”h ]”h"]”h$]”h&]”uh1jNhŸh³h K-hjKhžhubjO)”}”(hŒ¸atime: The inode access time. This is stamped whenever an inode's contents are read. Widely considered to be a terrible mistake. Usually avoided with options like noatime or relatime. ”h]”(jU)”}”(hŒatime:”h]”hŒatime:”…””}”(hj¶hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jThŸh³h K2hj²ubje)”}”(hhh]”hÛ)”}”(hŒ°The inode access time. This is stamped whenever an inode's contents are read. Widely considered to be a terrible mistake. Usually avoided with options like noatime or relatime.”h]”hŒ²The inode access time. This is stamped whenever an inode’s contents are read. Widely considered to be a terrible mistake. Usually avoided with options like noatime or relatime.”…””}”(hjÇhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K0hjÄubah}”(h]”h ]”h"]”h$]”h&]”uh1jdhj²ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jNhŸh³h K2hjKhžhubeh}”(h]”h ]”h"]”h$]”h&]”uh1jIhj*hžhhŸh³h NubhÛ)”}”(hŒoUpdating the mtime always implies a change to the ctime, but updating the atime due to a read request does not.”h]”hŒoUpdating the mtime always implies a change to the ctime, but updating the atime due to a read request does not.”…””}”(hjçhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K4hj*hžhubhÛ)”}”(hŒ›Multigrain timestamps are only tracked for the ctime and the mtime. atimes are not affected and always use the coarse-grained value (subject to the floor).”h]”hŒ›Multigrain timestamps are only tracked for the ctime and the mtime. atimes are not affected and always use the coarse-grained value (subject to the floor).”…””}”(hjõhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K7hj*hžhubeh}”(h]”Œinode-timestamps”ah ]”h"]”Œinode timestamps”ah$]”h&]”uh1h´hh¶hžhhŸh³h K"ubhµ)”}”(hhh]”(hº)”}”(hŒInode Timestamp Ordering”h]”hŒInode Timestamp Ordering”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hj hžhhŸh³h K;ubhÛ)”}”(hXIn addition to just providing info about changes to individual files, file timestamps also serve an important purpose in applications like "make". These programs measure timestamps in order to determine whether source files might be newer than cached objects.”h]”hXIn addition to just providing info about changes to individual files, file timestamps also serve an important purpose in applications like “makeâ€. These programs measure timestamps in order to determine whether source files might be newer than cached objects.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K=hj hžhubhÛ)”}”(hXYUserland applications like make can only determine ordering based on operational boundaries. For a syscall those are the syscall entry and exit points. For io_uring or nfsd operations, that's the request submission and response. In the case of concurrent operations, userland can make no determination about the order in which things will occur.”h]”hX[Userland applications like make can only determine ordering based on operational boundaries. For a syscall those are the syscall entry and exit points. For io_uring or nfsd operations, that’s the request submission and response. In the case of concurrent operations, userland can make no determination about the order in which things will occur.”…””}”(hj*hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KBhj hžhubhÛ)”}”(hŒôFor instance, if a single thread modifies one file, and then another file in sequence, the second file must show an equal or later mtime than the first. The same is true if two threads are issuing similar operations that do not overlap in time.”h]”hŒôFor instance, if a single thread modifies one file, and then another file in sequence, the second file must show an equal or later mtime than the first. The same is true if two threads are issuing similar operations that do not overlap in time.”…””}”(hj8hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KHhj hžhubhÛ)”}”(hŒõIf however, two threads have racing syscalls that overlap in time, then there is no such guarantee, and the second file may appear to have been modified before, after or at the same time as the first, regardless of which one was submitted first.”h]”hŒõIf however, two threads have racing syscalls that overlap in time, then there is no such guarantee, and the second file may appear to have been modified before, after or at the same time as the first, regardless of which one was submitted first.”…””}”(hjFhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KMhj hžhubhÛ)”}”(hŒÞNote that the above assumes that the system doesn't experience a backward jump of the realtime clock. If that occurs at an inopportune time, then timestamps can appear to go backward, even on a properly functioning system.”h]”hŒàNote that the above assumes that the system doesn’t experience a backward jump of the realtime clock. If that occurs at an inopportune time, then timestamps can appear to go backward, even on a properly functioning system.”…””}”(hjThžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KRhj hžhubeh}”(h]”Œinode-timestamp-ordering”ah ]”h"]”Œinode timestamp ordering”ah$]”h&]”uh1h´hh¶hžhhŸh³h K;ubhµ)”}”(hhh]”(hº)”}”(hŒ#Multigrain Timestamp Implementation”h]”hŒ#Multigrain Timestamp Implementation”…””}”(hjmhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjjhžhhŸh³h KWubhÛ)”}”(hXMultigrain timestamps are aimed at ensuring that changes to a single file are always recognizable, without violating the ordering guarantees when multiple different files are modified. This affects the mtime and the ctime, but the atime will always use coarse-grained timestamps.”h]”hXMultigrain timestamps are aimed at ensuring that changes to a single file are always recognizable, without violating the ordering guarantees when multiple different files are modified. This affects the mtime and the ctime, but the atime will always use coarse-grained timestamps.”…””}”(hj{hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KXhjjhžhubhÛ)”}”(hXIt uses an unused bit in the i_ctime_nsec field to indicate whether the mtime or ctime has been queried. If either or both have, then the kernel takes special care to ensure the next timestamp update will display a visible change. This ensures tight cache coherency for use-cases like NFS, without sacrificing the benefits of reduced metadata updates when files aren't being watched.”h]”hXIt uses an unused bit in the i_ctime_nsec field to indicate whether the mtime or ctime has been queried. If either or both have, then the kernel takes special care to ensure the next timestamp update will display a visible change. This ensures tight cache coherency for use-cases like NFS, without sacrificing the benefits of reduced metadata updates when files aren’t being watched.”…””}”(hj‰hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K]hjjhžhubeh}”(h]”Œ#multigrain-timestamp-implementation”ah ]”h"]”Œ#multigrain timestamp implementation”ah$]”h&]”uh1h´hh¶hžhhŸh³h KWubhµ)”}”(hhh]”(hº)”}”(hŒThe Ctime Floor Value”h]”hŒThe Ctime Floor Value”…””}”(hj¢hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjŸhžhhŸh³h KdubhÛ)”}”(hXLIt's not sufficient to simply use fine or coarse-grained timestamps based on whether the mtime or ctime has been queried. A file could get a fine grained timestamp, and then a second file modified later could get a coarse-grained one that appears earlier than the first, which would break the kernel's timestamp ordering guarantees.”h]”hXPIt’s not sufficient to simply use fine or coarse-grained timestamps based on whether the mtime or ctime has been queried. A file could get a fine grained timestamp, and then a second file modified later could get a coarse-grained one that appears earlier than the first, which would break the kernel’s timestamp ordering guarantees.”…””}”(hj°hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KehjŸhžhubhÛ)”}”(hXˆTo mitigate this problem, maintain a global floor value that ensures that this can't happen. The two files in the above example may appear to have been modified at the same time in such a case, but they will never show the reverse order. To avoid problems with realtime clock jumps, the floor is managed as a monotonic ktime_t, and the values are converted to realtime clock values as needed.”h]”hXŠTo mitigate this problem, maintain a global floor value that ensures that this can’t happen. The two files in the above example may appear to have been modified at the same time in such a case, but they will never show the reverse order. To avoid problems with realtime clock jumps, the floor is managed as a monotonic ktime_t, and the values are converted to realtime clock values as needed.”…””}”(hj¾hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KkhjŸhžhubeh}”(h]”Œthe-ctime-floor-value”ah ]”h"]”Œthe ctime floor value”ah$]”h&]”uh1h´hh¶hžhhŸh³h Kdubhµ)”}”(hhh]”(hº)”}”(hŒImplementation Notes”h]”hŒImplementation Notes”…””}”(hj×hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjÔhžhhŸh³h KsubhÛ)”}”(hŒÔMultigrain timestamps are intended for use by local filesystems that get ctime values from the local clock. This is in contrast to network filesystems and the like that just mirror timestamp values from a server.”h]”hŒÔMultigrain timestamps are intended for use by local filesystems that get ctime values from the local clock. This is in contrast to network filesystems and the like that just mirror timestamp values from a server.”…””}”(hjåhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KthjÔhžhubhÛ)”}”(hX¢For most filesystems, it's sufficient to just set the FS_MGTIME flag in the fstype->fs_flags in order to opt-in, providing the ctime is only ever set via inode_set_ctime_current(). If the filesystem has a ->getattr routine that doesn't call generic_fillattr, then it should call fill_mg_cmtime() to fill those values. For setattr, it should use setattr_copy() to update the timestamps, or otherwise mimic its behavior.”h]”hX¦For most filesystems, it’s sufficient to just set the FS_MGTIME flag in the fstype->fs_flags in order to opt-in, providing the ctime is only ever set via inode_set_ctime_current(). If the filesystem has a ->getattr routine that doesn’t call generic_fillattr, then it should call fill_mg_cmtime() to fill those values. For setattr, it should use setattr_copy() to update the timestamps, or otherwise mimic its behavior.”…””}”(hjóhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KxhjÔhžhubeh}”(h]”Œimplementation-notes”ah ]”h"]”Œimplementation notes”ah$]”h&]”uh1h´hh¶hžhhŸh³h Ksubeh}”(h]”Œmultigrain-timestamps”ah ]”h"]”Œmultigrain timestamps”ah$]”h&]”uh1h´hhhžhhŸh³h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¹NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j4Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jj j'j$jjjgjdjœj™jÑjÎjjuŒ nametypes”}”(j‰j'‰j‰jg‰jœ‰jщj‰uh}”(j h¶j$hÉjj*jdj j™jjjÎjŸjjÔuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.