rbd_types.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Ceph - scalable distributed file system
  3. *
  4. * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
  5. *
  6. * This is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License version 2.1, as published by the Free Software
  9. * Foundation. See file COPYING.
  10. *
  11. */
  12. #ifndef CEPH_RBD_TYPES_H
  13. #define CEPH_RBD_TYPES_H
  14. #include <linux/types.h>
  15. /* For format version 2, rbd image 'foo' consists of objects
  16. * rbd_id.foo - id of image
  17. * rbd_header.<id> - image metadata
  18. * rbd_data.<id>.0000000000000000
  19. * rbd_data.<id>.0000000000000001
  20. * ... - data
  21. * Clients do not access header data directly in rbd format 2.
  22. */
  23. #define RBD_HEADER_PREFIX "rbd_header."
  24. #define RBD_ID_PREFIX "rbd_id."
  25. #define RBD_V2_DATA_FORMAT "%s.%016llx"
  26. #define RBD_LOCK_NAME "rbd_lock"
  27. #define RBD_LOCK_TAG "internal"
  28. #define RBD_LOCK_COOKIE_PREFIX "auto"
  29. enum rbd_notify_op {
  30. RBD_NOTIFY_OP_ACQUIRED_LOCK = 0,
  31. RBD_NOTIFY_OP_RELEASED_LOCK = 1,
  32. RBD_NOTIFY_OP_REQUEST_LOCK = 2,
  33. RBD_NOTIFY_OP_HEADER_UPDATE = 3,
  34. };
  35. /*
  36. * For format version 1, rbd image 'foo' consists of objects
  37. * foo.rbd - image metadata
  38. * rb.<idhi>.<idlo>.<extra>.000000000000
  39. * rb.<idhi>.<idlo>.<extra>.000000000001
  40. * ... - data
  41. * There is no notion of a persistent image id in rbd format 1.
  42. */
  43. #define RBD_SUFFIX ".rbd"
  44. #define RBD_V1_DATA_FORMAT "%s.%012llx"
  45. #define RBD_DIRECTORY "rbd_directory"
  46. #define RBD_INFO "rbd_info"
  47. #define RBD_DEFAULT_OBJ_ORDER 22 /* 4MB */
  48. #define RBD_MIN_OBJ_ORDER 16
  49. #define RBD_MAX_OBJ_ORDER 30
  50. #define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
  51. #define RBD_HEADER_SIGNATURE "RBD"
  52. #define RBD_HEADER_VERSION "001.005"
  53. struct rbd_image_snap_ondisk {
  54. __le64 id;
  55. __le64 image_size;
  56. } __attribute__((packed));
  57. struct rbd_image_header_ondisk {
  58. char text[40];
  59. char object_prefix[24];
  60. char signature[4];
  61. char version[8];
  62. struct {
  63. __u8 order;
  64. __u8 crypt_type;
  65. __u8 comp_type;
  66. __u8 unused;
  67. } __attribute__((packed)) options;
  68. __le64 image_size;
  69. __le64 snap_seq;
  70. __le32 snap_count;
  71. __le32 reserved;
  72. __le64 snap_names_len;
  73. struct rbd_image_snap_ondisk snaps[0];
  74. } __attribute__((packed));
  75. #endif