diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-11-13 17:49:11 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:36:52 -0500 |
commit | b657c95c11088d77fc1bfc9c84d940f778bf9d12 (patch) | |
tree | 7e52e73aabbdbc55f644ad26735edc25a652ac32 /fs/ocfs2/inode.h | |
parent | a68979b857283daf4acc405e476dcc8812a3ff2b (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/inode.h')
-rw-r--r-- | fs/ocfs2/inode.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index 2f37af9bcc4a..b79c371a9d27 100644 --- a/fs/ocfs2/inode.h +++ b/fs/ocfs2/inode.h | |||
@@ -128,8 +128,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 feoff, unsigned flags, | |||
128 | int sysfile_type); | 128 | int sysfile_type); |
129 | int ocfs2_inode_init_private(struct inode *inode); | 129 | int ocfs2_inode_init_private(struct inode *inode); |
130 | int ocfs2_inode_revalidate(struct dentry *dentry); | 130 | int ocfs2_inode_revalidate(struct dentry *dentry); |
131 | int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | 131 | void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, |
132 | int create_ino); | 132 | int create_ino); |
133 | void ocfs2_read_inode(struct inode *inode); | 133 | void ocfs2_read_inode(struct inode *inode); |
134 | void ocfs2_read_inode2(struct inode *inode, void *opaque); | 134 | void ocfs2_read_inode2(struct inode *inode, void *opaque); |
135 | ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf, | 135 | ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf, |
@@ -153,4 +153,16 @@ static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode) | |||
153 | return (blkcnt_t)(OCFS2_I(inode)->ip_clusters << c_to_s_bits); | 153 | return (blkcnt_t)(OCFS2_I(inode)->ip_clusters << c_to_s_bits); |
154 | } | 154 | } |
155 | 155 | ||
156 | /* Validate that a bh contains a valid inode */ | ||
157 | int ocfs2_validate_inode_block(struct super_block *sb, | ||
158 | struct buffer_head *bh); | ||
159 | /* | ||
160 | * Read an inode block into *bh. If *bh is NULL, a bh will be allocated. | ||
161 | * This is a cached read. The inode will be validated with | ||
162 | * ocfs2_validate_inode_block(). | ||
163 | */ | ||
164 | int ocfs2_read_inode_block(struct inode *inode, struct buffer_head **bh); | ||
165 | /* The same, but can be passed OCFS2_BH_* flags */ | ||
166 | int ocfs2_read_inode_block_full(struct inode *inode, struct buffer_head **bh, | ||
167 | int flags); | ||
156 | #endif /* OCFS2_INODE_H */ | 168 | #endif /* OCFS2_INODE_H */ |