Blame view

include/linux/nfs_page.h 4.11 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /*
   * linux/include/linux/nfs_page.h
   *
   * Copyright (C) 2000 Trond Myklebust
   *
   * NFS page cache wrapper.
   */
  
  #ifndef _LINUX_NFS_PAGE_H
  #define _LINUX_NFS_PAGE_H
  
  
  #include <linux/list.h>
  #include <linux/pagemap.h>
  #include <linux/wait.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
  #include <linux/sunrpc/auth.h>
  #include <linux/nfs_xdr.h>
c03b40246   Trond Myklebust   NFS: Convert stru...
18
  #include <linux/kref.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
20
  
  /*
c6a556b88   Trond Myklebust   [PATCH] NFS: Make...
21
22
   * Valid flags for the radix tree
   */
9fd367f0f   Trond Myklebust   NFS cleanup: Rena...
23
  #define NFS_PAGE_TAG_LOCKED	0
5c3696834   Trond Myklebust   NFS cleanup: spee...
24
  #define NFS_PAGE_TAG_COMMIT	1
c6a556b88   Trond Myklebust   [PATCH] NFS: Make...
25
26
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
   * Valid flags for a dirty buffer
   */
e468bae97   Trond Myklebust   NFS: Allow redirt...
29
30
  enum {
  	PG_BUSY = 0,
2df485a77   Trond Myklebust   nfs: remove extra...
31
  	PG_MAPPED,
e468bae97   Trond Myklebust   NFS: Allow redirt...
32
33
34
  	PG_CLEAN,
  	PG_NEED_COMMIT,
  	PG_NEED_RESCHED,
a861a1e1c   Fred Isaman   NFSv4.1: add gene...
35
  	PG_PNFS_COMMIT,
fba730050   Trond Myklebust   NFS: Don't rely o...
36
  	PG_PARTIAL_READ_FAILED,
e468bae97   Trond Myklebust   NFS: Allow redirt...
37
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38

3da28eb1c   Trond Myklebust   [PATCH] NFS: Repl...
39
  struct nfs_inode;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
  struct nfs_page {
a861a1e1c   Fred Isaman   NFSv4.1: add gene...
41
42
43
44
  	union {
  		struct list_head	wb_list;	/* Defines state of page: */
  		struct pnfs_layout_segment *wb_commit_lseg; /* Used when PG_PNFS_COMMIT set */
  	};
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
  	struct page		*wb_page;	/* page to read in/write out */
  	struct nfs_open_context	*wb_context;	/* File state context info */
f11ac8db5   Trond Myklebust   NFSv4: Ensure tha...
47
  	struct nfs_lock_context	*wb_lock_context;	/* lock context info */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
  	atomic_t		wb_complete;	/* i/os we're waiting for */
ca52fec15   Trond Myklebust   NFS: Use pgoff_t ...
49
  	pgoff_t			wb_index;	/* Offset >> PAGE_CACHE_SHIFT */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
  	unsigned int		wb_offset,	/* Offset & ~PAGE_CACHE_MASK */
  				wb_pgbase,	/* Start of page data */
  				wb_bytes;	/* Length of request */
c03b40246   Trond Myklebust   NFS: Convert stru...
53
  	struct kref		wb_kref;	/* reference count */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
  	unsigned long		wb_flags;
  	struct nfs_writeverf	wb_verf;	/* Commit cookie */
  };
1751c3638   Trond Myklebust   NFS: Cleanup of t...
57
58
  struct nfs_pageio_descriptor;
  struct nfs_pageio_ops {
d8007d4dd   Trond Myklebust   NFSv4.1: Add an i...
59
  	void	(*pg_init)(struct nfs_pageio_descriptor *, struct nfs_page *);
1751c3638   Trond Myklebust   NFS: Cleanup of t...
60
61
62
  	bool	(*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
  	int	(*pg_doio)(struct nfs_pageio_descriptor *);
  };
d8a5ad75c   Trond Myklebust   NFS: Cleanup the ...
63
64
  struct nfs_pageio_descriptor {
  	struct list_head	pg_list;
bcb71bba7   Trond Myklebust   NFS: Another clea...
65
  	unsigned long		pg_bytes_written;
d8a5ad75c   Trond Myklebust   NFS: Cleanup the ...
66
67
68
  	size_t			pg_count;
  	size_t			pg_bsize;
  	unsigned int		pg_base;
d9156f9f3   Trond Myklebust   NFS: Allow the nf...
69
70
  	unsigned char		pg_moreio : 1,
  				pg_recoalesce : 1;
bcb71bba7   Trond Myklebust   NFS: Another clea...
71
72
  
  	struct inode		*pg_inode;
1751c3638   Trond Myklebust   NFS: Cleanup of t...
73
  	const struct nfs_pageio_ops *pg_ops;
bcb71bba7   Trond Myklebust   NFS: Another clea...
74
75
  	int 			pg_ioflags;
  	int			pg_error;
50828d7e6   Trond Myklebust   NFS: Cache rpc_op...
76
  	const struct rpc_call_ops *pg_rpc_callops;
94ad1c80e   Fred Isaman   NFSv4.1: coelesce...
77
  	struct pnfs_layout_segment *pg_lseg;
d8a5ad75c   Trond Myklebust   NFS: Cleanup the ...
78
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
  #define NFS_WBACK_BUSY(req)	(test_bit(PG_BUSY,&(req)->wb_flags))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
81
82
83
84
85
  
  extern	struct nfs_page *nfs_create_request(struct nfs_open_context *ctx,
  					    struct inode *inode,
  					    struct page *page,
  					    unsigned int offset,
  					    unsigned int count);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
  extern	void nfs_release_request(struct nfs_page *req);
5c3696834   Trond Myklebust   NFS cleanup: spee...
87
88
  extern	int nfs_scan_list(struct nfs_inode *nfsi, struct list_head *dst,
  			  pgoff_t idx_start, unsigned int npages, int tag);
bcb71bba7   Trond Myklebust   NFS: Another clea...
89
90
  extern	void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
  			     struct inode *inode,
1751c3638   Trond Myklebust   NFS: Cleanup of t...
91
  			     const struct nfs_pageio_ops *pg_ops,
bcb71bba7   Trond Myklebust   NFS: Another clea...
92
93
  			     size_t bsize,
  			     int how);
8b09bee30   Trond Myklebust   NFS: Cleanup for ...
94
95
  extern	int nfs_pageio_add_request(struct nfs_pageio_descriptor *,
  				   struct nfs_page *);
bcb71bba7   Trond Myklebust   NFS: Another clea...
96
  extern	void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
7fe7f8487   Trond Myklebust   NFS: Avoid a dead...
97
  extern	void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
19345cb29   Benny Halevy   NFSv4.1: file lay...
98
99
100
  extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
  				struct nfs_page *prev,
  				struct nfs_page *req);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
  extern  int nfs_wait_on_request(struct nfs_page *);
  extern	void nfs_unlock_request(struct nfs_page *req);
acee478af   Trond Myklebust   NFS: Clean up the...
103
  extern	int nfs_set_page_tag_locked(struct nfs_page *req);
9fd367f0f   Trond Myklebust   NFS cleanup: Rena...
104
  extern  void nfs_clear_page_tag_locked(struct nfs_page *req);
c6a556b88   Trond Myklebust   [PATCH] NFS: Make...
105

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  /*
c03b40246   Trond Myklebust   NFS: Convert stru...
107
   * Lock the page of an asynchronous request without getting a new reference
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
109
110
111
   */
  static inline int
  nfs_lock_request_dontget(struct nfs_page *req)
  {
a911fd9a6   Chuck Lever   NFS: simplify inl...
112
  	return !test_and_set_bit(PG_BUSY, &req->wb_flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  }
3da28eb1c   Trond Myklebust   [PATCH] NFS: Repl...
114
115
116
117
118
119
120
121
122
  /**
   * nfs_list_add_request - Insert a request into a list
   * @req: request
   * @head: head of list into which to insert the request.
   */
  static inline void
  nfs_list_add_request(struct nfs_page *req, struct list_head *head)
  {
  	list_add_tail(&req->wb_list, head);
3da28eb1c   Trond Myklebust   [PATCH] NFS: Repl...
123
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
126
127
128
129
130
131
132
133
  
  /**
   * nfs_list_remove_request - Remove a request from its wb_list
   * @req: request
   */
  static inline void
  nfs_list_remove_request(struct nfs_page *req)
  {
  	if (list_empty(&req->wb_list))
  		return;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
  	list_del_init(&req->wb_list);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
137
138
139
140
141
142
143
144
145
146
147
148
  static inline struct nfs_page *
  nfs_list_entry(struct list_head *head)
  {
  	return list_entry(head, struct nfs_page, wb_list);
  }
  
  static inline
  loff_t req_offset(struct nfs_page *req)
  {
  	return (((loff_t)req->wb_index) << PAGE_CACHE_SHIFT) + req->wb_offset;
  }
  
  #endif /* _LINUX_NFS_PAGE_H */