]> git.ipfire.org Git - thirdparty/linux.git/blame - fs/ceph/cache.h
netfs: Move pinning-for-writeback from fscache to netfs
[thirdparty/linux.git] / fs / ceph / cache.h
CommitLineData
1f327613 1/* SPDX-License-Identifier: GPL-2.0-only */
99ccbd22
MT
2/*
3 * Ceph cache definitions.
4 *
5 * Copyright (C) 2013 by Adfin Solutions, Inc. All Rights Reserved.
6 * Written by Milosz Tanski (milosz@adfin.com)
99ccbd22
MT
7 */
8
9#ifndef _CEPH_CACHE_H
10#define _CEPH_CACHE_H
11
f0702876
JL
12#include <linux/netfs.h>
13
99ccbd22 14#ifdef CONFIG_CEPH_FSCACHE
400e1286 15#include <linux/fscache.h>
99ccbd22 16
82995cc6 17int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc);
99ccbd22
MT
18void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);
19
46b59b2b 20void ceph_fscache_register_inode_cookie(struct inode *inode);
99ccbd22 21void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci);
400e1286
JL
22
23void ceph_fscache_use_cookie(struct inode *inode, bool will_modify);
24void ceph_fscache_unuse_cookie(struct inode *inode, bool update);
25
26void ceph_fscache_update(struct inode *inode);
27void ceph_fscache_invalidate(struct inode *inode, bool dio_write);
99ccbd22 28
f0702876
JL
29static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
30{
e81fb419 31 return netfs_i_cookie(&ci->netfs);
f0702876
JL
32}
33
400e1286 34static inline void ceph_fscache_resize(struct inode *inode, loff_t to)
99ccbd22 35{
400e1286
JL
36 struct ceph_inode_info *ci = ceph_inode(inode);
37 struct fscache_cookie *cookie = ceph_fscache_cookie(ci);
38
39 if (cookie) {
40 ceph_fscache_use_cookie(inode, true);
41 fscache_resize_cookie(cookie, to);
42 ceph_fscache_unuse_cookie(inode, true);
43 }
99ccbd22
MT
44}
45
c9c4ff12 46static inline int ceph_fscache_unpin_writeback(struct inode *inode,
400e1286 47 struct writeback_control *wbc)
f0702876 48{
c9c4ff12 49 return netfs_unpin_writeback(inode, wbc);
400e1286
JL
50}
51
c9c4ff12 52#define ceph_fscache_dirty_folio netfs_dirty_folio
f0702876 53
400e1286 54static inline bool ceph_is_cache_enabled(struct inode *inode)
99ccbd22 55{
400e1286 56 return fscache_cookie_enabled(ceph_fscache_cookie(ceph_inode(inode)));
99ccbd22
MT
57}
58
400e1286 59static inline void ceph_fscache_note_page_release(struct inode *inode)
99ccbd22 60{
400e1286 61 struct ceph_inode_info *ci = ceph_inode(inode);
99ccbd22 62
400e1286
JL
63 fscache_note_page_release(ceph_fscache_cookie(ci));
64}
65#else /* CONFIG_CEPH_FSCACHE */
82995cc6
DH
66static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc,
67 struct fs_context *fc)
99ccbd22
MT
68{
69 return 0;
70}
71
72static inline void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc)
73{
74}
75
400e1286 76static inline void ceph_fscache_register_inode_cookie(struct inode *inode)
f0702876 77{
f0702876
JL
78}
79
400e1286 80static inline void ceph_fscache_unregister_inode_cookie(struct ceph_inode_info* ci)
46b59b2b
YZ
81{
82}
83
400e1286 84static inline void ceph_fscache_use_cookie(struct inode *inode, bool will_modify)
46b59b2b
YZ
85{
86}
87
400e1286 88static inline void ceph_fscache_unuse_cookie(struct inode *inode, bool update)
99ccbd22
MT
89{
90}
91
400e1286 92static inline void ceph_fscache_update(struct inode *inode)
99ccbd22
MT
93{
94}
95
400e1286
JL
96static inline void ceph_fscache_invalidate(struct inode *inode, bool dio_write)
97{
98}
99
100static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
101{
102 return NULL;
103}
104
105static inline void ceph_fscache_resize(struct inode *inode, loff_t to)
106{
107}
108
c9c4ff12
DH
109static inline int ceph_fscache_unpin_writeback(struct inode *inode,
110 struct writeback_control *wbc)
400e1286 111{
c9c4ff12 112 return 0;
400e1286
JL
113}
114
c9c4ff12 115#define ceph_fscache_dirty_folio filemap_dirty_folio
400e1286 116
f0702876
JL
117static inline bool ceph_is_cache_enabled(struct inode *inode)
118{
119 return false;
120}
121
400e1286
JL
122static inline void ceph_fscache_note_page_release(struct inode *inode)
123{
124}
125#endif /* CONFIG_CEPH_FSCACHE */
126
127#endif