diff options
author | Fan Li <fanofcode.li@samsung.com> | 2015-08-18 11:13:13 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-08-22 07:45:06 +0200 |
commit | f8b703da2c23f9bfda7299bd14e4f7201c2be3c8 (patch) | |
tree | 82fe2fc35b8597ed8659b67623b35045630e98c0 /fs/f2fs/extent_cache.c | |
parent | f2fs: fix typo (diff) | |
download | linux-f8b703da2c23f9bfda7299bd14e4f7201c2be3c8.tar.xz linux-f8b703da2c23f9bfda7299bd14e4f7201c2be3c8.zip |
f2fs: fix to update cached_en of extent tree properly
In f2fs_lookup_extent_tree, et->cached_en was read and updated with only
read lock held,
it could cause __lookup_extent_tree within return entirely wrong
extent_node, if other
thread update et->cached_en just before __lookup_extent_tree return.
However, there are two things about this patch that need to be noticed:
1. It does no good to arrange the order of concurrent read/write, the result
would still
be random in such case.
2. It's built on this assumption: the mix up of reads and writes on a single
pointer would
not make the pointer partially wrong at any time. Please let me know if I'm
wrong, thx.
Signed-off-by: Fan li <fanofcode.li@samsung.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/extent_cache.c')
-rw-r--r-- | fs/f2fs/extent_cache.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 32fae8ad5b7e..cea581353bc2 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -85,13 +85,13 @@ static struct extent_node *__lookup_extent_tree(struct extent_tree *et, unsigned int fofs) { struct rb_node *node = et->root.rb_node; - struct extent_node *en; + struct extent_node *en = et->cached_en; - if (et->cached_en) { - struct extent_info *cei = &et->cached_en->ei; + if (en) { + struct extent_info *cei = &en->ei; if (cei->fofs <= fofs && cei->fofs + cei->len > fofs) - return et->cached_en; + return en; } while (node) { |