/* * row_get_queue_prio() - Get queue priority for a given request * * This is a helping function which purpose is to determine what * ROW queue the given request should be added to (and * dispatched from later on) * */ static enum row_queue_prio row_get_queue_prio(struct request *rq, struct row_data *rd) { const int data_dir = rq_data_dir(rq); const bool is_sync = rq_is_sync(rq); enum row_queue_prio q_type = ROWQ_MAX_PRIO; int ioprio_class = IOPRIO_PRIO_CLASS(rq->elv.icq->ioc->ioprio); if (unlikely(row_get_current()->flags & PF_MUTEX_GC)) { if (data_dir == READ) q_type = ROWQ_PRIO_HIGH_READ; else q_type = ROWQ_PRIO_HIGH_SWRITE; return q_type; } switch (ioprio_class) { case IOPRIO_CLASS_RT: if (data_dir == READ) q_type = ROWQ_PRIO_HIGH_READ; else if (is_sync) q_type = ROWQ_PRIO_HIGH_SWRITE; else { q_type = ROWQ_PRIO_REG_WRITE; } break; case IOPRIO_CLASS_IDLE: if (data_dir == READ) q_type = ROWQ_PRIO_LOW_READ; else if (is_sync) q_type = ROWQ_PRIO_LOW_SWRITE; else { pr_err("%s:%s(): got a simple write from IDLE_CLASS. How???",/*lint !e585*/ rq->rq_disk->disk_name, __func__); q_type = ROWQ_PRIO_REG_WRITE; } break; case IOPRIO_CLASS_NONE: case IOPRIO_CLASS_BE: default: if (data_dir == READ) q_type = ROWQ_PRIO_REG_READ; else if (is_sync) q_type = ROWQ_PRIO_REG_SWRITE; else q_type = ROWQ_PRIO_REG_WRITE; break; } return q_type; }
/* * Return a (ioclass, iodata) Python tuple representing process I/O priority. */ static PyObject* linux_ioprio_get(PyObject* self, PyObject* args) { long pid; int ioprio, ioclass, iodata; if (! PyArg_ParseTuple(args, "l", &pid)) { return NULL; } ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid); if (ioprio == -1) { return PyErr_SetFromErrno(PyExc_OSError); } ioclass = IOPRIO_PRIO_CLASS(ioprio); iodata = IOPRIO_PRIO_DATA(ioprio); return Py_BuildValue("ii", ioclass, iodata); }
/* * row_get_queue_prio() - Get queue priority for a given request * * This is a helping function which purpose is to determine what * ROW queue the given request should be added to (and * dispatched from later on) * */ static enum row_queue_prio row_get_queue_prio(struct request *rq) { const int data_dir = rq_data_dir(rq); const bool is_sync = rq_is_sync(rq); enum row_queue_prio q_type = ROWQ_MAX_PRIO; int ioprio_class = IOPRIO_PRIO_CLASS(rq->elv.icq->ioc->ioprio); switch (ioprio_class) { case IOPRIO_CLASS_RT: if (data_dir == READ) q_type = ROWQ_PRIO_HIGH_READ; else if (is_sync) q_type = ROWQ_PRIO_HIGH_SWRITE; else { pr_err("%s:%s(): got a simple write from RT_CLASS. How???", rq->rq_disk->disk_name, __func__); q_type = ROWQ_PRIO_REG_WRITE; } rq->cmd_flags |= REQ_URGENT; break; case IOPRIO_CLASS_IDLE: if (data_dir == READ) q_type = ROWQ_PRIO_LOW_READ; else if (is_sync) q_type = ROWQ_PRIO_LOW_SWRITE; else { pr_err("%s:%s(): got a simple write from IDLE_CLASS. How???", rq->rq_disk->disk_name, __func__); q_type = ROWQ_PRIO_REG_WRITE; } break; case IOPRIO_CLASS_NONE: case IOPRIO_CLASS_BE: default: if (data_dir == READ) q_type = ROWQ_PRIO_REG_READ; else if (is_sync) q_type = ROWQ_PRIO_REG_SWRITE; else q_type = ROWQ_PRIO_REG_WRITE; break; } return q_type; }
static void ioprio_print(int pid) { int ioprio = ioprio_get(IOPRIO_WHO_PROCESS, pid); if (ioprio == -1) err(EXIT_FAILURE, _("ioprio_get failed")); else { int ioclass = IOPRIO_PRIO_CLASS(ioprio); const char *name = _("unknown"); if (ioclass > 0 && (size_t) ioclass < ARRAY_SIZE(to_prio)) name = to_prio[ioclass]; if (ioclass != IOPRIO_CLASS_IDLE) printf(_("%s: prio %lu\n"), name, IOPRIO_PRIO_DATA(ioprio)); else printf("%s\n", name); } }
static inline int is_rt(struct fuse_conn *fc) { /* Returns 1 if request is RT class */ /* && FUSE_HANDLE_RT_CLASS bit of fc->flags is set. */ /* FUSE_HANDLE_RT_CLASS bit is set by 'handle_rt_class' */ /* mount option while mounting a file system. */ struct io_context *ioc; if (!fc) return 0; if (!(fc->flags & FUSE_HANDLE_RT_CLASS)) /* Don't handle RT class */ return 0; ioc = get_io_context(GFP_NOWAIT, 0); if (ioc && IOPRIO_PRIO_CLASS(ioc->ioprio) == IOPRIO_CLASS_RT) return 1; return 0; }
static inline int is_rt(struct fuse_conn *fc) { /* * Returns 1 if a process is RT class. */ struct io_context *ioc = NULL; int ret = 0; if (!fc) return 0; if (!(fc->flags & FUSE_HANDLE_RT_CLASS)) /* Don't handle RT class */ return 0; get_io_context(ioc); if(!ioc) return 0; if(IOPRIO_PRIO_CLASS(ioc->ioprio) == IOPRIO_CLASS_RT) ret = 1; put_io_context(ioc); return ret; }
static inline int is_rt(struct fuse_conn *fc) { /* Returns 1 if request is RT class */ /* && FUSE_HANDLE_RT_CLASS bit of fc->flags is set. */ /* FUSE_HANDLE_RT_CLASS bit is set by 'handle_rt_class' */ struct io_context *ioc; int ret = 0; if (!fc) return 0; if (!(fc->flags & FUSE_HANDLE_RT_CLASS)) /* Don't handle RT class */ return 0; ioc = get_io_context(GFP_NOWAIT, 0); if (!ioc) return 0; if (IOPRIO_PRIO_CLASS(ioc->ioprio) == IOPRIO_CLASS_RT) ret = 1; put_io_context(ioc); return ret; }
static void fiops_init_prio_data(struct fiops_ioc *cic) { struct task_struct *tsk = current; struct io_context *ioc = cic->icq.ioc; int ioprio_class; if (!fiops_ioc_prio_changed(cic)) return; ioprio_class = IOPRIO_PRIO_CLASS(ioc->ioprio); switch (ioprio_class) { default: printk(KERN_ERR "fiops: bad prio %x\n", ioprio_class); case IOPRIO_CLASS_NONE: /* * no prio set, inherit CPU scheduling settings */ cic->ioprio = task_nice_ioprio(tsk); cic->wl_type = fiops_wl_type(task_nice_ioclass(tsk)); break; case IOPRIO_CLASS_RT: cic->ioprio = task_ioprio(ioc); cic->wl_type = fiops_wl_type(IOPRIO_CLASS_RT); break; case IOPRIO_CLASS_BE: cic->ioprio = task_ioprio(ioc); cic->wl_type = fiops_wl_type(IOPRIO_CLASS_BE); break; case IOPRIO_CLASS_IDLE: cic->wl_type = fiops_wl_type(IOPRIO_CLASS_IDLE); cic->ioprio = 7; break; } fiops_clear_ioc_prio_changed(cic); }