Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: conversion to new fscache API

Now that the fscache API has been reworked and simplified, change ceph
over to use it.

With the old API, we would only instantiate a cookie when the file was
open for reads. Change it to instantiate the cookie when the inode is
instantiated and call use/unuse when the file is opened/closed.

Also, ensure we resize the cached data on truncates, and invalidate the
cache in response to the appropriate events. This will allow us to
plumb in write support later.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20211129162907.149445-2-jlayton@kernel.org/ # v1
Link: https://lore.kernel.org/r/20211207134451.66296-2-jlayton@kernel.org/ # v2
Link: https://lore.kernel.org/r/163906984277.143852.14697110691303589000.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967188351.1823006.5065634844099079351.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021581427.640689.14128682147127509264.stgit@warthog.procyon.org.uk/ # v4

authored by

Jeff Layton and committed by
David Howells
400e1286 16f2f4e6

+195 -241
+1 -1
fs/ceph/Kconfig
··· 21 21 if CEPH_FS 22 22 config CEPH_FSCACHE 23 23 bool "Enable Ceph client caching support" 24 - depends on CEPH_FS=m && FSCACHE_OLD_API || CEPH_FS=y && FSCACHE_OLD_API=y 24 + depends on CEPH_FS=m && FSCACHE || CEPH_FS=y && FSCACHE=y 25 25 help 26 26 Choose Y here to enable persistent, read-only local 27 27 caching support for Ceph clients using FS-Cache
+20 -14
fs/ceph/addr.c
··· 126 126 BUG_ON(PagePrivate(page)); 127 127 attach_page_private(page, snapc); 128 128 129 - return __set_page_dirty_nobuffers(page); 129 + return ceph_fscache_set_page_dirty(page); 130 130 } 131 131 132 132 /* ··· 141 141 struct ceph_inode_info *ci; 142 142 struct ceph_snap_context *snapc; 143 143 144 - wait_on_page_fscache(page); 145 - 146 144 inode = page->mapping->host; 147 145 ci = ceph_inode(inode); 148 146 ··· 151 153 } 152 154 153 155 WARN_ON(!PageLocked(page)); 154 - if (!PagePrivate(page)) 155 - return; 156 + if (PagePrivate(page)) { 157 + dout("%p invalidatepage %p idx %lu full dirty page\n", 158 + inode, page, page->index); 156 159 157 - dout("%p invalidatepage %p idx %lu full dirty page\n", 158 - inode, page, page->index); 160 + snapc = detach_page_private(page); 161 + ceph_put_wrbuffer_cap_refs(ci, 1, snapc); 162 + ceph_put_snap_context(snapc); 163 + } 159 164 160 - snapc = detach_page_private(page); 161 - ceph_put_wrbuffer_cap_refs(ci, 1, snapc); 162 - ceph_put_snap_context(snapc); 165 + wait_on_page_fscache(page); 163 166 } 164 167 165 168 static int ceph_releasepage(struct page *page, gfp_t gfp) 166 169 { 167 - dout("%p releasepage %p idx %lu (%sdirty)\n", page->mapping->host, 168 - page, page->index, PageDirty(page) ? "" : "not "); 170 + struct inode *inode = page->mapping->host; 171 + 172 + dout("%llx:%llx releasepage %p idx %lu (%sdirty)\n", 173 + ceph_vinop(inode), page, 174 + page->index, PageDirty(page) ? "" : "not "); 175 + 176 + if (PagePrivate(page)) 177 + return 0; 169 178 170 179 if (PageFsCache(page)) { 171 - if (!(gfp & __GFP_DIRECT_RECLAIM) || !(gfp & __GFP_FS)) 180 + if (!gfpflags_allow_blocking(gfp) || !(gfp & __GFP_FS)) 172 181 return 0; 173 182 wait_on_page_fscache(page); 174 183 } 175 - return !PagePrivate(page); 184 + ceph_fscache_note_page_release(inode); 185 + return 1; 176 186 } 177 187 178 188 static void ceph_netfs_expand_readahead(struct netfs_read_request *rreq)
+75 -175
fs/ceph/cache.c
··· 12 12 #include "super.h" 13 13 #include "cache.h" 14 14 15 - struct fscache_netfs ceph_cache_netfs = { 16 - .name = "ceph", 17 - .version = 0, 18 - }; 19 - 20 - static DEFINE_MUTEX(ceph_fscache_lock); 21 - static LIST_HEAD(ceph_fscache_list); 22 - 23 - struct ceph_fscache_entry { 24 - struct list_head list; 25 - struct fscache_cookie *fscache; 26 - size_t uniq_len; 27 - /* The following members must be last */ 28 - struct ceph_fsid fsid; 29 - char uniquifier[]; 30 - }; 31 - 32 - static const struct fscache_cookie_def ceph_fscache_fsid_object_def = { 33 - .name = "CEPH.fsid", 34 - .type = FSCACHE_COOKIE_TYPE_INDEX, 35 - }; 36 - 37 - int __init ceph_fscache_register(void) 15 + void ceph_fscache_register_inode_cookie(struct inode *inode) 38 16 { 39 - return fscache_register_netfs(&ceph_cache_netfs); 17 + struct ceph_inode_info *ci = ceph_inode(inode); 18 + struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 19 + 20 + /* No caching for filesystem? */ 21 + if (!fsc->fscache) 22 + return; 23 + 24 + /* Regular files only */ 25 + if (!S_ISREG(inode->i_mode)) 26 + return; 27 + 28 + /* Only new inodes! */ 29 + if (!(inode->i_state & I_NEW)) 30 + return; 31 + 32 + WARN_ON_ONCE(ci->fscache); 33 + 34 + ci->fscache = fscache_acquire_cookie(fsc->fscache, 0, 35 + &ci->i_vino, sizeof(ci->i_vino), 36 + &ci->i_version, sizeof(ci->i_version), 37 + i_size_read(inode)); 40 38 } 41 39 42 - void ceph_fscache_unregister(void) 40 + void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci) 43 41 { 44 - fscache_unregister_netfs(&ceph_cache_netfs); 42 + struct fscache_cookie *cookie = ci->fscache; 43 + 44 + fscache_relinquish_cookie(cookie, false); 45 + } 46 + 47 + void ceph_fscache_use_cookie(struct inode *inode, bool will_modify) 48 + { 49 + struct ceph_inode_info *ci = ceph_inode(inode); 50 + 51 + fscache_use_cookie(ci->fscache, will_modify); 52 + } 53 + 54 + void ceph_fscache_unuse_cookie(struct inode *inode, bool update) 55 + { 56 + struct ceph_inode_info *ci = ceph_inode(inode); 57 + 58 + if (update) { 59 + loff_t i_size = i_size_read(inode); 60 + 61 + fscache_unuse_cookie(ci->fscache, &ci->i_version, &i_size); 62 + } else { 63 + fscache_unuse_cookie(ci->fscache, NULL, NULL); 64 + } 65 + } 66 + 67 + void ceph_fscache_update(struct inode *inode) 68 + { 69 + struct ceph_inode_info *ci = ceph_inode(inode); 70 + loff_t i_size = i_size_read(inode); 71 + 72 + fscache_update_cookie(ci->fscache, &ci->i_version, &i_size); 73 + } 74 + 75 + void ceph_fscache_invalidate(struct inode *inode, bool dio_write) 76 + { 77 + struct ceph_inode_info *ci = ceph_inode(inode); 78 + 79 + fscache_invalidate(ceph_inode(inode)->fscache, 80 + &ci->i_version, i_size_read(inode), 81 + dio_write ? FSCACHE_INVAL_DIO_WRITE : 0); 45 82 } 46 83 47 84 int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc) ··· 86 49 const struct ceph_fsid *fsid = &fsc->client->fsid; 87 50 const char *fscache_uniq = fsc->mount_options->fscache_uniq; 88 51 size_t uniq_len = fscache_uniq ? strlen(fscache_uniq) : 0; 89 - struct ceph_fscache_entry *ent; 52 + char *name; 90 53 int err = 0; 91 54 92 - mutex_lock(&ceph_fscache_lock); 93 - list_for_each_entry(ent, &ceph_fscache_list, list) { 94 - if (memcmp(&ent->fsid, fsid, sizeof(*fsid))) 95 - continue; 96 - if (ent->uniq_len != uniq_len) 97 - continue; 98 - if (uniq_len && memcmp(ent->uniquifier, fscache_uniq, uniq_len)) 99 - continue; 55 + name = kasprintf(GFP_KERNEL, "ceph,%pU%s%s", fsid, uniq_len ? "," : "", 56 + uniq_len ? fscache_uniq : ""); 57 + if (!name) 58 + return -ENOMEM; 100 59 101 - errorfc(fc, "fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option", 102 - fsid); 103 - err = -EBUSY; 104 - goto out_unlock; 60 + fsc->fscache = fscache_acquire_volume(name, NULL, NULL, 0); 61 + if (IS_ERR_OR_NULL(fsc->fscache)) { 62 + errorfc(fc, "Unable to register fscache cookie for %s", name); 63 + err = fsc->fscache ? PTR_ERR(fsc->fscache) : -EOPNOTSUPP; 64 + fsc->fscache = NULL; 105 65 } 106 - 107 - ent = kzalloc(sizeof(*ent) + uniq_len, GFP_KERNEL); 108 - if (!ent) { 109 - err = -ENOMEM; 110 - goto out_unlock; 111 - } 112 - 113 - memcpy(&ent->fsid, fsid, sizeof(*fsid)); 114 - if (uniq_len > 0) { 115 - memcpy(&ent->uniquifier, fscache_uniq, uniq_len); 116 - ent->uniq_len = uniq_len; 117 - } 118 - 119 - fsc->fscache = fscache_acquire_cookie(ceph_cache_netfs.primary_index, 120 - &ceph_fscache_fsid_object_def, 121 - &ent->fsid, sizeof(ent->fsid) + uniq_len, 122 - NULL, 0, 123 - fsc, 0, true); 124 - 125 - if (fsc->fscache) { 126 - ent->fscache = fsc->fscache; 127 - list_add_tail(&ent->list, &ceph_fscache_list); 128 - } else { 129 - kfree(ent); 130 - errorfc(fc, "unable to register fscache cookie for fsid %pU", 131 - fsid); 132 - /* all other fs ignore this error */ 133 - } 134 - out_unlock: 135 - mutex_unlock(&ceph_fscache_lock); 66 + kfree(name); 136 67 return err; 137 - } 138 - 139 - static enum fscache_checkaux ceph_fscache_inode_check_aux( 140 - void *cookie_netfs_data, const void *data, uint16_t dlen, 141 - loff_t object_size) 142 - { 143 - struct ceph_inode_info* ci = cookie_netfs_data; 144 - struct inode* inode = &ci->vfs_inode; 145 - 146 - if (dlen != sizeof(ci->i_version) || 147 - i_size_read(inode) != object_size) 148 - return FSCACHE_CHECKAUX_OBSOLETE; 149 - 150 - if (*(u64 *)data != ci->i_version) 151 - return FSCACHE_CHECKAUX_OBSOLETE; 152 - 153 - dout("ceph inode 0x%p cached okay\n", ci); 154 - return FSCACHE_CHECKAUX_OKAY; 155 - } 156 - 157 - static const struct fscache_cookie_def ceph_fscache_inode_object_def = { 158 - .name = "CEPH.inode", 159 - .type = FSCACHE_COOKIE_TYPE_DATAFILE, 160 - .check_aux = ceph_fscache_inode_check_aux, 161 - }; 162 - 163 - void ceph_fscache_register_inode_cookie(struct inode *inode) 164 - { 165 - struct ceph_inode_info *ci = ceph_inode(inode); 166 - struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 167 - 168 - /* No caching for filesystem */ 169 - if (!fsc->fscache) 170 - return; 171 - 172 - /* Only cache for regular files that are read only */ 173 - if (!S_ISREG(inode->i_mode)) 174 - return; 175 - 176 - inode_lock_nested(inode, I_MUTEX_CHILD); 177 - if (!ci->fscache) { 178 - ci->fscache = fscache_acquire_cookie(fsc->fscache, 179 - &ceph_fscache_inode_object_def, 180 - &ci->i_vino, sizeof(ci->i_vino), 181 - &ci->i_version, sizeof(ci->i_version), 182 - ci, i_size_read(inode), false); 183 - } 184 - inode_unlock(inode); 185 - } 186 - 187 - void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci) 188 - { 189 - struct fscache_cookie* cookie; 190 - 191 - if ((cookie = ci->fscache) == NULL) 192 - return; 193 - 194 - ci->fscache = NULL; 195 - 196 - fscache_relinquish_cookie(cookie, &ci->i_vino, false); 197 - } 198 - 199 - static bool ceph_fscache_can_enable(void *data) 200 - { 201 - struct inode *inode = data; 202 - return !inode_is_open_for_write(inode); 203 - } 204 - 205 - void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp) 206 - { 207 - struct ceph_inode_info *ci = ceph_inode(inode); 208 - 209 - if (!fscache_cookie_valid(ci->fscache)) 210 - return; 211 - 212 - if (inode_is_open_for_write(inode)) { 213 - dout("fscache_file_set_cookie %p %p disabling cache\n", 214 - inode, filp); 215 - fscache_disable_cookie(ci->fscache, &ci->i_vino, false); 216 - } else { 217 - fscache_enable_cookie(ci->fscache, &ci->i_vino, i_size_read(inode), 218 - ceph_fscache_can_enable, inode); 219 - if (fscache_cookie_enabled(ci->fscache)) { 220 - dout("fscache_file_set_cookie %p %p enabling cache\n", 221 - inode, filp); 222 - } 223 - } 224 68 } 225 69 226 70 void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc) 227 71 { 228 - if (fscache_cookie_valid(fsc->fscache)) { 229 - struct ceph_fscache_entry *ent; 230 - bool found = false; 231 - 232 - mutex_lock(&ceph_fscache_lock); 233 - list_for_each_entry(ent, &ceph_fscache_list, list) { 234 - if (ent->fscache == fsc->fscache) { 235 - list_del(&ent->list); 236 - kfree(ent); 237 - found = true; 238 - break; 239 - } 240 - } 241 - WARN_ON_ONCE(!found); 242 - mutex_unlock(&ceph_fscache_lock); 243 - 244 - __fscache_relinquish_cookie(fsc->fscache, NULL, false); 245 - } 246 - fsc->fscache = NULL; 72 + fscache_relinquish_volume(fsc->fscache, NULL, false); 247 73 }
+69 -30
fs/ceph/cache.h
··· 12 12 #include <linux/netfs.h> 13 13 14 14 #ifdef CONFIG_CEPH_FSCACHE 15 - 16 - extern struct fscache_netfs ceph_cache_netfs; 17 - 18 - int ceph_fscache_register(void); 19 - void ceph_fscache_unregister(void); 15 + #include <linux/fscache.h> 20 16 21 17 int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc); 22 18 void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc); 23 19 24 20 void ceph_fscache_register_inode_cookie(struct inode *inode); 25 21 void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci); 26 - void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp); 27 - void ceph_fscache_revalidate_cookie(struct ceph_inode_info *ci); 22 + 23 + void ceph_fscache_use_cookie(struct inode *inode, bool will_modify); 24 + void ceph_fscache_unuse_cookie(struct inode *inode, bool update); 25 + 26 + void ceph_fscache_update(struct inode *inode); 27 + void ceph_fscache_invalidate(struct inode *inode, bool dio_write); 28 28 29 29 static inline void ceph_fscache_inode_init(struct ceph_inode_info *ci) 30 30 { ··· 36 36 return ci->fscache; 37 37 } 38 38 39 - static inline void ceph_fscache_invalidate(struct inode *inode) 39 + static inline void ceph_fscache_resize(struct inode *inode, loff_t to) 40 40 { 41 - fscache_invalidate(ceph_inode(inode)->fscache); 41 + struct ceph_inode_info *ci = ceph_inode(inode); 42 + struct fscache_cookie *cookie = ceph_fscache_cookie(ci); 43 + 44 + if (cookie) { 45 + ceph_fscache_use_cookie(inode, true); 46 + fscache_resize_cookie(cookie, to); 47 + ceph_fscache_unuse_cookie(inode, true); 48 + } 42 49 } 43 50 44 - static inline bool ceph_is_cache_enabled(struct inode *inode) 51 + static inline void ceph_fscache_unpin_writeback(struct inode *inode, 52 + struct writeback_control *wbc) 45 53 { 46 - struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(inode)); 54 + fscache_unpin_writeback(wbc, ceph_fscache_cookie(ceph_inode(inode))); 55 + } 47 56 48 - if (!cookie) 49 - return false; 50 - return fscache_cookie_enabled(cookie); 57 + static inline int ceph_fscache_set_page_dirty(struct page *page) 58 + { 59 + struct inode *inode = page->mapping->host; 60 + struct ceph_inode_info *ci = ceph_inode(inode); 61 + 62 + return fscache_set_page_dirty(page, ceph_fscache_cookie(ci)); 51 63 } 52 64 53 65 static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq) 54 66 { 55 67 struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode)); 56 68 57 - return fscache_begin_read_operation(rreq, cookie); 69 + return fscache_begin_read_operation(&rreq->cache_resources, cookie); 58 70 } 59 - #else 60 71 61 - static inline int ceph_fscache_register(void) 72 + static inline bool ceph_is_cache_enabled(struct inode *inode) 62 73 { 63 - return 0; 74 + return fscache_cookie_enabled(ceph_fscache_cookie(ceph_inode(inode))); 64 75 } 65 76 66 - static inline void ceph_fscache_unregister(void) 77 + static inline void ceph_fscache_note_page_release(struct inode *inode) 67 78 { 68 - } 79 + struct ceph_inode_info *ci = ceph_inode(inode); 69 80 81 + fscache_note_page_release(ceph_fscache_cookie(ci)); 82 + } 83 + #else /* CONFIG_CEPH_FSCACHE */ 70 84 static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc, 71 85 struct fs_context *fc) 72 86 { ··· 95 81 { 96 82 } 97 83 98 - static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) 99 - { 100 - return NULL; 101 - } 102 - 103 84 static inline void ceph_fscache_register_inode_cookie(struct inode *inode) 104 85 { 105 86 } ··· 103 94 { 104 95 } 105 96 106 - static inline void ceph_fscache_file_set_cookie(struct inode *inode, 107 - struct file *filp) 97 + static inline void ceph_fscache_use_cookie(struct inode *inode, bool will_modify) 108 98 { 109 99 } 110 100 111 - static inline void ceph_fscache_invalidate(struct inode *inode) 101 + static inline void ceph_fscache_unuse_cookie(struct inode *inode, bool update) 112 102 { 103 + } 104 + 105 + static inline void ceph_fscache_update(struct inode *inode) 106 + { 107 + } 108 + 109 + static inline void ceph_fscache_invalidate(struct inode *inode, bool dio_write) 110 + { 111 + } 112 + 113 + static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci) 114 + { 115 + return NULL; 116 + } 117 + 118 + static inline void ceph_fscache_resize(struct inode *inode, loff_t to) 119 + { 120 + } 121 + 122 + static inline void ceph_fscache_unpin_writeback(struct inode *inode, 123 + struct writeback_control *wbc) 124 + { 125 + } 126 + 127 + static inline int ceph_fscache_set_page_dirty(struct page *page) 128 + { 129 + return __set_page_dirty_nobuffers(page); 113 130 } 114 131 115 132 static inline bool ceph_is_cache_enabled(struct inode *inode) ··· 147 112 { 148 113 return -ENOBUFS; 149 114 } 150 - #endif 151 115 152 - #endif /* _CEPH_CACHE_H */ 116 + static inline void ceph_fscache_note_page_release(struct inode *inode) 117 + { 118 + } 119 + #endif /* CONFIG_CEPH_FSCACHE */ 120 + 121 + #endif
+2 -1
fs/ceph/caps.c
··· 1856 1856 u32 invalidating_gen = ci->i_rdcache_gen; 1857 1857 1858 1858 spin_unlock(&ci->i_ceph_lock); 1859 - ceph_fscache_invalidate(inode); 1859 + ceph_fscache_invalidate(inode, false); 1860 1860 invalidate_mapping_pages(&inode->i_data, 0, -1); 1861 1861 spin_lock(&ci->i_ceph_lock); 1862 1862 ··· 2388 2388 int wait = (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync); 2389 2389 2390 2390 dout("write_inode %p wait=%d\n", inode, wait); 2391 + ceph_fscache_unpin_writeback(inode, wbc); 2391 2392 if (wait) { 2392 2393 dirty = try_flush_caps(inode, &flush_tid); 2393 2394 if (dirty)
+10 -3
fs/ceph/file.c
··· 248 248 249 249 switch (inode->i_mode & S_IFMT) { 250 250 case S_IFREG: 251 - ceph_fscache_register_inode_cookie(inode); 252 - ceph_fscache_file_set_cookie(inode, file); 251 + ceph_fscache_use_cookie(inode, file->f_mode & FMODE_WRITE); 253 252 fallthrough; 254 253 case S_IFDIR: 255 254 ret = ceph_init_file_info(inode, file, fmode, ··· 809 810 dout("release inode %p regular file %p\n", inode, file); 810 811 WARN_ON(!list_empty(&fi->rw_contexts)); 811 812 813 + ceph_fscache_unuse_cookie(inode, file->f_mode & FMODE_WRITE); 812 814 ceph_put_fmode(ci, fi->fmode, 1); 813 815 814 816 kmem_cache_free(ceph_file_cachep, fi); ··· 1206 1206 snapc, snapc ? snapc->seq : 0); 1207 1207 1208 1208 if (write) { 1209 - int ret2 = invalidate_inode_pages2_range(inode->i_mapping, 1209 + int ret2; 1210 + 1211 + ceph_fscache_invalidate(inode, true); 1212 + 1213 + ret2 = invalidate_inode_pages2_range(inode->i_mapping, 1210 1214 pos >> PAGE_SHIFT, 1211 1215 (pos + count - 1) >> PAGE_SHIFT); 1212 1216 if (ret2 < 0) ··· 1421 1417 if (ret < 0) 1422 1418 return ret; 1423 1419 1420 + ceph_fscache_invalidate(inode, false); 1424 1421 ret = invalidate_inode_pages2_range(inode->i_mapping, 1425 1422 pos >> PAGE_SHIFT, 1426 1423 (pos + count - 1) >> PAGE_SHIFT); ··· 2106 2101 goto unlock; 2107 2102 2108 2103 filemap_invalidate_lock(inode->i_mapping); 2104 + ceph_fscache_invalidate(inode, false); 2109 2105 ceph_zero_pagecache_range(inode, offset, length); 2110 2106 ret = ceph_zero_objects(inode, offset, length); 2111 2107 ··· 2431 2425 goto out_caps; 2432 2426 2433 2427 /* Drop dst file cached pages */ 2428 + ceph_fscache_invalidate(dst_inode, false); 2434 2429 ret = invalidate_inode_pages2_range(dst_inode->i_mapping, 2435 2430 dst_off >> PAGE_SHIFT, 2436 2431 (dst_off + len) >> PAGE_SHIFT);
+16 -6
fs/ceph/inode.c
··· 564 564 percpu_counter_dec(&mdsc->metric.total_inodes); 565 565 566 566 truncate_inode_pages_final(&inode->i_data); 567 + if (inode->i_state & I_PINNING_FSCACHE_WB) 568 + ceph_fscache_unuse_cookie(inode, true); 567 569 clear_inode(inode); 568 570 569 571 ceph_fscache_unregister_inode_cookie(ci); ··· 636 634 } 637 635 i_size_write(inode, size); 638 636 inode->i_blocks = calc_inode_blocks(size); 637 + /* 638 + * If we're expanding, then we should be able to just update 639 + * the existing cookie. 640 + */ 641 + if (size > isize) 642 + ceph_fscache_update(inode); 639 643 ci->i_reported_size = size; 640 644 if (truncate_seq != ci->i_truncate_seq) { 641 645 dout("truncate_seq %u -> %u\n", ··· 674 666 truncate_size); 675 667 ci->i_truncate_size = truncate_size; 676 668 } 677 - 678 - if (queue_trunc) 679 - ceph_fscache_invalidate(inode); 680 - 681 669 return queue_trunc; 682 670 } 683 671 ··· 1056 1052 } 1057 1053 1058 1054 spin_unlock(&ci->i_ceph_lock); 1055 + 1056 + ceph_fscache_register_inode_cookie(inode); 1059 1057 1060 1058 if (fill_inline) 1061 1059 ceph_fill_inline_data(inode, locked_page, ··· 1820 1814 spin_lock(&ci->i_ceph_lock); 1821 1815 dout("set_size %p %llu -> %llu\n", inode, i_size_read(inode), size); 1822 1816 i_size_write(inode, size); 1817 + ceph_fscache_update(inode); 1823 1818 inode->i_blocks = calc_inode_blocks(size); 1824 1819 1825 1820 ret = __ceph_should_report_size(ci); 1826 1821 1827 1822 spin_unlock(&ci->i_ceph_lock); 1823 + 1828 1824 return ret; 1829 1825 } 1830 1826 ··· 1852 1844 u32 orig_gen; 1853 1845 int check = 0; 1854 1846 1847 + ceph_fscache_invalidate(inode, false); 1848 + 1855 1849 mutex_lock(&ci->i_truncate_mutex); 1856 1850 1857 1851 if (ceph_inode_is_shutdown(inode)) { ··· 1878 1868 orig_gen = ci->i_rdcache_gen; 1879 1869 spin_unlock(&ci->i_ceph_lock); 1880 1870 1881 - ceph_fscache_invalidate(inode); 1871 + ceph_fscache_invalidate(inode, false); 1882 1872 if (invalidate_inode_pages2(inode->i_mapping) < 0) { 1883 1873 pr_err("invalidate_inode_pages2 %llx.%llx failed\n", 1884 1874 ceph_vinop(inode)); ··· 1947 1937 ci->i_truncate_pending, to); 1948 1938 spin_unlock(&ci->i_ceph_lock); 1949 1939 1940 + ceph_fscache_resize(inode, to); 1950 1941 truncate_pagecache(inode, to); 1951 1942 1952 1943 spin_lock(&ci->i_ceph_lock); ··· 2194 2183 2195 2184 if (inode_dirty_flags) 2196 2185 __mark_inode_dirty(inode, inode_dirty_flags); 2197 - 2198 2186 2199 2187 if (mask) { 2200 2188 req->r_inode = inode;
+1 -9
fs/ceph/super.c
··· 787 787 if (!ceph_wb_pagevec_pool) 788 788 goto bad_pagevec_pool; 789 789 790 - error = ceph_fscache_register(); 791 - if (error) 792 - goto bad_fscache; 793 - 794 790 return 0; 795 791 796 - bad_fscache: 797 - kmem_cache_destroy(ceph_mds_request_cachep); 798 792 bad_pagevec_pool: 799 - mempool_destroy(ceph_wb_pagevec_pool); 793 + kmem_cache_destroy(ceph_mds_request_cachep); 800 794 bad_mds_req: 801 795 kmem_cache_destroy(ceph_dir_file_cachep); 802 796 bad_dir_file: ··· 822 828 kmem_cache_destroy(ceph_dir_file_cachep); 823 829 kmem_cache_destroy(ceph_mds_request_cachep); 824 830 mempool_destroy(ceph_wb_pagevec_pool); 825 - 826 - ceph_fscache_unregister(); 827 831 } 828 832 829 833 static void __ceph_umount_begin(struct ceph_fs_client *fsc)
+1 -2
fs/ceph/super.h
··· 21 21 #include <linux/ceph/libceph.h> 22 22 23 23 #ifdef CONFIG_CEPH_FSCACHE 24 - #define FSCACHE_USE_NEW_IO_API 25 24 #include <linux/fscache.h> 26 25 #endif 27 26 ··· 134 135 #endif 135 136 136 137 #ifdef CONFIG_CEPH_FSCACHE 137 - struct fscache_cookie *fscache; 138 + struct fscache_volume *fscache; 138 139 #endif 139 140 }; 140 141