ext4: cache all of an extent tree's leaf block upon reading
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 16 lines · Linux Kernel
Gitweb: http://git.kernel.org/linus/;a=commit;h=107a7bd31ac003e42c0f966aa8e5b26947de6024 Commit: 107a7bd31ac003e42c0f966aa8e5b26947de6024 Parent: 3be78c73179c9347bdc0a92b2898063bd2300ff7 Author: Theodore Ts'o <[email protected]> AuthorDate: Fri Aug 16 21:23:41 2013 -0400 Committer: Theodore Ts'o <[email protected]> CommitDate: Fri Aug 16 21:23:41 2013 -0400ext4: cache all of an extent tree's leaf block upon reading
+ *
ext4_es_cache_extent()inserts information into the extent status
+ * tree if and only if there isn't information about the range in
+ * question already.
+ */(quoted diff) +1
-0+void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
Review
Quoted 10 lines
(quoted diff) +10
-0+ ext4_lblk_t len, ext4_fsblk_t pblk, + unsigned int status) +{ + struct extent_status *es; + struct extent_status newes; + ext4_lblk_t end = lblk + len - 1; + + newes.es_lblk = lblk; + newes.es_len = len; + ext4_es_store_pblock(&newes, pblk);
ext4_es_store_pblock or's the pblk with the existing contents of the struct member. (albeit masked with ES_MASK)
Should there be a
newes.es_pblk = 0;
up there too ?
It seems like if the stack happened to contain any of ES_WRITTEN | ES_UNWRITTEN | ES_DELAYED | ES_HOLE then it could leak through into the new extent status.
Dave
Quoted 16 lines · Dave Jones
Review
Quoted 11 lines
(quoted diff) +11
-0+void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk, + ext4_lblk_t len, ext4_fsblk_t pblk, + unsigned int status) +{ + struct extent_status *es; + struct extent_status newes; + ext4_lblk_t end = lblk + len - 1; + + newes.es_lblk = lblk; + newes.es_len = len; + ext4_es_store_pblock(&newes, pblk);
ext4_es_store_pblockor's the pblk with the existing contents of the struct member. (albeit masked withES_MASK)
Quoted 5 lines
Should there be a
newes.es_pblk = 0;up there too ?
The next line after ext4_es_store_pblock() is:
ext4_es_store_status(&newes, status);
This will set remaining ES_WRITTEN | ES_UNWRITTEN... bits.
So the only reason to add a line explicitly setting es_pblk to zero would be to suppress a warning from some insufficiently smart static code analysis tool. I didn't see a warning from gcc, but it's possible that this is something which is causing Coverity or some other code scanner heartburn.
Cheers,
- Ted
Quoted 13 lines · Theodore Ts'o
Quoted 8 lines
ext4_es_store_pblockor's the pblk with the existing contents of the struct member. (albeit masked withES_MASK)Should there be a
newes.es_pblk = 0;up there too ?
The next line after
ext4_es_store_pblock()is:ext4_es_store_status(&newes, status);
Quoted 7 lines
This will set remaining
ES_WRITTEN|ES_UNWRITTEN... bits.So the only reason to add a line explicitly setting
es_pblkto zero would be to suppress a warning from some insufficiently smart static code analysis tool. I didn't see a warning from gcc, but it's possible that this is something which is causing Coverity or some other code scanner heartburn.
Yep, that's what picked it up. I'll add a 'not a bug' annotation to stop it getting flagged again. This was the only ext* issue that Coverity picked up from yesterdays merge btw, which I guess is good news ;)
Dave
Quoted 9 lines · Dave Jones
Quoted 5 lines
So the only reason to add a line explicitly setting
es_pblkto zero would be to suppress a warning from some insufficiently smart static code analysis tool. I didn't see a warning from gcc, but it's possible that this is something which is causing Coverity or some other code scanner heartburn.Yep, that's what picked it up. I'll add a 'not a bug' annotation to stop it getting flagged again. This was the only ext* issue that Coverity picked up from yesterdays merge btw, which I guess is good news ;)
Indeed.
Hmm... I could add a new inline function "ext4_es_store_pblock_status()" which sets both parts of the es_pblk word at once, and which doesn't depend looking at its original value at all. I doubt we would never measure a difference in performance, but in theory it would be more efficient. And if it eliminates a potential static code analysis complaint, maybe the two justifications is good enough to add the new function.
Thanks for checking the coverity results!!
- Ted