aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-13 17:49:19 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:36:53 -0500
commit970e4936d7d15f35d00fd15a14f5343ba78b2fc8 (patch)
tree92057c7deab6b9d8e5c3889d6a354b5989a3b68d /fs/ocfs2/xattr.c
parent4ae1d69bedc8d174cb8a558694607e013157cde1 (diff)
ocfs2: Validate metadata only when it's read from disk.
Add an optional validation hook to ocfs2_read_blocks(). Now the validation function is only called when a block was actually read off of disk. It is not called when the buffer was in cache. We add a buffer state bit BH_NeedsValidate to flag these buffers. It must always be one higher than the last JBD2 buffer state bit. The dinode, dirblock, extent_block, and xattr_block validators are lifted to this scheme directly. The group_descriptor validator needs to be split into two pieces. The first part only needs the gd buffer and is passed to ocfs2_read_block(). The second part requires the dinode as well, and is called every time. It's only 3 compares, so it's tiny. This also allows us to clean up the non-fatal gd check used by resize.c. It now has no magic argument. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index ef4aa5482d01..8af29b3bd6de 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -266,7 +266,8 @@ static int ocfs2_read_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
266 int rc; 266 int rc;
267 267
268 rc = ocfs2_read_blocks(bucket->bu_inode, xb_blkno, 268 rc = ocfs2_read_blocks(bucket->bu_inode, xb_blkno,
269 bucket->bu_blocks, bucket->bu_bhs, 0); 269 bucket->bu_blocks, bucket->bu_bhs, 0,
270 NULL);
270 if (rc) 271 if (rc)
271 ocfs2_xattr_bucket_relse(bucket); 272 ocfs2_xattr_bucket_relse(bucket);
272 return rc; 273 return rc;
@@ -359,12 +360,8 @@ static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno,
359 int rc; 360 int rc;
360 struct buffer_head *tmp = *bh; 361 struct buffer_head *tmp = *bh;
361 362
362 rc = ocfs2_read_block(inode, xb_blkno, &tmp); 363 rc = ocfs2_read_block(inode, xb_blkno, &tmp,
363 if (!rc) { 364 ocfs2_validate_xattr_block);
364 rc = ocfs2_validate_xattr_block(inode->i_sb, tmp);
365 if (rc)
366 brelse(tmp);
367 }
368 365
369 /* If ocfs2_read_block() got us a new bh, pass it up. */ 366 /* If ocfs2_read_block() got us a new bh, pass it up. */
370 if (!rc && !*bh) 367 if (!rc && !*bh)
@@ -925,7 +922,7 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode,
925 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); 922 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
926 /* Copy ocfs2_xattr_value */ 923 /* Copy ocfs2_xattr_value */
927 for (i = 0; i < num_clusters * bpc; i++, blkno++) { 924 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
928 ret = ocfs2_read_block(inode, blkno, &bh); 925 ret = ocfs2_read_block(inode, blkno, &bh, NULL);
929 if (ret) { 926 if (ret) {
930 mlog_errno(ret); 927 mlog_errno(ret);
931 goto out; 928 goto out;
@@ -1174,7 +1171,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
1174 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); 1171 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
1175 1172
1176 for (i = 0; i < num_clusters * bpc; i++, blkno++) { 1173 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
1177 ret = ocfs2_read_block(inode, blkno, &bh); 1174 ret = ocfs2_read_block(inode, blkno, &bh, NULL);
1178 if (ret) { 1175 if (ret) {
1179 mlog_errno(ret); 1176 mlog_errno(ret);
1180 goto out; 1177 goto out;
@@ -2206,7 +2203,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,
2206 base = xis->base; 2203 base = xis->base;
2207 credits += OCFS2_INODE_UPDATE_CREDITS; 2204 credits += OCFS2_INODE_UPDATE_CREDITS;
2208 } else { 2205 } else {
2209 int i, block_off; 2206 int i, block_off = 0;
2210 xb = (struct ocfs2_xattr_block *)xbs->xattr_bh->b_data; 2207 xb = (struct ocfs2_xattr_block *)xbs->xattr_bh->b_data;
2211 xe = xbs->here; 2208 xe = xbs->here;
2212 name_offset = le16_to_cpu(xe->xe_name_offset); 2209 name_offset = le16_to_cpu(xe->xe_name_offset);
@@ -2840,6 +2837,7 @@ static int ocfs2_find_xe_in_bucket(struct inode *inode,
2840 break; 2837 break;
2841 } 2838 }
2842 2839
2840
2843 xe_name = bucket_block(bucket, block_off) + new_offset; 2841 xe_name = bucket_block(bucket, block_off) + new_offset;
2844 if (!memcmp(name, xe_name, name_len)) { 2842 if (!memcmp(name, xe_name, name_len)) {
2845 *xe_index = i; 2843 *xe_index = i;
@@ -3598,7 +3596,7 @@ static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode,
3598 goto out; 3596 goto out;
3599 } 3597 }
3600 3598
3601 ret = ocfs2_read_block(inode, prev_blkno, &old_bh); 3599 ret = ocfs2_read_block(inode, prev_blkno, &old_bh, NULL);
3602 if (ret < 0) { 3600 if (ret < 0) {
3603 mlog_errno(ret); 3601 mlog_errno(ret);
3604 brelse(new_bh); 3602 brelse(new_bh);
@@ -3990,7 +3988,7 @@ static int ocfs2_cp_xattr_cluster(struct inode *inode,
3990 ocfs2_journal_dirty(handle, first_bh); 3988 ocfs2_journal_dirty(handle, first_bh);
3991 3989
3992 /* update the new bucket header. */ 3990 /* update the new bucket header. */
3993 ret = ocfs2_read_block(inode, to_blk_start, &bh); 3991 ret = ocfs2_read_block(inode, to_blk_start, &bh, NULL);
3994 if (ret < 0) { 3992 if (ret < 0) {
3995 mlog_errno(ret); 3993 mlog_errno(ret);
3996 goto out; 3994 goto out;
@@ -4337,7 +4335,7 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode,
4337 goto out; 4335 goto out;
4338 } 4336 }
4339 4337
4340 ret = ocfs2_read_block(inode, p_blkno, &first_bh); 4338 ret = ocfs2_read_block(inode, p_blkno, &first_bh, NULL);
4341 if (ret) { 4339 if (ret) {
4342 mlog_errno(ret); 4340 mlog_errno(ret);
4343 goto out; 4341 goto out;
@@ -4635,7 +4633,7 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4635 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize); 4633 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
4636 value_blk += header_bh->b_blocknr; 4634 value_blk += header_bh->b_blocknr;
4637 4635
4638 ret = ocfs2_read_block(inode, value_blk, &value_bh); 4636 ret = ocfs2_read_block(inode, value_blk, &value_bh, NULL);
4639 if (ret) { 4637 if (ret) {
4640 mlog_errno(ret); 4638 mlog_errno(ret);
4641 goto out; 4639 goto out;