|
@@ -0,0 +1,54 @@
|
|
|
+/*
|
|
|
+ * blk-integrity.c - Block layer data integrity extensions
|
|
|
+ *
|
|
|
+ * Copyright (C) 2007, 2008 Oracle Corporation
|
|
|
+ * Written by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
+ *
|
|
|
+ * This program is free software; you can redistribute it and/or
|
|
|
+ * modify it under the terms of the GNU General Public License version
|
|
|
+ * 2 as published by the Free Software Foundation.
|
|
|
+ *
|
|
|
+ * This program is distributed in the hope that it will be useful, but
|
|
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
+ * General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program; see the file COPYING. If not, write to
|
|
|
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
|
|
|
+ * USA.
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+#include <linux/blkdev.h>
|
|
|
+#include <linux/mempool.h>
|
|
|
+#include <linux/bio.h>
|
|
|
+#include <linux/scatterlist.h>
|
|
|
+#include <linux/export.h>
|
|
|
+#include <linux/slab.h>
|
|
|
+
|
|
|
+#include "blk.h"
|
|
|
+
|
|
|
+static struct kmem_cache *integrity_cachep;
|
|
|
+
|
|
|
+static const char *bi_unsupported_name = "unsupported";
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_rq_count_integrity_sg - Count number of integrity scatterlist elements
|
|
|
+ * @q: request queue
|
|
|
+ * @bio: bio with integrity metadata attached
|
|
|
+ *
|
|
|
+ * Description: Returns the number of elements required in a
|
|
|
+ * scatterlist corresponding to the integrity metadata in a bio.
|
|
|
+ */
|
|
|
+int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
|
|
|
+{
|
|
|
+ struct bio_vec *iv, *ivprv = NULL;
|
|
|
+ unsigned int segments = 0;
|
|
|
+ unsigned int seg_size = 0;
|
|
|
+ unsigned int i = 0;
|
|
|
+
|
|
|
+ bio_for_each_integrity_vec(iv, bio, i) {
|
|
|
+
|
|
|
+ if (ivprv) {
|
|
|
+ if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv))
|