2 * Data types and function declerations for interfacing with the
3 * pNFS standard object layout driver.
5 * Copyright (C) 2007 Panasas Inc. [year of first publication]
8 * Benny Halevy <bhalevy@panasas.com>
9 * Boaz Harrosh <bharrosh@panasas.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2
13 * See the file COPYING included with this distribution for more details.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the Panasas company nor the names of its
25 * contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <linux/nfs_fs.h>
45 #include <linux/pnfs_osd_xdr.h>
52 struct pnfs_layout_hdr pnfs_layout;
54 /* for layout_return */
56 struct list_head err_list;
59 static inline struct objlayout *
60 OBJLAYOUT(struct pnfs_layout_hdr *lo)
62 return container_of(lo, struct objlayout, pnfs_layout);
66 * per-I/O operation state
67 * embedded in objects provider io_state data structure
69 struct objlayout_io_state {
70 struct pnfs_layout_segment *lseg;
82 int committed; /* res */
84 /* Error reporting (layout_return) */
85 struct list_head err_list;
87 /* Pointer to array of error descriptors of size num_comps.
88 * It should contain as many entries as devices in the osd_layout
89 * that participate in the I/O. It is up to the io_engine to allocate
90 * needed space and set num_comps.
92 struct pnfs_osd_ioerr *ioerrs;
98 extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
99 struct pnfs_layout_hdr *pnfslay,
100 struct pnfs_layout_range *range,
101 struct xdr_stream *xdr,
103 extern void objio_free_lseg(struct pnfs_layout_segment *lseg);
105 extern int objio_alloc_io_state(
106 struct pnfs_layout_segment *lseg,
107 struct objlayout_io_state **outp,
109 extern void objio_free_io_state(struct objlayout_io_state *state);
111 extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state);
112 extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state,
118 extern void objlayout_io_set_result(struct objlayout_io_state *state,
119 unsigned index, struct pnfs_osd_objid *pooid,
120 int osd_error, u64 offset, u64 length, bool is_write);
122 extern void objlayout_read_done(struct objlayout_io_state *state,
123 ssize_t status, bool sync);
124 extern void objlayout_write_done(struct objlayout_io_state *state,
125 ssize_t status, bool sync);
127 extern int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
128 struct nfs4_deviceid *d_id, struct pnfs_osd_deviceaddr **deviceaddr,
130 extern void objlayout_put_deviceinfo(struct pnfs_osd_deviceaddr *deviceaddr);
133 * exported generic objects function vectors
136 extern struct pnfs_layout_hdr *objlayout_alloc_layout_hdr(struct inode *, gfp_t gfp_flags);
137 extern void objlayout_free_layout_hdr(struct pnfs_layout_hdr *);
139 extern struct pnfs_layout_segment *objlayout_alloc_lseg(
140 struct pnfs_layout_hdr *,
141 struct nfs4_layoutget_res *,
143 extern void objlayout_free_lseg(struct pnfs_layout_segment *);
145 extern enum pnfs_try_status objlayout_read_pagelist(
146 struct nfs_read_data *);
148 extern enum pnfs_try_status objlayout_write_pagelist(
149 struct nfs_write_data *,
152 extern void objlayout_encode_layoutreturn(
153 struct pnfs_layout_hdr *,
155 const struct nfs4_layoutreturn_args *);
157 #endif /* _OBJLAYOUT_H */