Commit 39e567ae36fe03c2b446e1b83ee3d39bea08f90b
Committed by
Trond Myklebust
1 parent
de040beccd
Exists in
master
and in
6 other branches
pnfsblock: acquire im_lock in _preload_range
When calling _add_entry, we should take the im_lock to protect agains other modifiers. Cc: <stable@vger.kernel.org> #3.1+ Signed-off-by: Peng Tao <peng_tao@emc.com> Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff
fs/nfs/blocklayout/extents.c
... | ... | @@ -139,11 +139,13 @@ |
139 | 139 | } |
140 | 140 | |
141 | 141 | /* Ensure that future operations on given range of tree will not malloc */ |
142 | -static int _preload_range(struct my_tree *tree, u64 offset, u64 length) | |
142 | +static int _preload_range(struct pnfs_inval_markings *marks, | |
143 | + u64 offset, u64 length) | |
143 | 144 | { |
144 | 145 | u64 start, end, s; |
145 | 146 | int count, i, used = 0, status = -ENOMEM; |
146 | 147 | struct pnfs_inval_tracking **storage; |
148 | + struct my_tree *tree = &marks->im_tree; | |
147 | 149 | |
148 | 150 | dprintk("%s(%llu, %llu) enter\n", __func__, offset, length); |
149 | 151 | start = normalize(offset, tree->mtt_step_size); |
150 | 152 | |
151 | 153 | |
... | ... | @@ -161,12 +163,11 @@ |
161 | 163 | goto out_cleanup; |
162 | 164 | } |
163 | 165 | |
164 | - /* Now need lock - HOW??? */ | |
165 | - | |
166 | + spin_lock(&marks->im_lock); | |
166 | 167 | for (s = start; s < end; s += tree->mtt_step_size) |
167 | 168 | used += _add_entry(tree, s, INTERNAL_EXISTS, storage[used]); |
169 | + spin_unlock(&marks->im_lock); | |
168 | 170 | |
169 | - /* Unlock - HOW??? */ | |
170 | 171 | status = 0; |
171 | 172 | |
172 | 173 | out_cleanup: |
... | ... | @@ -286,7 +287,7 @@ |
286 | 287 | |
287 | 288 | start = normalize(offset, marks->im_block_size); |
288 | 289 | end = normalize_up(offset + length, marks->im_block_size); |
289 | - if (_preload_range(&marks->im_tree, start, end - start)) | |
290 | + if (_preload_range(marks, start, end - start)) | |
290 | 291 | goto outerr; |
291 | 292 | |
292 | 293 | spin_lock(&marks->im_lock); |