]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.suse/SoN-29-nfs-swapper.patch
Changed checkfs to auto reboot after correctable fsck fixes.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / SoN-29-nfs-swapper.patch
1 From: Peter Zijlstra <a.p.zijlstra@chello.nl>
2 Subject: nfs: disable data cache revalidation for swapfiles
3 Patch-mainline: No
4 References: FATE#303834
5
6 Do as Trond suggested:
7 http://lkml.org/lkml/2006/8/25/348
8
9 Disable NFS data cache revalidation on swap files since it doesn't really
10 make sense to have other clients change the file while you are using it.
11
12 Thereby we can stop setting PG_private on swap pages, since there ought to
13 be no further races with invalidate_inode_pages2() to deal with.
14
15 And since we cannot set PG_private we cannot use page->private (which is
16 already used by PG_swapcache pages anyway) to store the nfs_page. Thus
17 augment the new nfs_page_find_request logic.
18
19 Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
20 Acked-by: Neil Brown <neilb@suse.de>
21 Acked-by: Suresh Jayaraman <sjayaraman@suse.de>
22
23 ---
24 fs/nfs/inode.c | 6 ++++
25 fs/nfs/write.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++-----------
26 2 files changed, 64 insertions(+), 13 deletions(-)
27
28 Index: linux-2.6.26/fs/nfs/inode.c
29 ===================================================================
30 --- linux-2.6.26.orig/fs/nfs/inode.c
31 +++ linux-2.6.26/fs/nfs/inode.c
32 @@ -824,6 +824,12 @@ int nfs_revalidate_mapping_nolock(struct
33 struct nfs_inode *nfsi = NFS_I(inode);
34 int ret = 0;
35
36 + /*
37 + * swapfiles are not supposed to be shared.
38 + */
39 + if (IS_SWAPFILE(inode))
40 + goto out;
41 +
42 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE)
43 || nfs_attribute_timeout(inode) || NFS_STALE(inode)) {
44 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
45 Index: linux-2.6.26/fs/nfs/write.c
46 ===================================================================
47 --- linux-2.6.26.orig/fs/nfs/write.c
48 +++ linux-2.6.26/fs/nfs/write.c
49 @@ -106,25 +106,62 @@ static void nfs_context_set_write_error(
50 set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
51 }
52
53 -static struct nfs_page *nfs_page_find_request_locked(struct page *page)
54 +static struct nfs_page *
55 +__nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page, int get)
56 {
57 struct nfs_page *req = NULL;
58
59 - if (PagePrivate(page)) {
60 + if (PagePrivate(page))
61 req = (struct nfs_page *)page_private(page);
62 - if (req != NULL)
63 - kref_get(&req->wb_kref);
64 - }
65 + else if (unlikely(PageSwapCache(page)))
66 + req = radix_tree_lookup(&nfsi->nfs_page_tree, page_file_index(page));
67 +
68 + if (get && req)
69 + kref_get(&req->wb_kref);
70 +
71 return req;
72 }
73
74 +static inline struct nfs_page *
75 +nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page)
76 +{
77 + return __nfs_page_find_request_locked(nfsi, page, 1);
78 +}
79 +
80 +static int __nfs_page_has_request(struct page *page)
81 +{
82 + struct inode *inode = page_file_mapping(page)->host;
83 + struct nfs_page *req = NULL;
84 +
85 + spin_lock(&inode->i_lock);
86 + req = __nfs_page_find_request_locked(NFS_I(inode), page, 0);
87 + spin_unlock(&inode->i_lock);
88 +
89 + /*
90 + * hole here plugged by the caller holding onto PG_locked
91 + */
92 +
93 + return req != NULL;
94 +}
95 +
96 +static inline int nfs_page_has_request(struct page *page)
97 +{
98 + if (PagePrivate(page))
99 + return 1;
100 +
101 + if (unlikely(PageSwapCache(page)))
102 + return __nfs_page_has_request(page);
103 +
104 + return 0;
105 +}
106 +
107 static struct nfs_page *nfs_page_find_request(struct page *page)
108 {
109 struct inode *inode = page_file_mapping(page)->host;
110 struct nfs_page *req = NULL;
111
112 spin_lock(&inode->i_lock);
113 - req = nfs_page_find_request_locked(page);
114 + req = nfs_page_find_request_locked(NFS_I(inode), page);
115 spin_unlock(&inode->i_lock);
116 return req;
117 }
118 @@ -228,7 +265,7 @@ static int nfs_page_async_flush(struct n
119
120 spin_lock(&inode->i_lock);
121 for(;;) {
122 - req = nfs_page_find_request_locked(page);
123 + req = nfs_page_find_request_locked(NFS_I(inode), page);
124 if (req == NULL) {
125 spin_unlock(&inode->i_lock);
126 return 0;
127 @@ -351,8 +388,14 @@ static int nfs_inode_add_request(struct
128 if (nfs_have_delegation(inode, FMODE_WRITE))
129 nfsi->change_attr++;
130 }
131 - SetPagePrivate(req->wb_page);
132 - set_page_private(req->wb_page, (unsigned long)req);
133 + /*
134 + * Swap-space should not get truncated. Hence no need to plug the race
135 + * with invalidate/truncate.
136 + */
137 + if (likely(!PageSwapCache(req->wb_page))) {
138 + SetPagePrivate(req->wb_page);
139 + set_page_private(req->wb_page, (unsigned long)req);
140 + }
141 nfsi->npages++;
142 kref_get(&req->wb_kref);
143 radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index,
144 @@ -374,8 +417,10 @@ static void nfs_inode_remove_request(str
145 BUG_ON (!NFS_WBACK_BUSY(req));
146
147 spin_lock(&inode->i_lock);
148 - set_page_private(req->wb_page, 0);
149 - ClearPagePrivate(req->wb_page);
150 + if (likely(!PageSwapCache(req->wb_page))) {
151 + set_page_private(req->wb_page, 0);
152 + ClearPagePrivate(req->wb_page);
153 + }
154 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index);
155 nfsi->npages--;
156 if (!nfsi->npages) {
157 @@ -579,7 +624,7 @@ static struct nfs_page *nfs_try_to_updat
158 spin_lock(&inode->i_lock);
159
160 for (;;) {
161 - req = nfs_page_find_request_locked(page);
162 + req = nfs_page_find_request_locked(NFS_I(inode), page);
163 if (req == NULL)
164 goto out_unlock;
165
166 @@ -1490,7 +1535,7 @@ int nfs_wb_page_cancel(struct inode *ino
167 if (ret < 0)
168 goto out;
169 }
170 - if (!PagePrivate(page))
171 + if (!nfs_page_has_request(page))
172 return 0;
173 ret = nfs_sync_mapping_wait(page_file_mapping(page), &wbc, FLUSH_INVALIDATE);
174 out: