Skip to content

Commit 39e567a

Browse files
bergwolfTrond Myklebust
authored andcommitted
pnfsblock: acquire im_lock in _preload_range
When calling _add_entry, we should take the im_lock to protect agains other modifiers. Cc: <[email protected]> raspberrypi#3.1+ Signed-off-by: Peng Tao <[email protected]> Signed-off-by: Benny Halevy <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent de040be commit 39e567a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/nfs/blocklayout/extents.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ static int _set_range(struct my_tree *tree, int32_t tag, u64 s, u64 length)
139139
}
140140

141141
/* 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)
143144
{
144145
u64 start, end, s;
145146
int count, i, used = 0, status = -ENOMEM;
146147
struct pnfs_inval_tracking **storage;
148+
struct my_tree *tree = &marks->im_tree;
147149

148150
dprintk("%s(%llu, %llu) enter\n", __func__, offset, length);
149151
start = normalize(offset, tree->mtt_step_size);
@@ -161,12 +163,11 @@ static int _preload_range(struct my_tree *tree, u64 offset, u64 length)
161163
goto out_cleanup;
162164
}
163165

164-
/* Now need lock - HOW??? */
165-
166+
spin_lock(&marks->im_lock);
166167
for (s = start; s < end; s += tree->mtt_step_size)
167168
used += _add_entry(tree, s, INTERNAL_EXISTS, storage[used]);
169+
spin_unlock(&marks->im_lock);
168170

169-
/* Unlock - HOW??? */
170171
status = 0;
171172

172173
out_cleanup:
@@ -286,7 +287,7 @@ int bl_mark_sectors_init(struct pnfs_inval_markings *marks,
286287

287288
start = normalize(offset, marks->im_block_size);
288289
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))
290291
goto outerr;
291292

292293
spin_lock(&marks->im_lock);

0 commit comments

Comments
 (0)