This source file includes following definitions.
- ceph_block_o_direct
- ceph_start_io_read
- ceph_end_io_read
- ceph_start_io_write
- ceph_end_io_write
- ceph_block_buffered
- ceph_start_io_direct
- ceph_end_io_direct
1
2
3
4
5
6
7
8
9
10
11 #include <linux/ceph/ceph_debug.h>
12
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/rwsem.h>
16 #include <linux/fs.h>
17
18 #include "super.h"
19 #include "io.h"
20
21
22 static void ceph_block_o_direct(struct ceph_inode_info *ci, struct inode *inode)
23 {
24 lockdep_assert_held_write(&inode->i_rwsem);
25
26 if (READ_ONCE(ci->i_ceph_flags) & CEPH_I_ODIRECT) {
27 spin_lock(&ci->i_ceph_lock);
28 ci->i_ceph_flags &= ~CEPH_I_ODIRECT;
29 spin_unlock(&ci->i_ceph_lock);
30 inode_dio_wait(inode);
31 }
32 }
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 void
51 ceph_start_io_read(struct inode *inode)
52 {
53 struct ceph_inode_info *ci = ceph_inode(inode);
54
55
56 down_read(&inode->i_rwsem);
57 if (!(READ_ONCE(ci->i_ceph_flags) & CEPH_I_ODIRECT))
58 return;
59 up_read(&inode->i_rwsem);
60
61 down_write(&inode->i_rwsem);
62 ceph_block_o_direct(ci, inode);
63 downgrade_write(&inode->i_rwsem);
64 }
65
66
67
68
69
70
71
72
73 void
74 ceph_end_io_read(struct inode *inode)
75 {
76 up_read(&inode->i_rwsem);
77 }
78
79
80
81
82
83
84
85
86 void
87 ceph_start_io_write(struct inode *inode)
88 {
89 down_write(&inode->i_rwsem);
90 ceph_block_o_direct(ceph_inode(inode), inode);
91 }
92
93
94
95
96
97
98
99
100 void
101 ceph_end_io_write(struct inode *inode)
102 {
103 up_write(&inode->i_rwsem);
104 }
105
106
107 static void ceph_block_buffered(struct ceph_inode_info *ci, struct inode *inode)
108 {
109 lockdep_assert_held_write(&inode->i_rwsem);
110
111 if (!(READ_ONCE(ci->i_ceph_flags) & CEPH_I_ODIRECT)) {
112 spin_lock(&ci->i_ceph_lock);
113 ci->i_ceph_flags |= CEPH_I_ODIRECT;
114 spin_unlock(&ci->i_ceph_lock);
115
116 filemap_write_and_wait(inode->i_mapping);
117 }
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 void
137 ceph_start_io_direct(struct inode *inode)
138 {
139 struct ceph_inode_info *ci = ceph_inode(inode);
140
141
142 down_read(&inode->i_rwsem);
143 if (READ_ONCE(ci->i_ceph_flags) & CEPH_I_ODIRECT)
144 return;
145 up_read(&inode->i_rwsem);
146
147 down_write(&inode->i_rwsem);
148 ceph_block_buffered(ci, inode);
149 downgrade_write(&inode->i_rwsem);
150 }
151
152
153
154
155
156
157
158
159 void
160 ceph_end_io_direct(struct inode *inode)
161 {
162 up_read(&inode->i_rwsem);
163 }