]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | |
2 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | |
3 | // vim: ts=8 sw=2 smarttab ft=cpp | |
4 | ||
5 | /* | |
6 | * Ceph - scalable distributed file system | |
7 | * | |
8 | * Copyright (C) 2019 Red Hat, Inc. | |
9 | * | |
10 | * This is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU Lesser General Public | |
12 | * License version 2.1, as published by the Free Software | |
13 | * Foundation. See file COPYING. | |
14 | * | |
15 | */ | |
16 | ||
17 | ||
18 | #pragma once | |
19 | ||
20 | #include <atomic> | |
21 | ||
22 | struct rgw_io_id { | |
23 | int64_t id{0}; | |
24 | int channels{0}; | |
25 | ||
26 | rgw_io_id() {} | |
27 | rgw_io_id(int64_t _id, int _channels) : id(_id), channels(_channels) {} | |
28 | ||
29 | bool intersects(const rgw_io_id& rhs) { | |
30 | return (id == rhs.id && ((channels | rhs.channels) != 0)); | |
31 | } | |
32 | ||
33 | bool operator<(const rgw_io_id& rhs) const { | |
34 | if (id < rhs.id) { | |
35 | return true; | |
36 | } | |
37 | return (id == rhs.id && | |
38 | channels < rhs.channels); | |
39 | } | |
40 | }; | |
41 | ||
42 | class RGWIOIDProvider | |
43 | { | |
44 | std::atomic<int64_t> max = {0}; | |
45 | ||
46 | public: | |
47 | RGWIOIDProvider() {} | |
48 | int64_t get_next() { | |
49 | return ++max; | |
50 | } | |
51 | }; | |
52 | ||
53 | class RGWIOProvider | |
54 | { | |
55 | int64_t id{-1}; | |
56 | ||
57 | public: | |
58 | RGWIOProvider() {} | |
59 | virtual ~RGWIOProvider() = default; | |
60 | ||
61 | void assign_io(RGWIOIDProvider& io_id_provider, int io_type = -1); | |
62 | rgw_io_id get_io_id(int io_type) { | |
63 | return rgw_io_id{id, io_type}; | |
64 | } | |
65 | ||
66 | virtual void set_io_user_info(void *_user_info) = 0; | |
67 | virtual void *get_io_user_info() = 0; | |
68 | }; | |
69 |