aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/addr.c
diff options
context:
space:
mode:
authorMilosz Tanski <milosz@adfin.com>2013-08-21 17:29:54 -0400
committerMilosz Tanski <milosz@adfin.com>2013-09-06 12:50:11 -0400
commit99ccbd229cf7453206bc858e795ec1f0345ff258 (patch)
tree343ab082d154d7c970d90bf44c9887fdb0251cdb /fs/ceph/addr.c
parentcd0a2df681ec2af45f50c555c2a39dc92a4dff71 (diff)
ceph: use fscache as a local presisent cache
Adding support for fscache to the Ceph filesystem. This would bring it to on par with some of the other network filesystems in Linux (like NFS, AFS, etc...) In order to mount the filesystem with fscache the 'fsc' mount option must be passed. Signed-off-by: Milosz Tanski <milosz@adfin.com> Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'fs/ceph/addr.c')
-rw-r--r--fs/ceph/addr.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 3bed7da38326..3a21a7cbc21c 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -11,6 +11,7 @@
11 11
12#include "super.h" 12#include "super.h"
13#include "mds_client.h" 13#include "mds_client.h"
14#include "cache.h"
14#include <linux/ceph/osd_client.h> 15#include <linux/ceph/osd_client.h>
15 16
16/* 17/*
@@ -144,6 +145,11 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
144 return; 145 return;
145 } 146 }
146 147
148 ceph_invalidate_fscache_page(inode, page);
149
150 if (!PagePrivate(page))
151 return;
152
147 /* 153 /*
148 * We can get non-dirty pages here due to races between 154 * We can get non-dirty pages here due to races between
149 * set_page_dirty and truncate_complete_page; just spit out a 155 * set_page_dirty and truncate_complete_page; just spit out a
@@ -163,14 +169,17 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
163 ClearPagePrivate(page); 169 ClearPagePrivate(page);
164} 170}
165 171
166/* just a sanity check */
167static int ceph_releasepage(struct page *page, gfp_t g) 172static int ceph_releasepage(struct page *page, gfp_t g)
168{ 173{
169 struct inode *inode = page->mapping ? page->mapping->host : NULL; 174 struct inode *inode = page->mapping ? page->mapping->host : NULL;
170 dout("%p releasepage %p idx %lu\n", inode, page, page->index); 175 dout("%p releasepage %p idx %lu\n", inode, page, page->index);
171 WARN_ON(PageDirty(page)); 176 WARN_ON(PageDirty(page));
172 WARN_ON(PagePrivate(page)); 177
173 return 0; 178 /* Can we release the page from the cache? */
179 if (!ceph_release_fscache_page(page, g))
180 return 0;
181
182 return !PagePrivate(page);
174} 183}
175 184
176/* 185/*
@@ -180,11 +189,16 @@ static int readpage_nounlock(struct file *filp, struct page *page)
180{ 189{
181 struct inode *inode = file_inode(filp); 190 struct inode *inode = file_inode(filp);
182 struct ceph_inode_info *ci = ceph_inode(inode); 191 struct ceph_inode_info *ci = ceph_inode(inode);
183 struct ceph_osd_client *osdc = 192 struct ceph_osd_client *osdc =
184 &ceph_inode_to_client(inode)->client->osdc; 193 &ceph_inode_to_client(inode)->client->osdc;
185 int err = 0; 194 int err = 0;
186 u64 len = PAGE_CACHE_SIZE; 195 u64 len = PAGE_CACHE_SIZE;
187 196
197 err = ceph_readpage_from_fscache(inode, page);
198
199 if (err == 0)
200 goto out;
201
188 dout("readpage inode %p file %p page %p index %lu\n", 202 dout("readpage inode %p file %p page %p index %lu\n",
189 inode, filp, page, page->index); 203 inode, filp, page, page->index);
190 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout, 204 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
@@ -202,6 +216,9 @@ static int readpage_nounlock(struct file *filp, struct page *page)
202 } 216 }
203 SetPageUptodate(page); 217 SetPageUptodate(page);
204 218
219 if (err == 0)
220 ceph_readpage_to_fscache(inode, page);
221
205out: 222out:
206 return err < 0 ? err : 0; 223 return err < 0 ? err : 0;
207} 224}
@@ -244,6 +261,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
244 page->index); 261 page->index);
245 flush_dcache_page(page); 262 flush_dcache_page(page);
246 SetPageUptodate(page); 263 SetPageUptodate(page);
264 ceph_readpage_to_fscache(inode, page);
247 unlock_page(page); 265 unlock_page(page);
248 page_cache_release(page); 266 page_cache_release(page);
249 bytes -= PAGE_CACHE_SIZE; 267 bytes -= PAGE_CACHE_SIZE;
@@ -313,7 +331,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
313 page = list_entry(page_list->prev, struct page, lru); 331 page = list_entry(page_list->prev, struct page, lru);
314 BUG_ON(PageLocked(page)); 332 BUG_ON(PageLocked(page));
315 list_del(&page->lru); 333 list_del(&page->lru);
316 334
317 dout("start_read %p adding %p idx %lu\n", inode, page, 335 dout("start_read %p adding %p idx %lu\n", inode, page,
318 page->index); 336 page->index);
319 if (add_to_page_cache_lru(page, &inode->i_data, page->index, 337 if (add_to_page_cache_lru(page, &inode->i_data, page->index,
@@ -360,6 +378,12 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
360 int rc = 0; 378 int rc = 0;
361 int max = 0; 379 int max = 0;
362 380
381 rc = ceph_readpages_from_fscache(mapping->host, mapping, page_list,
382 &nr_pages);
383
384 if (rc == 0)
385 goto out;
386
363 if (fsc->mount_options->rsize >= PAGE_CACHE_SIZE) 387 if (fsc->mount_options->rsize >= PAGE_CACHE_SIZE)
364 max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1) 388 max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1)
365 >> PAGE_SHIFT; 389 >> PAGE_SHIFT;
@@ -479,6 +503,8 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
479 CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb)) 503 CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
480 set_bdi_congested(&fsc->backing_dev_info, BLK_RW_ASYNC); 504 set_bdi_congested(&fsc->backing_dev_info, BLK_RW_ASYNC);
481 505
506 ceph_readpage_to_fscache(inode, page);
507
482 set_page_writeback(page); 508 set_page_writeback(page);
483 err = ceph_osdc_writepages(osdc, ceph_vino(inode), 509 err = ceph_osdc_writepages(osdc, ceph_vino(inode),
484 &ci->i_layout, snapc, 510 &ci->i_layout, snapc,
@@ -534,7 +560,6 @@ static void ceph_release_pages(struct page **pages, int num)
534 pagevec_release(&pvec); 560 pagevec_release(&pvec);
535} 561}
536 562
537
538/* 563/*
539 * async writeback completion handler. 564 * async writeback completion handler.
540 * 565 *