Esempio n. 1
0
/**
 * bfq_get_io_context - return the @cic associated to @bfqd in @ioc.
 * @bfqd: the search key.
 * @gfp_mask: the mask to use for cic allocation.
 *
 * Setup general io context and cfq io context.  There can be several cfq
 * io contexts per general io context, if this process is doing io to more
 * than one device managed by cfq.
 */
static struct cfq_io_context *bfq_get_io_context(struct bfq_data *bfqd,
						 gfp_t gfp_mask)
{
	struct io_context *ioc = NULL;
	struct cfq_io_context *cic;

	might_sleep_if(gfp_mask & __GFP_WAIT);

	ioc = get_io_context(gfp_mask, bfqd->queue->node);
	if (ioc == NULL)
		return NULL;

	/* Lookup for an existing cic. */
	cic = bfq_cic_lookup(bfqd, ioc);
	if (cic != NULL)
		goto out;

	/* Alloc one if needed. */
	cic = bfq_alloc_io_context(bfqd, gfp_mask);
	if (cic == NULL)
		goto err;

	/* Link it into the ioc's radix tree and cic list. */
	if (bfq_cic_link(bfqd, ioc, cic, gfp_mask) != 0)
		goto err_free;

out:
	/*
	 * test_and_clear_bit() implies a memory barrier, paired with
	 * the wmb() in fs/ioprio.c, so the value seen for ioprio is the
	 * new one.
	 */
	if (unlikely(test_and_clear_bit(IOC_BFQ_IOPRIO_CHANGED,
					ioc->ioprio_changed)))
		bfq_ioc_set_ioprio(ioc);

	return cic;
err_free:
	bfq_cic_free(cic);
err:
	put_io_context(ioc);
	return NULL;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
/**
 * get_task_io_context - get io_context of a task
 * @task: task of interest
 * @gfp_flags: allocation flags, used if allocation is necessary
 * @node: allocation node, used if allocation is necessary
 *
 * Return io_context of @task.  If it doesn't exist, it is created with
 * @gfp_flags and @node.  The returned io_context has its reference count
 * incremented.
 *
 * This function always goes through task_lock() and it's better to use
 * %current->io_context + get_io_context() for %current.
 */
struct io_context *get_task_io_context(struct task_struct *task,
				       gfp_t gfp_flags, int node)
{
	struct io_context *ioc;

	might_sleep_if(gfp_flags & __GFP_WAIT);

	do {
		task_lock(task);
		ioc = task->io_context;
		if (likely(ioc)) {
			get_io_context(ioc);
			task_unlock(task);
			return ioc;
		}
		task_unlock(task);
	} while (create_io_context(task, gfp_flags, node));

	return NULL;
}
Esempio n. 4
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
#endif // !defined(ASIO_WINDOWS_RUNTIME)

#if defined(ASIO_HAS_MOVE)
    ip::udp::socket socket7(std::move(socket6));
#endif // defined(ASIO_HAS_MOVE)

    // basic_datagram_socket operators.

#if defined(ASIO_HAS_MOVE)
    socket1 = ip::udp::socket(ioc);
    socket1 = std::move(socket2);
#endif // defined(ASIO_HAS_MOVE)

    // basic_io_object functions.

    io_context& ioc_ref = socket1.get_io_context();
    (void)ioc_ref;

    ip::udp::socket::executor_type ex = socket1.get_executor();
    (void)ex;

    // basic_socket functions.

    ip::udp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
    (void)lowest_layer;

    const ip::udp::socket& socket8 = socket1;
    const ip::udp::socket::lowest_layer_type& lowest_layer2
      = socket8.lowest_layer();
    (void)lowest_layer2;
Esempio n. 7
0
 void on_setup(Executor & exec)
 {
     pipe = std::make_shared<boost::process::async_pipe>(get_io_context(exec.seq));
 }