Sage Weil | 5cd068c | 2010-07-07 08:38:17 -0700 | [diff] [blame] | 1 | #ifndef CEPH_RADOS_H |
| 2 | #define CEPH_RADOS_H |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 3 | |
| 4 | /* |
| 5 | * Data types for the Ceph distributed object storage layer RADOS |
| 6 | * (Reliable Autonomic Distributed Object Store). |
| 7 | */ |
| 8 | |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 9 | #include <linux/ceph/msgr.h> |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * fs id |
| 13 | */ |
| 14 | struct ceph_fsid { |
| 15 | unsigned char fsid[16]; |
| 16 | }; |
| 17 | |
| 18 | static inline int ceph_fsid_compare(const struct ceph_fsid *a, |
| 19 | const struct ceph_fsid *b) |
| 20 | { |
| 21 | return memcmp(a, b, sizeof(*a)); |
| 22 | } |
| 23 | |
| 24 | /* |
| 25 | * ino, object, etc. |
| 26 | */ |
| 27 | typedef __le64 ceph_snapid_t; |
| 28 | #define CEPH_SNAPDIR ((__u64)(-1)) /* reserved for hidden .snap dir */ |
| 29 | #define CEPH_NOSNAP ((__u64)(-2)) /* "head", "live" revision */ |
| 30 | #define CEPH_MAXSNAP ((__u64)(-3)) /* largest valid snapid */ |
| 31 | |
| 32 | struct ceph_timespec { |
| 33 | __le32 tv_sec; |
| 34 | __le32 tv_nsec; |
| 35 | } __attribute__ ((packed)); |
| 36 | |
| 37 | |
| 38 | /* |
| 39 | * object layout - how objects are mapped into PGs |
| 40 | */ |
| 41 | #define CEPH_OBJECT_LAYOUT_HASH 1 |
| 42 | #define CEPH_OBJECT_LAYOUT_LINEAR 2 |
| 43 | #define CEPH_OBJECT_LAYOUT_HASHINO 3 |
| 44 | |
| 45 | /* |
| 46 | * pg layout -- how PGs are mapped onto (sets of) OSDs |
| 47 | */ |
| 48 | #define CEPH_PG_LAYOUT_CRUSH 0 |
| 49 | #define CEPH_PG_LAYOUT_HASH 1 |
| 50 | #define CEPH_PG_LAYOUT_LINEAR 2 |
| 51 | #define CEPH_PG_LAYOUT_HYBRID 3 |
| 52 | |
Sage Weil | d85b705 | 2010-05-10 10:24:48 -0700 | [diff] [blame] | 53 | #define CEPH_PG_MAX_SIZE 16 /* max # osds in a single pg */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * placement group. |
| 57 | * we encode this into one __le64. |
| 58 | */ |
Sage Weil | 12979354 | 2013-01-08 09:15:10 -0800 | [diff] [blame] | 59 | struct ceph_pg_v1 { |
Sage Weil | 5104212 | 2009-11-04 11:39:12 -0800 | [diff] [blame] | 60 | __le16 preferred; /* preferred primary osd */ |
| 61 | __le16 ps; /* placement seed */ |
| 62 | __le32 pool; /* object pool */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 63 | } __attribute__ ((packed)); |
| 64 | |
| 65 | /* |
| 66 | * pg_pool is a set of pgs storing a pool of objects |
| 67 | * |
| 68 | * pg_num -- base number of pseudorandomly placed pgs |
| 69 | * |
| 70 | * pgp_num -- effective number when calculating pg placement. this |
| 71 | * is used for pg_num increases. new pgs result in data being "split" |
| 72 | * into new pgs. for this to proceed smoothly, new pgs are intiially |
| 73 | * colocated with their parents; that is, pgp_num doesn't increase |
| 74 | * until the new pgs have successfully split. only _then_ are the new |
| 75 | * pgs placed independently. |
| 76 | * |
| 77 | * lpg_num -- localized pg count (per device). replicas are randomly |
| 78 | * selected. |
| 79 | * |
| 80 | * lpgp_num -- as above. |
| 81 | */ |
Alex Elder | 86b00e0 | 2012-10-25 23:34:42 -0500 | [diff] [blame] | 82 | #define CEPH_NOPOOL ((__u64) (-1)) /* pool id not defined */ |
| 83 | |
Ilya Dryomov | 2abebdb | 2014-03-24 17:12:47 +0200 | [diff] [blame] | 84 | #define CEPH_POOL_TYPE_REP 1 |
| 85 | #define CEPH_POOL_TYPE_RAID4 2 /* never implemented */ |
| 86 | #define CEPH_POOL_TYPE_EC 3 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 87 | |
| 88 | /* |
| 89 | * stable_mod func is used to control number of placement groups. |
| 90 | * similar to straight-up modulo, but produces a stable mapping as b |
| 91 | * increases over time. b is the number of bins, and bmask is the |
| 92 | * containing power of 2 minus 1. |
| 93 | * |
| 94 | * b <= bmask and bmask=(2**n)-1 |
| 95 | * e.g., b=12 -> bmask=15, b=123 -> bmask=127 |
| 96 | */ |
| 97 | static inline int ceph_stable_mod(int x, int b, int bmask) |
| 98 | { |
| 99 | if ((x & bmask) < b) |
| 100 | return x & bmask; |
| 101 | else |
| 102 | return x & (bmask >> 1); |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * object layout - how a given object should be stored. |
| 107 | */ |
| 108 | struct ceph_object_layout { |
Sage Weil | 12979354 | 2013-01-08 09:15:10 -0800 | [diff] [blame] | 109 | struct ceph_pg_v1 ol_pgid; /* raw pg, with _full_ ps precision. */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 110 | __le32 ol_stripe_unit; /* for per-object parity, if any */ |
| 111 | } __attribute__ ((packed)); |
| 112 | |
| 113 | /* |
| 114 | * compound epoch+version, used by storage layer to serialize mutations |
| 115 | */ |
| 116 | struct ceph_eversion { |
| 117 | __le32 epoch; |
| 118 | __le64 version; |
| 119 | } __attribute__ ((packed)); |
| 120 | |
| 121 | /* |
| 122 | * osd map bits |
| 123 | */ |
| 124 | |
| 125 | /* status bits */ |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 126 | #define CEPH_OSD_EXISTS (1<<0) |
| 127 | #define CEPH_OSD_UP (1<<1) |
| 128 | #define CEPH_OSD_AUTOOUT (1<<2) /* osd was automatically marked out */ |
| 129 | #define CEPH_OSD_NEW (1<<3) /* osd is new, never marked in */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 130 | |
Alex Elder | 4b568b1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 131 | extern const char *ceph_osd_state_name(int s); |
| 132 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 133 | /* osd weights. fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */ |
| 134 | #define CEPH_OSD_IN 0x10000 |
| 135 | #define CEPH_OSD_OUT 0 |
| 136 | |
Ilya Dryomov | 2cfa34f | 2014-03-21 19:05:30 +0200 | [diff] [blame] | 137 | /* osd primary-affinity. fixed point value: 0x10000 == baseline */ |
| 138 | #define CEPH_OSD_MAX_PRIMARY_AFFINITY 0x10000 |
| 139 | #define CEPH_OSD_DEFAULT_PRIMARY_AFFINITY 0x10000 |
| 140 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 141 | |
| 142 | /* |
| 143 | * osd map flag bits |
| 144 | */ |
| 145 | #define CEPH_OSDMAP_NEARFULL (1<<0) /* sync writes (near ENOSPC) */ |
| 146 | #define CEPH_OSDMAP_FULL (1<<1) /* no data writes (ENOSPC) */ |
| 147 | #define CEPH_OSDMAP_PAUSERD (1<<2) /* pause all reads */ |
| 148 | #define CEPH_OSDMAP_PAUSEWR (1<<3) /* pause all writes */ |
| 149 | #define CEPH_OSDMAP_PAUSEREC (1<<4) /* pause recovery */ |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 150 | #define CEPH_OSDMAP_NOUP (1<<5) /* block osd boot */ |
| 151 | #define CEPH_OSDMAP_NODOWN (1<<6) /* block osd mark-down/failure */ |
| 152 | #define CEPH_OSDMAP_NOOUT (1<<7) /* block osd auto mark-out */ |
| 153 | #define CEPH_OSDMAP_NOIN (1<<8) /* block osd auto mark-in */ |
| 154 | #define CEPH_OSDMAP_NOBACKFILL (1<<9) /* block osd backfill */ |
| 155 | #define CEPH_OSDMAP_NORECOVER (1<<10) /* block osd recovery and backfill */ |
| 156 | |
| 157 | /* |
| 158 | * The error code to return when an OSD can't handle a write |
| 159 | * because it is too large. |
| 160 | */ |
| 161 | #define OSD_WRITETOOBIG EMSGSIZE |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 162 | |
| 163 | /* |
| 164 | * osd ops |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 165 | * |
| 166 | * WARNING: do not use these op codes directly. Use the helpers |
| 167 | * defined below instead. In certain cases, op code behavior was |
| 168 | * redefined, resulting in special-cases in the helpers. |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 169 | */ |
| 170 | #define CEPH_OSD_OP_MODE 0xf000 |
| 171 | #define CEPH_OSD_OP_MODE_RD 0x1000 |
| 172 | #define CEPH_OSD_OP_MODE_WR 0x2000 |
| 173 | #define CEPH_OSD_OP_MODE_RMW 0x3000 |
| 174 | #define CEPH_OSD_OP_MODE_SUB 0x4000 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 175 | |
| 176 | #define CEPH_OSD_OP_TYPE 0x0f00 |
| 177 | #define CEPH_OSD_OP_TYPE_LOCK 0x0100 |
| 178 | #define CEPH_OSD_OP_TYPE_DATA 0x0200 |
| 179 | #define CEPH_OSD_OP_TYPE_ATTR 0x0300 |
| 180 | #define CEPH_OSD_OP_TYPE_EXEC 0x0400 |
| 181 | #define CEPH_OSD_OP_TYPE_PG 0x0500 |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 182 | #define CEPH_OSD_OP_TYPE_MULTI 0x0600 /* multiobject */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 183 | |
| 184 | enum { |
| 185 | /** data **/ |
| 186 | /* read */ |
| 187 | CEPH_OSD_OP_READ = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 1, |
| 188 | CEPH_OSD_OP_STAT = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 2, |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 189 | CEPH_OSD_OP_MAPEXT = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 3, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 190 | |
| 191 | /* fancy read */ |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 192 | CEPH_OSD_OP_MASKTRUNC = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 4, |
| 193 | CEPH_OSD_OP_SPARSE_READ = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 5, |
| 194 | |
| 195 | CEPH_OSD_OP_NOTIFY = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 6, |
| 196 | CEPH_OSD_OP_NOTIFY_ACK = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 7, |
| 197 | |
| 198 | /* versioning */ |
| 199 | CEPH_OSD_OP_ASSERT_VER = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 8, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 200 | |
| 201 | /* write */ |
| 202 | CEPH_OSD_OP_WRITE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 1, |
| 203 | CEPH_OSD_OP_WRITEFULL = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 2, |
| 204 | CEPH_OSD_OP_TRUNCATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 3, |
| 205 | CEPH_OSD_OP_ZERO = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 4, |
| 206 | CEPH_OSD_OP_DELETE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 5, |
| 207 | |
| 208 | /* fancy write */ |
| 209 | CEPH_OSD_OP_APPEND = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 6, |
| 210 | CEPH_OSD_OP_STARTSYNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 7, |
| 211 | CEPH_OSD_OP_SETTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 8, |
| 212 | CEPH_OSD_OP_TRIMTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 9, |
| 213 | |
| 214 | CEPH_OSD_OP_TMAPUP = CEPH_OSD_OP_MODE_RMW | CEPH_OSD_OP_TYPE_DATA | 10, |
| 215 | CEPH_OSD_OP_TMAPPUT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 11, |
| 216 | CEPH_OSD_OP_TMAPGET = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 12, |
| 217 | |
| 218 | CEPH_OSD_OP_CREATE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 13, |
Sage Weil | f0b18d9 | 2010-07-07 08:39:03 -0700 | [diff] [blame] | 219 | CEPH_OSD_OP_ROLLBACK= CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 14, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 220 | |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 221 | CEPH_OSD_OP_WATCH = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 15, |
| 222 | |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 223 | /* omap */ |
| 224 | CEPH_OSD_OP_OMAPGETKEYS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 17, |
| 225 | CEPH_OSD_OP_OMAPGETVALS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 18, |
| 226 | CEPH_OSD_OP_OMAPGETHEADER = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 19, |
| 227 | CEPH_OSD_OP_OMAPGETVALSBYKEYS = |
| 228 | CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 20, |
| 229 | CEPH_OSD_OP_OMAPSETVALS = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 21, |
| 230 | CEPH_OSD_OP_OMAPSETHEADER = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 22, |
| 231 | CEPH_OSD_OP_OMAPCLEAR = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 23, |
| 232 | CEPH_OSD_OP_OMAPRMKEYS = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 24, |
| 233 | CEPH_OSD_OP_OMAP_CMP = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 25, |
| 234 | |
Ilya Dryomov | c647b8a | 2014-02-25 16:22:27 +0200 | [diff] [blame] | 235 | /* hints */ |
| 236 | CEPH_OSD_OP_SETALLOCHINT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 35, |
| 237 | |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 238 | /** multi **/ |
| 239 | CEPH_OSD_OP_CLONERANGE = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_MULTI | 1, |
| 240 | CEPH_OSD_OP_ASSERT_SRC_VERSION = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_MULTI | 2, |
| 241 | CEPH_OSD_OP_SRC_CMPXATTR = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_MULTI | 3, |
| 242 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 243 | /** attrs **/ |
| 244 | /* read */ |
| 245 | CEPH_OSD_OP_GETXATTR = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 1, |
| 246 | CEPH_OSD_OP_GETXATTRS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 2, |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 247 | CEPH_OSD_OP_CMPXATTR = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 3, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 248 | |
| 249 | /* write */ |
| 250 | CEPH_OSD_OP_SETXATTR = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 1, |
| 251 | CEPH_OSD_OP_SETXATTRS = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 2, |
| 252 | CEPH_OSD_OP_RESETXATTRS = CEPH_OSD_OP_MODE_WR|CEPH_OSD_OP_TYPE_ATTR | 3, |
| 253 | CEPH_OSD_OP_RMXATTR = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 4, |
| 254 | |
| 255 | /** subop **/ |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 256 | CEPH_OSD_OP_PULL = CEPH_OSD_OP_MODE_SUB | 1, |
| 257 | CEPH_OSD_OP_PUSH = CEPH_OSD_OP_MODE_SUB | 2, |
| 258 | CEPH_OSD_OP_BALANCEREADS = CEPH_OSD_OP_MODE_SUB | 3, |
| 259 | CEPH_OSD_OP_UNBALANCEREADS = CEPH_OSD_OP_MODE_SUB | 4, |
| 260 | CEPH_OSD_OP_SCRUB = CEPH_OSD_OP_MODE_SUB | 5, |
| 261 | CEPH_OSD_OP_SCRUB_RESERVE = CEPH_OSD_OP_MODE_SUB | 6, |
| 262 | CEPH_OSD_OP_SCRUB_UNRESERVE = CEPH_OSD_OP_MODE_SUB | 7, |
| 263 | CEPH_OSD_OP_SCRUB_STOP = CEPH_OSD_OP_MODE_SUB | 8, |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 264 | CEPH_OSD_OP_SCRUB_MAP = CEPH_OSD_OP_MODE_SUB | 9, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 265 | |
| 266 | /** lock **/ |
| 267 | CEPH_OSD_OP_WRLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 1, |
| 268 | CEPH_OSD_OP_WRUNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 2, |
| 269 | CEPH_OSD_OP_RDLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 3, |
| 270 | CEPH_OSD_OP_RDUNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 4, |
| 271 | CEPH_OSD_OP_UPLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 5, |
| 272 | CEPH_OSD_OP_DNLOCK = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 6, |
| 273 | |
| 274 | /** exec **/ |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 275 | /* note: the RD bit here is wrong; see special-case below in helper */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 276 | CEPH_OSD_OP_CALL = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_EXEC | 1, |
| 277 | |
| 278 | /** pg **/ |
| 279 | CEPH_OSD_OP_PGLS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_PG | 1, |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 280 | CEPH_OSD_OP_PGLS_FILTER = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_PG | 2, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | static inline int ceph_osd_op_type_lock(int op) |
| 284 | { |
| 285 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK; |
| 286 | } |
| 287 | static inline int ceph_osd_op_type_data(int op) |
| 288 | { |
| 289 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA; |
| 290 | } |
| 291 | static inline int ceph_osd_op_type_attr(int op) |
| 292 | { |
| 293 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR; |
| 294 | } |
| 295 | static inline int ceph_osd_op_type_exec(int op) |
| 296 | { |
| 297 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC; |
| 298 | } |
| 299 | static inline int ceph_osd_op_type_pg(int op) |
| 300 | { |
| 301 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG; |
| 302 | } |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 303 | static inline int ceph_osd_op_type_multi(int op) |
| 304 | { |
| 305 | return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_MULTI; |
| 306 | } |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 307 | |
| 308 | static inline int ceph_osd_op_mode_subop(int op) |
| 309 | { |
| 310 | return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB; |
| 311 | } |
| 312 | static inline int ceph_osd_op_mode_read(int op) |
| 313 | { |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 314 | return (op & CEPH_OSD_OP_MODE_RD) && |
| 315 | op != CEPH_OSD_OP_CALL; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 316 | } |
| 317 | static inline int ceph_osd_op_mode_modify(int op) |
| 318 | { |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 319 | return op & CEPH_OSD_OP_MODE_WR; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Sage Weil | f0b18d9 | 2010-07-07 08:39:03 -0700 | [diff] [blame] | 322 | /* |
| 323 | * note that the following tmap stuff is also defined in the ceph librados.h |
| 324 | * any modification here needs to be updated there |
| 325 | */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 326 | #define CEPH_OSD_TMAP_HDR 'h' |
| 327 | #define CEPH_OSD_TMAP_SET 's' |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 328 | #define CEPH_OSD_TMAP_CREATE 'c' /* create key */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 329 | #define CEPH_OSD_TMAP_RM 'r' |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 330 | #define CEPH_OSD_TMAP_RMSLOPPY 'R' |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 331 | |
| 332 | extern const char *ceph_osd_op_name(int op); |
| 333 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 334 | /* |
| 335 | * osd op flags |
| 336 | * |
| 337 | * An op may be READ, WRITE, or READ|WRITE. |
| 338 | */ |
| 339 | enum { |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 340 | CEPH_OSD_FLAG_ACK = 0x0001, /* want (or is) "ack" ack */ |
| 341 | CEPH_OSD_FLAG_ONNVRAM = 0x0002, /* want (or is) "onnvram" ack */ |
| 342 | CEPH_OSD_FLAG_ONDISK = 0x0004, /* want (or is) "ondisk" ack */ |
| 343 | CEPH_OSD_FLAG_RETRY = 0x0008, /* resend attempt */ |
| 344 | CEPH_OSD_FLAG_READ = 0x0010, /* op may read */ |
| 345 | CEPH_OSD_FLAG_WRITE = 0x0020, /* op may write */ |
| 346 | CEPH_OSD_FLAG_ORDERSNAP = 0x0040, /* EOLDSNAP if snapc is out of order */ |
| 347 | CEPH_OSD_FLAG_PEERSTAT_OLD = 0x0080, /* DEPRECATED msg includes osd_peer_stat */ |
| 348 | CEPH_OSD_FLAG_BALANCE_READS = 0x0100, |
| 349 | CEPH_OSD_FLAG_PARALLELEXEC = 0x0200, /* execute op in parallel */ |
| 350 | CEPH_OSD_FLAG_PGOP = 0x0400, /* pg op, no object */ |
| 351 | CEPH_OSD_FLAG_EXEC = 0x0800, /* op may exec */ |
| 352 | CEPH_OSD_FLAG_EXEC_PUBLIC = 0x1000, /* DEPRECATED op may exec (public) */ |
| 353 | CEPH_OSD_FLAG_LOCALIZE_READS = 0x2000, /* read from nearby replica, if any */ |
| 354 | CEPH_OSD_FLAG_RWORDERED = 0x4000, /* order wrt concurrent reads */ |
Ilya Dryomov | 1b3f2ab | 2014-01-27 17:40:19 +0200 | [diff] [blame] | 355 | CEPH_OSD_FLAG_IGNORE_CACHE = 0x8000, /* ignore cache logic */ |
| 356 | CEPH_OSD_FLAG_SKIPRWLOCKS = 0x10000, /* skip rw locks */ |
| 357 | CEPH_OSD_FLAG_IGNORE_OVERLAY = 0x20000, /* ignore pool overlay */ |
| 358 | CEPH_OSD_FLAG_FLUSH = 0x40000, /* this is part of flush */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 359 | }; |
| 360 | |
| 361 | enum { |
| 362 | CEPH_OSD_OP_FLAG_EXCL = 1, /* EXCL object create */ |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 363 | CEPH_OSD_OP_FLAG_FAILOK = 2, /* continue despite failure */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 364 | }; |
| 365 | |
| 366 | #define EOLDSNAPC ERESTART /* ORDERSNAP flag set; writer has old snapc*/ |
| 367 | #define EBLACKLISTED ESHUTDOWN /* blacklisted */ |
| 368 | |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 369 | /* xattr comparison */ |
| 370 | enum { |
| 371 | CEPH_OSD_CMPXATTR_OP_NOP = 0, |
| 372 | CEPH_OSD_CMPXATTR_OP_EQ = 1, |
| 373 | CEPH_OSD_CMPXATTR_OP_NE = 2, |
| 374 | CEPH_OSD_CMPXATTR_OP_GT = 3, |
| 375 | CEPH_OSD_CMPXATTR_OP_GTE = 4, |
| 376 | CEPH_OSD_CMPXATTR_OP_LT = 5, |
| 377 | CEPH_OSD_CMPXATTR_OP_LTE = 6 |
| 378 | }; |
| 379 | |
| 380 | enum { |
| 381 | CEPH_OSD_CMPXATTR_MODE_STRING = 1, |
| 382 | CEPH_OSD_CMPXATTR_MODE_U64 = 2 |
| 383 | }; |
| 384 | |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 385 | #define RADOS_NOTIFY_VER 1 |
| 386 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 387 | /* |
| 388 | * an individual object operation. each may be accompanied by some data |
| 389 | * payload |
| 390 | */ |
| 391 | struct ceph_osd_op { |
| 392 | __le16 op; /* CEPH_OSD_OP_* */ |
Ilya Dryomov | 7b25bf5 | 2014-02-25 16:22:26 +0200 | [diff] [blame] | 393 | __le32 flags; /* CEPH_OSD_OP_FLAG_* */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 394 | union { |
| 395 | struct { |
| 396 | __le64 offset, length; |
Yehuda Sadeh | 0c94899 | 2010-02-01 16:10:45 -0800 | [diff] [blame] | 397 | __le64 truncate_size; |
| 398 | __le32 truncate_seq; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 399 | } __attribute__ ((packed)) extent; |
| 400 | struct { |
| 401 | __le32 name_len; |
| 402 | __le32 value_len; |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 403 | __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ |
| 404 | __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 405 | } __attribute__ ((packed)) xattr; |
| 406 | struct { |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 407 | __u8 class_len; |
| 408 | __u8 method_len; |
| 409 | __u8 argc; |
| 410 | __le32 indata_len; |
| 411 | } __attribute__ ((packed)) cls; |
| 412 | struct { |
| 413 | __le64 cookie, count; |
| 414 | } __attribute__ ((packed)) pgls; |
Sage Weil | f0b18d9 | 2010-07-07 08:39:03 -0700 | [diff] [blame] | 415 | struct { |
| 416 | __le64 snapid; |
| 417 | } __attribute__ ((packed)) snap; |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 418 | struct { |
| 419 | __le64 cookie; |
| 420 | __le64 ver; |
| 421 | __u8 flag; /* 0 = unwatch, 1 = watch */ |
| 422 | } __attribute__ ((packed)) watch; |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 423 | struct { |
| 424 | __le64 offset, length; |
| 425 | __le64 src_offset; |
| 426 | } __attribute__ ((packed)) clonerange; |
Ilya Dryomov | c647b8a | 2014-02-25 16:22:27 +0200 | [diff] [blame] | 427 | struct { |
| 428 | __le64 expected_object_size; |
| 429 | __le64 expected_write_size; |
| 430 | } __attribute__ ((packed)) alloc_hint; |
Alex Elder | 0315a77 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 431 | }; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 432 | __le32 payload_len; |
| 433 | } __attribute__ ((packed)); |
| 434 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 435 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 436 | #endif |