Merge tag 'xfs-for-linus-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / block / drbd / drbd_protocol.h
index ef9245363dccc6183e680083d764404e2e6acd16..4d296800f70680dd8dba0219d12c301e3e375bf7 100644 (file)
@@ -60,6 +60,15 @@ enum drbd_packet {
         * which is why I chose TRIM here, to disambiguate. */
        P_TRIM                = 0x31,
 
+       /* Only use these two if both support FF_THIN_RESYNC */
+       P_RS_THIN_REQ         = 0x32, /* Request a block for resync or reply P_RS_DEALLOCATED */
+       P_RS_DEALLOCATED      = 0x33, /* Contains only zeros on sync source node */
+
+       /* REQ_WRITE_SAME.
+        * On a receiving side without REQ_WRITE_SAME,
+        * we may fall back to an opencoded loop instead. */
+       P_WSAME               = 0x34,
+
        P_MAY_IGNORE          = 0x100, /* Flag to test if (cmd > P_MAY_IGNORE) ... */
        P_MAX_OPT_CMD         = 0x101,
 
@@ -106,16 +115,20 @@ struct p_header100 {
        u32       pad;
 } __packed;
 
-/* these defines must not be changed without changing the protocol version */
-#define DP_HARDBARRIER       1 /* depricated */
+/* These defines must not be changed without changing the protocol version.
+ * New defines may only be introduced together with protocol version bump or
+ * new protocol feature flags.
+ */
+#define DP_HARDBARRIER       1 /* no longer used */
 #define DP_RW_SYNC           2 /* equals REQ_SYNC    */
 #define DP_MAY_SET_IN_SYNC    4
 #define DP_UNPLUG             8 /* not used anymore   */
 #define DP_FUA               16 /* equals REQ_FUA     */
-#define DP_FLUSH             32 /* equals REQ_FLUSH   */
+#define DP_FLUSH             32 /* equals REQ_PREFLUSH   */
 #define DP_DISCARD           64 /* equals REQ_DISCARD */
 #define DP_SEND_RECEIVE_ACK 128 /* This is a proto B write request */
 #define DP_SEND_WRITE_ACK   256 /* This is a proto C write request */
+#define DP_WSAME            512 /* equiv. REQ_WRITE_SAME */
 
 struct p_data {
        u64         sector;    /* 64 bits sector number */
@@ -129,6 +142,11 @@ struct p_trim {
        u32         size;       /* == bio->bi_size */
 } __packed;
 
+struct p_wsame {
+       struct p_data p_data;
+       u32           size;     /* == bio->bi_size */
+} __packed;
+
 /*
  * commands which share a struct:
  *  p_block_ack:
@@ -160,7 +178,23 @@ struct p_block_req {
  *   ReportParams
  */
 
-#define FF_TRIM      1
+/* supports TRIM/DISCARD on the "wire" protocol */
+#define DRBD_FF_TRIM 1
+
+/* Detect all-zeros during resync, and rather TRIM/UNMAP/DISCARD those blocks
+ * instead of fully allocate a supposedly thin volume on initial resync */
+#define DRBD_FF_THIN_RESYNC 2
+
+/* supports REQ_WRITE_SAME on the "wire" protocol.
+ * Note: this flag is overloaded,
+ * its presence also
+ *   - indicates support for 128 MiB "batch bios",
+ *     max discard size of 128 MiB
+ *     instead of 4M before that.
+ *   - indicates that we exchange additional settings in p_sizes
+ *     drbd_send_sizes()/receive_sizes()
+ */
+#define DRBD_FF_WSAME 4
 
 struct p_connection_features {
        u32 protocol_min;
@@ -235,6 +269,40 @@ struct p_rs_uuid {
        u64         uuid;
 } __packed;
 
+/* optional queue_limits if (agreed_features & DRBD_FF_WSAME)
+ * see also struct queue_limits, as of late 2015 */
+struct o_qlim {
+       /* we don't need it yet, but we may as well communicate it now */
+       u32 physical_block_size;
+
+       /* so the original in struct queue_limits is unsigned short,
+        * but I'd have to put in padding anyways. */
+       u32 logical_block_size;
+
+       /* One incoming bio becomes one DRBD request,
+        * which may be translated to several bio on the receiving side.
+        * We don't need to communicate chunk/boundary/segment ... limits.
+        */
+
+       /* various IO hints may be useful with "diskless client" setups */
+       u32 alignment_offset;
+       u32 io_min;
+       u32 io_opt;
+
+       /* We may need to communicate integrity stuff at some point,
+        * but let's not get ahead of ourselves. */
+
+       /* Backend discard capabilities.
+        * Receiving side uses "blkdev_issue_discard()", no need to communicate
+        * more specifics.  If the backend cannot do discards, the DRBD peer
+        * may fall back to blkdev_issue_zeroout().
+        */
+       u8 discard_enabled;
+       u8 discard_zeroes_data;
+       u8 write_same_capable;
+       u8 _pad;
+} __packed;
+
 struct p_sizes {
        u64         d_size;  /* size of disk */
        u64         u_size;  /* user requested size */
@@ -242,6 +310,9 @@ struct p_sizes {
        u32         max_bio_size;  /* Maximal size of a BIO */
        u16         queue_order_type;  /* not yet implemented in DRBD*/
        u16         dds_flags; /* use enum dds_flags here. */
+
+       /* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */
+       struct o_qlim qlim[0];
 } __packed;
 
 struct p_state {