aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_dir2_data.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-11-08 15:05:39 -0800
committerDarrick J. Wong <darrick.wong@oracle.com>2019-11-10 16:54:24 -0800
commit1848b607a9ad084db0180118304b9af2be68384e (patch)
tree3e828c91d1b0a7295076088a00a7b2a27107c089 /fs/xfs/libxfs/xfs_dir2_data.c
parentxfs: cleanup xfs_dir2_data_entsize (diff)
downloadlinux-dev-1848b607a9ad084db0180118304b9af2be68384e.tar.xz
linux-dev-1848b607a9ad084db0180118304b9af2be68384e.zip
xfs: devirtualize ->data_bestfree_p
Replace the ->data_bestfree_p dir ops method with a directly called xfs_dir2_data_bestfree_p helper that takes care of the differences between the v4 and v5 on-disk format. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_dir2_data.c')
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index c1a843f6a8da..6ed9396225e3 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -25,6 +25,16 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(
struct xfs_dir2_data_unused *dup,
struct xfs_dir2_data_free **bf_ent);
+struct xfs_dir2_data_free *
+xfs_dir2_data_bestfree_p(
+ struct xfs_mount *mp,
+ struct xfs_dir2_data_hdr *hdr)
+{
+ if (xfs_sb_version_hascrc(&mp->m_sb))
+ return ((struct xfs_dir3_data_hdr *)hdr)->best_free;
+ return hdr->bestfree;
+}
+
/*
* Pointer to an entry's tag word.
*/
@@ -121,7 +131,7 @@ __xfs_dir3_data_check(
/*
* Account for zero bestfree entries.
*/
- bf = ops->data_bestfree_p(hdr);
+ bf = xfs_dir2_data_bestfree_p(mp, hdr);
count = lastfree = freeseen = 0;
if (!bf[0].length) {
if (bf[0].offset)
@@ -581,12 +591,11 @@ xfs_dir2_data_freeremove(
void
xfs_dir2_data_freescan_int(
struct xfs_mount *mp,
- const struct xfs_dir_ops *ops,
struct xfs_dir2_data_hdr *hdr,
int *loghead)
{
struct xfs_da_geometry *geo = mp->m_dir_geo;
- struct xfs_dir2_data_free *bf = ops->data_bestfree_p(hdr);
+ struct xfs_dir2_data_free *bf = xfs_dir2_data_bestfree_p(mp, hdr);
void *addr = hdr;
unsigned int offset = geo->data_entry_offset;
unsigned int end;
@@ -633,7 +642,7 @@ xfs_dir2_data_freescan(
struct xfs_dir2_data_hdr *hdr,
int *loghead)
{
- return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead);
+ return xfs_dir2_data_freescan_int(dp->i_mount, hdr, loghead);
}
/*
@@ -683,7 +692,7 @@ xfs_dir3_data_init(
} else
hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
- bf = dp->d_ops->data_bestfree_p(hdr);
+ bf = xfs_dir2_data_bestfree_p(mp, hdr);
bf[0].offset = cpu_to_be16(geo->data_entry_offset);
bf[0].length = cpu_to_be16(geo->blksize - geo->data_entry_offset);
for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
@@ -841,7 +850,7 @@ xfs_dir2_data_make_free(
* Previous and following entries are both free,
* merge everything into a single free entry.
*/
- bf = args->dp->d_ops->data_bestfree_p(hdr);
+ bf = xfs_dir2_data_bestfree_p(args->dp->i_mount, hdr);
if (prevdup && postdup) {
xfs_dir2_data_free_t *dfp2; /* another bestfree pointer */
@@ -1032,7 +1041,7 @@ xfs_dir2_data_use_free(
* Look up the entry in the bestfree table.
*/
oldlen = be16_to_cpu(dup->length);
- bf = args->dp->d_ops->data_bestfree_p(hdr);
+ bf = xfs_dir2_data_bestfree_p(args->dp->i_mount, hdr);
dfp = xfs_dir2_data_freefind(hdr, bf, dup);
ASSERT(dfp || oldlen <= be16_to_cpu(bf[2].length));
/*