nfs: remove unused arg from nfs_create_request
[deliverable/linux.git] / include / linux / nfs_page.h
CommitLineData
1da177e4
LT
1/*
2 * linux/include/linux/nfs_page.h
3 *
4 * Copyright (C) 2000 Trond Myklebust
5 *
6 * NFS page cache wrapper.
7 */
8
9#ifndef _LINUX_NFS_PAGE_H
10#define _LINUX_NFS_PAGE_H
11
12
13#include <linux/list.h>
14#include <linux/pagemap.h>
15#include <linux/wait.h>
1da177e4
LT
16#include <linux/sunrpc/auth.h>
17#include <linux/nfs_xdr.h>
18
c03b4024 19#include <linux/kref.h>
1da177e4
LT
20
21/*
22 * Valid flags for a dirty buffer
23 */
e468bae9 24enum {
12c05792
WAA
25 PG_BUSY = 0, /* nfs_{un}lock_request */
26 PG_MAPPED, /* page private set for buffered io */
27 PG_CLEAN, /* write succeeded */
28 PG_COMMIT_TO_DS, /* used by pnfs layouts */
e468bae9 29};
1da177e4 30
3da28eb1 31struct nfs_inode;
1da177e4 32struct nfs_page {
d6d6dc7c 33 struct list_head wb_list; /* Defines state of page: */
1da177e4
LT
34 struct page *wb_page; /* page to read in/write out */
35 struct nfs_open_context *wb_context; /* File state context info */
f11ac8db 36 struct nfs_lock_context *wb_lock_context; /* lock context info */
ca52fec1 37 pgoff_t wb_index; /* Offset >> PAGE_CACHE_SHIFT */
1da177e4
LT
38 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */
39 wb_pgbase, /* Start of page data */
40 wb_bytes; /* Length of request */
c03b4024 41 struct kref wb_kref; /* reference count */
1da177e4 42 unsigned long wb_flags;
2f2c63bc 43 struct nfs_write_verifier wb_verf; /* Commit cookie */
1da177e4
LT
44};
45
1751c363
TM
46struct nfs_pageio_descriptor;
47struct nfs_pageio_ops {
d8007d4d 48 void (*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *);
1751c363
TM
49 bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
50 int (*pg_doio)(struct nfs_pageio_descriptor *);
51};
52
4a0de55c 53struct nfs_rw_ops {
a4cdda59 54 const fmode_t rw_mode;
4a0de55c
AS
55 struct nfs_rw_header *(*rw_alloc_header)(void);
56 void (*rw_free_header)(struct nfs_rw_header *);
a4cdda59 57 void (*rw_release)(struct nfs_pgio_data *);
0eecb214
AS
58 int (*rw_done)(struct rpc_task *, struct nfs_pgio_data *, struct inode *);
59 void (*rw_result)(struct rpc_task *, struct nfs_pgio_data *);
1ed26f33
AS
60 void (*rw_initiate)(struct nfs_pgio_data *, struct rpc_message *,
61 struct rpc_task_setup *, int);
4a0de55c
AS
62};
63
d8a5ad75
TM
64struct nfs_pageio_descriptor {
65 struct list_head pg_list;
bcb71bba 66 unsigned long pg_bytes_written;
d8a5ad75
TM
67 size_t pg_count;
68 size_t pg_bsize;
69 unsigned int pg_base;
d9156f9f
TM
70 unsigned char pg_moreio : 1,
71 pg_recoalesce : 1;
bcb71bba
TM
72
73 struct inode *pg_inode;
1751c363 74 const struct nfs_pageio_ops *pg_ops;
4a0de55c 75 const struct nfs_rw_ops *pg_rw_ops;
bcb71bba
TM
76 int pg_ioflags;
77 int pg_error;
50828d7e 78 const struct rpc_call_ops *pg_rpc_callops;
061ae2ed 79 const struct nfs_pgio_completion_ops *pg_completion_ops;
94ad1c80 80 struct pnfs_layout_segment *pg_lseg;
584aa810 81 struct nfs_direct_req *pg_dreq;
f6166384 82 void *pg_layout_private;
d8a5ad75
TM
83};
84
1da177e4 85#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
1da177e4
LT
86
87extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
1da177e4
LT
88 struct page *page,
89 unsigned int offset,
90 unsigned int count);
1da177e4
LT
91extern void nfs_release_request(struct nfs_page *req);
92
93
bcb71bba
TM
94extern void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
95 struct inode *inode,
1751c363 96 const struct nfs_pageio_ops *pg_ops,
061ae2ed 97 const struct nfs_pgio_completion_ops *compl_ops,
4a0de55c 98 const struct nfs_rw_ops *rw_ops,
bcb71bba
TM
99 size_t bsize,
100 int how);
8b09bee3
TM
101extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
102 struct nfs_page *);
bcb71bba 103extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
7fe7f848 104extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
19345cb2
BH
105extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
106 struct nfs_page *prev,
107 struct nfs_page *req);
1da177e4
LT
108extern int nfs_wait_on_request(struct nfs_page *);
109extern void nfs_unlock_request(struct nfs_page *req);
1d1afcbc 110extern void nfs_unlock_and_release_request(struct nfs_page *req);
c6a556b8 111
1da177e4 112/*
7ad84aa9 113 * Lock the page of an asynchronous request
1da177e4 114 */
8dd37758
TM
115static inline int
116nfs_lock_request(struct nfs_page *req)
117{
7ad84aa9 118 return !test_and_set_bit(PG_BUSY, &req->wb_flags);
8dd37758
TM
119}
120
3da28eb1
TM
121/**
122 * nfs_list_add_request - Insert a request into a list
123 * @req: request
124 * @head: head of list into which to insert the request.
125 */
126static inline void
127nfs_list_add_request(struct nfs_page *req, struct list_head *head)
128{
129 list_add_tail(&req->wb_list, head);
3da28eb1
TM
130}
131
1da177e4
LT
132
133/**
134 * nfs_list_remove_request - Remove a request from its wb_list
135 * @req: request
136 */
137static inline void
138nfs_list_remove_request(struct nfs_page *req)
139{
140 if (list_empty(&req->wb_list))
141 return;
1da177e4 142 list_del_init(&req->wb_list);
1da177e4
LT
143}
144
1da177e4
LT
145static inline struct nfs_page *
146nfs_list_entry(struct list_head *head)
147{
148 return list_entry(head, struct nfs_page, wb_list);
149}
150
151static inline
152loff_t req_offset(struct nfs_page *req)
153{
154 return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
155}
156
157#endif /* _LINUX_NFS_PAGE_H */
This page took 1.000868 seconds and 5 git commands to generate.