Repository navigation
Commit 4e752f0
rbd: access snapshot context and mapping size safely
These fields may both change while the image is mapped if a snapshot
is created or deleted or the image is resized. They are guarded by
rbd_dev->header_rwsem, so hold that while reading them, and store a
local copy to refer to outside of the critical section. The local copy
will stay consistent since the snapshot context is reference counted,
and the mapping size is just a u64. This prevents torn loads from
giving us inconsistent values.
Move reading header.snapc into the caller of rbd_img_request_create()
so that we only need to take the semaphore once. The read-only caller,
rbd_parent_request_create() can just pass NULL for snapc, since the
snapshot context is only relevant for writes.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>1 parent 7dd440c commit 4e752f0
1 file changed
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2057 | 2057 | | |
2058 | 2058 | | |
2059 | 2059 | | |
2060 | | - | |
| 2060 | + | |
| 2061 | + | |
2061 | 2062 | | |
2062 | 2063 | | |
2063 | 2064 | | |
2064 | 2065 | | |
2065 | 2066 | | |
2066 | 2067 | | |
2067 | 2068 | | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
2071 | | - | |
2072 | | - | |
2073 | | - | |
2074 | 2069 | | |
2075 | 2070 | | |
2076 | 2071 | | |
2077 | 2072 | | |
2078 | 2073 | | |
2079 | 2074 | | |
2080 | 2075 | | |
2081 | | - | |
| 2076 | + | |
2082 | 2077 | | |
2083 | 2078 | | |
2084 | 2079 | | |
| |||
2134 | 2129 | | |
2135 | 2130 | | |
2136 | 2131 | | |
2137 | | - | |
2138 | | - | |
| 2132 | + | |
| 2133 | + | |
2139 | 2134 | | |
2140 | 2135 | | |
2141 | 2136 | | |
| |||
3183 | 3178 | | |
3184 | 3179 | | |
3185 | 3180 | | |
| 3181 | + | |
3186 | 3182 | | |
3187 | 3183 | | |
3188 | 3184 | | |
| 3185 | + | |
3189 | 3186 | | |
3190 | 3187 | | |
3191 | 3188 | | |
| |||
3226 | 3223 | | |
3227 | 3224 | | |
3228 | 3225 | | |
3229 | | - | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
3230 | 3235 | | |
3231 | | - | |
| 3236 | + | |
3232 | 3237 | | |
3233 | 3238 | | |
3234 | 3239 | | |
3235 | 3240 | | |
3236 | | - | |
| 3241 | + | |
| 3242 | + | |
3237 | 3243 | | |
3238 | 3244 | | |
3239 | 3245 | | |
| |||
3256 | 3262 | | |
3257 | 3263 | | |
3258 | 3264 | | |
| 3265 | + | |
| 3266 | + | |
3259 | 3267 | | |
3260 | 3268 | | |
3261 | 3269 | | |
| |||
0 commit comments