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