Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Ceph - scalable distributed file system
0003  *
0004  * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
0005  *
0006  * This is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License version 2.1, as published by the Free Software
0009  * Foundation.  See file COPYING.
0010  *
0011  */
0012 
0013 #ifndef CEPH_RBD_TYPES_H
0014 #define CEPH_RBD_TYPES_H
0015 
0016 #include <linux/types.h>
0017 
0018 /* For format version 2, rbd image 'foo' consists of objects
0019  *   rbd_id.foo     - id of image
0020  *   rbd_header.<id>    - image metadata
0021  *   rbd_object_map.<id> - optional image object map
0022  *   rbd_data.<id>.0000000000000000
0023  *   rbd_data.<id>.0000000000000001
0024  *   ...        - data
0025  * Clients do not access header data directly in rbd format 2.
0026  */
0027 
0028 #define RBD_HEADER_PREFIX      "rbd_header."
0029 #define RBD_OBJECT_MAP_PREFIX  "rbd_object_map."
0030 #define RBD_ID_PREFIX          "rbd_id."
0031 #define RBD_V2_DATA_FORMAT     "%s.%016llx"
0032 
0033 #define RBD_LOCK_NAME          "rbd_lock"
0034 #define RBD_LOCK_TAG           "internal"
0035 #define RBD_LOCK_COOKIE_PREFIX "auto"
0036 
0037 enum rbd_notify_op {
0038     RBD_NOTIFY_OP_ACQUIRED_LOCK      = 0,
0039     RBD_NOTIFY_OP_RELEASED_LOCK      = 1,
0040     RBD_NOTIFY_OP_REQUEST_LOCK       = 2,
0041     RBD_NOTIFY_OP_HEADER_UPDATE      = 3,
0042 };
0043 
0044 #define OBJECT_NONEXISTENT  0
0045 #define OBJECT_EXISTS       1
0046 #define OBJECT_PENDING      2
0047 #define OBJECT_EXISTS_CLEAN 3
0048 
0049 #define RBD_FLAG_OBJECT_MAP_INVALID (1ULL << 0)
0050 #define RBD_FLAG_FAST_DIFF_INVALID  (1ULL << 1)
0051 
0052 /*
0053  * For format version 1, rbd image 'foo' consists of objects
0054  *   foo.rbd        - image metadata
0055  *   rb.<idhi>.<idlo>.<extra>.000000000000
0056  *   rb.<idhi>.<idlo>.<extra>.000000000001
0057  *   ...        - data
0058  * There is no notion of a persistent image id in rbd format 1.
0059  */
0060 
0061 #define RBD_SUFFIX      ".rbd"
0062 #define RBD_V1_DATA_FORMAT  "%s.%012llx"
0063 
0064 #define RBD_DIRECTORY           "rbd_directory"
0065 #define RBD_INFO                "rbd_info"
0066 
0067 #define RBD_DEFAULT_OBJ_ORDER   22   /* 4MB */
0068 #define RBD_MIN_OBJ_ORDER       16
0069 #define RBD_MAX_OBJ_ORDER       30
0070 
0071 #define RBD_HEADER_TEXT     "<<< Rados Block Device Image >>>\n"
0072 #define RBD_HEADER_SIGNATURE    "RBD"
0073 #define RBD_HEADER_VERSION  "001.005"
0074 
0075 struct rbd_image_snap_ondisk {
0076     __le64 id;
0077     __le64 image_size;
0078 } __attribute__((packed));
0079 
0080 struct rbd_image_header_ondisk {
0081     char text[40];
0082     char object_prefix[24];
0083     char signature[4];
0084     char version[8];
0085     struct {
0086         __u8 order;
0087         __u8 crypt_type;
0088         __u8 comp_type;
0089         __u8 unused;
0090     } __attribute__((packed)) options;
0091     __le64 image_size;
0092     __le64 snap_seq;
0093     __le32 snap_count;
0094     __le32 reserved;
0095     __le64 snap_names_len;
0096     struct rbd_image_snap_ondisk snaps[];
0097 } __attribute__((packed));
0098 
0099 
0100 #endif