rbd_types.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_DATA_PREFIX "rbd_data."
  25. #define RBD_ID_PREFIX "rbd_id."
  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>.00000000
  39. * rb.<idhi>.<idlo>.00000001
  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_DIRECTORY "rbd_directory"
  45. #define RBD_INFO "rbd_info"
  46. #define RBD_DEFAULT_OBJ_ORDER 22 /* 4MB */
  47. #define RBD_MIN_OBJ_ORDER 16
  48. #define RBD_MAX_OBJ_ORDER 30
  49. #define RBD_COMP_NONE 0
  50. #define RBD_CRYPT_NONE 0
  51. #define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
  52. #define RBD_HEADER_SIGNATURE "RBD"
  53. #define RBD_HEADER_VERSION "001.005"
  54. struct rbd_image_snap_ondisk {
  55. __le64 id;
  56. __le64 image_size;
  57. } __attribute__((packed));
  58. struct rbd_image_header_ondisk {
  59. char text[40];
  60. char object_prefix[24];
  61. char signature[4];
  62. char version[8];
  63. struct {
  64. __u8 order;
  65. __u8 crypt_type;
  66. __u8 comp_type;
  67. __u8 unused;
  68. } __attribute__((packed)) options;
  69. __le64 image_size;
  70. __le64 snap_seq;
  71. __le32 snap_count;
  72. __le32 reserved;
  73. __le64 snap_names_len;
  74. struct rbd_image_snap_ondisk snaps[0];
  75. } __attribute__((packed));
  76. #endif