ceph: rip out old fscache readpage handling
authorJeff Layton <jlayton@kernel.org>
Thu, 21 Jan 2021 17:32:05 +0000 (12:32 -0500)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 27 Apr 2021 21:52:21 +0000 (23:52 +0200)
With the new netfs read helper functions, we won't need a lot of this
infrastructure as it handles the pagecache pages itself. Rip out the
read handling for now, and much of the old infrastructure that deals in
individual pages.

The cookie handling is mostly unchanged, however.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/addr.c
fs/ceph/cache.c
fs/ceph/cache.h
fs/ceph/caps.c
fs/ceph/super.h

index 26e66436f0058cd2ebd201c924e4445686680955..e267aa60c8b669857d33965a82ec39f16de6f2b2 100644 (file)
@@ -155,8 +155,6 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
                return;
        }
 
-       ceph_invalidate_fscache_page(inode, page);
-
        WARN_ON(!PageLocked(page));
        if (!PagePrivate(page))
                return;
@@ -175,10 +173,6 @@ static int ceph_releasepage(struct page *page, gfp_t g)
        dout("%p releasepage %p idx %lu (%sdirty)\n", page->mapping->host,
             page, page->index, PageDirty(page) ? "" : "not ");
 
-       /* Can we release the page from the cache? */
-       if (!ceph_release_fscache_page(page, g))
-               return 0;
-
        return !PagePrivate(page);
 }
 
@@ -213,10 +207,6 @@ static int ceph_do_readpage(struct file *filp, struct page *page)
                return 0;
        }
 
-       err = ceph_readpage_from_fscache(inode, page);
-       if (err == 0)
-               return -EINPROGRESS;
-
        dout("readpage ino %llx.%llx file %p off %llu len %llu page %p index %lu\n",
             vino.ino, vino.snap, filp, off, len, page, page->index);
        req = ceph_osdc_new_request(osdc, &ci->i_layout, vino, off, &len, 0, 1,
@@ -241,7 +231,6 @@ static int ceph_do_readpage(struct file *filp, struct page *page)
        if (err == -ENOENT)
                err = 0;
        if (err < 0) {
-               ceph_fscache_readpage_cancel(inode, page);
                if (err == -EBLOCKLISTED)
                        fsc->blocklisted = true;
                goto out;
@@ -253,8 +242,6 @@ static int ceph_do_readpage(struct file *filp, struct page *page)
                flush_dcache_page(page);
 
        SetPageUptodate(page);
-       ceph_readpage_to_fscache(inode, page);
-
 out:
        return err < 0 ? err : 0;
 }
@@ -294,10 +281,8 @@ static void finish_read(struct ceph_osd_request *req)
        for (i = 0; i < num_pages; i++) {
                struct page *page = osd_data->pages[i];
 
-               if (rc < 0 && rc != -ENOENT) {
-                       ceph_fscache_readpage_cancel(inode, page);
+               if (rc < 0 && rc != -ENOENT)
                        goto unlock;
-               }
                if (bytes < (int)PAGE_SIZE) {
                        /* zero (remainder of) page */
                        int s = bytes < 0 ? 0 : bytes;
@@ -307,7 +292,6 @@ static void finish_read(struct ceph_osd_request *req)
                     page->index);
                flush_dcache_page(page);
                SetPageUptodate(page);
-               ceph_readpage_to_fscache(inode, page);
 unlock:
                unlock_page(page);
                put_page(page);
@@ -408,7 +392,6 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
                     page->index);
                if (add_to_page_cache_lru(page, &inode->i_data, page->index,
                                          GFP_KERNEL)) {
-                       ceph_fscache_uncache_page(inode, page);
                        put_page(page);
                        dout("start_read %p add_to_page_cache failed %p\n",
                             inode, page);
@@ -440,10 +423,8 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
        return nr_pages;
 
 out_pages:
-       for (i = 0; i < nr_pages; ++i) {
-               ceph_fscache_readpage_cancel(inode, pages[i]);
+       for (i = 0; i < nr_pages; ++i)
                unlock_page(pages[i]);
-       }
        ceph_put_page_vector(pages, nr_pages, false);
 out_put:
        ceph_osdc_put_request(req);
@@ -471,12 +452,6 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
        if (ceph_inode(inode)->i_inline_version != CEPH_INLINE_NONE)
                return -EINVAL;
 
-       rc = ceph_readpages_from_fscache(mapping->host, mapping, page_list,
-                                        &nr_pages);
-
-       if (rc == 0)
-               goto out;
-
        rw_ctx = ceph_find_rw_context(fi);
        max = fsc->mount_options->rsize >> PAGE_SHIFT;
        dout("readpages %p file %p ctx %p nr_pages %d max %d\n",
@@ -487,8 +462,6 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
                        goto out;
        }
 out:
-       ceph_fscache_readpages_cancel(inode, page_list);
-
        dout("readpages %p file %p ret %d\n", inode, file, rc);
        return rc;
 }
index 2f5cb6bc78e1d00e029f029009b279684aff711a..9cfadbb86568558b47358a6eac28c8bdffe121c3 100644 (file)
@@ -173,7 +173,6 @@ void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
 
        ci->fscache = NULL;
 
-       fscache_uncache_all_inode_pages(cookie, &ci->vfs_inode);
        fscache_relinquish_cookie(cookie, &ci->i_vino, false);
 }
 
@@ -194,7 +193,6 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
                dout("fscache_file_set_cookie %p %p disabling cache\n",
                     inode, filp);
                fscache_disable_cookie(ci->fscache, &ci->i_vino, false);
-               fscache_uncache_all_inode_pages(ci->fscache, inode);
        } else {
                fscache_enable_cookie(ci->fscache, &ci->i_vino, i_size_read(inode),
                                      ceph_fscache_can_enable, inode);
@@ -205,108 +203,6 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
        }
 }
 
-static void ceph_readpage_from_fscache_complete(struct page *page, void *data, int error)
-{
-       if (!error)
-               SetPageUptodate(page);
-
-       unlock_page(page);
-}
-
-static inline bool cache_valid(struct ceph_inode_info *ci)
-{
-       return ci->i_fscache_gen == ci->i_rdcache_gen;
-}
-
-
-/* Atempt to read from the fscache,
- *
- * This function is called from the readpage_nounlock context. DO NOT attempt to
- * unlock the page here (or in the callback).
- */
-int ceph_readpage_from_fscache(struct inode *inode, struct page *page)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       int ret;
-
-       if (!cache_valid(ci))
-               return -ENOBUFS;
-
-       ret = fscache_read_or_alloc_page(ci->fscache, page,
-                                        ceph_readpage_from_fscache_complete, NULL,
-                                        GFP_KERNEL);
-
-       switch (ret) {
-               case 0: /* Page found */
-                       dout("page read submitted\n");
-                       return 0;
-               case -ENOBUFS: /* Pages were not found, and can't be */
-               case -ENODATA: /* Pages were not found */
-                       dout("page/inode not in cache\n");
-                       return ret;
-               default:
-                       dout("%s: unknown error ret = %i\n", __func__, ret);
-                       return ret;
-       }
-}
-
-int ceph_readpages_from_fscache(struct inode *inode,
-                                 struct address_space *mapping,
-                                 struct list_head *pages,
-                                 unsigned *nr_pages)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       int ret;
-
-       if (!cache_valid(ci))
-               return -ENOBUFS;
-
-       ret = fscache_read_or_alloc_pages(ci->fscache, mapping, pages, nr_pages,
-                                         ceph_readpage_from_fscache_complete,
-                                         NULL, mapping_gfp_mask(mapping));
-
-       switch (ret) {
-               case 0: /* All pages found */
-                       dout("all-page read submitted\n");
-                       return 0;
-               case -ENOBUFS: /* Some pages were not found, and can't be */
-               case -ENODATA: /* some pages were not found */
-                       dout("page/inode not in cache\n");
-                       return ret;
-               default:
-                       dout("%s: unknown error ret = %i\n", __func__, ret);
-                       return ret;
-       }
-}
-
-void ceph_readpage_to_fscache(struct inode *inode, struct page *page)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       int ret;
-
-       if (!PageFsCache(page))
-               return;
-
-       if (!cache_valid(ci))
-               return;
-
-       ret = fscache_write_page(ci->fscache, page, i_size_read(inode),
-                                GFP_KERNEL);
-       if (ret)
-                fscache_uncache_page(ci->fscache, page);
-}
-
-void ceph_invalidate_fscache_page(struct inode* inode, struct page *page)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-
-       if (!PageFsCache(page))
-               return;
-
-       fscache_wait_on_page_write(ci->fscache, page);
-       fscache_uncache_page(ci->fscache, page);
-}
-
 void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
 {
        if (fscache_cookie_valid(fsc->fscache)) {
@@ -329,24 +225,3 @@ void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
        }
        fsc->fscache = NULL;
 }
-
-/*
- * caller should hold CEPH_CAP_FILE_{RD,CACHE}
- */
-void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci)
-{
-       if (cache_valid(ci))
-               return;
-
-       /* resue i_truncate_mutex. There should be no pending
-        * truncate while the caller holds CEPH_CAP_FILE_RD */
-       mutex_lock(&ci->i_truncate_mutex);
-       if (!cache_valid(ci)) {
-               if (fscache_check_consistency(ci->fscache, &ci->i_vino))
-                       fscache_invalidate(ci->fscache);
-               spin_lock(&ci->i_ceph_lock);
-               ci->i_fscache_gen = ci->i_rdcache_gen;
-               spin_unlock(&ci->i_ceph_lock);
-       }
-       mutex_unlock(&ci->i_truncate_mutex);
-}
index 89dbdd1eb14a999a1553ef4d4531d011888662f8..10c21317b62fcc49cd21e859e676fff8cc4a1e85 100644 (file)
@@ -29,13 +29,10 @@ int ceph_readpages_from_fscache(struct inode *inode,
                                struct address_space *mapping,
                                struct list_head *pages,
                                unsigned *nr_pages);
-void ceph_readpage_to_fscache(struct inode *inode, struct page *page);
-void ceph_invalidate_fscache_page(struct inode* inode, struct page *page);
 
 static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci)
 {
        ci->fscache = NULL;
-       ci->i_fscache_gen = 0;
 }
 
 static inline void ceph_fscache_invalidate(struct inode *inode)
@@ -43,40 +40,6 @@ static inline void ceph_fscache_invalidate(struct inode *inode)
        fscache_invalidate(ceph_inode(inode)->fscache);
 }
 
-static inline void ceph_fscache_uncache_page(struct inode *inode,
-                                            struct page *page)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       return fscache_uncache_page(ci->fscache, page);
-}
-
-static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
-{
-       struct inode* inode = page->mapping->host;
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       return fscache_maybe_release_page(ci->fscache, page, gfp);
-}
-
-static inline void ceph_fscache_readpage_cancel(struct inode *inode,
-                                               struct page *page)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       if (fscache_cookie_valid(ci->fscache) && PageFsCache(page))
-               __fscache_uncache_page(ci->fscache, page);
-}
-
-static inline void ceph_fscache_readpages_cancel(struct inode *inode,
-                                                struct list_head *pages)
-{
-       struct ceph_inode_info *ci = ceph_inode(inode);
-       return fscache_readpages_cancel(ci->fscache, pages);
-}
-
-static inline void ceph_disable_fscache_readpage(struct ceph_inode_info *ci)
-{
-       ci->i_fscache_gen = ci->i_rdcache_gen - 1;
-}
-
 #else
 
 static inline int ceph_fscache_register(void)
@@ -115,62 +78,10 @@ static inline void ceph_fscache_file_set_cookie(struct inode *inode,
 {
 }
 
-static inline void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci)
-{
-}
-
-static inline void ceph_fscache_uncache_page(struct inode *inode,
-                                            struct page *pages)
-{
-}
-
-static inline int ceph_readpage_from_fscache(struct inode* inode,
-                                            struct page *page)
-{
-       return -ENOBUFS;
-}
-
-static inline int ceph_readpages_from_fscache(struct inode *inode,
-                                             struct address_space *mapping,
-                                             struct list_head *pages,
-                                             unsigned *nr_pages)
-{
-       return -ENOBUFS;
-}
-
-static inline void ceph_readpage_to_fscache(struct inode *inode,
-                                           struct page *page)
-{
-}
-
 static inline void ceph_fscache_invalidate(struct inode *inode)
 {
 }
 
-static inline void ceph_invalidate_fscache_page(struct inode *inode,
-                                               struct page *page)
-{
-}
-
-static inline int ceph_release_fscache_page(struct page *page, gfp_t gfp)
-{
-       return 1;
-}
-
-static inline void ceph_fscache_readpage_cancel(struct inode *inode,
-                                               struct page *page)
-{
-}
-
-static inline void ceph_fscache_readpages_cancel(struct inode *inode,
-                                                struct list_head *pages)
-{
-}
-
-static inline void ceph_disable_fscache_readpage(struct ceph_inode_info *ci)
-{
-}
-
 #endif
 
-#endif
+#endif /* _CEPH_CACHE_H */
index 570731c4d019d406b9ce90fafe00cb54f02c55c2..b256fc8c68d0cf7a33ee7919848d1be4056d9d4e 100644 (file)
@@ -2730,10 +2730,6 @@ again:
                                *got = need | want;
                        else
                                *got = need;
-                       if (S_ISREG(inode->i_mode) &&
-                           (need & CEPH_CAP_FILE_RD) &&
-                           !(*got & CEPH_CAP_FILE_CACHE))
-                               ceph_disable_fscache_readpage(ci);
                        ceph_take_cap_refs(ci, *got, true);
                        ret = 1;
                }
@@ -2983,11 +2979,6 @@ int ceph_get_caps(struct file *filp, int need, int want,
                }
                break;
        }
-
-       if (S_ISREG(ci->vfs_inode.i_mode) &&
-           (_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE))
-               ceph_fscache_revalidate_cookie(ci);
-
        *got = _got;
        return 0;
 }
index c48bb30c8d70efc231400296dd7a8fa8bbbf15d6..6185c59954e398930b38206afc486713f62844b9 100644 (file)
@@ -427,7 +427,6 @@ struct ceph_inode_info {
 
 #ifdef CONFIG_CEPH_FSCACHE
        struct fscache_cookie *fscache;
-       u32 i_fscache_gen;
 #endif
        errseq_t i_meta_err;