ocfs2: Morph the haphazard OCFS2_IS_VALID_DINODE() checks.
PATCH 1/1 ocfs2: Morph the haphazard OCFS2_IS_VALID_DINODE() checks.
Quoted 24 lines · Joel Becker
Random places in the code would check a dinode bh to see if it was valid. Not only did they do different levels of validation, they handled errors in different ways.
The previous commit unified inode block reads, validating all block reads in the same place. Thus, these haphazard checks are no longer necessary. Rather than eliminate them, however, we change them to
BUG_ON()checks. This ensures the assumptions remain true. All of the code paths to these checks have been audited to ensure they come from a validated inode read.Signed-off-by Joel Becker <[email protected]>--- fs/ocfs2/alloc.c | 50 +++++++++++++++++++++----------------------------- fs/ocfs2/journal.c | 17 +++++------------ fs/ocfs2/resize.c | 10 ++++------ fs/ocfs2/suballoc.c | 36 ++++++++++++++++-------------------- 4 files changed, 46 insertions(+), 67 deletions(-)fs/ocfs2/alloc.c +0
-0
fs/ocfs2/alloc.c static int ocfs2_dinode_insert_check(struct inode *inode, · line 193
Quoted 9 lines
fs/ocfs2/alloc.c +2
-2@@ -187,20 +187,12 @@ static int ocfs2_dinode_insert_check(struct inode *inode,static int ocfs2_dinode_sanity_check (struct inode *inode,struct ocfs2_extent_tree *et) { -int ret =0 ; -struct ocfs2_dinode *di; +struct ocfs2_dinode *di = et->et_object;BUG_ON (et->et_ops != &ocfs2_dinode_et_ops); +BUG_ON (!OCFS2_IS_VALID_DINODE (di));
This all looks good to me. It should be pretty easy for us later on to search on 'BUG_ON(!OCFS2_IS_VALID_DINODE' to remove these redundant checks once we're confident the conversion went ok.
--Mark
--
Mark Fasheh