Commit 50f6bb6b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: devirtualize ->sf_entsize and ->sf_nextentry

Just check for file-type enabled directories directly.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 84915e1b
...@@ -15,48 +15,6 @@ ...@@ -15,48 +15,6 @@
#include "xfs_dir2.h" #include "xfs_dir2.h"
#include "xfs_dir2_priv.h" #include "xfs_dir2_priv.h"
/*
* Shortform directory ops
*/
static int
xfs_dir2_sf_entsize(
struct xfs_dir2_sf_hdr *hdr,
int len)
{
int count = sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */
count += len; /* name */
count += hdr->i8count ? XFS_INO64_SIZE : XFS_INO32_SIZE; /* ino # */
return count;
}
static int
xfs_dir3_sf_entsize(
struct xfs_dir2_sf_hdr *hdr,
int len)
{
return xfs_dir2_sf_entsize(hdr, len) + sizeof(uint8_t);
}
static struct xfs_dir2_sf_entry *
xfs_dir2_sf_nextentry(
struct xfs_dir2_sf_hdr *hdr,
struct xfs_dir2_sf_entry *sfep)
{
return (struct xfs_dir2_sf_entry *)
((char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->namelen));
}
static struct xfs_dir2_sf_entry *
xfs_dir3_sf_nextentry(
struct xfs_dir2_sf_hdr *hdr,
struct xfs_dir2_sf_entry *sfep)
{
return (struct xfs_dir2_sf_entry *)
((char *)sfep + xfs_dir3_sf_entsize(hdr, sfep->namelen));
}
/* /*
* For filetype enabled shortform directories, the file type field is stored at * For filetype enabled shortform directories, the file type field is stored at
* the end of the name. Because it's only a single byte, endian conversion is * the end of the name. Because it's only a single byte, endian conversion is
...@@ -401,8 +359,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr) ...@@ -401,8 +359,6 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
} }
static const struct xfs_dir_ops xfs_dir2_ops = { static const struct xfs_dir_ops xfs_dir2_ops = {
.sf_entsize = xfs_dir2_sf_entsize,
.sf_nextentry = xfs_dir2_sf_nextentry,
.sf_get_ftype = xfs_dir2_sfe_get_ftype, .sf_get_ftype = xfs_dir2_sfe_get_ftype,
.sf_put_ftype = xfs_dir2_sfe_put_ftype, .sf_put_ftype = xfs_dir2_sfe_put_ftype,
.sf_get_ino = xfs_dir2_sfe_get_ino, .sf_get_ino = xfs_dir2_sfe_get_ino,
...@@ -430,8 +386,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = { ...@@ -430,8 +386,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
}; };
static const struct xfs_dir_ops xfs_dir2_ftype_ops = { static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
.sf_entsize = xfs_dir3_sf_entsize,
.sf_nextentry = xfs_dir3_sf_nextentry,
.sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_get_ftype = xfs_dir3_sfe_get_ftype,
.sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype,
.sf_get_ino = xfs_dir3_sfe_get_ino, .sf_get_ino = xfs_dir3_sfe_get_ino,
...@@ -459,8 +413,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = { ...@@ -459,8 +413,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
}; };
static const struct xfs_dir_ops xfs_dir3_ops = { static const struct xfs_dir_ops xfs_dir3_ops = {
.sf_entsize = xfs_dir3_sf_entsize,
.sf_nextentry = xfs_dir3_sf_nextentry,
.sf_get_ftype = xfs_dir3_sfe_get_ftype, .sf_get_ftype = xfs_dir3_sfe_get_ftype,
.sf_put_ftype = xfs_dir3_sfe_put_ftype, .sf_put_ftype = xfs_dir3_sfe_put_ftype,
.sf_get_ino = xfs_dir3_sfe_get_ino, .sf_get_ino = xfs_dir3_sfe_get_ino,
......
...@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode); ...@@ -32,10 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);
* directory operations vector for encode/decode routines * directory operations vector for encode/decode routines
*/ */
struct xfs_dir_ops { struct xfs_dir_ops {
int (*sf_entsize)(struct xfs_dir2_sf_hdr *hdr, int len);
struct xfs_dir2_sf_entry *
(*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr,
struct xfs_dir2_sf_entry *sfep);
uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep); uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);
void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep, void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,
uint8_t ftype); uint8_t ftype);
......
...@@ -1225,7 +1225,7 @@ xfs_dir2_sf_to_block( ...@@ -1225,7 +1225,7 @@ xfs_dir2_sf_to_block(
if (++i == sfp->count) if (++i == sfp->count)
sfep = NULL; sfep = NULL;
else else
sfep = dp->d_ops->sf_nextentry(sfp, sfep); sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
} }
/* Done with the temporary buffer */ /* Done with the temporary buffer */
kmem_free(sfp); kmem_free(sfp);
......
...@@ -147,6 +147,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp, ...@@ -147,6 +147,8 @@ extern int xfs_dir2_free_read(struct xfs_trans *tp, struct xfs_inode *dp,
/* xfs_dir2_sf.c */ /* xfs_dir2_sf.c */
xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr); xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *hdr);
void xfs_dir2_sf_put_parent_ino(struct xfs_dir2_sf_hdr *hdr, xfs_ino_t ino); void xfs_dir2_sf_put_parent_ino(struct xfs_dir2_sf_hdr *hdr, xfs_ino_t ino);
struct xfs_dir2_sf_entry *xfs_dir2_sf_nextentry(struct xfs_mount *mp,
struct xfs_dir2_sf_hdr *hdr, struct xfs_dir2_sf_entry *sfep);
extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp); struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp, extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
......
This diff is collapsed.
...@@ -48,6 +48,7 @@ xfs_dir2_sf_getdents( ...@@ -48,6 +48,7 @@ xfs_dir2_sf_getdents(
{ {
int i; /* shortform entry number */ int i; /* shortform entry number */
struct xfs_inode *dp = args->dp; /* incore directory inode */ struct xfs_inode *dp = args->dp; /* incore directory inode */
struct xfs_mount *mp = dp->i_mount;
xfs_dir2_dataptr_t off; /* current entry's offset */ xfs_dir2_dataptr_t off; /* current entry's offset */
xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
...@@ -109,7 +110,7 @@ xfs_dir2_sf_getdents( ...@@ -109,7 +110,7 @@ xfs_dir2_sf_getdents(
xfs_dir2_sf_get_offset(sfep)); xfs_dir2_sf_get_offset(sfep));
if (ctx->pos > off) { if (ctx->pos > off) {
sfep = dp->d_ops->sf_nextentry(sfp, sfep); sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
continue; continue;
} }
...@@ -122,9 +123,9 @@ xfs_dir2_sf_getdents( ...@@ -122,9 +123,9 @@ xfs_dir2_sf_getdents(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino, if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
xfs_dir3_get_dtype(dp->i_mount, filetype))) xfs_dir3_get_dtype(mp, filetype)))
return 0; return 0;
sfep = dp->d_ops->sf_nextentry(sfp, sfep); sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
} }
ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) & ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
......
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