diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:35:38 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:35:38 -0400 |
commit | c2066e2662070e794f57a96a129c42575e77cfcb (patch) | |
tree | c1261009d7482af80db1b554a96b5a62f35b4877 /fs/xfs/xfs_dir2_node.c | |
parent | a64b04179735de6bfd9f00c130a68ed7f20d18ef (diff) |
xfs: avoid usage of struct xfs_dir2_data
In most places we can simply pass around and use the struct xfs_dir2_data_hdr,
which is the first and most important member of struct xfs_dir2_data instead
of the full structure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 02da7b7a005a..8d4b54c1bedb 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -842,7 +842,7 @@ xfs_dir2_leafn_remove( | |||
842 | xfs_da_state_blk_t *dblk, /* data block */ | 842 | xfs_da_state_blk_t *dblk, /* data block */ |
843 | int *rval) /* resulting block needs join */ | 843 | int *rval) /* resulting block needs join */ |
844 | { | 844 | { |
845 | xfs_dir2_data_t *data; /* data block structure */ | 845 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
846 | xfs_dir2_db_t db; /* data block number */ | 846 | xfs_dir2_db_t db; /* data block number */ |
847 | xfs_dabuf_t *dbp; /* data block buffer */ | 847 | xfs_dabuf_t *dbp; /* data block buffer */ |
848 | xfs_dir2_data_entry_t *dep; /* data block entry */ | 848 | xfs_dir2_data_entry_t *dep; /* data block entry */ |
@@ -887,9 +887,9 @@ xfs_dir2_leafn_remove( | |||
887 | * in the data block in case it changes. | 887 | * in the data block in case it changes. |
888 | */ | 888 | */ |
889 | dbp = dblk->bp; | 889 | dbp = dblk->bp; |
890 | data = dbp->data; | 890 | hdr = dbp->data; |
891 | dep = (xfs_dir2_data_entry_t *)((char *)data + off); | 891 | dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); |
892 | longest = be16_to_cpu(data->hdr.bestfree[0].length); | 892 | longest = be16_to_cpu(hdr->bestfree[0].length); |
893 | needlog = needscan = 0; | 893 | needlog = needscan = 0; |
894 | xfs_dir2_data_make_free(tp, dbp, off, | 894 | xfs_dir2_data_make_free(tp, dbp, off, |
895 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); | 895 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); |
@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove( | |||
898 | * Log the data block header if needed. | 898 | * Log the data block header if needed. |
899 | */ | 899 | */ |
900 | if (needscan) | 900 | if (needscan) |
901 | xfs_dir2_data_freescan(mp, data, &needlog); | 901 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
902 | if (needlog) | 902 | if (needlog) |
903 | xfs_dir2_data_log_header(tp, dbp); | 903 | xfs_dir2_data_log_header(tp, dbp); |
904 | xfs_dir2_data_check(dp, dbp); | 904 | xfs_dir2_data_check(dp, dbp); |
@@ -906,7 +906,7 @@ xfs_dir2_leafn_remove( | |||
906 | * If the longest data block freespace changes, need to update | 906 | * If the longest data block freespace changes, need to update |
907 | * the corresponding freeblock entry. | 907 | * the corresponding freeblock entry. |
908 | */ | 908 | */ |
909 | if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) { | 909 | if (longest < be16_to_cpu(hdr->bestfree[0].length)) { |
910 | int error; /* error return value */ | 910 | int error; /* error return value */ |
911 | xfs_dabuf_t *fbp; /* freeblock buffer */ | 911 | xfs_dabuf_t *fbp; /* freeblock buffer */ |
912 | xfs_dir2_db_t fdb; /* freeblock block number */ | 912 | xfs_dir2_db_t fdb; /* freeblock block number */ |
@@ -932,19 +932,19 @@ xfs_dir2_leafn_remove( | |||
932 | * Calculate which entry we need to fix. | 932 | * Calculate which entry we need to fix. |
933 | */ | 933 | */ |
934 | findex = xfs_dir2_db_to_fdindex(mp, db); | 934 | findex = xfs_dir2_db_to_fdindex(mp, db); |
935 | longest = be16_to_cpu(data->hdr.bestfree[0].length); | 935 | longest = be16_to_cpu(hdr->bestfree[0].length); |
936 | /* | 936 | /* |
937 | * If the data block is now empty we can get rid of it | 937 | * If the data block is now empty we can get rid of it |
938 | * (usually). | 938 | * (usually). |
939 | */ | 939 | */ |
940 | if (longest == mp->m_dirblksize - (uint)sizeof(data->hdr)) { | 940 | if (longest == mp->m_dirblksize - (uint)sizeof(*hdr)) { |
941 | /* | 941 | /* |
942 | * Try to punch out the data block. | 942 | * Try to punch out the data block. |
943 | */ | 943 | */ |
944 | error = xfs_dir2_shrink_inode(args, db, dbp); | 944 | error = xfs_dir2_shrink_inode(args, db, dbp); |
945 | if (error == 0) { | 945 | if (error == 0) { |
946 | dblk->bp = NULL; | 946 | dblk->bp = NULL; |
947 | data = NULL; | 947 | hdr = NULL; |
948 | } | 948 | } |
949 | /* | 949 | /* |
950 | * We can get ENOSPC if there's no space reservation. | 950 | * We can get ENOSPC if there's no space reservation. |
@@ -960,7 +960,7 @@ xfs_dir2_leafn_remove( | |||
960 | * If we got rid of the data block, we can eliminate that entry | 960 | * If we got rid of the data block, we can eliminate that entry |
961 | * in the free block. | 961 | * in the free block. |
962 | */ | 962 | */ |
963 | if (data == NULL) { | 963 | if (hdr == NULL) { |
964 | /* | 964 | /* |
965 | * One less used entry in the free table. | 965 | * One less used entry in the free table. |
966 | */ | 966 | */ |
@@ -1356,7 +1356,7 @@ xfs_dir2_node_addname_int( | |||
1356 | xfs_da_args_t *args, /* operation arguments */ | 1356 | xfs_da_args_t *args, /* operation arguments */ |
1357 | xfs_da_state_blk_t *fblk) /* optional freespace block */ | 1357 | xfs_da_state_blk_t *fblk) /* optional freespace block */ |
1358 | { | 1358 | { |
1359 | xfs_dir2_data_t *data; /* data block structure */ | 1359 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
1360 | xfs_dir2_db_t dbno; /* data block number */ | 1360 | xfs_dir2_db_t dbno; /* data block number */ |
1361 | xfs_dabuf_t *dbp; /* data block buffer */ | 1361 | xfs_dabuf_t *dbp; /* data block buffer */ |
1362 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ | 1362 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ |
@@ -1641,8 +1641,8 @@ xfs_dir2_node_addname_int( | |||
1641 | * We haven't allocated the data entry yet so this will | 1641 | * We haven't allocated the data entry yet so this will |
1642 | * change again. | 1642 | * change again. |
1643 | */ | 1643 | */ |
1644 | data = dbp->data; | 1644 | hdr = dbp->data; |
1645 | free->bests[findex] = data->hdr.bestfree[0].length; | 1645 | free->bests[findex] = hdr->bestfree[0].length; |
1646 | logfree = 1; | 1646 | logfree = 1; |
1647 | } | 1647 | } |
1648 | /* | 1648 | /* |
@@ -1667,21 +1667,21 @@ xfs_dir2_node_addname_int( | |||
1667 | xfs_da_buf_done(fbp); | 1667 | xfs_da_buf_done(fbp); |
1668 | return error; | 1668 | return error; |
1669 | } | 1669 | } |
1670 | data = dbp->data; | 1670 | hdr = dbp->data; |
1671 | logfree = 0; | 1671 | logfree = 0; |
1672 | } | 1672 | } |
1673 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length); | 1673 | ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length); |
1674 | /* | 1674 | /* |
1675 | * Point to the existing unused space. | 1675 | * Point to the existing unused space. |
1676 | */ | 1676 | */ |
1677 | dup = (xfs_dir2_data_unused_t *) | 1677 | dup = (xfs_dir2_data_unused_t *) |
1678 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | 1678 | ((char *)hdr + be16_to_cpu(hdr->bestfree[0].offset)); |
1679 | needscan = needlog = 0; | 1679 | needscan = needlog = 0; |
1680 | /* | 1680 | /* |
1681 | * Mark the first part of the unused space, inuse for us. | 1681 | * Mark the first part of the unused space, inuse for us. |
1682 | */ | 1682 | */ |
1683 | xfs_dir2_data_use_free(tp, dbp, dup, | 1683 | xfs_dir2_data_use_free(tp, dbp, dup, |
1684 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length, | 1684 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, |
1685 | &needlog, &needscan); | 1685 | &needlog, &needscan); |
1686 | /* | 1686 | /* |
1687 | * Fill in the new entry and log it. | 1687 | * Fill in the new entry and log it. |
@@ -1691,13 +1691,13 @@ xfs_dir2_node_addname_int( | |||
1691 | dep->namelen = args->namelen; | 1691 | dep->namelen = args->namelen; |
1692 | memcpy(dep->name, args->name, dep->namelen); | 1692 | memcpy(dep->name, args->name, dep->namelen); |
1693 | tagp = xfs_dir2_data_entry_tag_p(dep); | 1693 | tagp = xfs_dir2_data_entry_tag_p(dep); |
1694 | *tagp = cpu_to_be16((char *)dep - (char *)data); | 1694 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
1695 | xfs_dir2_data_log_entry(tp, dbp, dep); | 1695 | xfs_dir2_data_log_entry(tp, dbp, dep); |
1696 | /* | 1696 | /* |
1697 | * Rescan the block for bestfree if needed. | 1697 | * Rescan the block for bestfree if needed. |
1698 | */ | 1698 | */ |
1699 | if (needscan) | 1699 | if (needscan) |
1700 | xfs_dir2_data_freescan(mp, data, &needlog); | 1700 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
1701 | /* | 1701 | /* |
1702 | * Log the data block header if needed. | 1702 | * Log the data block header if needed. |
1703 | */ | 1703 | */ |
@@ -1706,8 +1706,8 @@ xfs_dir2_node_addname_int( | |||
1706 | /* | 1706 | /* |
1707 | * If the freespace entry is now wrong, update it. | 1707 | * If the freespace entry is now wrong, update it. |
1708 | */ | 1708 | */ |
1709 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) { | 1709 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(hdr->bestfree[0].length)) { |
1710 | free->bests[findex] = data->hdr.bestfree[0].length; | 1710 | free->bests[findex] = hdr->bestfree[0].length; |
1711 | logfree = 1; | 1711 | logfree = 1; |
1712 | } | 1712 | } |
1713 | /* | 1713 | /* |
@@ -1857,7 +1857,7 @@ xfs_dir2_node_replace( | |||
1857 | xfs_da_args_t *args) /* operation arguments */ | 1857 | xfs_da_args_t *args) /* operation arguments */ |
1858 | { | 1858 | { |
1859 | xfs_da_state_blk_t *blk; /* leaf block */ | 1859 | xfs_da_state_blk_t *blk; /* leaf block */ |
1860 | xfs_dir2_data_t *data; /* data block structure */ | 1860 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
1861 | xfs_dir2_data_entry_t *dep; /* data entry changed */ | 1861 | xfs_dir2_data_entry_t *dep; /* data entry changed */ |
1862 | int error; /* error return value */ | 1862 | int error; /* error return value */ |
1863 | int i; /* btree level */ | 1863 | int i; /* btree level */ |
@@ -1901,10 +1901,10 @@ xfs_dir2_node_replace( | |||
1901 | /* | 1901 | /* |
1902 | * Point to the data entry. | 1902 | * Point to the data entry. |
1903 | */ | 1903 | */ |
1904 | data = state->extrablk.bp->data; | 1904 | hdr = state->extrablk.bp->data; |
1905 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | 1905 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); |
1906 | dep = (xfs_dir2_data_entry_t *) | 1906 | dep = (xfs_dir2_data_entry_t *) |
1907 | ((char *)data + | 1907 | ((char *)hdr + |
1908 | xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); | 1908 | xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); |
1909 | ASSERT(inum != be64_to_cpu(dep->inumber)); | 1909 | ASSERT(inum != be64_to_cpu(dep->inumber)); |
1910 | /* | 1910 | /* |