diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-04-03 01:11:21 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-04-27 12:58:16 -0400 |
commit | cbc8adf89724b961c08b823d8bfb6dadbfa8733d (patch) | |
tree | 31a43d0f0445c69b446f3091ab9666d5934c115d /fs/xfs/xfs_dir2_leaf.c | |
parent | f5f3d9b0161633e8943520e83df634ad540b3b7f (diff) |
xfs: add CRC checking to dir2 free blocks
This addition follows the same pattern as the dir2 block CRCs, but
with a few differences. The main difference is that the free block
header is different between the v2 and v3 formats, so an "in-core"
free block header has been added and _todisk/_from_disk functions
used to abstract the differences in structure format from the code.
This is similar to the on-disk superblock versus the in-core
superblock setup. The in-core strucutre is populated when the buffer
is read from disk, all the in memory checks and modifications are
done on the in-core version of the structure which is written back
to the buffer before the buffer is logged.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_leaf.c')
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index ef163f06fd16..979735b0c76d 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -1881,6 +1881,7 @@ xfs_dir2_node_to_leaf( | |||
1881 | xfs_mount_t *mp; /* filesystem mount point */ | 1881 | xfs_mount_t *mp; /* filesystem mount point */ |
1882 | int rval; /* successful free trim? */ | 1882 | int rval; /* successful free trim? */ |
1883 | xfs_trans_t *tp; /* transaction pointer */ | 1883 | xfs_trans_t *tp; /* transaction pointer */ |
1884 | struct xfs_dir3_icfree_hdr freehdr; | ||
1884 | 1885 | ||
1885 | /* | 1886 | /* |
1886 | * There's more than a leaf level in the btree, so there must | 1887 | * There's more than a leaf level in the btree, so there must |
@@ -1938,15 +1939,15 @@ xfs_dir2_node_to_leaf( | |||
1938 | if (error) | 1939 | if (error) |
1939 | return error; | 1940 | return error; |
1940 | free = fbp->b_addr; | 1941 | free = fbp->b_addr; |
1941 | ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); | 1942 | xfs_dir3_free_hdr_from_disk(&freehdr, free); |
1942 | ASSERT(!free->hdr.firstdb); | 1943 | |
1944 | ASSERT(!freehdr.firstdb); | ||
1943 | 1945 | ||
1944 | /* | 1946 | /* |
1945 | * Now see if the leafn and free data will fit in a leaf1. | 1947 | * Now see if the leafn and free data will fit in a leaf1. |
1946 | * If not, release the buffer and give up. | 1948 | * If not, release the buffer and give up. |
1947 | */ | 1949 | */ |
1948 | if (xfs_dir2_leaf_size(&leaf->hdr, be32_to_cpu(free->hdr.nvalid)) > | 1950 | if (xfs_dir2_leaf_size(&leaf->hdr, freehdr.nvalid) > mp->m_dirblksize) { |
1949 | mp->m_dirblksize) { | ||
1950 | xfs_trans_brelse(tp, fbp); | 1951 | xfs_trans_brelse(tp, fbp); |
1951 | return 0; | 1952 | return 0; |
1952 | } | 1953 | } |
@@ -1967,12 +1968,12 @@ xfs_dir2_node_to_leaf( | |||
1967 | * Set up the leaf tail from the freespace block. | 1968 | * Set up the leaf tail from the freespace block. |
1968 | */ | 1969 | */ |
1969 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 1970 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
1970 | ltp->bestcount = free->hdr.nvalid; | 1971 | ltp->bestcount = cpu_to_be32(freehdr.nvalid); |
1971 | /* | 1972 | /* |
1972 | * Set up the leaf bests table. | 1973 | * Set up the leaf bests table. |
1973 | */ | 1974 | */ |
1974 | memcpy(xfs_dir2_leaf_bests_p(ltp), free->bests, | 1975 | memcpy(xfs_dir2_leaf_bests_p(ltp), xfs_dir3_free_bests_p(mp, free), |
1975 | be32_to_cpu(ltp->bestcount) * sizeof(xfs_dir2_data_off_t)); | 1976 | freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); |
1976 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); | 1977 | xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); |
1977 | xfs_dir2_leaf_log_tail(tp, lbp); | 1978 | xfs_dir2_leaf_log_tail(tp, lbp); |
1978 | xfs_dir2_leaf_check(dp, lbp); | 1979 | xfs_dir2_leaf_check(dp, lbp); |