]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blobdiff - fs/ceph/addr.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[mirror_ubuntu-kernels.git] / fs / ceph / addr.c
index 19adeb0ef82a397f122682db3a9ba31f56df5f5d..4801571f51cb4e7461d8d1f9f8f3136fb6713fbc 100644 (file)
@@ -143,7 +143,7 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
        inode = page->mapping->host;
        ci = ceph_inode(inode);
 
-       if (offset != 0 || length != PAGE_CACHE_SIZE) {
+       if (offset != 0 || length != PAGE_SIZE) {
                dout("%p invalidatepage %p idx %lu partial dirty page %u~%u\n",
                     inode, page, page->index, offset, length);
                return;
@@ -175,8 +175,8 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
 
 static int ceph_releasepage(struct page *page, gfp_t g)
 {
-       struct inode *inode = page->mapping ? page->mapping->host : NULL;
-       dout("%p releasepage %p idx %lu\n", inode, page, page->index);
+       dout("%p releasepage %p idx %lu\n", page->mapping->host,
+            page, page->index);
        WARN_ON(PageDirty(page));
 
        /* Can we release the page from the cache? */
@@ -197,10 +197,10 @@ static int readpage_nounlock(struct file *filp, struct page *page)
                &ceph_inode_to_client(inode)->client->osdc;
        int err = 0;
        u64 off = page_offset(page);
-       u64 len = PAGE_CACHE_SIZE;
+       u64 len = PAGE_SIZE;
 
        if (off >= i_size_read(inode)) {
-               zero_user_segment(page, 0, PAGE_CACHE_SIZE);
+               zero_user_segment(page, 0, PAGE_SIZE);
                SetPageUptodate(page);
                return 0;
        }
@@ -212,7 +212,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
                 */
                if (off == 0)
                        return -EINVAL;
-               zero_user_segment(page, 0, PAGE_CACHE_SIZE);
+               zero_user_segment(page, 0, PAGE_SIZE);
                SetPageUptodate(page);
                return 0;
        }
@@ -234,9 +234,9 @@ static int readpage_nounlock(struct file *filp, struct page *page)
                ceph_fscache_readpage_cancel(inode, page);
                goto out;
        }
-       if (err < PAGE_CACHE_SIZE)
+       if (err < PAGE_SIZE)
                /* zero fill remainder of page */
-               zero_user_segment(page, err, PAGE_CACHE_SIZE);
+               zero_user_segment(page, err, PAGE_SIZE);
        else
                flush_dcache_page(page);
 
@@ -276,12 +276,12 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
        for (i = 0; i < num_pages; i++) {
                struct page *page = osd_data->pages[i];
 
-               if (rc < 0 && rc != ENOENT)
+               if (rc < 0 && rc != -ENOENT)
                        goto unlock;
-               if (bytes < (int)PAGE_CACHE_SIZE) {
+               if (bytes < (int)PAGE_SIZE) {
                        /* zero (remainder of) page */
                        int s = bytes < 0 ? 0 : bytes;
-                       zero_user_segment(page, s, PAGE_CACHE_SIZE);
+                       zero_user_segment(page, s, PAGE_SIZE);
                }
                dout("finish_read %p uptodate %p idx %lu\n", inode, page,
                     page->index);
@@ -290,8 +290,8 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
                ceph_readpage_to_fscache(inode, page);
 unlock:
                unlock_page(page);
-               page_cache_release(page);
-               bytes -= PAGE_CACHE_SIZE;
+               put_page(page);
+               bytes -= PAGE_SIZE;
        }
        kfree(osd_data->pages);
 }
@@ -336,7 +336,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
                if (max && nr_pages == max)
                        break;
        }
-       len = nr_pages << PAGE_CACHE_SHIFT;
+       len = nr_pages << PAGE_SHIFT;
        dout("start_read %p nr_pages %d is %lld~%lld\n", inode, nr_pages,
             off, len);
        vino = ceph_vino(inode);
@@ -364,7 +364,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
                if (add_to_page_cache_lru(page, &inode->i_data, page->index,
                                          GFP_KERNEL)) {
                        ceph_fscache_uncache_page(inode, page);
-                       page_cache_release(page);
+                       put_page(page);
                        dout("start_read %p add_to_page_cache failed %p\n",
                             inode, page);
                        nr_pages = i;
@@ -415,8 +415,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
        if (rc == 0)
                goto out;
 
-       if (fsc->mount_options->rsize >= PAGE_CACHE_SIZE)
-               max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1)
+       if (fsc->mount_options->rsize >= PAGE_SIZE)
+               max = (fsc->mount_options->rsize + PAGE_SIZE - 1)
                        >> PAGE_SHIFT;
 
        dout("readpages %p file %p nr_pages %d max %d\n", inode,
@@ -484,7 +484,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
        long writeback_stat;
        u64 truncate_size;
        u32 truncate_seq;
-       int err = 0, len = PAGE_CACHE_SIZE;
+       int err = 0, len = PAGE_SIZE;
 
        dout("writepage %p idx %lu\n", page, page->index);
 
@@ -606,71 +606,71 @@ static void writepages_finish(struct ceph_osd_request *req,
        struct inode *inode = req->r_inode;
        struct ceph_inode_info *ci = ceph_inode(inode);
        struct ceph_osd_data *osd_data;
-       unsigned wrote;
        struct page *page;
-       int num_pages;
-       int i;
+       int num_pages, total_pages = 0;
+       int i, j;
+       int rc = req->r_result;
        struct ceph_snap_context *snapc = req->r_snapc;
        struct address_space *mapping = inode->i_mapping;
-       int rc = req->r_result;
-       u64 bytes = req->r_ops[0].extent.length;
        struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
-       long writeback_stat;
-       unsigned issued = ceph_caps_issued(ci);
+       bool remove_page;
 
-       osd_data = osd_req_op_extent_osd_data(req, 0);
-       BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
-       num_pages = calc_pages_for((u64)osd_data->alignment,
-                                       (u64)osd_data->length);
-       if (rc >= 0) {
-               /*
-                * Assume we wrote the pages we originally sent.  The
-                * osd might reply with fewer pages if our writeback
-                * raced with a truncation and was adjusted at the osd,
-                * so don't believe the reply.
-                */
-               wrote = num_pages;
-       } else {
-               wrote = 0;
+
+       dout("writepages_finish %p rc %d\n", inode, rc);
+       if (rc < 0)
                mapping_set_error(mapping, rc);
-       }
-       dout("writepages_finish %p rc %d bytes %llu wrote %d (pages)\n",
-            inode, rc, bytes, wrote);
 
-       /* clean all pages */
-       for (i = 0; i < num_pages; i++) {
-               page = osd_data->pages[i];
-               BUG_ON(!page);
-               WARN_ON(!PageUptodate(page));
+       /*
+        * We lost the cache cap, need to truncate the page before
+        * it is unlocked, otherwise we'd truncate it later in the
+        * page truncation thread, possibly losing some data that
+        * raced its way in
+        */
+       remove_page = !(ceph_caps_issued(ci) &
+                       (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO));
 
-               writeback_stat =
-                       atomic_long_dec_return(&fsc->writeback_count);
-               if (writeback_stat <
-                   CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
-                       clear_bdi_congested(&fsc->backing_dev_info,
-                                           BLK_RW_ASYNC);
+       /* clean all pages */
+       for (i = 0; i < req->r_num_ops; i++) {
+               if (req->r_ops[i].op != CEPH_OSD_OP_WRITE)
+                       break;
 
-               ceph_put_snap_context(page_snap_context(page));
-               page->private = 0;
-               ClearPagePrivate(page);
-               dout("unlocking %d %p\n", i, page);
-               end_page_writeback(page);
+               osd_data = osd_req_op_extent_osd_data(req, i);
+               BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
+               num_pages = calc_pages_for((u64)osd_data->alignment,
+                                          (u64)osd_data->length);
+               total_pages += num_pages;
+               for (j = 0; j < num_pages; j++) {
+                       page = osd_data->pages[j];
+                       BUG_ON(!page);
+                       WARN_ON(!PageUptodate(page));
+
+                       if (atomic_long_dec_return(&fsc->writeback_count) <
+                            CONGESTION_OFF_THRESH(
+                                       fsc->mount_options->congestion_kb))
+                               clear_bdi_congested(&fsc->backing_dev_info,
+                                                   BLK_RW_ASYNC);
+
+                       ceph_put_snap_context(page_snap_context(page));
+                       page->private = 0;
+                       ClearPagePrivate(page);
+                       dout("unlocking %p\n", page);
+                       end_page_writeback(page);
+
+                       if (remove_page)
+                               generic_error_remove_page(inode->i_mapping,
+                                                         page);
 
-               /*
-                * We lost the cache cap, need to truncate the page before
-                * it is unlocked, otherwise we'd truncate it later in the
-                * page truncation thread, possibly losing some data that
-                * raced its way in
-                */
-               if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0)
-                       generic_error_remove_page(inode->i_mapping, page);
+                       unlock_page(page);
+               }
+               dout("writepages_finish %p wrote %llu bytes cleaned %d pages\n",
+                    inode, osd_data->length, rc >= 0 ? num_pages : 0);
 
-               unlock_page(page);
+               ceph_release_pages(osd_data->pages, num_pages);
        }
-       dout("%p wrote+cleaned %d pages\n", inode, wrote);
-       ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc);
 
-       ceph_release_pages(osd_data->pages, num_pages);
+       ceph_put_wrbuffer_cap_refs(ci, total_pages, snapc);
+
+       osd_data = osd_req_op_extent_osd_data(req, 0);
        if (osd_data->pages_from_pool)
                mempool_free(osd_data->pages,
                             ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
@@ -725,9 +725,9 @@ static int ceph_writepages_start(struct address_space *mapping,
        }
        if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize)
                wsize = fsc->mount_options->wsize;
-       if (wsize < PAGE_CACHE_SIZE)
-               wsize = PAGE_CACHE_SIZE;
-       max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
+       if (wsize < PAGE_SIZE)
+               wsize = PAGE_SIZE;
+       max_pages_ever = wsize >> PAGE_SHIFT;
 
        pagevec_init(&pvec, 0);
 
@@ -737,8 +737,8 @@ static int ceph_writepages_start(struct address_space *mapping,
                end = -1;
                dout(" cyclic, start at %lu\n", start);
        } else {
-               start = wbc->range_start >> PAGE_CACHE_SHIFT;
-               end = wbc->range_end >> PAGE_CACHE_SHIFT;
+               start = wbc->range_start >> PAGE_SHIFT;
+               end = wbc->range_end >> PAGE_SHIFT;
                if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
                        range_whole = 1;
                should_loop = 0;
@@ -778,17 +778,15 @@ retry:
        while (!done && index <= end) {
                unsigned i;
                int first;
-               pgoff_t next;
-               int pvec_pages, locked_pages;
-               struct page **pages = NULL;
+               pgoff_t strip_unit_end = 0;
+               int num_ops = 0, op_idx;
+               int pvec_pages, locked_pages = 0;
+               struct page **pages = NULL, **data_pages;
                mempool_t *pool = NULL; /* Becomes non-null if mempool used */
                struct page *page;
                int want;
-               u64 offset, len;
-               long writeback_stat;
+               u64 offset = 0, len = 0;
 
-               next = 0;
-               locked_pages = 0;
                max_pages = max_pages_ever;
 
 get_more_pages:
@@ -824,8 +822,8 @@ get_more_pages:
                                unlock_page(page);
                                break;
                        }
-                       if (next && (page->index != next)) {
-                               dout("not consecutive %p\n", page);
+                       if (strip_unit_end && (page->index > strip_unit_end)) {
+                               dout("end of strip unit %p\n", page);
                                unlock_page(page);
                                break;
                        }
@@ -867,36 +865,31 @@ get_more_pages:
                        /*
                         * We have something to write.  If this is
                         * the first locked page this time through,
-                        * allocate an osd request and a page array
-                        * that it will use.
+                        * calculate max possinle write size and
+                        * allocate a page array
                         */
                        if (locked_pages == 0) {
-                               BUG_ON(pages);
+                               u64 objnum;
+                               u64 objoff;
+
                                /* prepare async write request */
                                offset = (u64)page_offset(page);
                                len = wsize;
-                               req = ceph_osdc_new_request(&fsc->client->osdc,
-                                                       &ci->i_layout, vino,
-                                                       offset, &len, 0,
-                                                       do_sync ? 2 : 1,
-                                                       CEPH_OSD_OP_WRITE,
-                                                       CEPH_OSD_FLAG_WRITE |
-                                                       CEPH_OSD_FLAG_ONDISK,
-                                                       snapc, truncate_seq,
-                                                       truncate_size, true);
-                               if (IS_ERR(req)) {
-                                       rc = PTR_ERR(req);
+
+                               rc = ceph_calc_file_object_mapping(&ci->i_layout,
+                                                               offset, len,
+                                                               &objnum, &objoff,
+                                                               &len);
+                               if (rc < 0) {
                                        unlock_page(page);
                                        break;
                                }
 
-                               if (do_sync)
-                                       osd_req_op_init(req, 1,
-                                                       CEPH_OSD_OP_STARTSYNC, 0);
-
-                               req->r_callback = writepages_finish;
-                               req->r_inode = inode;
+                               num_ops = 1 + do_sync;
+                               strip_unit_end = page->index +
+                                       ((len - 1) >> PAGE_SHIFT);
 
+                               BUG_ON(pages);
                                max_pages = calc_pages_for(0, (u64)len);
                                pages = kmalloc(max_pages * sizeof (*pages),
                                                GFP_NOFS);
@@ -905,6 +898,20 @@ get_more_pages:
                                        pages = mempool_alloc(pool, GFP_NOFS);
                                        BUG_ON(!pages);
                                }
+
+                               len = 0;
+                       } else if (page->index !=
+                                  (offset + len) >> PAGE_SHIFT) {
+                               if (num_ops >= (pool ?  CEPH_OSD_SLAB_OPS :
+                                                       CEPH_OSD_MAX_OPS)) {
+                                       redirty_page_for_writepage(wbc, page);
+                                       unlock_page(page);
+                                       break;
+                               }
+
+                               num_ops++;
+                               offset = (u64)page_offset(page);
+                               len = 0;
                        }
 
                        /* note position of first page in pvec */
@@ -913,18 +920,16 @@ get_more_pages:
                        dout("%p will write page %p idx %lu\n",
                             inode, page, page->index);
 
-                       writeback_stat =
-                              atomic_long_inc_return(&fsc->writeback_count);
-                       if (writeback_stat > CONGESTION_ON_THRESH(
+                       if (atomic_long_inc_return(&fsc->writeback_count) >
+                           CONGESTION_ON_THRESH(
                                    fsc->mount_options->congestion_kb)) {
                                set_bdi_congested(&fsc->backing_dev_info,
                                                  BLK_RW_ASYNC);
                        }
 
-                       set_page_writeback(page);
                        pages[locked_pages] = page;
                        locked_pages++;
-                       next = page->index + 1;
+                       len += PAGE_SIZE;
                }
 
                /* did we get anything? */
@@ -944,38 +949,119 @@ get_more_pages:
                        /* shift unused pages over in the pvec...  we
                         * will need to release them below. */
                        for (j = i; j < pvec_pages; j++) {
-                               dout(" pvec leftover page %p\n",
-                                    pvec.pages[j]);
+                               dout(" pvec leftover page %p\n", pvec.pages[j]);
                                pvec.pages[j-i+first] = pvec.pages[j];
                        }
                        pvec.nr -= i-first;
                }
 
-               /* Format the osd request message and submit the write */
+new_request:
                offset = page_offset(pages[0]);
-               len = (u64)locked_pages << PAGE_CACHE_SHIFT;
-               if (snap_size == -1) {
-                       len = min(len, (u64)i_size_read(inode) - offset);
-                        /* writepages_finish() clears writeback pages
-                         * according to the data length, so make sure
-                         * data length covers all locked pages */
-                       len = max(len, 1 +
-                               ((u64)(locked_pages - 1) << PAGE_CACHE_SHIFT));
-               } else {
-                       len = min(len, snap_size - offset);
+               len = wsize;
+
+               req = ceph_osdc_new_request(&fsc->client->osdc,
+                                       &ci->i_layout, vino,
+                                       offset, &len, 0, num_ops,
+                                       CEPH_OSD_OP_WRITE,
+                                       CEPH_OSD_FLAG_WRITE |
+                                       CEPH_OSD_FLAG_ONDISK,
+                                       snapc, truncate_seq,
+                                       truncate_size, false);
+               if (IS_ERR(req)) {
+                       req = ceph_osdc_new_request(&fsc->client->osdc,
+                                               &ci->i_layout, vino,
+                                               offset, &len, 0,
+                                               min(num_ops,
+                                                   CEPH_OSD_SLAB_OPS),
+                                               CEPH_OSD_OP_WRITE,
+                                               CEPH_OSD_FLAG_WRITE |
+                                               CEPH_OSD_FLAG_ONDISK,
+                                               snapc, truncate_seq,
+                                               truncate_size, true);
+                       BUG_ON(IS_ERR(req));
                }
-               dout("writepages got %d pages at %llu~%llu\n",
-                    locked_pages, offset, len);
+               BUG_ON(len < page_offset(pages[locked_pages - 1]) +
+                            PAGE_SIZE - offset);
+
+               req->r_callback = writepages_finish;
+               req->r_inode = inode;
 
-               osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0,
+               /* Format the osd request message and submit the write */
+               len = 0;
+               data_pages = pages;
+               op_idx = 0;
+               for (i = 0; i < locked_pages; i++) {
+                       u64 cur_offset = page_offset(pages[i]);
+                       if (offset + len != cur_offset) {
+                               if (op_idx + do_sync + 1 == req->r_num_ops)
+                                       break;
+                               osd_req_op_extent_dup_last(req, op_idx,
+                                                          cur_offset - offset);
+                               dout("writepages got pages at %llu~%llu\n",
+                                    offset, len);
+                               osd_req_op_extent_osd_data_pages(req, op_idx,
+                                                       data_pages, len, 0,
                                                        !!pool, false);
+                               osd_req_op_extent_update(req, op_idx, len);
 
-               pages = NULL;   /* request message now owns the pages array */
-               pool = NULL;
+                               len = 0;
+                               offset = cur_offset; 
+                               data_pages = pages + i;
+                               op_idx++;
+                       }
 
-               /* Update the write op length in case we changed it */
+                       set_page_writeback(pages[i]);
+                       len += PAGE_SIZE;
+               }
+
+               if (snap_size != -1) {
+                       len = min(len, snap_size - offset);
+               } else if (i == locked_pages) {
+                       /* writepages_finish() clears writeback pages
+                        * according to the data length, so make sure
+                        * data length covers all locked pages */
+                       u64 min_len = len + 1 - PAGE_SIZE;
+                       len = min(len, (u64)i_size_read(inode) - offset);
+                       len = max(len, min_len);
+               }
+               dout("writepages got pages at %llu~%llu\n", offset, len);
+
+               osd_req_op_extent_osd_data_pages(req, op_idx, data_pages, len,
+                                                0, !!pool, false);
+               osd_req_op_extent_update(req, op_idx, len);
 
-               osd_req_op_extent_update(req, 0, len);
+               if (do_sync) {
+                       op_idx++;
+                       osd_req_op_init(req, op_idx, CEPH_OSD_OP_STARTSYNC, 0);
+               }
+               BUG_ON(op_idx + 1 != req->r_num_ops);
+
+               pool = NULL;
+               if (i < locked_pages) {
+                       BUG_ON(num_ops <= req->r_num_ops);
+                       num_ops -= req->r_num_ops;
+                       num_ops += do_sync;
+                       locked_pages -= i;
+
+                       /* allocate new pages array for next request */
+                       data_pages = pages;
+                       pages = kmalloc(locked_pages * sizeof (*pages),
+                                       GFP_NOFS);
+                       if (!pages) {
+                               pool = fsc->wb_pagevec_pool;
+                               pages = mempool_alloc(pool, GFP_NOFS);
+                               BUG_ON(!pages);
+                       }
+                       memcpy(pages, data_pages + i,
+                              locked_pages * sizeof(*pages));
+                       memset(data_pages + i, 0,
+                              locked_pages * sizeof(*pages));
+               } else {
+                       BUG_ON(num_ops != req->r_num_ops);
+                       index = pages[i - 1]->index + 1;
+                       /* request message now owns the pages array */
+                       pages = NULL;
+               }
 
                vino = ceph_vino(inode);
                ceph_osdc_build_request(req, offset, snapc, vino.snap,
@@ -985,9 +1071,10 @@ get_more_pages:
                BUG_ON(rc);
                req = NULL;
 
-               /* continue? */
-               index = next;
-               wbc->nr_to_write -= locked_pages;
+               wbc->nr_to_write -= i;
+               if (pages)
+                       goto new_request;
+
                if (wbc->nr_to_write <= 0)
                        done = 1;
 
@@ -1048,8 +1135,8 @@ static int ceph_update_writeable_page(struct file *file,
 {
        struct inode *inode = file_inode(file);
        struct ceph_inode_info *ci = ceph_inode(inode);
-       loff_t page_off = pos & PAGE_CACHE_MASK;
-       int pos_in_page = pos & ~PAGE_CACHE_MASK;
+       loff_t page_off = pos & PAGE_MASK;
+       int pos_in_page = pos & ~PAGE_MASK;
        int end_in_page = pos_in_page + len;
        loff_t i_size;
        int r;
@@ -1104,7 +1191,7 @@ retry_locked:
        }
 
        /* full page? */
-       if (pos_in_page == 0 && len == PAGE_CACHE_SIZE)
+       if (pos_in_page == 0 && len == PAGE_SIZE)
                return 0;
 
        /* past end of file? */
@@ -1112,12 +1199,12 @@ retry_locked:
 
        if (page_off >= i_size ||
            (pos_in_page == 0 && (pos+len) >= i_size &&
-            end_in_page - pos_in_page != PAGE_CACHE_SIZE)) {
+            end_in_page - pos_in_page != PAGE_SIZE)) {
                dout(" zeroing %p 0 - %d and %d - %d\n",
-                    page, pos_in_page, end_in_page, (int)PAGE_CACHE_SIZE);
+                    page, pos_in_page, end_in_page, (int)PAGE_SIZE);
                zero_user_segments(page,
                                   0, pos_in_page,
-                                  end_in_page, PAGE_CACHE_SIZE);
+                                  end_in_page, PAGE_SIZE);
                return 0;
        }
 
@@ -1141,7 +1228,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
 {
        struct inode *inode = file_inode(file);
        struct page *page;
-       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+       pgoff_t index = pos >> PAGE_SHIFT;
        int r;
 
        do {
@@ -1155,7 +1242,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
 
                r = ceph_update_writeable_page(file, pos, len, page);
                if (r < 0)
-                       page_cache_release(page);
+                       put_page(page);
                else
                        *pagep = page;
        } while (r == -EAGAIN);
@@ -1172,7 +1259,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
                          struct page *page, void *fsdata)
 {
        struct inode *inode = file_inode(file);
-       unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+       unsigned from = pos & (PAGE_SIZE - 1);
        int check_cap = 0;
 
        dout("write_end file %p inode %p page %p %d~%d (%d)\n", file,
@@ -1192,7 +1279,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
        set_page_dirty(page);
 
        unlock_page(page);
-       page_cache_release(page);
+       put_page(page);
 
        if (check_cap)
                ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY, NULL);
@@ -1235,11 +1322,11 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        struct ceph_inode_info *ci = ceph_inode(inode);
        struct ceph_file_info *fi = vma->vm_file->private_data;
        struct page *pinned_page = NULL;
-       loff_t off = vmf->pgoff << PAGE_CACHE_SHIFT;
+       loff_t off = vmf->pgoff << PAGE_SHIFT;
        int want, got, ret;
 
        dout("filemap_fault %p %llx.%llx %llu~%zd trying to get caps\n",
-            inode, ceph_vinop(inode), off, (size_t)PAGE_CACHE_SIZE);
+            inode, ceph_vinop(inode), off, (size_t)PAGE_SIZE);
        if (fi->fmode & CEPH_FILE_MODE_LAZY)
                want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
        else
@@ -1256,7 +1343,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                }
        }
        dout("filemap_fault %p %llu~%zd got cap refs on %s\n",
-            inode, off, (size_t)PAGE_CACHE_SIZE, ceph_cap_string(got));
+            inode, off, (size_t)PAGE_SIZE, ceph_cap_string(got));
 
        if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
            ci->i_inline_version == CEPH_INLINE_NONE)
@@ -1265,16 +1352,16 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                ret = -EAGAIN;
 
        dout("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n",
-            inode, off, (size_t)PAGE_CACHE_SIZE, ceph_cap_string(got), ret);
+            inode, off, (size_t)PAGE_SIZE, ceph_cap_string(got), ret);
        if (pinned_page)
-               page_cache_release(pinned_page);
+               put_page(pinned_page);
        ceph_put_cap_refs(ci, got);
 
        if (ret != -EAGAIN)
                return ret;
 
        /* read inline data */
-       if (off >= PAGE_CACHE_SIZE) {
+       if (off >= PAGE_SIZE) {
                /* does not support inline data > PAGE_SIZE */
                ret = VM_FAULT_SIGBUS;
        } else {
@@ -1291,12 +1378,12 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
                                         CEPH_STAT_CAP_INLINE_DATA, true);
                if (ret1 < 0 || off >= i_size_read(inode)) {
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                        ret = VM_FAULT_SIGBUS;
                        goto out;
                }
-               if (ret1 < PAGE_CACHE_SIZE)
-                       zero_user_segment(page, ret1, PAGE_CACHE_SIZE);
+               if (ret1 < PAGE_SIZE)
+                       zero_user_segment(page, ret1, PAGE_SIZE);
                else
                        flush_dcache_page(page);
                SetPageUptodate(page);
@@ -1305,7 +1392,7 @@ static int ceph_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        }
 out:
        dout("filemap_fault %p %llu~%zd read inline data ret %d\n",
-            inode, off, (size_t)PAGE_CACHE_SIZE, ret);
+            inode, off, (size_t)PAGE_SIZE, ret);
        return ret;
 }
 
@@ -1343,10 +1430,10 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
                }
        }
 
-       if (off + PAGE_CACHE_SIZE <= size)
-               len = PAGE_CACHE_SIZE;
+       if (off + PAGE_SIZE <= size)
+               len = PAGE_SIZE;
        else
-               len = size & ~PAGE_CACHE_MASK;
+               len = size & ~PAGE_MASK;
 
        dout("page_mkwrite %p %llx.%llx %llu~%zd getting caps i_size %llu\n",
             inode, ceph_vinop(inode), off, len, size);
@@ -1432,7 +1519,7 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
                        return;
                if (PageUptodate(page)) {
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                        return;
                }
        }
@@ -1447,14 +1534,14 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
        }
 
        if (page != locked_page) {
-               if (len < PAGE_CACHE_SIZE)
-                       zero_user_segment(page, len, PAGE_CACHE_SIZE);
+               if (len < PAGE_SIZE)
+                       zero_user_segment(page, len, PAGE_SIZE);
                else
                        flush_dcache_page(page);
 
                SetPageUptodate(page);
                unlock_page(page);
-               page_cache_release(page);
+               put_page(page);
        }
 }
 
@@ -1491,7 +1578,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
                                from_pagecache = true;
                                lock_page(page);
                        } else {
-                               page_cache_release(page);
+                               put_page(page);
                                page = NULL;
                        }
                }
@@ -1499,8 +1586,8 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
 
        if (page) {
                len = i_size_read(inode);
-               if (len > PAGE_CACHE_SIZE)
-                       len = PAGE_CACHE_SIZE;
+               if (len > PAGE_SIZE)
+                       len = PAGE_SIZE;
        } else {
                page = __page_cache_alloc(GFP_NOFS);
                if (!page) {
@@ -1522,7 +1609,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
                                    ceph_vino(inode), 0, &len, 0, 1,
                                    CEPH_OSD_OP_CREATE,
                                    CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE,
-                                   ceph_empty_snapc, 0, 0, false);
+                                   NULL, 0, 0, false);
        if (IS_ERR(req)) {
                err = PTR_ERR(req);
                goto out;
@@ -1540,9 +1627,8 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
                                    ceph_vino(inode), 0, &len, 1, 3,
                                    CEPH_OSD_OP_WRITE,
                                    CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_WRITE,
-                                   ceph_empty_snapc,
-                                   ci->i_truncate_seq, ci->i_truncate_size,
-                                   false);
+                                   NULL, ci->i_truncate_seq,
+                                   ci->i_truncate_size, false);
        if (IS_ERR(req)) {
                err = PTR_ERR(req);
                goto out;
@@ -1584,7 +1670,7 @@ out:
        if (page && page != locked_page) {
                if (from_pagecache) {
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                } else
                        __free_pages(page, 0);
        }
@@ -1663,8 +1749,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
                goto out;
        }
 
-       rd_req = ceph_osdc_alloc_request(&fsc->client->osdc,
-                                        ceph_empty_snapc,
+       rd_req = ceph_osdc_alloc_request(&fsc->client->osdc, NULL,
                                         1, false, GFP_NOFS);
        if (!rd_req) {
                err = -ENOMEM;
@@ -1678,8 +1763,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
                 "%llx.00000000", ci->i_vino.ino);
        rd_req->r_base_oid.name_len = strlen(rd_req->r_base_oid.name);
 
-       wr_req = ceph_osdc_alloc_request(&fsc->client->osdc,
-                                        ceph_empty_snapc,
+       wr_req = ceph_osdc_alloc_request(&fsc->client->osdc, NULL,
                                         1, false, GFP_NOFS);
        if (!wr_req) {
                err = -ENOMEM;