blocklayout.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * linux/fs/nfs/blocklayout/blocklayout.c
  3. *
  4. * Module for the NFSv4.1 pNFS block layout driver.
  5. *
  6. * Copyright (c) 2006 The Regents of the University of Michigan.
  7. * All rights reserved.
  8. *
  9. * Andy Adamson <andros@citi.umich.edu>
  10. * Fred Isaman <iisaman@umich.edu>
  11. *
  12. * permission is granted to use, copy, create derivative works and
  13. * redistribute this software and such derivative works for any purpose,
  14. * so long as the name of the university of michigan is not used in
  15. * any advertising or publicity pertaining to the use or distribution
  16. * of this software without specific, written prior authorization. if
  17. * the above copyright notice or any other identification of the
  18. * university of michigan is included in any copy of any portion of
  19. * this software, then the disclaimer below must also be included.
  20. *
  21. * this software is provided as is, without representation from the
  22. * university of michigan as to its fitness for any purpose, and without
  23. * warranty by the university of michigan of any kind, either express
  24. * or implied, including without limitation the implied warranties of
  25. * merchantability and fitness for a particular purpose. the regents
  26. * of the university of michigan shall not be liable for any damages,
  27. * including special, indirect, incidental, or consequential damages,
  28. * with respect to any claim arising out or in connection with the use
  29. * of the software, even if it has been or is hereafter advised of the
  30. * possibility of such damages.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/init.h>
  34. #include "blocklayout.h"
  35. #define NFSDBG_FACILITY NFSDBG_PNFS_LD
  36. MODULE_LICENSE("GPL");
  37. MODULE_AUTHOR("Andy Adamson <andros@citi.umich.edu>");
  38. MODULE_DESCRIPTION("The NFSv4.1 pNFS Block layout driver");
  39. static enum pnfs_try_status
  40. bl_read_pagelist(struct nfs_read_data *rdata)
  41. {
  42. return PNFS_NOT_ATTEMPTED;
  43. }
  44. static enum pnfs_try_status
  45. bl_write_pagelist(struct nfs_write_data *wdata,
  46. int sync)
  47. {
  48. return PNFS_NOT_ATTEMPTED;
  49. }
  50. /* STUB */
  51. static void
  52. release_extents(struct pnfs_block_layout *bl,
  53. struct pnfs_layout_range *range)
  54. {
  55. return;
  56. }
  57. /* STUB */
  58. static void
  59. release_inval_marks(struct pnfs_inval_markings *marks)
  60. {
  61. return;
  62. }
  63. static void bl_free_layout_hdr(struct pnfs_layout_hdr *lo)
  64. {
  65. struct pnfs_block_layout *bl = BLK_LO2EXT(lo);
  66. dprintk("%s enter\n", __func__);
  67. release_extents(bl, NULL);
  68. release_inval_marks(&bl->bl_inval);
  69. kfree(bl);
  70. }
  71. static struct pnfs_layout_hdr *bl_alloc_layout_hdr(struct inode *inode,
  72. gfp_t gfp_flags)
  73. {
  74. struct pnfs_block_layout *bl;
  75. dprintk("%s enter\n", __func__);
  76. bl = kzalloc(sizeof(*bl), gfp_flags);
  77. if (!bl)
  78. return NULL;
  79. spin_lock_init(&bl->bl_ext_lock);
  80. INIT_LIST_HEAD(&bl->bl_extents[0]);
  81. INIT_LIST_HEAD(&bl->bl_extents[1]);
  82. INIT_LIST_HEAD(&bl->bl_commit);
  83. INIT_LIST_HEAD(&bl->bl_committing);
  84. bl->bl_count = 0;
  85. bl->bl_blocksize = NFS_SERVER(inode)->pnfs_blksize >> SECTOR_SHIFT;
  86. BL_INIT_INVAL_MARKS(&bl->bl_inval, bl->bl_blocksize);
  87. return &bl->bl_layout;
  88. }
  89. static void
  90. bl_free_lseg(struct pnfs_layout_segment *lseg)
  91. {
  92. }
  93. static struct pnfs_layout_segment *
  94. bl_alloc_lseg(struct pnfs_layout_hdr *lo,
  95. struct nfs4_layoutget_res *lgr, gfp_t gfp_flags)
  96. {
  97. return NULL;
  98. }
  99. static void
  100. bl_encode_layoutcommit(struct pnfs_layout_hdr *lo, struct xdr_stream *xdr,
  101. const struct nfs4_layoutcommit_args *arg)
  102. {
  103. }
  104. static void
  105. bl_cleanup_layoutcommit(struct nfs4_layoutcommit_data *lcdata)
  106. {
  107. }
  108. static int
  109. bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
  110. {
  111. dprintk("%s enter\n", __func__);
  112. return 0;
  113. }
  114. static int
  115. bl_clear_layoutdriver(struct nfs_server *server)
  116. {
  117. dprintk("%s enter\n", __func__);
  118. return 0;
  119. }
  120. static struct pnfs_layoutdriver_type blocklayout_type = {
  121. .id = LAYOUT_BLOCK_VOLUME,
  122. .name = "LAYOUT_BLOCK_VOLUME",
  123. .read_pagelist = bl_read_pagelist,
  124. .write_pagelist = bl_write_pagelist,
  125. .alloc_layout_hdr = bl_alloc_layout_hdr,
  126. .free_layout_hdr = bl_free_layout_hdr,
  127. .alloc_lseg = bl_alloc_lseg,
  128. .free_lseg = bl_free_lseg,
  129. .encode_layoutcommit = bl_encode_layoutcommit,
  130. .cleanup_layoutcommit = bl_cleanup_layoutcommit,
  131. .set_layoutdriver = bl_set_layoutdriver,
  132. .clear_layoutdriver = bl_clear_layoutdriver,
  133. };
  134. static int __init nfs4blocklayout_init(void)
  135. {
  136. int ret;
  137. dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__);
  138. ret = pnfs_register_layoutdriver(&blocklayout_type);
  139. return ret;
  140. }
  141. static void __exit nfs4blocklayout_exit(void)
  142. {
  143. dprintk("%s: NFSv4 Block Layout Driver Unregistering...\n",
  144. __func__);
  145. pnfs_unregister_layoutdriver(&blocklayout_type);
  146. }
  147. MODULE_ALIAS("nfs-layouttype4-3");
  148. module_init(nfs4blocklayout_init);
  149. module_exit(nfs4blocklayout_exit);