aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/addr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph/addr.c')
-rw-r--r--fs/ceph/addr.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index efbc604001c8..5a3953db8118 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1,4 +1,4 @@
1#include "ceph_debug.h" 1#include <linux/ceph/ceph_debug.h>
2 2
3#include <linux/backing-dev.h> 3#include <linux/backing-dev.h>
4#include <linux/fs.h> 4#include <linux/fs.h>
@@ -10,7 +10,8 @@
10#include <linux/task_io_accounting_ops.h> 10#include <linux/task_io_accounting_ops.h>
11 11
12#include "super.h" 12#include "super.h"
13#include "osd_client.h" 13#include "mds_client.h"
14#include <linux/ceph/osd_client.h>
14 15
15/* 16/*
16 * Ceph address space ops. 17 * Ceph address space ops.
@@ -23,7 +24,7 @@
23 * context needs to be associated with the osd write during writeback. 24 * context needs to be associated with the osd write during writeback.
24 * 25 *
25 * Similarly, struct ceph_inode_info maintains a set of counters to 26 * Similarly, struct ceph_inode_info maintains a set of counters to
26 * count dirty pages on the inode. In the absense of snapshots, 27 * count dirty pages on the inode. In the absence of snapshots,
27 * i_wrbuffer_ref == i_wrbuffer_ref_head == the dirty page count. 28 * i_wrbuffer_ref == i_wrbuffer_ref_head == the dirty page count.
28 * 29 *
29 * When a snapshot is taken (that is, when the client receives 30 * When a snapshot is taken (that is, when the client receives
@@ -91,7 +92,7 @@ static int ceph_set_page_dirty(struct page *page)
91 ci->i_head_snapc = ceph_get_snap_context(snapc); 92 ci->i_head_snapc = ceph_get_snap_context(snapc);
92 ++ci->i_wrbuffer_ref_head; 93 ++ci->i_wrbuffer_ref_head;
93 if (ci->i_wrbuffer_ref == 0) 94 if (ci->i_wrbuffer_ref == 0)
94 igrab(inode); 95 ihold(inode);
95 ++ci->i_wrbuffer_ref; 96 ++ci->i_wrbuffer_ref;
96 dout("%p set_page_dirty %p idx %lu head %d/%d -> %d/%d " 97 dout("%p set_page_dirty %p idx %lu head %d/%d -> %d/%d "
97 "snapc %p seq %lld (%d snaps)\n", 98 "snapc %p seq %lld (%d snaps)\n",
@@ -193,7 +194,8 @@ static int readpage_nounlock(struct file *filp, struct page *page)
193{ 194{
194 struct inode *inode = filp->f_dentry->d_inode; 195 struct inode *inode = filp->f_dentry->d_inode;
195 struct ceph_inode_info *ci = ceph_inode(inode); 196 struct ceph_inode_info *ci = ceph_inode(inode);
196 struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc; 197 struct ceph_osd_client *osdc =
198 &ceph_inode_to_client(inode)->client->osdc;
197 int err = 0; 199 int err = 0;
198 u64 len = PAGE_CACHE_SIZE; 200 u64 len = PAGE_CACHE_SIZE;
199 201
@@ -202,7 +204,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
202 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout, 204 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
203 page->index << PAGE_CACHE_SHIFT, &len, 205 page->index << PAGE_CACHE_SHIFT, &len,
204 ci->i_truncate_seq, ci->i_truncate_size, 206 ci->i_truncate_seq, ci->i_truncate_size,
205 &page, 1); 207 &page, 1, 0);
206 if (err == -ENOENT) 208 if (err == -ENOENT)
207 err = 0; 209 err = 0;
208 if (err < 0) { 210 if (err < 0) {
@@ -265,7 +267,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
265{ 267{
266 struct inode *inode = file->f_dentry->d_inode; 268 struct inode *inode = file->f_dentry->d_inode;
267 struct ceph_inode_info *ci = ceph_inode(inode); 269 struct ceph_inode_info *ci = ceph_inode(inode);
268 struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc; 270 struct ceph_osd_client *osdc =
271 &ceph_inode_to_client(inode)->client->osdc;
269 int rc = 0; 272 int rc = 0;
270 struct page **pages; 273 struct page **pages;
271 loff_t offset; 274 loff_t offset;
@@ -284,7 +287,7 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
284 rc = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout, 287 rc = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
285 offset, &len, 288 offset, &len,
286 ci->i_truncate_seq, ci->i_truncate_size, 289 ci->i_truncate_seq, ci->i_truncate_size,
287 pages, nr_pages); 290 pages, nr_pages, 0);
288 if (rc == -ENOENT) 291 if (rc == -ENOENT)
289 rc = 0; 292 rc = 0;
290 if (rc < 0) 293 if (rc < 0)
@@ -365,7 +368,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
365{ 368{
366 struct inode *inode; 369 struct inode *inode;
367 struct ceph_inode_info *ci; 370 struct ceph_inode_info *ci;
368 struct ceph_client *client; 371 struct ceph_fs_client *fsc;
369 struct ceph_osd_client *osdc; 372 struct ceph_osd_client *osdc;
370 loff_t page_off = page->index << PAGE_CACHE_SHIFT; 373 loff_t page_off = page->index << PAGE_CACHE_SHIFT;
371 int len = PAGE_CACHE_SIZE; 374 int len = PAGE_CACHE_SIZE;
@@ -383,8 +386,8 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
383 } 386 }
384 inode = page->mapping->host; 387 inode = page->mapping->host;
385 ci = ceph_inode(inode); 388 ci = ceph_inode(inode);
386 client = ceph_inode_to_client(inode); 389 fsc = ceph_inode_to_client(inode);
387 osdc = &client->osdc; 390 osdc = &fsc->client->osdc;
388 391
389 /* verify this is a writeable snap context */ 392 /* verify this is a writeable snap context */
390 snapc = (void *)page->private; 393 snapc = (void *)page->private;
@@ -414,10 +417,10 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
414 dout("writepage %p page %p index %lu on %llu~%u snapc %p\n", 417 dout("writepage %p page %p index %lu on %llu~%u snapc %p\n",
415 inode, page, page->index, page_off, len, snapc); 418 inode, page, page->index, page_off, len, snapc);
416 419
417 writeback_stat = atomic_long_inc_return(&client->writeback_count); 420 writeback_stat = atomic_long_inc_return(&fsc->writeback_count);
418 if (writeback_stat > 421 if (writeback_stat >
419 CONGESTION_ON_THRESH(client->mount_args->congestion_kb)) 422 CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
420 set_bdi_congested(&client->backing_dev_info, BLK_RW_ASYNC); 423 set_bdi_congested(&fsc->backing_dev_info, BLK_RW_ASYNC);
421 424
422 set_page_writeback(page); 425 set_page_writeback(page);
423 err = ceph_osdc_writepages(osdc, ceph_vino(inode), 426 err = ceph_osdc_writepages(osdc, ceph_vino(inode),
@@ -450,7 +453,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc)
450 int err; 453 int err;
451 struct inode *inode = page->mapping->host; 454 struct inode *inode = page->mapping->host;
452 BUG_ON(!inode); 455 BUG_ON(!inode);
453 igrab(inode); 456 ihold(inode);
454 err = writepage_nounlock(page, wbc); 457 err = writepage_nounlock(page, wbc);
455 unlock_page(page); 458 unlock_page(page);
456 iput(inode); 459 iput(inode);
@@ -496,7 +499,7 @@ static void writepages_finish(struct ceph_osd_request *req,
496 struct address_space *mapping = inode->i_mapping; 499 struct address_space *mapping = inode->i_mapping;
497 __s32 rc = -EIO; 500 __s32 rc = -EIO;
498 u64 bytes = 0; 501 u64 bytes = 0;
499 struct ceph_client *client = ceph_inode_to_client(inode); 502 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
500 long writeback_stat; 503 long writeback_stat;
501 unsigned issued = ceph_caps_issued(ci); 504 unsigned issued = ceph_caps_issued(ci);
502 505
@@ -529,10 +532,10 @@ static void writepages_finish(struct ceph_osd_request *req,
529 WARN_ON(!PageUptodate(page)); 532 WARN_ON(!PageUptodate(page));
530 533
531 writeback_stat = 534 writeback_stat =
532 atomic_long_dec_return(&client->writeback_count); 535 atomic_long_dec_return(&fsc->writeback_count);
533 if (writeback_stat < 536 if (writeback_stat <
534 CONGESTION_OFF_THRESH(client->mount_args->congestion_kb)) 537 CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
535 clear_bdi_congested(&client->backing_dev_info, 538 clear_bdi_congested(&fsc->backing_dev_info,
536 BLK_RW_ASYNC); 539 BLK_RW_ASYNC);
537 540
538 ceph_put_snap_context((void *)page->private); 541 ceph_put_snap_context((void *)page->private);
@@ -569,13 +572,13 @@ static void writepages_finish(struct ceph_osd_request *req,
569 * mempool. we avoid the mempool if we can because req->r_num_pages 572 * mempool. we avoid the mempool if we can because req->r_num_pages
570 * may be less than the maximum write size. 573 * may be less than the maximum write size.
571 */ 574 */
572static void alloc_page_vec(struct ceph_client *client, 575static void alloc_page_vec(struct ceph_fs_client *fsc,
573 struct ceph_osd_request *req) 576 struct ceph_osd_request *req)
574{ 577{
575 req->r_pages = kmalloc(sizeof(struct page *) * req->r_num_pages, 578 req->r_pages = kmalloc(sizeof(struct page *) * req->r_num_pages,
576 GFP_NOFS); 579 GFP_NOFS);
577 if (!req->r_pages) { 580 if (!req->r_pages) {
578 req->r_pages = mempool_alloc(client->wb_pagevec_pool, GFP_NOFS); 581 req->r_pages = mempool_alloc(fsc->wb_pagevec_pool, GFP_NOFS);
579 req->r_pages_from_pool = 1; 582 req->r_pages_from_pool = 1;
580 WARN_ON(!req->r_pages); 583 WARN_ON(!req->r_pages);
581 } 584 }
@@ -588,9 +591,8 @@ static int ceph_writepages_start(struct address_space *mapping,
588 struct writeback_control *wbc) 591 struct writeback_control *wbc)
589{ 592{
590 struct inode *inode = mapping->host; 593 struct inode *inode = mapping->host;
591 struct backing_dev_info *bdi = mapping->backing_dev_info;
592 struct ceph_inode_info *ci = ceph_inode(inode); 594 struct ceph_inode_info *ci = ceph_inode(inode);
593 struct ceph_client *client; 595 struct ceph_fs_client *fsc;
594 pgoff_t index, start, end; 596 pgoff_t index, start, end;
595 int range_whole = 0; 597 int range_whole = 0;
596 int should_loop = 1; 598 int should_loop = 1;
@@ -617,26 +619,19 @@ static int ceph_writepages_start(struct address_space *mapping,
617 wbc->sync_mode == WB_SYNC_NONE ? "NONE" : 619 wbc->sync_mode == WB_SYNC_NONE ? "NONE" :
618 (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD")); 620 (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD"));
619 621
620 client = ceph_inode_to_client(inode); 622 fsc = ceph_inode_to_client(inode);
621 if (client->mount_state == CEPH_MOUNT_SHUTDOWN) { 623 if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) {
622 pr_warning("writepage_start %p on forced umount\n", inode); 624 pr_warning("writepage_start %p on forced umount\n", inode);
623 return -EIO; /* we're in a forced umount, don't write! */ 625 return -EIO; /* we're in a forced umount, don't write! */
624 } 626 }
625 if (client->mount_args->wsize && client->mount_args->wsize < wsize) 627 if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize)
626 wsize = client->mount_args->wsize; 628 wsize = fsc->mount_options->wsize;
627 if (wsize < PAGE_CACHE_SIZE) 629 if (wsize < PAGE_CACHE_SIZE)
628 wsize = PAGE_CACHE_SIZE; 630 wsize = PAGE_CACHE_SIZE;
629 max_pages_ever = wsize >> PAGE_CACHE_SHIFT; 631 max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
630 632
631 pagevec_init(&pvec, 0); 633 pagevec_init(&pvec, 0);
632 634
633 /* ?? */
634 if (wbc->nonblocking && bdi_write_congested(bdi)) {
635 dout(" writepages congested\n");
636 wbc->encountered_congestion = 1;
637 goto out_final;
638 }
639
640 /* where to start/end? */ 635 /* where to start/end? */
641 if (wbc->range_cyclic) { 636 if (wbc->range_cyclic) {
642 start = mapping->writeback_index; /* Start from prev offset */ 637 start = mapping->writeback_index; /* Start from prev offset */
@@ -769,7 +764,7 @@ get_more_pages:
769 offset = (unsigned long long)page->index 764 offset = (unsigned long long)page->index
770 << PAGE_CACHE_SHIFT; 765 << PAGE_CACHE_SHIFT;
771 len = wsize; 766 len = wsize;
772 req = ceph_osdc_new_request(&client->osdc, 767 req = ceph_osdc_new_request(&fsc->client->osdc,
773 &ci->i_layout, 768 &ci->i_layout,
774 ceph_vino(inode), 769 ceph_vino(inode),
775 offset, &len, 770 offset, &len,
@@ -779,10 +774,17 @@ get_more_pages:
779 snapc, do_sync, 774 snapc, do_sync,
780 ci->i_truncate_seq, 775 ci->i_truncate_seq,
781 ci->i_truncate_size, 776 ci->i_truncate_size,
782 &inode->i_mtime, true, 1); 777 &inode->i_mtime, true, 1, 0);
778
779 if (!req) {
780 rc = -ENOMEM;
781 unlock_page(page);
782 break;
783 }
784
783 max_pages = req->r_num_pages; 785 max_pages = req->r_num_pages;
784 786
785 alloc_page_vec(client, req); 787 alloc_page_vec(fsc, req);
786 req->r_callback = writepages_finish; 788 req->r_callback = writepages_finish;
787 req->r_inode = inode; 789 req->r_inode = inode;
788 } 790 }
@@ -794,10 +796,10 @@ get_more_pages:
794 inode, page, page->index); 796 inode, page, page->index);
795 797
796 writeback_stat = 798 writeback_stat =
797 atomic_long_inc_return(&client->writeback_count); 799 atomic_long_inc_return(&fsc->writeback_count);
798 if (writeback_stat > CONGESTION_ON_THRESH( 800 if (writeback_stat > CONGESTION_ON_THRESH(
799 client->mount_args->congestion_kb)) { 801 fsc->mount_options->congestion_kb)) {
800 set_bdi_congested(&client->backing_dev_info, 802 set_bdi_congested(&fsc->backing_dev_info,
801 BLK_RW_ASYNC); 803 BLK_RW_ASYNC);
802 } 804 }
803 805
@@ -846,7 +848,8 @@ get_more_pages:
846 op->payload_len = cpu_to_le32(len); 848 op->payload_len = cpu_to_le32(len);
847 req->r_request->hdr.data_len = cpu_to_le32(len); 849 req->r_request->hdr.data_len = cpu_to_le32(len);
848 850
849 ceph_osdc_start_request(&client->osdc, req, true); 851 rc = ceph_osdc_start_request(&fsc->client->osdc, req, true);
852 BUG_ON(rc);
850 req = NULL; 853 req = NULL;
851 854
852 /* continue? */ 855 /* continue? */
@@ -878,11 +881,8 @@ release_pvec_pages:
878out: 881out:
879 if (req) 882 if (req)
880 ceph_osdc_put_request(req); 883 ceph_osdc_put_request(req);
881 if (rc > 0)
882 rc = 0; /* vfs expects us to return 0 */
883 ceph_put_snap_context(snapc); 884 ceph_put_snap_context(snapc);
884 dout("writepages done, rc = %d\n", rc); 885 dout("writepages done, rc = %d\n", rc);
885out_final:
886 return rc; 886 return rc;
887} 887}
888 888
@@ -915,7 +915,7 @@ static int ceph_update_writeable_page(struct file *file,
915{ 915{
916 struct inode *inode = file->f_dentry->d_inode; 916 struct inode *inode = file->f_dentry->d_inode;
917 struct ceph_inode_info *ci = ceph_inode(inode); 917 struct ceph_inode_info *ci = ceph_inode(inode);
918 struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc; 918 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
919 loff_t page_off = pos & PAGE_CACHE_MASK; 919 loff_t page_off = pos & PAGE_CACHE_MASK;
920 int pos_in_page = pos & ~PAGE_CACHE_MASK; 920 int pos_in_page = pos & ~PAGE_CACHE_MASK;
921 int end_in_page = pos_in_page + len; 921 int end_in_page = pos_in_page + len;
@@ -1053,8 +1053,8 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
1053 struct page *page, void *fsdata) 1053 struct page *page, void *fsdata)
1054{ 1054{
1055 struct inode *inode = file->f_dentry->d_inode; 1055 struct inode *inode = file->f_dentry->d_inode;
1056 struct ceph_client *client = ceph_inode_to_client(inode); 1056 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
1057 struct ceph_mds_client *mdsc = &client->mdsc; 1057 struct ceph_mds_client *mdsc = fsc->mdsc;
1058 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 1058 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
1059 int check_cap = 0; 1059 int check_cap = 0;
1060 1060
@@ -1123,7 +1123,7 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
1123{ 1123{
1124 struct inode *inode = vma->vm_file->f_dentry->d_inode; 1124 struct inode *inode = vma->vm_file->f_dentry->d_inode;
1125 struct page *page = vmf->page; 1125 struct page *page = vmf->page;
1126 struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc; 1126 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
1127 loff_t off = page->index << PAGE_CACHE_SHIFT; 1127 loff_t off = page->index << PAGE_CACHE_SHIFT;
1128 loff_t size, len; 1128 loff_t size, len;
1129 int ret; 1129 int ret;