nfs: call nfs_can_coalesce_requests for every req
[deliverable/linux.git] / include / linux / nfs_page.h
... / ...
CommitLineData
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>
16#include <linux/sunrpc/auth.h>
17#include <linux/nfs_xdr.h>
18
19#include <linux/kref.h>
20
21/*
22 * Valid flags for a dirty buffer
23 */
24enum {
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 */
29};
30
31struct nfs_inode;
32struct nfs_page {
33 struct list_head wb_list; /* Defines state of page: */
34 struct page *wb_page; /* page to read in/write out */
35 struct nfs_open_context *wb_context; /* File state context info */
36 struct nfs_lock_context *wb_lock_context; /* lock context info */
37 pgoff_t wb_index; /* Offset >> PAGE_CACHE_SHIFT */
38 unsigned int wb_offset, /* Offset & ~PAGE_CACHE_MASK */
39 wb_pgbase, /* Start of page data */
40 wb_bytes; /* Length of request */
41 struct kref wb_kref; /* reference count */
42 unsigned long wb_flags;
43 struct nfs_write_verifier wb_verf; /* Commit cookie */
44};
45
46struct nfs_pageio_descriptor;
47struct nfs_pageio_ops {
48 void (*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *);
49 size_t (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *,
50 struct nfs_page *);
51 int (*pg_doio)(struct nfs_pageio_descriptor *);
52};
53
54struct nfs_rw_ops {
55 const fmode_t rw_mode;
56 struct nfs_rw_header *(*rw_alloc_header)(void);
57 void (*rw_free_header)(struct nfs_rw_header *);
58 void (*rw_release)(struct nfs_pgio_data *);
59 int (*rw_done)(struct rpc_task *, struct nfs_pgio_data *, struct inode *);
60 void (*rw_result)(struct rpc_task *, struct nfs_pgio_data *);
61 void (*rw_initiate)(struct nfs_pgio_data *, struct rpc_message *,
62 struct rpc_task_setup *, int);
63};
64
65struct nfs_pageio_descriptor {
66 struct list_head pg_list;
67 unsigned long pg_bytes_written;
68 size_t pg_count;
69 size_t pg_bsize;
70 unsigned int pg_base;
71 unsigned char pg_moreio : 1,
72 pg_recoalesce : 1;
73
74 struct inode *pg_inode;
75 const struct nfs_pageio_ops *pg_ops;
76 const struct nfs_rw_ops *pg_rw_ops;
77 int pg_ioflags;
78 int pg_error;
79 const struct rpc_call_ops *pg_rpc_callops;
80 const struct nfs_pgio_completion_ops *pg_completion_ops;
81 struct pnfs_layout_segment *pg_lseg;
82 struct nfs_direct_req *pg_dreq;
83 void *pg_layout_private;
84};
85
86#define NFS_WBACK_BUSY(req) (test_bit(PG_BUSY,&(req)->wb_flags))
87
88extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
89 struct page *page,
90 unsigned int offset,
91 unsigned int count);
92extern void nfs_release_request(struct nfs_page *req);
93
94
95extern void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
96 struct inode *inode,
97 const struct nfs_pageio_ops *pg_ops,
98 const struct nfs_pgio_completion_ops *compl_ops,
99 const struct nfs_rw_ops *rw_ops,
100 size_t bsize,
101 int how);
102extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
103 struct nfs_page *);
104extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
105extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
106extern size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
107 struct nfs_page *prev,
108 struct nfs_page *req);
109extern int nfs_wait_on_request(struct nfs_page *);
110extern void nfs_unlock_request(struct nfs_page *req);
111extern void nfs_unlock_and_release_request(struct nfs_page *req);
112
113/*
114 * Lock the page of an asynchronous request
115 */
116static inline int
117nfs_lock_request(struct nfs_page *req)
118{
119 return !test_and_set_bit(PG_BUSY, &req->wb_flags);
120}
121
122/**
123 * nfs_list_add_request - Insert a request into a list
124 * @req: request
125 * @head: head of list into which to insert the request.
126 */
127static inline void
128nfs_list_add_request(struct nfs_page *req, struct list_head *head)
129{
130 list_add_tail(&req->wb_list, head);
131}
132
133
134/**
135 * nfs_list_remove_request - Remove a request from its wb_list
136 * @req: request
137 */
138static inline void
139nfs_list_remove_request(struct nfs_page *req)
140{
141 if (list_empty(&req->wb_list))
142 return;
143 list_del_init(&req->wb_list);
144}
145
146static inline struct nfs_page *
147nfs_list_entry(struct list_head *head)
148{
149 return list_entry(head, struct nfs_page, wb_list);
150}
151
152static inline
153loff_t req_offset(struct nfs_page *req)
154{
155 return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
156}
157
158#endif /* _LINUX_NFS_PAGE_H */
This page took 0.04895 seconds and 5 git commands to generate.