aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dir.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-13 17:49:11 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:36:52 -0500
commitb657c95c11088d77fc1bfc9c84d940f778bf9d12 (patch)
tree7e52e73aabbdbc55f644ad26735edc25a652ac32 /fs/ocfs2/dir.c
parenta68979b857283daf4acc405e476dcc8812a3ff2b (diff)
ocfs2: Wrap inode block reads in a dedicated function.
The ocfs2 code currently reads inodes off disk with a simple ocfs2_read_block() call. Each place that does this has a different set of sanity checks it performs. Some check only the signature. A couple validate the block number (the block read vs di->i_blkno). A couple others check for VALID_FL. Only one place validates i_fs_generation. A couple check nothing. Even when an error is found, they don't all do the same thing. We wrap inode reading into ocfs2_read_inode_block(). This will validate all the above fields, going readonly if they are invalid (they never should be). ocfs2_read_inode_block_full() is provided for the places that want to pass read_block flags. Every caller is passing a struct inode with a valid ip_blkno, so we don't need a separate blkno argument either. We will remove the validation checks from the rest of the code in a later commit, as they are no longer necessary. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dir.c')
-rw-r--r--fs/ocfs2/dir.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 026e6eb85187..5777045f1a67 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -231,7 +231,7 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name,
231 struct ocfs2_dinode *di; 231 struct ocfs2_dinode *di;
232 struct ocfs2_inline_data *data; 232 struct ocfs2_inline_data *data;
233 233
234 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); 234 ret = ocfs2_read_inode_block(dir, &di_bh);
235 if (ret) { 235 if (ret) {
236 mlog_errno(ret); 236 mlog_errno(ret);
237 goto out; 237 goto out;
@@ -458,7 +458,7 @@ static inline int ocfs2_delete_entry_id(handle_t *handle,
458 struct ocfs2_dinode *di; 458 struct ocfs2_dinode *di;
459 struct ocfs2_inline_data *data; 459 struct ocfs2_inline_data *data;
460 460
461 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); 461 ret = ocfs2_read_inode_block(dir, &di_bh);
462 if (ret) { 462 if (ret) {
463 mlog_errno(ret); 463 mlog_errno(ret);
464 goto out; 464 goto out;
@@ -636,7 +636,7 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode,
636 struct ocfs2_inline_data *data; 636 struct ocfs2_inline_data *data;
637 struct ocfs2_dir_entry *de; 637 struct ocfs2_dir_entry *de;
638 638
639 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); 639 ret = ocfs2_read_inode_block(inode, &di_bh);
640 if (ret) { 640 if (ret) {
641 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n", 641 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
642 (unsigned long long)OCFS2_I(inode)->ip_blkno); 642 (unsigned long long)OCFS2_I(inode)->ip_blkno);