blob: 9a405e8069f30a3ac8c532ffd1e6bcf020daa164 [file] [log] [blame]
Boaz Harrosh09f5bf42011-05-22 19:50:20 +03001/*
2 * Data types and function declerations for interfacing with the
3 * pNFS standard object layout driver.
4 *
5 * Copyright (C) 2007 Panasas Inc. [year of first publication]
6 * All rights reserved.
7 *
8 * Benny Halevy <bhalevy@panasas.com>
9 * Boaz Harrosh <bharrosh@panasas.com>
10 *
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.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
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.
27 *
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.
39 */
40
41#ifndef _OBJLAYOUT_H
42#define _OBJLAYOUT_H
43
44#include <linux/nfs_fs.h>
45#include <linux/pnfs_osd_xdr.h>
46#include "../pnfs.h"
47
48/*
Benny Halevye51b8412011-05-22 19:51:48 +030049 * per-inode layout
50 */
51struct objlayout {
52 struct pnfs_layout_hdr pnfs_layout;
53};
54
55static inline struct objlayout *
56OBJLAYOUT(struct pnfs_layout_hdr *lo)
57{
58 return container_of(lo, struct objlayout, pnfs_layout);
59}
60
61/*
Boaz Harrosh04f83452011-05-22 19:52:19 +030062 * per-I/O operation state
63 * embedded in objects provider io_state data structure
64 */
65struct objlayout_io_state {
66 struct pnfs_layout_segment *lseg;
67
68 struct page **pages;
69 unsigned pgbase;
70 unsigned nr_pages;
71 unsigned long count;
72 loff_t offset;
73 bool sync;
74
75 void *rpcdata;
76 int status; /* res */
77 int eof; /* res */
78 int committed; /* res */
79};
80
81/*
Boaz Harrosh09f5bf42011-05-22 19:50:20 +030082 * Raid engine I/O API
83 */
84extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
85 struct pnfs_layout_hdr *pnfslay,
86 struct pnfs_layout_range *range,
87 struct xdr_stream *xdr,
88 gfp_t gfp_flags);
89extern void objio_free_lseg(struct pnfs_layout_segment *lseg);
90
Boaz Harrosh04f83452011-05-22 19:52:19 +030091extern int objio_alloc_io_state(
92 struct pnfs_layout_segment *lseg,
93 struct objlayout_io_state **outp,
94 gfp_t gfp_flags);
95extern void objio_free_io_state(struct objlayout_io_state *state);
96
97extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state);
98extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state,
99 bool stable);
100
Boaz Harrosh09f5bf42011-05-22 19:50:20 +0300101/*
Boaz Harroshb6c05f12011-05-26 21:45:34 +0300102 * callback API
103 */
Boaz Harrosh04f83452011-05-22 19:52:19 +0300104extern void objlayout_read_done(struct objlayout_io_state *state,
105 ssize_t status, bool sync);
106extern void objlayout_write_done(struct objlayout_io_state *state,
107 ssize_t status, bool sync);
108
Boaz Harroshb6c05f12011-05-26 21:45:34 +0300109extern int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
110 struct nfs4_deviceid *d_id, struct pnfs_osd_deviceaddr **deviceaddr,
111 gfp_t gfp_flags);
112extern void objlayout_put_deviceinfo(struct pnfs_osd_deviceaddr *deviceaddr);
113
114/*
Boaz Harrosh09f5bf42011-05-22 19:50:20 +0300115 * exported generic objects function vectors
116 */
Benny Halevye51b8412011-05-22 19:51:48 +0300117
118extern struct pnfs_layout_hdr *objlayout_alloc_layout_hdr(struct inode *, gfp_t gfp_flags);
119extern void objlayout_free_layout_hdr(struct pnfs_layout_hdr *);
120
Boaz Harrosh09f5bf42011-05-22 19:50:20 +0300121extern struct pnfs_layout_segment *objlayout_alloc_lseg(
122 struct pnfs_layout_hdr *,
123 struct nfs4_layoutget_res *,
124 gfp_t gfp_flags);
125extern void objlayout_free_lseg(struct pnfs_layout_segment *);
126
Boaz Harrosh04f83452011-05-22 19:52:19 +0300127extern enum pnfs_try_status objlayout_read_pagelist(
128 struct nfs_read_data *);
129
130extern enum pnfs_try_status objlayout_write_pagelist(
131 struct nfs_write_data *,
132 int how);
133
Boaz Harrosh09f5bf42011-05-22 19:50:20 +0300134#endif /* _OBJLAYOUT_H */