summaryrefslogtreecommitdiffstats
path: root/include/linux/nbd.h
diff options
context:
space:
mode:
authorPaul Clements <paul.clements@steeleye.com>2012-10-04 17:16:18 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-06 03:05:24 +0900
commita336d29870f8a1f8e5f10d9f1aa95531c4edeabe (patch)
tree9957b7a2dbdc5047fe1f2be7907f90f5bdb6fbf0 /include/linux/nbd.h
parent2f012508880f8037590372c24ca6e8b6af8fffb6 (diff)
nbd: handle discard requests
Add discard support to nbd. If the nbd-server supports discard, it will send NBD_FLAG_SEND_TRIM to the client. The client will then set the flag in the kernel via NBD_SET_FLAGS, which tells the kernel to enable discards for the device (QUEUE_FLAG_DISCARD). If discard support is enabled, then when the nbd client system receives a discard request, this will be passed along to the nbd-server. When the discard request is received by the nbd-server, it will perform: fallocate(.. FALLOC_FL_PUNCH_HOLE ..) To punch a hole in the backend storage, which is no longer needed. Signed-off-by: Paul Clements <paul.clements@steeleye.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/nbd.h')
-rw-r--r--include/linux/nbd.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index 4b8ed5a1cfb..5c86e2b33e2 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -32,12 +32,16 @@
enum {
NBD_CMD_READ = 0,
NBD_CMD_WRITE = 1,
- NBD_CMD_DISC = 2
+ NBD_CMD_DISC = 2,
+ /* there is a gap here to match userspace */
+ NBD_CMD_TRIM = 4
};
/* values for flags field */
#define NBD_FLAG_HAS_FLAGS (1 << 0) /* nbd-server supports flags */
#define NBD_FLAG_READ_ONLY (1 << 1) /* device is read-only */
+/* there is a gap here to match userspace */
+#define NBD_FLAG_SEND_TRIM (1 << 5) /* send trim/discard */
#define nbd_cmd(req) ((req)->cmd[0])