Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _LINUX_IVERSION_H |
| 3 | #define _LINUX_IVERSION_H |
| 4 | |
| 5 | #include <linux/fs.h> |
| 6 | |
| 7 | /* |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 8 | * The inode->i_version field: |
| 9 | * --------------------------- |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 10 | * The change attribute (i_version) is mandated by NFSv4 and is mostly for |
| 11 | * knfsd, but is also used for other purposes (e.g. IMA). The i_version must |
| 12 | * appear different to observers if there was a change to the inode's data or |
| 13 | * metadata since it was last queried. |
| 14 | * |
| 15 | * Observers see the i_version as a 64-bit number that never decreases. If it |
| 16 | * remains the same since it was last checked, then nothing has changed in the |
| 17 | * inode. If it's different then something has changed. Observers cannot infer |
| 18 | * anything about the nature or magnitude of the changes from the value, only |
| 19 | * that the inode has changed in some fashion. |
| 20 | * |
| 21 | * Not all filesystems properly implement the i_version counter. Subsystems that |
| 22 | * want to use i_version field on an inode should first check whether the |
| 23 | * filesystem sets the SB_I_VERSION flag (usually via the IS_I_VERSION macro). |
| 24 | * |
| 25 | * Those that set SB_I_VERSION will automatically have their i_version counter |
| 26 | * incremented on writes to normal files. If the SB_I_VERSION is not set, then |
| 27 | * the VFS will not touch it on writes, and the filesystem can use it how it |
| 28 | * wishes. Note that the filesystem is always responsible for updating the |
| 29 | * i_version on namespace changes in directories (mkdir, rmdir, unlink, etc.). |
| 30 | * We consider these sorts of filesystems to have a kernel-managed i_version. |
| 31 | * |
| 32 | * It may be impractical for filesystems to keep i_version updates atomic with |
| 33 | * respect to the changes that cause them. They should, however, guarantee |
| 34 | * that i_version updates are never visible before the changes that caused |
| 35 | * them. Also, i_version updates should never be delayed longer than it takes |
| 36 | * the original change to reach disk. |
| 37 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 38 | * This implementation uses the low bit in the i_version field as a flag to |
| 39 | * track when the value has been queried. If it has not been queried since it |
| 40 | * was last incremented, we can skip the increment in most cases. |
| 41 | * |
| 42 | * In the event that we're updating the ctime, we will usually go ahead and |
| 43 | * bump the i_version anyway. Since that has to go to stable storage in some |
| 44 | * fashion, we might as well increment it as well. |
| 45 | * |
| 46 | * With this implementation, the value should always appear to observers to |
| 47 | * increase over time if the file has changed. It's recommended to use |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 48 | * inode_eq_iversion() helper to compare values. |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 49 | * |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 50 | * Note that some filesystems (e.g. NFS and AFS) just use the field to store |
| 51 | * a server-provided value (for the most part). For that reason, those |
| 52 | * filesystems do not set SB_I_VERSION. These filesystems are considered to |
| 53 | * have a self-managed i_version. |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 54 | * |
| 55 | * Persistently storing the i_version |
| 56 | * ---------------------------------- |
| 57 | * Queries of the i_version field are not gated on them hitting the backing |
| 58 | * store. It's always possible that the host could crash after allowing |
| 59 | * a query of the value but before it has made it to disk. |
| 60 | * |
| 61 | * To mitigate this problem, filesystems should always use |
| 62 | * inode_set_iversion_queried when loading an existing inode from disk. This |
| 63 | * ensures that the next attempted inode increment will result in the value |
| 64 | * changing. |
| 65 | * |
| 66 | * Storing the value to disk therefore does not count as a query, so those |
| 67 | * filesystems should use inode_peek_iversion to grab the value to be stored. |
| 68 | * There is no need to flag the value as having been queried in that case. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 69 | */ |
| 70 | |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 71 | /* |
| 72 | * We borrow the lowest bit in the i_version to use as a flag to tell whether |
| 73 | * it has been queried since we last incremented it. If it has, then we must |
| 74 | * increment it on the next change. After that, we can clear the flag and |
| 75 | * avoid incrementing it again until it has again been queried. |
| 76 | */ |
| 77 | #define I_VERSION_QUERIED_SHIFT (1) |
| 78 | #define I_VERSION_QUERIED (1ULL << (I_VERSION_QUERIED_SHIFT - 1)) |
| 79 | #define I_VERSION_INCREMENT (1ULL << I_VERSION_QUERIED_SHIFT) |
| 80 | |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 81 | /** |
| 82 | * inode_set_iversion_raw - set i_version to the specified raw value |
| 83 | * @inode: inode to set |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 84 | * @val: new i_version value to set |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 85 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 86 | * Set @inode's i_version field to @val. This function is for use by |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 87 | * filesystems that self-manage the i_version. |
| 88 | * |
| 89 | * For example, the NFS client stores its NFSv4 change attribute in this way, |
| 90 | * and the AFS client stores the data_version from the server here. |
| 91 | */ |
| 92 | static inline void |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 93 | inode_set_iversion_raw(struct inode *inode, u64 val) |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 94 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 95 | atomic64_set(&inode->i_version, val); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * inode_peek_iversion_raw - grab a "raw" iversion value |
| 100 | * @inode: inode from which i_version should be read |
| 101 | * |
| 102 | * Grab a "raw" inode->i_version value and return it. The i_version is not |
| 103 | * flagged or converted in any way. This is mostly used to access a self-managed |
| 104 | * i_version. |
| 105 | * |
| 106 | * With those filesystems, we want to treat the i_version as an entirely |
| 107 | * opaque value. |
| 108 | */ |
| 109 | static inline u64 |
| 110 | inode_peek_iversion_raw(const struct inode *inode) |
| 111 | { |
| 112 | return atomic64_read(&inode->i_version); |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /** |
Jeff Layton | 441d367 | 2019-06-05 17:24:22 -0400 | [diff] [blame] | 116 | * inode_set_max_iversion_raw - update i_version new value is larger |
| 117 | * @inode: inode to set |
| 118 | * @val: new i_version to set |
| 119 | * |
| 120 | * Some self-managed filesystems (e.g Ceph) will only update the i_version |
| 121 | * value if the new value is larger than the one we already have. |
| 122 | */ |
| 123 | static inline void |
| 124 | inode_set_max_iversion_raw(struct inode *inode, u64 val) |
| 125 | { |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 126 | u64 cur = inode_peek_iversion_raw(inode); |
Jeff Layton | 441d367 | 2019-06-05 17:24:22 -0400 | [diff] [blame] | 127 | |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 128 | do { |
Jeff Layton | 441d367 | 2019-06-05 17:24:22 -0400 | [diff] [blame] | 129 | if (cur > val) |
| 130 | break; |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 131 | } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, val)); |
Jeff Layton | 441d367 | 2019-06-05 17:24:22 -0400 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /** |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 135 | * inode_set_iversion - set i_version to a particular value |
| 136 | * @inode: inode to set |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 137 | * @val: new i_version value to set |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 138 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 139 | * Set @inode's i_version field to @val. This function is for filesystems with |
| 140 | * a kernel-managed i_version, for initializing a newly-created inode from |
| 141 | * scratch. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 142 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 143 | * In this case, we do not set the QUERIED flag since we know that this value |
| 144 | * has never been queried. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 145 | */ |
| 146 | static inline void |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 147 | inode_set_iversion(struct inode *inode, u64 val) |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 148 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 149 | inode_set_iversion_raw(inode, val << I_VERSION_QUERIED_SHIFT); |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 153 | * inode_set_iversion_queried - set i_version to a particular value as quereied |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 154 | * @inode: inode to set |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 155 | * @val: new i_version value to set |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 156 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 157 | * Set @inode's i_version field to @val, and flag it for increment on the next |
| 158 | * change. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 159 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 160 | * Filesystems that persistently store the i_version on disk should use this |
| 161 | * when loading an existing inode from disk. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 162 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 163 | * When loading in an i_version value from a backing store, we can't be certain |
| 164 | * that it wasn't previously viewed before being stored. Thus, we must assume |
| 165 | * that it was, to ensure that we don't end up handing out the same value for |
| 166 | * different versions of the same inode. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 167 | */ |
| 168 | static inline void |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 169 | inode_set_iversion_queried(struct inode *inode, u64 val) |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 170 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 171 | inode_set_iversion_raw(inode, (val << I_VERSION_QUERIED_SHIFT) | |
| 172 | I_VERSION_QUERIED); |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /** |
| 176 | * inode_maybe_inc_iversion - increments i_version |
| 177 | * @inode: inode with the i_version that should be updated |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 178 | * @force: increment the counter even if it's not necessary? |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 179 | * |
| 180 | * Every time the inode is modified, the i_version field must be seen to have |
| 181 | * changed by any observer. |
| 182 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 183 | * If "force" is set or the QUERIED flag is set, then ensure that we increment |
| 184 | * the value, and clear the queried flag. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 185 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 186 | * In the common case where neither is set, then we can return "false" without |
| 187 | * updating i_version. |
| 188 | * |
| 189 | * If this function returns false, and no other metadata has changed, then we |
| 190 | * can avoid logging the metadata. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 191 | */ |
| 192 | static inline bool |
| 193 | inode_maybe_inc_iversion(struct inode *inode, bool force) |
| 194 | { |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 195 | u64 cur, new; |
Jeff Layton | 7594c46 | 2017-12-18 06:25:31 -0500 | [diff] [blame] | 196 | |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 197 | /* |
| 198 | * The i_version field is not strictly ordered with any other inode |
| 199 | * information, but the legacy inode_inc_iversion code used a spinlock |
| 200 | * to serialize increments. |
| 201 | * |
| 202 | * Here, we add full memory barriers to ensure that any de-facto |
| 203 | * ordering with other info is preserved. |
| 204 | * |
| 205 | * This barrier pairs with the barrier in inode_query_iversion() |
| 206 | */ |
| 207 | smp_mb(); |
| 208 | cur = inode_peek_iversion_raw(inode); |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 209 | do { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 210 | /* If flag is clear then we needn't do anything */ |
| 211 | if (!force && !(cur & I_VERSION_QUERIED)) |
| 212 | return false; |
| 213 | |
| 214 | /* Since lowest bit is flag, add 2 to avoid it */ |
| 215 | new = (cur & ~I_VERSION_QUERIED) + I_VERSION_INCREMENT; |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 216 | } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new)); |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 217 | return true; |
| 218 | } |
| 219 | |
Jeff Layton | 7594c46 | 2017-12-18 06:25:31 -0500 | [diff] [blame] | 220 | |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 221 | /** |
| 222 | * inode_inc_iversion - forcibly increment i_version |
| 223 | * @inode: inode that needs to be updated |
| 224 | * |
| 225 | * Forcbily increment the i_version field. This always results in a change to |
| 226 | * the observable value. |
| 227 | */ |
| 228 | static inline void |
| 229 | inode_inc_iversion(struct inode *inode) |
| 230 | { |
| 231 | inode_maybe_inc_iversion(inode, true); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * inode_iversion_need_inc - is the i_version in need of being incremented? |
| 236 | * @inode: inode to check |
| 237 | * |
| 238 | * Returns whether the inode->i_version counter needs incrementing on the next |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 239 | * change. Just fetch the value and check the QUERIED flag. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 240 | */ |
| 241 | static inline bool |
| 242 | inode_iversion_need_inc(struct inode *inode) |
| 243 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 244 | return inode_peek_iversion_raw(inode) & I_VERSION_QUERIED; |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /** |
| 248 | * inode_inc_iversion_raw - forcibly increment raw i_version |
| 249 | * @inode: inode that needs to be updated |
| 250 | * |
| 251 | * Forcbily increment the raw i_version field. This always results in a change |
| 252 | * to the raw value. |
| 253 | * |
| 254 | * NFS will use the i_version field to store the value from the server. It |
| 255 | * mostly treats it as opaque, but in the case where it holds a write |
| 256 | * delegation, it must increment the value itself. This function does that. |
| 257 | */ |
| 258 | static inline void |
| 259 | inode_inc_iversion_raw(struct inode *inode) |
| 260 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 261 | atomic64_inc(&inode->i_version); |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | /** |
| 265 | * inode_peek_iversion - read i_version without flagging it to be incremented |
| 266 | * @inode: inode from which i_version should be read |
| 267 | * |
| 268 | * Read the inode i_version counter for an inode without registering it as a |
| 269 | * query. |
| 270 | * |
| 271 | * This is typically used by local filesystems that need to store an i_version |
| 272 | * on disk. In that situation, it's not necessary to flag it as having been |
| 273 | * viewed, as the result won't be used to gauge changes from that point. |
| 274 | */ |
| 275 | static inline u64 |
| 276 | inode_peek_iversion(const struct inode *inode) |
| 277 | { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 278 | return inode_peek_iversion_raw(inode) >> I_VERSION_QUERIED_SHIFT; |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /** |
| 282 | * inode_query_iversion - read i_version for later use |
| 283 | * @inode: inode from which i_version should be read |
| 284 | * |
| 285 | * Read the inode i_version counter. This should be used by callers that wish |
| 286 | * to store the returned i_version for later comparison. This will guarantee |
| 287 | * that a later query of the i_version will result in a different value if |
| 288 | * anything has changed. |
| 289 | * |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 290 | * In this implementation, we fetch the current value, set the QUERIED flag and |
| 291 | * then try to swap it into place with a cmpxchg, if it wasn't already set. If |
| 292 | * that fails, we try again with the newly fetched value from the cmpxchg. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 293 | */ |
| 294 | static inline u64 |
| 295 | inode_query_iversion(struct inode *inode) |
| 296 | { |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 297 | u64 cur, new; |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 298 | |
| 299 | cur = inode_peek_iversion_raw(inode); |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 300 | do { |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 301 | /* If flag is already set, then no need to swap */ |
| 302 | if (cur & I_VERSION_QUERIED) { |
| 303 | /* |
| 304 | * This barrier (and the implicit barrier in the |
| 305 | * cmpxchg below) pairs with the barrier in |
| 306 | * inode_maybe_inc_iversion(). |
| 307 | */ |
| 308 | smp_mb(); |
| 309 | break; |
| 310 | } |
| 311 | |
| 312 | new = cur | I_VERSION_QUERIED; |
Uros Bizjak | da3f52b | 2022-08-21 21:30:11 +0200 | [diff] [blame^] | 313 | } while (!atomic64_try_cmpxchg(&inode->i_version, &cur, new)); |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 314 | return cur >> I_VERSION_QUERIED_SHIFT; |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 315 | } |
| 316 | |
J. Bruce Fields | 4b03d99 | 2020-11-30 17:46:16 -0500 | [diff] [blame] | 317 | /* |
| 318 | * For filesystems without any sort of change attribute, the best we can |
| 319 | * do is fake one up from the ctime: |
| 320 | */ |
| 321 | static inline u64 time_to_chattr(struct timespec64 *t) |
| 322 | { |
| 323 | u64 chattr = t->tv_sec; |
| 324 | |
| 325 | chattr <<= 32; |
| 326 | chattr += t->tv_nsec; |
| 327 | return chattr; |
| 328 | } |
| 329 | |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 330 | /** |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 331 | * inode_eq_iversion_raw - check whether the raw i_version counter has changed |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 332 | * @inode: inode to check |
| 333 | * @old: old value to check against its i_version |
| 334 | * |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 335 | * Compare the current raw i_version counter with a previous one. Returns true |
| 336 | * if they are the same or false if they are different. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 337 | */ |
Jeff Layton | c0cef30 | 2018-01-30 15:32:21 -0500 | [diff] [blame] | 338 | static inline bool |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 339 | inode_eq_iversion_raw(const struct inode *inode, u64 old) |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 340 | { |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 341 | return inode_peek_iversion_raw(inode) == old; |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | /** |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 345 | * inode_eq_iversion - check whether the i_version counter has changed |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 346 | * @inode: inode to check |
| 347 | * @old: old value to check against its i_version |
| 348 | * |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 349 | * Compare an i_version counter with a previous one. Returns true if they are |
| 350 | * the same, and false if they are different. |
Jeff Layton | f02a9ad | 2017-12-21 07:45:44 -0500 | [diff] [blame] | 351 | * |
| 352 | * Note that we don't need to set the QUERIED flag in this case, as the value |
| 353 | * in the inode is not being recorded for later use. |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 354 | */ |
Jeff Layton | c0cef30 | 2018-01-30 15:32:21 -0500 | [diff] [blame] | 355 | static inline bool |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 356 | inode_eq_iversion(const struct inode *inode, u64 old) |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 357 | { |
Goffredo Baroncelli | c472c07 | 2018-02-01 08:15:25 -0500 | [diff] [blame] | 358 | return inode_peek_iversion(inode) == old; |
Jeff Layton | ae5e165 | 2018-01-29 06:41:30 -0500 | [diff] [blame] | 359 | } |
| 360 | #endif |