diff mbox series

[1/2] block: adjust code for get_task_ioprio()

Message ID 20190415055703.5512-2-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series block: set per bio io-priority in blk-lib | expand

Commit Message

Chaitanya Kulkarni April 15, 2019, 5:57 a.m. UTC
This is a preparation patch which adjusts the code and exports
get_task_ioprio().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/ioprio.c         | 20 ++++++++++++++++----
 include/linux/ioprio.h |  2 ++
 2 files changed, 18 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/block/ioprio.c b/block/ioprio.c
index f9821080c92c..9853e9077022 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -156,7 +156,7 @@  SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
 	return ret;
 }
 
-static int get_task_ioprio(struct task_struct *p)
+static int __get_task_ioprio(struct task_struct *p)
 {
 	int ret;
 
@@ -172,6 +172,18 @@  static int get_task_ioprio(struct task_struct *p)
 	return ret;
 }
 
+int get_task_ioprio(struct task_struct *p)
+{
+	int ret;
+
+	rcu_read_lock();
+	ret = __get_task_ioprio(p);
+	rcu_read_unlock();
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(get_task_ioprio);
+
 int ioprio_best(unsigned short aprio, unsigned short bprio)
 {
 	if (!ioprio_valid(aprio))
@@ -199,7 +211,7 @@  SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
 			else
 				p = find_task_by_vpid(who);
 			if (p)
-				ret = get_task_ioprio(p);
+				ret = __get_task_ioprio(p);
 			break;
 		case IOPRIO_WHO_PGRP:
 			if (!who)
@@ -207,7 +219,7 @@  SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
 			else
 				pgrp = find_vpid(who);
 			do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
-				tmpio = get_task_ioprio(p);
+				tmpio = __get_task_ioprio(p);
 				if (tmpio < 0)
 					continue;
 				if (ret == -ESRCH)
@@ -230,7 +242,7 @@  SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
 				if (!uid_eq(task_uid(p), user->uid) ||
 				    !task_pid_vnr(p))
 					continue;
-				tmpio = get_task_ioprio(p);
+				tmpio = __get_task_ioprio(p);
 				if (tmpio < 0)
 					continue;
 				if (ret == -ESRCH)
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index e9bfe6972aed..1384446c614d 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -90,6 +90,8 @@  extern int ioprio_best(unsigned short aprio, unsigned short bprio);
 
 extern int set_task_ioprio(struct task_struct *task, int ioprio);
 
+extern int get_task_ioprio(struct task_struct *p);
+
 #ifdef CONFIG_BLOCK
 extern int ioprio_check_cap(int ioprio);
 #else