[Concept,09/23] linux: Add ioprio.h with I/O priority definitions

Message ID 20260119061529.3383191-10-sjg@u-boot.org
State New
Headers
Series Reduce ext4_uboot.h by moving definitions to linux headers |

Commit Message

Simon Glass Jan. 19, 2026, 6:15 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Create linux/ioprio.h with I/O priority class definitions and
helper macros including IOPRIO_CLASS_*, IOPRIO_PRIO_VALUE(),
IOPRIO_PRIO_CLASS(), get_current_ioprio(), and set_task_ioprio().

Update ext4_uboot.h to use linux/ioprio.h and remove the function
implementations from stub.c since they are now macros.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h  | 13 ++++-----
 fs/ext4l/stub.c        | 10 +------
 include/linux/ioprio.h | 64 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 17 deletions(-)
 create mode 100644 include/linux/ioprio.h
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 83dcf772c45..aae248a6930 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -1243,8 +1243,8 @@  void ext4_unregister_li_request(struct super_block *sb);
 /* Path lookup flags - use linux/namei.h */
 #include <linux/namei.h>
 
-/* I/O priority classes */
-#define IOPRIO_CLASS_BE			2
+/* I/O priority classes - use linux/ioprio.h */
+#include <linux/ioprio.h>
 
 /* SB_INLINECRYPT, SB_SILENT, SB_POSIXACL are in linux/fs.h */
 #define SB_I_CGROUPWB			0	/* Not supported in U-Boot */
@@ -1343,8 +1343,7 @@  int inode_generic_drop(struct inode *inode);
 
 /* Path operations - path_put, d_path are in linux/path.h */
 
-/* I/O priority - declaration for stub.c */
-int IOPRIO_PRIO_VALUE(int class, int data);
+/* I/O priority stubs are in linux/ioprio.h */
 
 /* kmemdup_nul is in linux/slab.h */
 /* fscrypt declarations are in ext4_fscrypt.h */
@@ -1393,8 +1392,7 @@  unsigned int bdev_max_discard_sectors(struct block_device *bdev);
 
 /* bgl_lock_init is now in linux/blockgroup_lock.h */
 
-/* Task I/O priority - declaration for stub.c */
-void set_task_ioprio(void *task, int ioprio);
+/* set_task_ioprio is in linux/ioprio.h */
 
 /* Superblock identity functions */
 static inline void super_set_uuid(struct super_block *sb, const u8 *uuid,
@@ -1617,8 +1615,7 @@  bool __folio_start_writeback(struct folio *folio, bool keep_write);
 
 /* d_alloc, d_drop are now in linux/dcache.h */
 
-/* get_current_ioprio - I/O priority (not used in U-Boot) */
-#define get_current_ioprio()		(0)
+/* get_current_ioprio is in linux/ioprio.h */
 
 /* JBD2 checkpoint.c stubs */
 #define mutex_lock_io(m)		mutex_lock(m)
diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c
index bdb8b8bb675..1b9c72a6cc2 100644
--- a/fs/ext4l/stub.c
+++ b/fs/ext4l/stub.c
@@ -400,15 +400,7 @@  int ___ratelimit(struct ratelimit_state *rs, const char *func)
 	return 1;
 }
 
-/* I/O priority */
-int IOPRIO_PRIO_VALUE(int class, int data)
-{
-	return (class << 13) | data;
-}
-
-void set_task_ioprio(void *task, int ioprio)
-{
-}
+/* I/O priority stubs are now in linux/ioprio.h */
 
 /* ext4_fc_init is now in fast_commit.c */
 
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
new file mode 100644
index 00000000000..2cec5cac818
--- /dev/null
+++ b/include/linux/ioprio.h
@@ -0,0 +1,64 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * I/O priority definitions for U-Boot
+ *
+ * Based on Linux ioprio.h - I/O scheduling priority.
+ * U-Boot stub - I/O priority not supported.
+ */
+#ifndef IOPRIO_H
+#define IOPRIO_H
+
+/* I/O priority classes */
+#define IOPRIO_CLASS_NONE	0
+#define IOPRIO_CLASS_RT		1
+#define IOPRIO_CLASS_BE		2
+#define IOPRIO_CLASS_IDLE	3
+
+/* I/O priority levels (0-7, lower is higher priority) */
+#define IOPRIO_NR_LEVELS	8
+#define IOPRIO_BE_NR		IOPRIO_NR_LEVELS
+
+/**
+ * IOPRIO_PRIO_VALUE() - create I/O priority value from class and level
+ * @class: I/O priority class
+ * @data: priority level within class
+ *
+ * Return: encoded priority value
+ */
+#define IOPRIO_PRIO_VALUE(class, data)	(((class) << 13) | (data))
+
+/**
+ * IOPRIO_PRIO_CLASS() - extract class from priority value
+ * @ioprio: encoded priority
+ *
+ * Return: I/O priority class
+ */
+#define IOPRIO_PRIO_CLASS(ioprio)	(((ioprio) >> 13) & 0x3)
+
+/**
+ * IOPRIO_PRIO_DATA() - extract data/level from priority value
+ * @ioprio: encoded priority
+ *
+ * Return: priority level
+ */
+#define IOPRIO_PRIO_DATA(ioprio)	((ioprio) & 0x1fff)
+
+/**
+ * get_current_ioprio() - get I/O priority of current task
+ *
+ * U-Boot stub - always returns 0.
+ *
+ * Return: I/O priority value
+ */
+#define get_current_ioprio()		(0)
+
+/**
+ * set_task_ioprio() - set I/O priority of a task
+ * @task: task to modify (ignored)
+ * @ioprio: priority to set (ignored)
+ *
+ * U-Boot stub - no-op.
+ */
+#define set_task_ioprio(task, ioprio)	do { (void)(task); (void)(ioprio); } while (0)
+
+#endif /* IOPRIO_H */