dataOperationOfSprayTerminal.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * blk-integrity.c - Block layer data integrity extensions
  3. *
  4. * Copyright (C) 2007, 2008 Oracle Corporation
  5. * Written by: Martin K. Petersen <martin.petersen@oracle.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; see the file COPYING. If not, write to
  18. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  19. * USA.
  20. *
  21. */
  22. #include <linux/blkdev.h>
  23. #include <linux/mempool.h>
  24. #include <linux/bio.h>
  25. #include <linux/scatterlist.h>
  26. #include <linux/export.h>
  27. #include <linux/slab.h>
  28. #include "blk.h"
  29. static struct kmem_cache *integrity_cachep;
  30. static const char *bi_unsupported_name = "unsupported";
  31. /**
  32. * blk_rq_count_integrity_sg - Count number of integrity scatterlist elements
  33. * @q: request queue
  34. * @bio: bio with integrity metadata attached
  35. *
  36. * Description: Returns the number of elements required in a
  37. * scatterlist corresponding to the integrity metadata in a bio.
  38. */
  39. int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
  40. {
  41. struct bio_vec *iv, *ivprv = NULL;
  42. unsigned int segments = 0;
  43. unsigned int seg_size = 0;
  44. unsigned int i = 0;
  45. bio_for_each_integrity_vec(iv, bio, i) {
  46. if (ivprv) {
  47. if (!BIOVEC_PHYS_MERGEABLE(ivprv, iv))