[Concept,05/23] linux: Add iversion.h with inode version stubs
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Create linux/iversion.h with inode version operation stubs including
inode_peek_iversion(), inode_set_iversion(), inode_inc_iversion(),
inode_eq_iversion(), and inode_query_iversion().
U-Boot does not track inode versions, so these are all no-ops or
return constant values.
Update ext4_uboot.h to use linux/iversion.h and remove the
inode_set_iversion() implementation from stub.c since it is now
a macro.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 14 ++----
fs/ext4l/stub.c | 4 +-
include/linux/iversion.h | 96 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 13 deletions(-)
create mode 100644 include/linux/iversion.h
@@ -982,13 +982,9 @@ static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
return ts;
}
-/* Inode version operations */
-#define inode_peek_iversion_raw(i) (0ULL)
-#define inode_peek_iversion(i) (0ULL)
+/* Inode version operations - use linux/iversion.h */
+#include <linux/iversion.h>
#define inode_set_flags(i, f, m) do { } while (0)
-#define inode_set_iversion_raw(i, v) do { } while (0)
-#define inode_set_iversion_queried(i, v) do { } while (0)
-#define inode_inc_iversion(i) do { } while (0)
/* Inode credential helpers */
static inline unsigned int i_uid_read(const struct inode *inode)
@@ -1062,9 +1058,7 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino);
/* Readahead operations are in linux/pagemap.h */
-/* Inode version operations */
-#define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; })
-#define inode_query_iversion(i) ({ (void)(i); 0ULL; })
+/* Inode version operations are in linux/iversion.h */
/* dir_emit, dir_relax_shared are in linux/fs.h */
@@ -1344,7 +1338,7 @@ void fs_put_dax(void *dax, void *holder);
/* Inode allocation - declaration for stub.c */
void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache,
gfp_t gfp);
-void inode_set_iversion(struct inode *inode, u64 version);
+/* inode_set_iversion is in linux/iversion.h */
int inode_generic_drop(struct inode *inode);
/* rwlock_init is a macro in linux/spinlock.h */
@@ -346,9 +346,7 @@ void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache,
return NULL;
}
-void inode_set_iversion(struct inode *inode, u64 version)
-{
-}
+/* inode_set_iversion is now a macro in linux/iversion.h */
/* rwlock_init is now a macro in linux/spinlock.h */
new file mode 100644
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Inode version definitions for U-Boot
+ *
+ * Based on Linux iversion.h - inode version management.
+ * U-Boot stub - version tracking not supported.
+ */
+#ifndef _LINUX_IVERSION_H
+#define _LINUX_IVERSION_H
+
+#include <linux/types.h>
+
+/* Forward declarations */
+struct inode;
+
+/**
+ * inode_peek_iversion_raw() - read inode version without side effects
+ * @inode: inode to read
+ *
+ * U-Boot stub - always returns 0.
+ *
+ * Return: inode version
+ */
+#define inode_peek_iversion_raw(inode) (0ULL)
+
+/**
+ * inode_peek_iversion() - read inode version
+ * @inode: inode to read
+ *
+ * U-Boot stub - always returns 0.
+ *
+ * Return: inode version
+ */
+#define inode_peek_iversion(inode) (0ULL)
+
+/**
+ * inode_set_iversion_raw() - set inode version directly
+ * @inode: inode to modify
+ * @version: version to set
+ *
+ * U-Boot stub - no-op.
+ */
+#define inode_set_iversion_raw(inode, version) \
+ do { (void)(inode); (void)(version); } while (0)
+
+/**
+ * inode_set_iversion() - set inode version
+ * @inode: inode to modify
+ * @version: version to set
+ *
+ * U-Boot stub - no-op.
+ */
+#define inode_set_iversion(inode, version) \
+ do { (void)(inode); (void)(version); } while (0)
+
+/**
+ * inode_set_iversion_queried() - set inode version as queried
+ * @inode: inode to modify
+ * @version: version to set
+ *
+ * U-Boot stub - no-op.
+ */
+#define inode_set_iversion_queried(inode, version) \
+ do { (void)(inode); (void)(version); } while (0)
+
+/**
+ * inode_inc_iversion() - increment inode version
+ * @inode: inode to modify
+ *
+ * U-Boot stub - no-op.
+ */
+#define inode_inc_iversion(inode) do { (void)(inode); } while (0)
+
+/**
+ * inode_eq_iversion() - check if inode version matches
+ * @inode: inode to check
+ * @version: version to compare
+ *
+ * U-Boot stub - always returns true.
+ *
+ * Return: true if versions match
+ */
+#define inode_eq_iversion(inode, version) \
+ ({ (void)(inode); (void)(version); true; })
+
+/**
+ * inode_query_iversion() - query inode version
+ * @inode: inode to query
+ *
+ * U-Boot stub - always returns 0.
+ *
+ * Return: inode version
+ */
+#define inode_query_iversion(inode) ({ (void)(inode); 0ULL; })
+
+#endif /* _LINUX_IVERSION_H */