Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255135
b: refs/heads/master
c: a64b041
h: refs/heads/master
i:
  255133: 1ce2591
  255131: e3821c5
  255127: d24a5dc
  255119: b710200
  255103: dad8f9b
v: v3
  • Loading branch information
Christoph Hellwig committed Jul 8, 2011
1 parent 6975253 commit 3702141
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4f6ae1a49ed5c81501d6f7385416bb4e07289e99
refs/heads/master: a64b04179735de6bfd9f00c130a68ed7f20d18ef
12 changes: 4 additions & 8 deletions trunk/fs/xfs/xfs_dir2_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ xfs_dir2_block_getdents(
xfs_off_t *offset,
filldir_t filldir)
{
xfs_dir2_block_t *block; /* directory block structure */
xfs_dir2_data_hdr_t *hdr; /* block header */
xfs_dabuf_t *bp; /* buffer for block */
xfs_dir2_block_tail_t *btp; /* block tail */
Expand Down Expand Up @@ -471,14 +470,13 @@ xfs_dir2_block_getdents(
* We'll skip entries before this.
*/
wantoff = xfs_dir2_dataptr_to_off(mp, *offset);
block = bp->data;
hdr = &block->hdr;
hdr = bp->data;
xfs_dir2_data_check(dp, bp);
/*
* Set up values for the loop.
*/
btp = xfs_dir2_block_tail_p(mp, hdr);
ptr = (char *)block->u;
ptr = (char *)(hdr + 1);
endptr = (char *)xfs_dir2_block_leaf_p(btp);

/*
Expand Down Expand Up @@ -1020,7 +1018,6 @@ xfs_dir2_sf_to_block(
xfs_da_args_t *args) /* operation arguments */
{
xfs_dir2_db_t blkno; /* dir-relative block # (0) */
xfs_dir2_block_t *block; /* block structure */
xfs_dir2_data_hdr_t *hdr; /* block header */
xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
xfs_dabuf_t *bp; /* block buffer */
Expand Down Expand Up @@ -1091,8 +1088,7 @@ xfs_dir2_sf_to_block(
kmem_free(sfp);
return error;
}
block = bp->data;
hdr = &block->hdr;
hdr = bp->data;
hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
/*
* Compute size of block "tail" area.
Expand All @@ -1103,7 +1099,7 @@ xfs_dir2_sf_to_block(
* The whole thing is initialized to free by the init routine.
* Say we're using the leaf and tail area.
*/
dup = (xfs_dir2_data_unused_t *)block->u;
dup = (xfs_dir2_data_unused_t *)(hdr + 1);
needlog = needscan = 0;
xfs_dir2_data_use_free(tp, bp, dup, mp->m_dirblksize - i, i, &needlog,
&needscan);
Expand Down
44 changes: 23 additions & 21 deletions trunk/fs/xfs/xfs_dir2_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,30 @@
#define __XFS_DIR2_BLOCK_H__

/*
* xfs_dir2_block.h
* Directory version 2, single block format structures
* Directory version 2, single block format structures.
*
* The single block format looks like the following drawing on disk:
*
* +-------------------------------------------------+
* | xfs_dir2_data_hdr_t |
* +-------------------------------------------------+
* | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
* | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
* | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
* | ... |
* +-------------------------------------------------+
* | unused space |
* +-------------------------------------------------+
* | ... |
* | xfs_dir2_leaf_entry_t |
* | xfs_dir2_leaf_entry_t |
* +-------------------------------------------------+
* | xfs_dir2_block_tail_t |
* +-------------------------------------------------+
*
* As all the entries are variable size structures the accessors in this
* file and xfs_dir2_data.h should be used to iterate over them.
*/

struct uio;
struct xfs_dabuf;
struct xfs_da_args;
Expand All @@ -32,31 +52,13 @@ struct xfs_inode;
struct xfs_mount;
struct xfs_trans;

/*
* The single block format is as follows:
* xfs_dir2_data_hdr_t structure
* xfs_dir2_data_entry_t and xfs_dir2_data_unused_t structures
* xfs_dir2_leaf_entry_t structures
* xfs_dir2_block_tail_t structure
*/

#define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */

typedef struct xfs_dir2_block_tail {
__be32 count; /* count of leaf entries */
__be32 stale; /* count of stale lf entries */
} xfs_dir2_block_tail_t;

/*
* Generic single-block structure, for xfs_db.
*/
typedef struct xfs_dir2_block {
xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_BLOCK_MAGIC */
xfs_dir2_data_union_t u[1];
xfs_dir2_leaf_entry_t leaf[1];
xfs_dir2_block_tail_t tail;
} xfs_dir2_block_t;

/*
* Pointer to the leaf header embedded in a data block (1-block format)
*/
Expand Down
14 changes: 7 additions & 7 deletions trunk/fs/xfs/xfs_dir2_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ xfs_dir2_block_to_sf(
int size, /* shortform directory size */
xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */
{
xfs_dir2_block_t *block; /* block structure */
xfs_dir2_data_hdr_t *hdr; /* block header */
xfs_dir2_block_tail_t *btp; /* block tail pointer */
xfs_dir2_data_entry_t *dep; /* data entry pointer */
xfs_inode_t *dp; /* incore directory inode */
Expand All @@ -248,8 +248,8 @@ xfs_dir2_block_to_sf(
* Make a copy of the block data, so we can shrink the inode
* and add local data.
*/
block = kmem_alloc(mp->m_dirblksize, KM_SLEEP);
memcpy(block, bp->data, mp->m_dirblksize);
hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP);
memcpy(hdr, bp->data, mp->m_dirblksize);
logflags = XFS_ILOG_CORE;
if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) {
ASSERT(error != ENOSPC);
Expand Down Expand Up @@ -277,8 +277,8 @@ xfs_dir2_block_to_sf(
/*
* Set up to loop over the block's entries.
*/
btp = xfs_dir2_block_tail_p(mp, &block->hdr);
ptr = (char *)block->u;
btp = xfs_dir2_block_tail_p(mp, hdr);
ptr = (char *)(hdr + 1);
endptr = (char *)xfs_dir2_block_leaf_p(btp);
sfep = xfs_dir2_sf_firstentry(sfp);
/*
Expand Down Expand Up @@ -314,7 +314,7 @@ xfs_dir2_block_to_sf(
sfep->namelen = dep->namelen;
xfs_dir2_sf_put_offset(sfep,
(xfs_dir2_data_aoff_t)
((char *)dep - (char *)block));
((char *)dep - (char *)hdr));
memcpy(sfep->name, dep->name, dep->namelen);
xfs_dir2_sfe_put_ino(sfp, sfep,
be64_to_cpu(dep->inumber));
Expand All @@ -327,7 +327,7 @@ xfs_dir2_block_to_sf(
xfs_dir2_sf_check(args);
out:
xfs_trans_log_inode(args->trans, dp, logflags);
kmem_free(block);
kmem_free(hdr);
return error;
}

Expand Down

0 comments on commit 3702141

Please sign in to comment.