AFIO  v2.00 late alpha
afio_v2_xxx::handle::flag_base Struct Reference

Bitwise flags which can be specified. More...

#include "handle.hpp"

Public Types

enum  enum_type : unsigned {
  none = 0, unlink_on_close = 1 << 0, disable_safety_fsyncs = 1 << 2, disable_safety_unlinks = 1 << 3,
  disable_prefetching = 1 << 4, maximum_prefetching = 1 << 5, win_disable_unlink_emulation = 1 << 24, win_disable_sparse_file_creation = 1 << 25,
  overlapped = 1 << 28, byte_lock_insanity = 1 << 29, anonymous_inode = 1 << 30
}
 

Detailed Description

Bitwise flags which can be specified.

Member Enumeration Documentation

◆ enum_type

Enumerator
none 

No flags.

unlink_on_close 

Unlinks the file on handle close. On POSIX, this simply unlinks whatever is pointed to by path() upon the call of close() if and only if the inode matches. On Windows, this opens the file handle with the FILE_FLAG_DELETE_ON_CLOSE modifier which substantially affects caching policy and causes the first handle close to make the file unavailable for anyone else to open with an errc::resource_unavailable_try_again error return. Because this is confusing, unless the win_disable_unlink_emulation flag is also specified, this POSIX behaviour is somewhat emulated by AFIO on Windows by renaming the file to a random name on close() causing it to appear to have been unlinked immediately.

disable_safety_fsyncs 

Some kernel caching modes have unhelpfully inconsistent behaviours in getting your data onto storage, so by default unless this flag is specified AFIO adds extra fsyncs to the following operations for the caching modes specified below: truncation of file length either explicitly or during file open. closing of the handle either explicitly or in the destructor.

Additionally on Linux only to prevent loss of file metadata: On the parent directory whenever a file might have been created. On the parent directory on file close.

This only occurs for these kernel caching modes: caching::none caching::reads caching::reads_and_metadata caching::safety_fsyncs

disable_safety_unlinks 

file_handle::unlink() could accidentally delete the wrong file if someone has renamed the open file handle since the time it was opened. To prevent this occuring, where the OS doesn't provide race free unlink-by-open-handle we compare the inode of the path we are about to unlink with that of the open handle before unlinking.

Warning
This does not prevent races where in between the time of checking the inode and executing the unlink a third party changes the item about to be unlinked. Only operating systems with a true race-free unlink syscall are race free.
disable_prefetching 

Ask the OS to disable prefetching of data. This can improve random i/o performance.

maximum_prefetching 

Ask the OS to maximise prefetching of data, possibly prefetching the entire file into kernel cache. This can improve sequential i/o performance.

win_disable_unlink_emulation 

See the documentation for unlink_on_close

win_disable_sparse_file_creation 

Microsoft Windows NTFS, having been created in the late 1980s, did not originally implement extents-based storage and thus could only represent sparse files via efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000), a proper extents-based on-storage representation was added, thus allowing only 64Kb extent chunks written to be stored irrespective of whatever the maximum file extent was set to.

For various historical reasons, extents-based storage is disabled by default in newly created files on NTFS, unlike in almost every other major filing system. You have to explicitly "opt in" to extents-based storage.

As extents-based storage is nearly cost free on NTFS, AFIO by default opts in to extents-based storage for any empty file it creates. If you don't want this, you can specify this flag to prevent that happening.

overlapped 

On Windows, create any new handles with OVERLAPPED semantics.

byte_lock_insanity 

Using insane POSIX byte range locks.

anonymous_inode 

This is an inode created with no representation on the filing system.

97  {
98  none = 0, //!< No flags
99  /*! Unlinks the file on handle close. On POSIX, this simply unlinks whatever is pointed
100  to by `path()` upon the call of `close()` if and only if the inode matches. On Windows,
101  this opens the file handle with the `FILE_FLAG_DELETE_ON_CLOSE` modifier which substantially
102  affects caching policy and causes the \b first handle close to make the file unavailable for
103  anyone else to open with an `errc::resource_unavailable_try_again` error return. Because this is confusing, unless the
104  `win_disable_unlink_emulation` flag is also specified, this POSIX behaviour is
105  somewhat emulated by AFIO on Windows by renaming the file to a random name on `close()`
106  causing it to appear to have been unlinked immediately.
107  */
108  unlink_on_close = 1 << 0,
109 
110  /*! Some kernel caching modes have unhelpfully inconsistent behaviours
111  in getting your data onto storage, so by default unless this flag is
112  specified AFIO adds extra fsyncs to the following operations for the
113  caching modes specified below:
114  * truncation of file length either explicitly or during file open.
115  * closing of the handle either explicitly or in the destructor.
116 
117  Additionally on Linux only to prevent loss of file metadata:
118  * On the parent directory whenever a file might have been created.
119  * On the parent directory on file close.
120 
121  This only occurs for these kernel caching modes:
122  * caching::none
123  * caching::reads
124  * caching::reads_and_metadata
125  * caching::safety_fsyncs
126  */
127  disable_safety_fsyncs = 1 << 2,
128  /*! `file_handle::unlink()` could accidentally delete the wrong file if someone has
129  renamed the open file handle since the time it was opened. To prevent this occuring,
130  where the OS doesn't provide race free unlink-by-open-handle we compare the inode of
131  the path we are about to unlink with that of the open handle before unlinking.
132  \warning This does not prevent races where in between the time of checking the inode
133  and executing the unlink a third party changes the item about to be unlinked. Only
134  operating systems with a true race-free unlink syscall are race free.
135  */
136  disable_safety_unlinks = 1 << 3,
137  /*! Ask the OS to disable prefetching of data. This can improve random
138  i/o performance.
139  */
140  disable_prefetching = 1 << 4,
141  /*! Ask the OS to maximise prefetching of data, possibly prefetching the entire file
142  into kernel cache. This can improve sequential i/o performance.
143  */
144  maximum_prefetching = 1 << 5,
145 
146  win_disable_unlink_emulation = 1 << 24, //!< See the documentation for `unlink_on_close`
147  /*! Microsoft Windows NTFS, having been created in the late 1980s, did not originally
148  implement extents-based storage and thus could only represent sparse files via
149  efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000),
150  a proper extents-based on-storage representation was added, thus allowing only 64Kb
151  extent chunks written to be stored irrespective of whatever the maximum file extent
152  was set to.
153 
154  For various historical reasons, extents-based storage is disabled by default in newly
155  created files on NTFS, unlike in almost every other major filing system. You have to
156  explicitly "opt in" to extents-based storage.
157 
158  As extents-based storage is nearly cost free on NTFS, AFIO by default opts in to
159  extents-based storage for any empty file it creates. If you don't want this, you
160  can specify this flag to prevent that happening.
161  */
163 
164  // NOTE: IF UPDATING THIS UPDATE THE std::ostream PRINTER BELOW!!!
165 
166  overlapped = 1 << 28, //!< On Windows, create any new handles with OVERLAPPED semantics
167  byte_lock_insanity = 1 << 29, //!< Using insane POSIX byte range locks
168  anonymous_inode = 1 << 30 //!< This is an inode created with no representation on the filing system
169  }
See the documentation for unlink_on_close
Definition: handle.hpp:146
This is an inode created with no representation on the filing system.
Definition: handle.hpp:168
On Windows, create any new handles with OVERLAPPED semantics.
Definition: handle.hpp:166
Using insane POSIX byte range locks.
Definition: handle.hpp:167
No flags.
Definition: handle.hpp:98

The documentation for this struct was generated from the following file: