extents.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * linux/fs/nfs/blocklayout/blocklayout.h
  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 "blocklayout.h"
  33. #define NFSDBG_FACILITY NFSDBG_PNFS_LD
  34. static void print_bl_extent(struct pnfs_block_extent *be)
  35. {
  36. dprintk("PRINT EXTENT extent %p\n", be);
  37. if (be) {
  38. dprintk(" be_f_offset %llu\n", (u64)be->be_f_offset);
  39. dprintk(" be_length %llu\n", (u64)be->be_length);
  40. dprintk(" be_v_offset %llu\n", (u64)be->be_v_offset);
  41. dprintk(" be_state %d\n", be->be_state);
  42. }
  43. }
  44. static void
  45. destroy_extent(struct kref *kref)
  46. {
  47. struct pnfs_block_extent *be;
  48. be = container_of(kref, struct pnfs_block_extent, be_refcnt);
  49. dprintk("%s be=%p\n", __func__, be);
  50. kfree(be);
  51. }
  52. void
  53. bl_put_extent(struct pnfs_block_extent *be)
  54. {
  55. if (be) {
  56. dprintk("%s enter %p (%i)\n", __func__, be,
  57. atomic_read(&be->be_refcnt.refcount));
  58. kref_put(&be->be_refcnt, destroy_extent);
  59. }
  60. }
  61. struct pnfs_block_extent *bl_alloc_extent(void)
  62. {
  63. struct pnfs_block_extent *be;
  64. be = kmalloc(sizeof(struct pnfs_block_extent), GFP_NOFS);
  65. if (!be)
  66. return NULL;
  67. INIT_LIST_HEAD(&be->be_node);
  68. kref_init(&be->be_refcnt);
  69. be->be_inval = NULL;
  70. return be;
  71. }
  72. static void print_elist(struct list_head *list)
  73. {
  74. struct pnfs_block_extent *be;
  75. dprintk("****************\n");
  76. dprintk("Extent list looks like:\n");
  77. list_for_each_entry(be, list, be_node) {
  78. print_bl_extent(be);
  79. }
  80. dprintk("****************\n");
  81. }