Commit 2ca98774 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: vectorise directory data operations part 2

Convert the rest of the directory data block encode/decode
operations to vector format.

This further reduces the size of the built binary:

   text    data     bss     dec     hex filename
 794490   96802    1096  892388   d9de4 fs/xfs/xfs.o.orig
 792986   96802    1096  890884   d9804 fs/xfs/xfs.o.p1
 792350   96802    1096  890248   d9588 fs/xfs/xfs.o.p2
 789293   96802    1096  887191   d8997 fs/xfs/xfs.o.p3
 789005   96802    1096  886903   d8997 fs/xfs/xfs.o.p4
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 9d23fc85
...@@ -383,6 +383,58 @@ xfs_dir3_data_first_entry_p( ...@@ -383,6 +383,58 @@ xfs_dir3_data_first_entry_p(
((char *)hdr + xfs_dir3_data_first_offset()); ((char *)hdr + xfs_dir3_data_first_offset());
} }
static struct xfs_dir2_data_free *
xfs_dir2_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
{
return hdr->bestfree;
}
static struct xfs_dir2_data_free *
xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
{
return ((struct xfs_dir3_data_hdr *)hdr)->best_free;
}
static size_t
xfs_dir2_data_entry_offset(void)
{
return sizeof(struct xfs_dir2_data_hdr);
}
static struct xfs_dir2_data_entry *
xfs_dir2_data_entry_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_entry *)
((char *)hdr + xfs_dir2_data_entry_offset());
}
static struct xfs_dir2_data_unused *
xfs_dir2_data_unused_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_unused *)
((char *)hdr + xfs_dir2_data_entry_offset());
}
static size_t
xfs_dir3_data_entry_offset(void)
{
return sizeof(struct xfs_dir3_data_hdr);
}
static struct xfs_dir2_data_entry *
xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_entry *)
((char *)hdr + xfs_dir3_data_entry_offset());
}
static struct xfs_dir2_data_unused *
xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_unused *)
((char *)hdr + xfs_dir3_data_entry_offset());
}
const struct xfs_dir_ops xfs_dir2_ops = { const struct xfs_dir_ops xfs_dir2_ops = {
.sf_entsize = xfs_dir2_sf_entsize, .sf_entsize = xfs_dir2_sf_entsize,
.sf_nextentry = xfs_dir2_sf_nextentry, .sf_nextentry = xfs_dir2_sf_nextentry,
...@@ -397,13 +449,19 @@ const struct xfs_dir_ops xfs_dir2_ops = { ...@@ -397,13 +449,19 @@ const struct xfs_dir_ops xfs_dir2_ops = {
.data_get_ftype = xfs_dir2_data_get_ftype, .data_get_ftype = xfs_dir2_data_get_ftype,
.data_put_ftype = xfs_dir2_data_put_ftype, .data_put_ftype = xfs_dir2_data_put_ftype,
.data_entry_tag_p = xfs_dir2_data_entry_tag_p, .data_entry_tag_p = xfs_dir2_data_entry_tag_p,
.data_bestfree_p = xfs_dir2_data_bestfree_p,
.data_dot_offset = xfs_dir2_data_dot_offset, .data_dot_offset = xfs_dir2_data_dot_offset,
.data_dotdot_offset = xfs_dir2_data_dotdot_offset, .data_dotdot_offset = xfs_dir2_data_dotdot_offset,
.data_first_offset = xfs_dir2_data_first_offset, .data_first_offset = xfs_dir2_data_first_offset,
.data_entry_offset = xfs_dir2_data_entry_offset,
.data_dot_entry_p = xfs_dir2_data_dot_entry_p, .data_dot_entry_p = xfs_dir2_data_dot_entry_p,
.data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p, .data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p,
.data_first_entry_p = xfs_dir2_data_first_entry_p, .data_first_entry_p = xfs_dir2_data_first_entry_p,
.data_entry_p = xfs_dir2_data_entry_p,
.data_unused_p = xfs_dir2_data_unused_p,
}; };
const struct xfs_dir_ops xfs_dir2_ftype_ops = { const struct xfs_dir_ops xfs_dir2_ftype_ops = {
...@@ -420,13 +478,18 @@ const struct xfs_dir_ops xfs_dir2_ftype_ops = { ...@@ -420,13 +478,18 @@ const struct xfs_dir_ops xfs_dir2_ftype_ops = {
.data_get_ftype = xfs_dir3_data_get_ftype, .data_get_ftype = xfs_dir3_data_get_ftype,
.data_put_ftype = xfs_dir3_data_put_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,
.data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
.data_bestfree_p = xfs_dir2_data_bestfree_p,
.data_dot_offset = xfs_dir2_data_dot_offset, .data_dot_offset = xfs_dir2_data_dot_offset,
.data_dotdot_offset = xfs_dir2_data_dotdot_offset, .data_dotdot_offset = xfs_dir2_data_dotdot_offset,
.data_first_offset = xfs_dir2_data_first_offset, .data_first_offset = xfs_dir2_data_first_offset,
.data_entry_offset = xfs_dir2_data_entry_offset,
.data_dot_entry_p = xfs_dir2_data_dot_entry_p, .data_dot_entry_p = xfs_dir2_data_dot_entry_p,
.data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p, .data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p,
.data_first_entry_p = xfs_dir2_data_first_entry_p, .data_first_entry_p = xfs_dir2_data_first_entry_p,
.data_entry_p = xfs_dir2_data_entry_p,
.data_unused_p = xfs_dir2_data_unused_p,
}; };
const struct xfs_dir_ops xfs_dir3_ops = { const struct xfs_dir_ops xfs_dir3_ops = {
...@@ -443,11 +506,16 @@ const struct xfs_dir_ops xfs_dir3_ops = { ...@@ -443,11 +506,16 @@ const struct xfs_dir_ops xfs_dir3_ops = {
.data_get_ftype = xfs_dir3_data_get_ftype, .data_get_ftype = xfs_dir3_data_get_ftype,
.data_put_ftype = xfs_dir3_data_put_ftype, .data_put_ftype = xfs_dir3_data_put_ftype,
.data_entry_tag_p = xfs_dir3_data_entry_tag_p, .data_entry_tag_p = xfs_dir3_data_entry_tag_p,
.data_bestfree_p = xfs_dir3_data_bestfree_p,
.data_dot_offset = xfs_dir3_data_dot_offset, .data_dot_offset = xfs_dir3_data_dot_offset,
.data_dotdot_offset = xfs_dir3_data_dotdot_offset, .data_dotdot_offset = xfs_dir3_data_dotdot_offset,
.data_first_offset = xfs_dir3_data_first_offset, .data_first_offset = xfs_dir3_data_first_offset,
.data_entry_offset = xfs_dir3_data_entry_offset,
.data_dot_entry_p = xfs_dir3_data_dot_entry_p, .data_dot_entry_p = xfs_dir3_data_dot_entry_p,
.data_dotdot_entry_p = xfs_dir3_data_dotdot_entry_p, .data_dotdot_entry_p = xfs_dir3_data_dotdot_entry_p,
.data_first_entry_p = xfs_dir3_data_first_entry_p, .data_first_entry_p = xfs_dir3_data_first_entry_p,
.data_entry_p = xfs_dir3_data_entry_p,
.data_unused_p = xfs_dir3_data_unused_p,
}; };
...@@ -412,17 +412,6 @@ struct xfs_dir3_data_hdr { ...@@ -412,17 +412,6 @@ struct xfs_dir3_data_hdr {
#define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc) #define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc)
static inline struct xfs_dir2_data_free *
xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
{
if (hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
struct xfs_dir3_data_hdr *hdr3 = (struct xfs_dir3_data_hdr *)hdr;
return hdr3->best_free;
}
return hdr->bestfree;
}
/* /*
* Active entry in a data block. * Active entry in a data block.
* *
...@@ -465,36 +454,6 @@ xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup) ...@@ -465,36 +454,6 @@ xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup)
be16_to_cpu(dup->length) - sizeof(__be16)); be16_to_cpu(dup->length) - sizeof(__be16));
} }
static inline size_t
xfs_dir3_data_hdr_size(bool dir3)
{
if (dir3)
return sizeof(struct xfs_dir3_data_hdr);
return sizeof(struct xfs_dir2_data_hdr);
}
static inline size_t
xfs_dir3_data_entry_offset(struct xfs_dir2_data_hdr *hdr)
{
bool dir3 = hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC);
return xfs_dir3_data_hdr_size(dir3);
}
static inline struct xfs_dir2_data_entry *
xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_entry *)
((char *)hdr + xfs_dir3_data_entry_offset(hdr));
}
static inline struct xfs_dir2_data_unused *
xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
{
return (struct xfs_dir2_data_unused *)
((char *)hdr + xfs_dir3_data_entry_offset(hdr));
}
/* /*
* Leaf block structures. * Leaf block structures.
* *
......
...@@ -56,16 +56,24 @@ struct xfs_dir_ops { ...@@ -56,16 +56,24 @@ struct xfs_dir_ops {
void (*data_put_ftype)(struct xfs_dir2_data_entry *dep, void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,
__uint8_t ftype); __uint8_t ftype);
__be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep); __be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep);
struct xfs_dir2_data_free *
(*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);
xfs_dir2_data_aoff_t (*data_dot_offset)(void); xfs_dir2_data_aoff_t (*data_dot_offset)(void);
xfs_dir2_data_aoff_t (*data_dotdot_offset)(void); xfs_dir2_data_aoff_t (*data_dotdot_offset)(void);
xfs_dir2_data_aoff_t (*data_first_offset)(void); xfs_dir2_data_aoff_t (*data_first_offset)(void);
size_t (*data_entry_offset)(void);
struct xfs_dir2_data_entry * struct xfs_dir2_data_entry *
(*data_dot_entry_p)(struct xfs_dir2_data_hdr *hdr); (*data_dot_entry_p)(struct xfs_dir2_data_hdr *hdr);
struct xfs_dir2_data_entry * struct xfs_dir2_data_entry *
(*data_dotdot_entry_p)(struct xfs_dir2_data_hdr *hdr); (*data_dotdot_entry_p)(struct xfs_dir2_data_hdr *hdr);
struct xfs_dir2_data_entry * struct xfs_dir2_data_entry *
(*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr); (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr);
struct xfs_dir2_data_entry *
(*data_entry_p)(struct xfs_dir2_data_hdr *hdr);
struct xfs_dir2_data_unused *
(*data_unused_p)(struct xfs_dir2_data_hdr *hdr);
}; };
extern const struct xfs_dir_ops xfs_dir2_ops; extern const struct xfs_dir_ops xfs_dir2_ops;
...@@ -115,19 +123,21 @@ extern void xfs_dir2_data_freescan(struct xfs_inode *dp, ...@@ -115,19 +123,21 @@ extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
struct xfs_dir2_data_hdr *hdr, int *loghead); struct xfs_dir2_data_hdr *hdr, int *loghead);
extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_inode *dp, extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_buf *bp, struct xfs_dir2_data_entry *dep); struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
extern void xfs_dir2_data_log_header(struct xfs_trans *tp, extern void xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_buf *bp); struct xfs_buf *bp);
extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp, extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp,
struct xfs_dir2_data_unused *dup); struct xfs_dir2_data_unused *dup);
extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_buf *bp, extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_buf *bp, xfs_dir2_data_aoff_t offset,
xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_buf *bp, struct xfs_dir2_data_unused *dup,
xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len, xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
int *needlogp, int *needscanp); int *needlogp, int *needscanp);
extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
struct xfs_dir2_data_unused *dup, xfs_dir2_data_aoff_t offset,
xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
extern struct xfs_dir2_data_free *xfs_dir2_data_freefind( extern struct xfs_dir2_data_free *xfs_dir2_data_freefind(
struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_unused *dup); struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
struct xfs_dir2_data_unused *dup);
extern const struct xfs_buf_ops xfs_dir3_block_buf_ops; extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops; extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops;
......
...@@ -168,6 +168,7 @@ xfs_dir3_block_init( ...@@ -168,6 +168,7 @@ xfs_dir3_block_init(
static void static void
xfs_dir2_block_need_space( xfs_dir2_block_need_space(
struct xfs_inode *dp,
struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_hdr *hdr,
struct xfs_dir2_block_tail *btp, struct xfs_dir2_block_tail *btp,
struct xfs_dir2_leaf_entry *blp, struct xfs_dir2_leaf_entry *blp,
...@@ -183,7 +184,7 @@ xfs_dir2_block_need_space( ...@@ -183,7 +184,7 @@ xfs_dir2_block_need_space(
struct xfs_dir2_data_unused *enddup = NULL; struct xfs_dir2_data_unused *enddup = NULL;
*compact = 0; *compact = 0;
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
/* /*
* If there are stale entries we'll use one for the leaf. * If there are stale entries we'll use one for the leaf.
...@@ -313,7 +314,7 @@ xfs_dir2_block_compact( ...@@ -313,7 +314,7 @@ xfs_dir2_block_compact(
*lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); *lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1);
*lfloghigh -= be32_to_cpu(btp->stale) - 1; *lfloghigh -= be32_to_cpu(btp->stale) - 1;
be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1));
xfs_dir2_data_make_free(tp, bp, xfs_dir2_data_make_free(tp, dp, bp,
(xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
(xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)),
needlog, &needscan); needlog, &needscan);
...@@ -383,7 +384,7 @@ xfs_dir2_block_addname( ...@@ -383,7 +384,7 @@ xfs_dir2_block_addname(
* Find out if we can reuse stale entries or whether we need extra * Find out if we can reuse stale entries or whether we need extra
* space for entry and new leaf. * space for entry and new leaf.
*/ */
xfs_dir2_block_need_space(hdr, btp, blp, &tagp, &dup, xfs_dir2_block_need_space(dp, hdr, btp, blp, &tagp, &dup,
&enddup, &compact, len); &enddup, &compact, len);
/* /*
...@@ -454,7 +455,7 @@ xfs_dir2_block_addname( ...@@ -454,7 +455,7 @@ xfs_dir2_block_addname(
/* /*
* Mark the space needed for the new leaf entry, now in use. * Mark the space needed for the new leaf entry, now in use.
*/ */
xfs_dir2_data_use_free(tp, bp, enddup, xfs_dir2_data_use_free(tp, dp, bp, enddup,
(xfs_dir2_data_aoff_t) (xfs_dir2_data_aoff_t)
((char *)enddup - (char *)hdr + be16_to_cpu(enddup->length) - ((char *)enddup - (char *)hdr + be16_to_cpu(enddup->length) -
sizeof(*blp)), sizeof(*blp)),
...@@ -541,7 +542,7 @@ xfs_dir2_block_addname( ...@@ -541,7 +542,7 @@ xfs_dir2_block_addname(
/* /*
* Mark space for the data entry used. * Mark space for the data entry used.
*/ */
xfs_dir2_data_use_free(tp, bp, dup, xfs_dir2_data_use_free(tp, dp, bp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr),
(xfs_dir2_data_aoff_t)len, &needlog, &needscan); (xfs_dir2_data_aoff_t)len, &needlog, &needscan);
/* /*
...@@ -559,7 +560,7 @@ xfs_dir2_block_addname( ...@@ -559,7 +560,7 @@ xfs_dir2_block_addname(
if (needscan) if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog); xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, bp); xfs_dir2_data_log_header(tp, dp, bp);
xfs_dir2_block_log_tail(tp, bp); xfs_dir2_block_log_tail(tp, bp);
xfs_dir2_data_log_entry(tp, dp, bp, dep); xfs_dir2_data_log_entry(tp, dp, bp, dep);
xfs_dir3_data_check(dp, bp); xfs_dir3_data_check(dp, bp);
...@@ -800,7 +801,7 @@ xfs_dir2_block_removename( ...@@ -800,7 +801,7 @@ xfs_dir2_block_removename(
* Mark the data entry's space free. * Mark the data entry's space free.
*/ */
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, bp, xfs_dir2_data_make_free(tp, dp, bp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
/* /*
...@@ -819,7 +820,7 @@ xfs_dir2_block_removename( ...@@ -819,7 +820,7 @@ xfs_dir2_block_removename(
if (needscan) if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog); xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, bp); xfs_dir2_data_log_header(tp, dp, bp);
xfs_dir3_data_check(dp, bp); xfs_dir3_data_check(dp, bp);
/* /*
* See if the size as a shortform is good enough. * See if the size as a shortform is good enough.
...@@ -950,7 +951,7 @@ xfs_dir2_leaf_to_block( ...@@ -950,7 +951,7 @@ xfs_dir2_leaf_to_block(
while (dp->i_d.di_size > mp->m_dirblksize) { while (dp->i_d.di_size > mp->m_dirblksize) {
int hdrsz; int hdrsz;
hdrsz = xfs_dir3_data_hdr_size(xfs_sb_version_hascrc(&mp->m_sb)); hdrsz = dp->d_ops->data_entry_offset();
bestsp = xfs_dir2_leaf_bests_p(ltp); bestsp = xfs_dir2_leaf_bests_p(ltp);
if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
mp->m_dirblksize - hdrsz) { mp->m_dirblksize - hdrsz) {
...@@ -1000,7 +1001,7 @@ xfs_dir2_leaf_to_block( ...@@ -1000,7 +1001,7 @@ xfs_dir2_leaf_to_block(
/* /*
* Use up the space at the end of the block (blp/btp). * Use up the space at the end of the block (blp/btp).
*/ */
xfs_dir2_data_use_free(tp, dbp, dup, mp->m_dirblksize - size, size, xfs_dir2_data_use_free(tp, dp, dbp, dup, mp->m_dirblksize - size, size,
&needlog, &needscan); &needlog, &needscan);
/* /*
* Initialize the block tail. * Initialize the block tail.
...@@ -1026,7 +1027,7 @@ xfs_dir2_leaf_to_block( ...@@ -1026,7 +1027,7 @@ xfs_dir2_leaf_to_block(
if (needscan) if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog); xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
/* /*
* Pitch the old leaf block. * Pitch the old leaf block.
*/ */
...@@ -1137,9 +1138,9 @@ xfs_dir2_sf_to_block( ...@@ -1137,9 +1138,9 @@ xfs_dir2_sf_to_block(
* The whole thing is initialized to free by the init routine. * The whole thing is initialized to free by the init routine.
* Say we're using the leaf and tail area. * Say we're using the leaf and tail area.
*/ */
dup = xfs_dir3_data_unused_p(hdr); dup = dp->d_ops->data_unused_p(hdr);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_use_free(tp, bp, dup, mp->m_dirblksize - i, i, &needlog, xfs_dir2_data_use_free(tp, dp, bp, dup, mp->m_dirblksize - i, i, &needlog,
&needscan); &needscan);
ASSERT(needscan == 0); ASSERT(needscan == 0);
/* /*
...@@ -1153,7 +1154,7 @@ xfs_dir2_sf_to_block( ...@@ -1153,7 +1154,7 @@ xfs_dir2_sf_to_block(
/* /*
* Remove the freespace, we'll manage it. * Remove the freespace, we'll manage it.
*/ */
xfs_dir2_data_use_free(tp, bp, dup, xfs_dir2_data_use_free(tp, dp, bp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr),
be16_to_cpu(dup->length), &needlog, &needscan); be16_to_cpu(dup->length), &needlog, &needscan);
/* /*
...@@ -1215,7 +1216,9 @@ xfs_dir2_sf_to_block( ...@@ -1215,7 +1216,9 @@ xfs_dir2_sf_to_block(
*xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16(
((char *)dup - (char *)hdr)); ((char *)dup - (char *)hdr));
xfs_dir2_data_log_unused(tp, bp, dup); xfs_dir2_data_log_unused(tp, bp, dup);
xfs_dir2_data_freeinsert(hdr, dup, &dummy); xfs_dir2_data_freeinsert(hdr,
dp->d_ops->data_bestfree_p(hdr),
dup, &dummy);
offset += be16_to_cpu(dup->length); offset += be16_to_cpu(dup->length);
continue; continue;
} }
......
This diff is collapsed.
...@@ -460,7 +460,7 @@ xfs_dir2_block_to_leaf( ...@@ -460,7 +460,7 @@ xfs_dir2_block_to_leaf(
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
blp = xfs_dir2_block_leaf_p(btp); blp = xfs_dir2_block_leaf_p(btp);
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
ents = xfs_dir3_leaf_ents_p(leaf); ents = xfs_dir3_leaf_ents_p(leaf);
/* /*
...@@ -484,7 +484,7 @@ xfs_dir2_block_to_leaf( ...@@ -484,7 +484,7 @@ xfs_dir2_block_to_leaf(
* Make the space formerly occupied by the leaf entries and block * Make the space formerly occupied by the leaf entries and block
* tail be free. * tail be free.
*/ */
xfs_dir2_data_make_free(tp, dbp, xfs_dir2_data_make_free(tp, dp, dbp,
(xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
(xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize - (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize -
(char *)blp), (char *)blp),
...@@ -512,7 +512,7 @@ xfs_dir2_block_to_leaf( ...@@ -512,7 +512,7 @@ xfs_dir2_block_to_leaf(
* Log the data header and leaf bests table. * Log the data header and leaf bests table.
*/ */
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
xfs_dir3_leaf_check(mp, lbp); xfs_dir3_leaf_check(mp, lbp);
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
xfs_dir3_leaf_log_bests(tp, lbp, 0, 0); xfs_dir3_leaf_log_bests(tp, lbp, 0, 0);
...@@ -862,7 +862,7 @@ xfs_dir2_leaf_addname( ...@@ -862,7 +862,7 @@ xfs_dir2_leaf_addname(
else else
xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block); xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block);
hdr = dbp->b_addr; hdr = dbp->b_addr;
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
bestsp[use_block] = bf[0].length; bestsp[use_block] = bf[0].length;
grown = 1; grown = 1;
} else { } else {
...@@ -878,7 +878,7 @@ xfs_dir2_leaf_addname( ...@@ -878,7 +878,7 @@ xfs_dir2_leaf_addname(
return error; return error;
} }
hdr = dbp->b_addr; hdr = dbp->b_addr;
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
grown = 0; grown = 0;
} }
/* /*
...@@ -891,7 +891,7 @@ xfs_dir2_leaf_addname( ...@@ -891,7 +891,7 @@ xfs_dir2_leaf_addname(
/* /*
* Mark the initial part of our freespace in use for the new entry. * Mark the initial part of our freespace in use for the new entry.
*/ */
xfs_dir2_data_use_free(tp, dbp, dup, xfs_dir2_data_use_free(tp, dp, dbp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
&needlog, &needscan); &needlog, &needscan);
/* /*
...@@ -913,7 +913,7 @@ xfs_dir2_leaf_addname( ...@@ -913,7 +913,7 @@ xfs_dir2_leaf_addname(
* Need to log the data block's header. * Need to log the data block's header.
*/ */
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
xfs_dir2_data_log_entry(tp, dp, dbp, dep); xfs_dir2_data_log_entry(tp, dp, dbp, dep);
/* /*
* If the bests table needs to be changed, do it. * If the bests table needs to be changed, do it.
...@@ -1413,7 +1413,7 @@ xfs_dir2_leaf_removename( ...@@ -1413,7 +1413,7 @@ xfs_dir2_leaf_removename(
leaf = lbp->b_addr; leaf = lbp->b_addr;
hdr = dbp->b_addr; hdr = dbp->b_addr;
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf); xfs_dir3_leaf_hdr_from_disk(&leafhdr, leaf);
ents = xfs_dir3_leaf_ents_p(leaf); ents = xfs_dir3_leaf_ents_p(leaf);
/* /*
...@@ -1431,7 +1431,7 @@ xfs_dir2_leaf_removename( ...@@ -1431,7 +1431,7 @@ xfs_dir2_leaf_removename(
/* /*
* Mark the former data entry unused. * Mark the former data entry unused.
*/ */
xfs_dir2_data_make_free(tp, dbp, xfs_dir2_data_make_free(tp, dp, dbp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
/* /*
...@@ -1451,7 +1451,7 @@ xfs_dir2_leaf_removename( ...@@ -1451,7 +1451,7 @@ xfs_dir2_leaf_removename(
if (needscan) if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog); xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
/* /*
* If the longest freespace in the data block has changed, * If the longest freespace in the data block has changed,
* put the new value in the bests table and log that. * put the new value in the bests table and log that.
...@@ -1465,7 +1465,7 @@ xfs_dir2_leaf_removename( ...@@ -1465,7 +1465,7 @@ xfs_dir2_leaf_removename(
* If the data block is now empty then get rid of the data block. * If the data block is now empty then get rid of the data block.
*/ */
if (be16_to_cpu(bf[0].length) == if (be16_to_cpu(bf[0].length) ==
mp->m_dirblksize - xfs_dir3_data_entry_offset(hdr)) { mp->m_dirblksize - dp->d_ops->data_entry_offset()) {
ASSERT(db != mp->m_dirdatablk); ASSERT(db != mp->m_dirdatablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
/* /*
...@@ -1659,12 +1659,12 @@ xfs_dir2_leaf_trim_data( ...@@ -1659,12 +1659,12 @@ xfs_dir2_leaf_trim_data(
#ifdef DEBUG #ifdef DEBUG
{ {
struct xfs_dir2_data_hdr *hdr = dbp->b_addr; struct xfs_dir2_data_hdr *hdr = dbp->b_addr;
struct xfs_dir2_data_free *bf = xfs_dir3_data_bestfree_p(hdr); struct xfs_dir2_data_free *bf = dp->d_ops->data_bestfree_p(hdr);
ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
ASSERT(be16_to_cpu(bf[0].length) == ASSERT(be16_to_cpu(bf[0].length) ==
mp->m_dirblksize - xfs_dir3_data_entry_offset(hdr)); mp->m_dirblksize - dp->d_ops->data_entry_offset());
ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
} }
#endif #endif
......
...@@ -1255,10 +1255,10 @@ xfs_dir2_leafn_remove( ...@@ -1255,10 +1255,10 @@ xfs_dir2_leafn_remove(
dbp = dblk->bp; dbp = dblk->bp;
hdr = dbp->b_addr; hdr = dbp->b_addr;
dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
longest = be16_to_cpu(bf[0].length); longest = be16_to_cpu(bf[0].length);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, dbp, off, xfs_dir2_data_make_free(tp, dp, dbp, off,
dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
/* /*
* Rescan the data block freespaces for bestfree. * Rescan the data block freespaces for bestfree.
...@@ -1267,7 +1267,7 @@ xfs_dir2_leafn_remove( ...@@ -1267,7 +1267,7 @@ xfs_dir2_leafn_remove(
if (needscan) if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog); xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
xfs_dir3_data_check(dp, dbp); xfs_dir3_data_check(dp, dbp);
/* /*
* If the longest data block freespace changes, need to update * If the longest data block freespace changes, need to update
...@@ -1308,7 +1308,7 @@ xfs_dir2_leafn_remove( ...@@ -1308,7 +1308,7 @@ xfs_dir2_leafn_remove(
* (usually). * (usually).
*/ */
if (longest == mp->m_dirblksize - if (longest == mp->m_dirblksize -
xfs_dir3_data_entry_offset(hdr)) { dp->d_ops->data_entry_offset()) {
/* /*
* Try to punch out the data block. * Try to punch out the data block.
*/ */
...@@ -1962,7 +1962,7 @@ xfs_dir2_node_addname_int( ...@@ -1962,7 +1962,7 @@ xfs_dir2_node_addname_int(
* change again. * change again.
*/ */
hdr = dbp->b_addr; hdr = dbp->b_addr;
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
bests[findex] = bf[0].length; bests[findex] = bf[0].length;
logfree = 1; logfree = 1;
} }
...@@ -1984,7 +1984,7 @@ xfs_dir2_node_addname_int( ...@@ -1984,7 +1984,7 @@ xfs_dir2_node_addname_int(
if (error) if (error)
return error; return error;
hdr = dbp->b_addr; hdr = dbp->b_addr;
bf = xfs_dir3_data_bestfree_p(hdr); bf = dp->d_ops->data_bestfree_p(hdr);
logfree = 0; logfree = 0;
} }
ASSERT(be16_to_cpu(bf[0].length) >= length); ASSERT(be16_to_cpu(bf[0].length) >= length);
...@@ -1997,7 +1997,7 @@ xfs_dir2_node_addname_int( ...@@ -1997,7 +1997,7 @@ xfs_dir2_node_addname_int(
/* /*
* Mark the first part of the unused space, inuse for us. * Mark the first part of the unused space, inuse for us.
*/ */
xfs_dir2_data_use_free(tp, dbp, dup, xfs_dir2_data_use_free(tp, dp, dbp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
&needlog, &needscan); &needlog, &needscan);
/* /*
...@@ -2020,7 +2020,7 @@ xfs_dir2_node_addname_int( ...@@ -2020,7 +2020,7 @@ xfs_dir2_node_addname_int(
* Log the data block header if needed. * Log the data block header if needed.
*/ */
if (needlog) if (needlog)
xfs_dir2_data_log_header(tp, dbp); xfs_dir2_data_log_header(tp, dp, dbp);
/* /*
* If the freespace entry is now wrong, update it. * If the freespace entry is now wrong, update it.
*/ */
......
...@@ -59,7 +59,8 @@ extern int xfs_dir3_data_readahead(struct xfs_trans *tp, struct xfs_inode *dp, ...@@ -59,7 +59,8 @@ extern int xfs_dir3_data_readahead(struct xfs_trans *tp, struct xfs_inode *dp,
extern struct xfs_dir2_data_free * extern struct xfs_dir2_data_free *
xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr, xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
struct xfs_dir2_data_unused *dup, int *loghead); struct xfs_dir2_data_free *bf, struct xfs_dir2_data_unused *dup,
int *loghead);
extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, extern int xfs_dir3_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
struct xfs_buf **bpp); struct xfs_buf **bpp);
......
...@@ -213,7 +213,7 @@ xfs_dir2_block_getdents( ...@@ -213,7 +213,7 @@ xfs_dir2_block_getdents(
* Set up values for the loop. * Set up values for the loop.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
ptr = (char *)xfs_dir3_data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
/* /*
...@@ -578,13 +578,13 @@ xfs_dir2_leaf_getdents( ...@@ -578,13 +578,13 @@ xfs_dir2_leaf_getdents(
/* /*
* Find our position in the block. * Find our position in the block.
*/ */
ptr = (char *)xfs_dir3_data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
byteoff = xfs_dir2_byte_to_off(mp, curoff); byteoff = xfs_dir2_byte_to_off(mp, curoff);
/* /*
* Skip past the header. * Skip past the header.
*/ */
if (byteoff == 0) if (byteoff == 0)
curoff += xfs_dir3_data_entry_offset(hdr); curoff += dp->d_ops->data_entry_offset();
/* /*
* Skip past entries until we reach our offset. * Skip past entries until we reach our offset.
*/ */
......
...@@ -210,7 +210,7 @@ xfs_dir2_block_to_sf( ...@@ -210,7 +210,7 @@ xfs_dir2_block_to_sf(
* Set up to loop over the block's entries. * Set up to loop over the block's entries.
*/ */
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
ptr = (char *)xfs_dir3_data_entry_p(hdr); ptr = (char *)dp->d_ops->data_entry_p(hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
sfep = xfs_dir2_sf_firstentry(sfp); sfep = xfs_dir2_sf_firstentry(sfp);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment