[XFS] Remove version 1 directory code. Never functioned on Linux, just
pure bloat. SGI-PV: 952969 SGI-Modid: xfs-linux-melb:xfs-kern:26251a Signed-off-by: Nathan Scott <nathans@sgi.com>
This commit is contained in:
parent
da2f4d679c
commit
f6c2d1fa63
@ -21,7 +21,6 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -29,7 +28,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "xfs_log.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_export.h"
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_btree.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -31,7 +30,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_imap.h"
|
||||
#include "xfs_alloc.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -33,7 +32,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -33,7 +32,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -35,7 +34,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -33,7 +32,6 @@
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
|
@ -21,12 +21,10 @@
|
||||
#include "xfs_bit.h"
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -35,7 +34,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -34,7 +33,6 @@
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,13 +24,11 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -40,13 +38,15 @@
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_ialloc.h"
|
||||
#include "xfs_itable.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
#include "xfs_dir2_block.h"
|
||||
#include "xfs_inode_item.h"
|
||||
#include "xfs_extfree_item.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_bmap.h"
|
||||
#include "xfs_rtalloc.h"
|
||||
#include "xfs_error.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_attr_leaf.h"
|
||||
#include "xfs_rw.h"
|
||||
#include "xfs_quota.h"
|
||||
@ -516,7 +516,7 @@ xfs_bmap_add_attrfork_local(
|
||||
dargs.total = mp->m_dirblkfsbs;
|
||||
dargs.whichfork = XFS_DATA_FORK;
|
||||
dargs.trans = tp;
|
||||
error = XFS_DIR_SHORTFORM_TO_SINGLE(mp, &dargs);
|
||||
error = xfs_dir2_sf_to_block(&dargs);
|
||||
} else
|
||||
error = xfs_bmap_local_to_extents(tp, ip, firstblock, 1, flags,
|
||||
XFS_DATA_FORK);
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_buf_item.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -43,7 +41,6 @@
|
||||
#include "xfs_bmap.h"
|
||||
#include "xfs_attr.h"
|
||||
#include "xfs_attr_leaf.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
#include "xfs_dir2_block.h"
|
||||
@ -159,7 +156,7 @@ xfs_da_split(xfs_da_state_t *state)
|
||||
max = state->path.active - 1;
|
||||
ASSERT((max >= 0) && (max < XFS_DA_NODE_MAXDEPTH));
|
||||
ASSERT(state->path.blk[max].magic == XFS_ATTR_LEAF_MAGIC ||
|
||||
state->path.blk[max].magic == XFS_DIRX_LEAF_MAGIC(state->mp));
|
||||
state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC);
|
||||
|
||||
addblk = &state->path.blk[max]; /* initial dummy value */
|
||||
for (i = max; (i >= 0) && addblk; state->path.active--, i--) {
|
||||
@ -199,38 +196,7 @@ xfs_da_split(xfs_da_state_t *state)
|
||||
return(error); /* GROT: attr inconsistent */
|
||||
addblk = newblk;
|
||||
break;
|
||||
case XFS_DIR_LEAF_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
error = xfs_dir_leaf_split(state, oldblk, newblk);
|
||||
if ((error != 0) && (error != ENOSPC)) {
|
||||
return(error); /* GROT: dir is inconsistent */
|
||||
}
|
||||
if (!error) {
|
||||
addblk = newblk;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Entry wouldn't fit, split the leaf again.
|
||||
*/
|
||||
state->extravalid = 1;
|
||||
if (state->inleaf) {
|
||||
state->extraafter = 0; /* before newblk */
|
||||
error = xfs_dir_leaf_split(state, oldblk,
|
||||
&state->extrablk);
|
||||
if (error)
|
||||
return(error); /* GROT: dir incon. */
|
||||
addblk = newblk;
|
||||
} else {
|
||||
state->extraafter = 1; /* after newblk */
|
||||
error = xfs_dir_leaf_split(state, newblk,
|
||||
&state->extrablk);
|
||||
if (error)
|
||||
return(error); /* GROT: dir incon. */
|
||||
addblk = newblk;
|
||||
}
|
||||
break;
|
||||
case XFS_DIR2_LEAFN_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
error = xfs_dir2_leafn_split(state, oldblk, newblk);
|
||||
if (error)
|
||||
return error;
|
||||
@ -363,7 +329,6 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
|
||||
size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
|
||||
(char *)oldroot);
|
||||
} else {
|
||||
ASSERT(XFS_DIR_IS_V2(mp));
|
||||
ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
|
||||
leaf = (xfs_dir2_leaf_t *)oldroot;
|
||||
size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] -
|
||||
@ -379,8 +344,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
|
||||
* Set up the new root node.
|
||||
*/
|
||||
error = xfs_da_node_create(args,
|
||||
args->whichfork == XFS_DATA_FORK &&
|
||||
XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0,
|
||||
(args->whichfork == XFS_DATA_FORK) ? mp->m_dirleafblk : 0,
|
||||
be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork);
|
||||
if (error)
|
||||
return(error);
|
||||
@ -427,10 +391,9 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
|
||||
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
|
||||
|
||||
/*
|
||||
* With V2 the extra block is data or freespace.
|
||||
* With V2 dirs the extra block is data or freespace.
|
||||
*/
|
||||
useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) ||
|
||||
state->args->whichfork == XFS_ATTR_FORK);
|
||||
useextra = state->extravalid && state->args->whichfork == XFS_ATTR_FORK;
|
||||
newcount = 1 + useextra;
|
||||
/*
|
||||
* Do we have to split the node?
|
||||
@ -624,7 +587,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
|
||||
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
|
||||
ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
|
||||
ASSERT(newblk->blkno != 0);
|
||||
if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
|
||||
if (state->args->whichfork == XFS_DATA_FORK)
|
||||
ASSERT(newblk->blkno >= mp->m_dirleafblk &&
|
||||
newblk->blkno < mp->m_dirfreeblk);
|
||||
|
||||
@ -670,7 +633,7 @@ xfs_da_join(xfs_da_state_t *state)
|
||||
save_blk = &state->altpath.blk[ state->path.active-1 ];
|
||||
ASSERT(state->path.blk[0].magic == XFS_DA_NODE_MAGIC);
|
||||
ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC ||
|
||||
drop_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp));
|
||||
drop_blk->magic == XFS_DIR2_LEAFN_MAGIC);
|
||||
|
||||
/*
|
||||
* Walk back up the tree joining/deallocating as necessary.
|
||||
@ -693,17 +656,7 @@ xfs_da_join(xfs_da_state_t *state)
|
||||
return(0);
|
||||
xfs_attr_leaf_unbalance(state, drop_blk, save_blk);
|
||||
break;
|
||||
case XFS_DIR_LEAF_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
error = xfs_dir_leaf_toosmall(state, &action);
|
||||
if (error)
|
||||
return(error);
|
||||
if (action == 0)
|
||||
return(0);
|
||||
xfs_dir_leaf_unbalance(state, drop_blk, save_blk);
|
||||
break;
|
||||
case XFS_DIR2_LEAFN_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
error = xfs_dir2_leafn_toosmall(state, &action);
|
||||
if (error)
|
||||
return error;
|
||||
@ -790,7 +743,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
|
||||
ASSERT(bp != NULL);
|
||||
blkinfo = bp->data;
|
||||
if (be16_to_cpu(oldroot->hdr.level) == 1) {
|
||||
ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
|
||||
ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIR2_LEAFN_MAGIC ||
|
||||
be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC);
|
||||
} else {
|
||||
ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC);
|
||||
@ -951,14 +904,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
|
||||
if (count == 0)
|
||||
return;
|
||||
break;
|
||||
case XFS_DIR_LEAF_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
lasthash = xfs_dir_leaf_lasthash(blk->bp, &count);
|
||||
if (count == 0)
|
||||
return;
|
||||
break;
|
||||
case XFS_DIR2_LEAFN_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
lasthash = xfs_dir2_leafn_lasthash(blk->bp, &count);
|
||||
if (count == 0)
|
||||
return;
|
||||
@ -1117,10 +1063,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
|
||||
* Descend thru the B-tree searching each level for the right
|
||||
* node to use, until the right hashval is found.
|
||||
*/
|
||||
if (args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(state->mp))
|
||||
blkno = state->mp->m_dirleafblk;
|
||||
else
|
||||
blkno = 0;
|
||||
blkno = (args->whichfork == XFS_DATA_FORK)? state->mp->m_dirleafblk : 0;
|
||||
for (blk = &state->path.blk[0], state->path.active = 1;
|
||||
state->path.active <= XFS_DA_NODE_MAXDEPTH;
|
||||
blk++, state->path.active++) {
|
||||
@ -1137,7 +1080,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
|
||||
}
|
||||
curr = blk->bp->data;
|
||||
ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC ||
|
||||
be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
|
||||
be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC ||
|
||||
be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC);
|
||||
|
||||
/*
|
||||
@ -1190,16 +1133,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
|
||||
blk->index = probe;
|
||||
blkno = be32_to_cpu(btree->before);
|
||||
}
|
||||
}
|
||||
else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
|
||||
} else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
|
||||
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
|
||||
break;
|
||||
}
|
||||
else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) {
|
||||
blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
|
||||
break;
|
||||
}
|
||||
else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
|
||||
} else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
|
||||
blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL);
|
||||
break;
|
||||
}
|
||||
@ -1212,12 +1149,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
|
||||
* next leaf and keep searching.
|
||||
*/
|
||||
for (;;) {
|
||||
if (blk->magic == XFS_DIR_LEAF_MAGIC) {
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
retval = xfs_dir_leaf_lookup_int(blk->bp, args,
|
||||
&blk->index);
|
||||
} else if (blk->magic == XFS_DIR2_LEAFN_MAGIC) {
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
if (blk->magic == XFS_DIR2_LEAFN_MAGIC) {
|
||||
retval = xfs_dir2_leafn_lookup_int(blk->bp, args,
|
||||
&blk->index, state);
|
||||
}
|
||||
@ -1270,7 +1202,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
|
||||
old_info = old_blk->bp->data;
|
||||
new_info = new_blk->bp->data;
|
||||
ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
|
||||
old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
|
||||
old_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
|
||||
old_blk->magic == XFS_ATTR_LEAF_MAGIC);
|
||||
ASSERT(old_blk->magic == be16_to_cpu(old_info->magic));
|
||||
ASSERT(new_blk->magic == be16_to_cpu(new_info->magic));
|
||||
@ -1280,12 +1212,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
|
||||
case XFS_ATTR_LEAF_MAGIC:
|
||||
before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp);
|
||||
break;
|
||||
case XFS_DIR_LEAF_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp);
|
||||
break;
|
||||
case XFS_DIR2_LEAFN_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
before = xfs_dir2_leafn_order(old_blk->bp, new_blk->bp);
|
||||
break;
|
||||
case XFS_DA_NODE_MAGIC:
|
||||
@ -1404,7 +1331,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
|
||||
save_info = save_blk->bp->data;
|
||||
drop_info = drop_blk->bp->data;
|
||||
ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
|
||||
save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
|
||||
save_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
|
||||
save_blk->magic == XFS_ATTR_LEAF_MAGIC);
|
||||
ASSERT(save_blk->magic == be16_to_cpu(save_info->magic));
|
||||
ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic));
|
||||
@ -1529,7 +1456,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
|
||||
ASSERT(blk->bp != NULL);
|
||||
info = blk->bp->data;
|
||||
ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC ||
|
||||
be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
|
||||
be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC ||
|
||||
be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
|
||||
blk->magic = be16_to_cpu(info->magic);
|
||||
if (blk->magic == XFS_DA_NODE_MAGIC) {
|
||||
@ -1548,20 +1475,13 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
|
||||
blk->hashval = xfs_attr_leaf_lasthash(blk->bp,
|
||||
NULL);
|
||||
break;
|
||||
case XFS_DIR_LEAF_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V1(state->mp));
|
||||
blk->hashval = xfs_dir_leaf_lasthash(blk->bp,
|
||||
NULL);
|
||||
break;
|
||||
case XFS_DIR2_LEAFN_MAGIC:
|
||||
ASSERT(XFS_DIR_IS_V2(state->mp));
|
||||
blk->hashval = xfs_dir2_leafn_lasthash(blk->bp,
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC ||
|
||||
blk->magic ==
|
||||
XFS_DIRX_LEAF_MAGIC(state->mp));
|
||||
blk->magic == XFS_DIR2_LEAFN_MAGIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1620,7 +1540,6 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
|
||||
xfs_bmbt_irec_t *mapp;
|
||||
xfs_inode_t *dp;
|
||||
int nmap, error, w, count, c, got, i, mapi;
|
||||
xfs_fsize_t size;
|
||||
xfs_trans_t *tp;
|
||||
xfs_mount_t *mp;
|
||||
|
||||
@ -1631,7 +1550,7 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
|
||||
/*
|
||||
* For new directories adjust the file offset and block count.
|
||||
*/
|
||||
if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) {
|
||||
if (w == XFS_DATA_FORK) {
|
||||
bno = mp->m_dirleafblk;
|
||||
count = mp->m_dirblkfsbs;
|
||||
} else {
|
||||
@ -1641,10 +1560,9 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
|
||||
/*
|
||||
* Find a spot in the file space to put the new block.
|
||||
*/
|
||||
if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, w))) {
|
||||
if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, w)))
|
||||
return error;
|
||||
}
|
||||
if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
|
||||
if (w == XFS_DATA_FORK)
|
||||
ASSERT(bno >= mp->m_dirleafblk && bno < mp->m_dirfreeblk);
|
||||
/*
|
||||
* Try mapping it in one filesystem block.
|
||||
@ -1706,19 +1624,6 @@ xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno)
|
||||
if (mapp != &map)
|
||||
kmem_free(mapp, sizeof(*mapp) * count);
|
||||
*new_blkno = (xfs_dablk_t)bno;
|
||||
/*
|
||||
* For version 1 directories, adjust the file size if it changed.
|
||||
*/
|
||||
if (w == XFS_DATA_FORK && XFS_DIR_IS_V1(mp)) {
|
||||
ASSERT(mapi == 1);
|
||||
if ((error = xfs_bmap_last_offset(tp, dp, &bno, w)))
|
||||
return error;
|
||||
size = XFS_FSB_TO_B(mp, bno);
|
||||
if (size != dp->i_d.di_size) {
|
||||
dp->i_d.di_size = size;
|
||||
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1743,7 +1648,6 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
|
||||
int error, w, entno, level, dead_level;
|
||||
xfs_da_blkinfo_t *dead_info, *sib_info;
|
||||
xfs_da_intnode_t *par_node, *dead_node;
|
||||
xfs_dir_leafblock_t *dead_leaf;
|
||||
xfs_dir2_leaf_t *dead_leaf2;
|
||||
xfs_dahash_t dead_hash;
|
||||
|
||||
@ -1754,11 +1658,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
|
||||
w = args->whichfork;
|
||||
ASSERT(w == XFS_DATA_FORK);
|
||||
mp = ip->i_mount;
|
||||
if (XFS_DIR_IS_V2(mp)) {
|
||||
lastoff = mp->m_dirfreeblk;
|
||||
error = xfs_bmap_last_before(tp, ip, &lastoff, w);
|
||||
} else
|
||||
error = xfs_bmap_last_offset(tp, ip, &lastoff, w);
|
||||
lastoff = mp->m_dirfreeblk;
|
||||
error = xfs_bmap_last_before(tp, ip, &lastoff, w);
|
||||
if (error)
|
||||
return error;
|
||||
if (unlikely(lastoff == 0)) {
|
||||
@ -1781,14 +1682,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
|
||||
/*
|
||||
* Get values from the moved block.
|
||||
*/
|
||||
if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) {
|
||||
ASSERT(XFS_DIR_IS_V1(mp));
|
||||
dead_leaf = (xfs_dir_leafblock_t *)dead_info;
|
||||
dead_level = 0;
|
||||
dead_hash = be32_to_cpu(dead_leaf->entries[
|
||||
be16_to_cpu(dead_leaf->hdr.count) - 1].hashval);
|
||||
} else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) {
|
||||
ASSERT(XFS_DIR_IS_V2(mp));
|
||||
if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) {
|
||||
dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
|
||||
dead_level = 0;
|
||||
dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval);
|
||||
@ -1843,7 +1737,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
|
||||
xfs_da_buf_done(sib_buf);
|
||||
sib_buf = NULL;
|
||||
}
|
||||
par_blkno = XFS_DIR_IS_V1(mp) ? 0 : mp->m_dirleafblk;
|
||||
par_blkno = mp->m_dirleafblk;
|
||||
level = -1;
|
||||
/*
|
||||
* Walk down the tree looking for the parent of the moved block.
|
||||
@ -1942,8 +1836,6 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
|
||||
{
|
||||
xfs_inode_t *dp;
|
||||
int done, error, w, count;
|
||||
xfs_fileoff_t bno;
|
||||
xfs_fsize_t size;
|
||||
xfs_trans_t *tp;
|
||||
xfs_mount_t *mp;
|
||||
|
||||
@ -1951,7 +1843,7 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
|
||||
w = args->whichfork;
|
||||
tp = args->trans;
|
||||
mp = dp->i_mount;
|
||||
if (w == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
|
||||
if (w == XFS_DATA_FORK)
|
||||
count = mp->m_dirblkfsbs;
|
||||
else
|
||||
count = 1;
|
||||
@ -1965,31 +1857,14 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
|
||||
0, args->firstblock, args->flist, NULL,
|
||||
&done)) == ENOSPC) {
|
||||
if (w != XFS_DATA_FORK)
|
||||
goto done;
|
||||
break;
|
||||
if ((error = xfs_da_swap_lastblock(args, &dead_blkno,
|
||||
&dead_buf)))
|
||||
goto done;
|
||||
} else if (error)
|
||||
goto done;
|
||||
else
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
ASSERT(done);
|
||||
xfs_da_binval(tp, dead_buf);
|
||||
/*
|
||||
* Adjust the directory size for version 1.
|
||||
*/
|
||||
if (w == XFS_DATA_FORK && XFS_DIR_IS_V1(mp)) {
|
||||
if ((error = xfs_bmap_last_offset(tp, dp, &bno, w)))
|
||||
return error;
|
||||
size = XFS_FSB_TO_B(dp->i_mount, bno);
|
||||
if (size != dp->i_d.di_size) {
|
||||
dp->i_d.di_size = size;
|
||||
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
done:
|
||||
xfs_da_binval(tp, dead_buf);
|
||||
return error;
|
||||
}
|
||||
@ -2050,10 +1925,7 @@ xfs_da_do_buf(
|
||||
xfs_dabuf_t *rbp;
|
||||
|
||||
mp = dp->i_mount;
|
||||
if (whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
|
||||
nfsb = mp->m_dirblkfsbs;
|
||||
else
|
||||
nfsb = 1;
|
||||
nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1;
|
||||
mappedbno = *mappedbnop;
|
||||
/*
|
||||
* Caller doesn't have a mapping. -2 means don't complain
|
||||
@ -2199,7 +2071,6 @@ xfs_da_do_buf(
|
||||
magic1 = be32_to_cpu(data->hdr.magic);
|
||||
if (unlikely(
|
||||
XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
|
||||
(magic != XFS_DIR_LEAF_MAGIC) &&
|
||||
(magic != XFS_ATTR_LEAF_MAGIC) &&
|
||||
(magic != XFS_DIR2_LEAF1_MAGIC) &&
|
||||
(magic != XFS_DIR2_LEAFN_MAGIC) &&
|
||||
|
@ -36,14 +36,10 @@ struct zone;
|
||||
* level in the Btree, and to identify which type of block this is.
|
||||
*/
|
||||
#define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */
|
||||
#define XFS_DIR_LEAF_MAGIC 0xfeeb /* magic number: directory leaf blks */
|
||||
#define XFS_ATTR_LEAF_MAGIC 0xfbee /* magic number: attribute leaf blks */
|
||||
#define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
|
||||
#define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
|
||||
|
||||
#define XFS_DIRX_LEAF_MAGIC(mp) \
|
||||
(XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC)
|
||||
|
||||
typedef struct xfs_da_blkinfo {
|
||||
__be32 forw; /* previous block in list */
|
||||
__be32 back; /* following block in list */
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -85,7 +85,6 @@ typedef struct xfs_dinode
|
||||
union {
|
||||
xfs_bmdr_block_t di_bmbt; /* btree root block */
|
||||
xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
|
||||
xfs_dir_shortform_t di_dirsf; /* shortform directory */
|
||||
xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
|
||||
char di_c[1]; /* local contents */
|
||||
xfs_dev_t di_dev; /* device for S_IFCHR/S_IFBLK */
|
||||
|
1213
fs/xfs/xfs_dir.c
1213
fs/xfs/xfs_dir.c
File diff suppressed because it is too large
Load Diff
142
fs/xfs/xfs_dir.h
142
fs/xfs/xfs_dir.h
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000,2005 Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef __XFS_DIR_H__
|
||||
#define __XFS_DIR_H__
|
||||
|
||||
/*
|
||||
* Large directories are structured around Btrees where all the data
|
||||
* elements are in the leaf nodes. Filenames are hashed into an int,
|
||||
* then that int is used as the index into the Btree. Since the hashval
|
||||
* of a filename may not be unique, we may have duplicate keys. The
|
||||
* internal links in the Btree are logical block offsets into the file.
|
||||
*
|
||||
* Small directories use a different format and are packed as tightly
|
||||
* as possible so as to fit into the literal area of the inode.
|
||||
*/
|
||||
|
||||
/*========================================================================
|
||||
* Function prototypes for the kernel.
|
||||
*========================================================================*/
|
||||
|
||||
struct uio;
|
||||
struct xfs_bmap_free;
|
||||
struct xfs_da_args;
|
||||
struct xfs_dinode;
|
||||
struct xfs_inode;
|
||||
struct xfs_mount;
|
||||
struct xfs_trans;
|
||||
|
||||
/*
|
||||
* Directory function types.
|
||||
* Put in structures (xfs_dirops_t) for v1 and v2 directories.
|
||||
*/
|
||||
typedef void (*xfs_dir_mount_t)(struct xfs_mount *mp);
|
||||
typedef int (*xfs_dir_isempty_t)(struct xfs_inode *dp);
|
||||
typedef int (*xfs_dir_init_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
struct xfs_inode *pdp);
|
||||
typedef int (*xfs_dir_createname_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t inum,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist,
|
||||
xfs_extlen_t total);
|
||||
typedef int (*xfs_dir_lookup_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t *inum);
|
||||
typedef int (*xfs_dir_removename_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t ino,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist,
|
||||
xfs_extlen_t total);
|
||||
typedef int (*xfs_dir_getdents_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
struct uio *uio,
|
||||
int *eofp);
|
||||
typedef int (*xfs_dir_replace_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t inum,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist,
|
||||
xfs_extlen_t total);
|
||||
typedef int (*xfs_dir_canenter_t)(struct xfs_trans *tp,
|
||||
struct xfs_inode *dp,
|
||||
char *name,
|
||||
int namelen);
|
||||
typedef int (*xfs_dir_shortform_validate_ondisk_t)(struct xfs_mount *mp,
|
||||
struct xfs_dinode *dip);
|
||||
typedef int (*xfs_dir_shortform_to_single_t)(struct xfs_da_args *args);
|
||||
|
||||
typedef struct xfs_dirops {
|
||||
xfs_dir_mount_t xd_mount;
|
||||
xfs_dir_isempty_t xd_isempty;
|
||||
xfs_dir_init_t xd_init;
|
||||
xfs_dir_createname_t xd_createname;
|
||||
xfs_dir_lookup_t xd_lookup;
|
||||
xfs_dir_removename_t xd_removename;
|
||||
xfs_dir_getdents_t xd_getdents;
|
||||
xfs_dir_replace_t xd_replace;
|
||||
xfs_dir_canenter_t xd_canenter;
|
||||
xfs_dir_shortform_validate_ondisk_t xd_shortform_validate_ondisk;
|
||||
xfs_dir_shortform_to_single_t xd_shortform_to_single;
|
||||
} xfs_dirops_t;
|
||||
|
||||
/*
|
||||
* Overall external interface routines.
|
||||
*/
|
||||
void xfs_dir_startup(void); /* called exactly once */
|
||||
|
||||
#define XFS_DIR_MOUNT(mp) \
|
||||
((mp)->m_dirops.xd_mount(mp))
|
||||
#define XFS_DIR_ISEMPTY(mp,dp) \
|
||||
((mp)->m_dirops.xd_isempty(dp))
|
||||
#define XFS_DIR_INIT(mp,tp,dp,pdp) \
|
||||
((mp)->m_dirops.xd_init(tp,dp,pdp))
|
||||
#define XFS_DIR_CREATENAME(mp,tp,dp,name,namelen,inum,first,flist,total) \
|
||||
((mp)->m_dirops.xd_createname(tp,dp,name,namelen,inum,first,flist,\
|
||||
total))
|
||||
#define XFS_DIR_LOOKUP(mp,tp,dp,name,namelen,inum) \
|
||||
((mp)->m_dirops.xd_lookup(tp,dp,name,namelen,inum))
|
||||
#define XFS_DIR_REMOVENAME(mp,tp,dp,name,namelen,ino,first,flist,total) \
|
||||
((mp)->m_dirops.xd_removename(tp,dp,name,namelen,ino,first,flist,total))
|
||||
#define XFS_DIR_GETDENTS(mp,tp,dp,uio,eofp) \
|
||||
((mp)->m_dirops.xd_getdents(tp,dp,uio,eofp))
|
||||
#define XFS_DIR_REPLACE(mp,tp,dp,name,namelen,inum,first,flist,total) \
|
||||
((mp)->m_dirops.xd_replace(tp,dp,name,namelen,inum,first,flist,total))
|
||||
#define XFS_DIR_CANENTER(mp,tp,dp,name,namelen) \
|
||||
((mp)->m_dirops.xd_canenter(tp,dp,name,namelen))
|
||||
#define XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp,dip) \
|
||||
((mp)->m_dirops.xd_shortform_validate_ondisk(mp,dip))
|
||||
#define XFS_DIR_SHORTFORM_TO_SINGLE(mp,args) \
|
||||
((mp)->m_dirops.xd_shortform_to_single(args))
|
||||
|
||||
#define XFS_DIR_IS_V1(mp) ((mp)->m_dirversion == 1)
|
||||
#define XFS_DIR_IS_V2(mp) ((mp)->m_dirversion == 2)
|
||||
extern xfs_dirops_t xfsv1_dirops;
|
||||
extern xfs_dirops_t xfsv2_dirops;
|
||||
|
||||
#endif /* __XFS_DIR_H__ */
|
@ -24,21 +24,18 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_inode_item.h"
|
||||
#include "xfs_bmap.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
#include "xfs_dir2_block.h"
|
||||
@ -46,69 +43,14 @@
|
||||
#include "xfs_dir2_trace.h"
|
||||
#include "xfs_error.h"
|
||||
|
||||
/*
|
||||
* Declarations for interface routines.
|
||||
*/
|
||||
static void xfs_dir2_mount(xfs_mount_t *mp);
|
||||
static int xfs_dir2_isempty(xfs_inode_t *dp);
|
||||
static int xfs_dir2_init(xfs_trans_t *tp, xfs_inode_t *dp,
|
||||
xfs_inode_t *pdp);
|
||||
static int xfs_dir2_createname(xfs_trans_t *tp, xfs_inode_t *dp,
|
||||
char *name, int namelen, xfs_ino_t inum,
|
||||
xfs_fsblock_t *first,
|
||||
xfs_bmap_free_t *flist, xfs_extlen_t total);
|
||||
static int xfs_dir2_lookup(xfs_trans_t *tp, xfs_inode_t *dp, char *name,
|
||||
int namelen, xfs_ino_t *inum);
|
||||
static int xfs_dir2_removename(xfs_trans_t *tp, xfs_inode_t *dp,
|
||||
char *name, int namelen, xfs_ino_t ino,
|
||||
xfs_fsblock_t *first,
|
||||
xfs_bmap_free_t *flist, xfs_extlen_t total);
|
||||
static int xfs_dir2_getdents(xfs_trans_t *tp, xfs_inode_t *dp, uio_t *uio,
|
||||
int *eofp);
|
||||
static int xfs_dir2_replace(xfs_trans_t *tp, xfs_inode_t *dp, char *name,
|
||||
int namelen, xfs_ino_t inum,
|
||||
xfs_fsblock_t *first, xfs_bmap_free_t *flist,
|
||||
xfs_extlen_t total);
|
||||
static int xfs_dir2_canenter(xfs_trans_t *tp, xfs_inode_t *dp, char *name,
|
||||
int namelen);
|
||||
static int xfs_dir2_shortform_validate_ondisk(xfs_mount_t *mp,
|
||||
xfs_dinode_t *dip);
|
||||
|
||||
/*
|
||||
* Utility routine declarations.
|
||||
*/
|
||||
static int xfs_dir2_put_dirent64_direct(xfs_dir2_put_args_t *pa);
|
||||
static int xfs_dir2_put_dirent64_uio(xfs_dir2_put_args_t *pa);
|
||||
|
||||
/*
|
||||
* Directory operations vector.
|
||||
*/
|
||||
xfs_dirops_t xfsv2_dirops = {
|
||||
.xd_mount = xfs_dir2_mount,
|
||||
.xd_isempty = xfs_dir2_isempty,
|
||||
.xd_init = xfs_dir2_init,
|
||||
.xd_createname = xfs_dir2_createname,
|
||||
.xd_lookup = xfs_dir2_lookup,
|
||||
.xd_removename = xfs_dir2_removename,
|
||||
.xd_getdents = xfs_dir2_getdents,
|
||||
.xd_replace = xfs_dir2_replace,
|
||||
.xd_canenter = xfs_dir2_canenter,
|
||||
.xd_shortform_validate_ondisk = xfs_dir2_shortform_validate_ondisk,
|
||||
.xd_shortform_to_single = xfs_dir2_sf_to_block,
|
||||
};
|
||||
|
||||
/*
|
||||
* Interface routines.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize directory-related fields in the mount structure.
|
||||
*/
|
||||
static void
|
||||
xfs_dir2_mount(
|
||||
xfs_mount_t *mp) /* filesystem mount point */
|
||||
void
|
||||
xfs_dir_mount(
|
||||
xfs_mount_t *mp)
|
||||
{
|
||||
mp->m_dirversion = 2;
|
||||
ASSERT(XFS_SB_VERSION_HASDIRV2(&mp->m_sb));
|
||||
ASSERT((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) <=
|
||||
XFS_MAX_BLOCKSIZE);
|
||||
mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog);
|
||||
@ -128,73 +70,99 @@ xfs_dir2_mount(
|
||||
/*
|
||||
* Return 1 if directory contains only "." and "..".
|
||||
*/
|
||||
static int /* return code */
|
||||
xfs_dir2_isempty(
|
||||
xfs_inode_t *dp) /* incore inode structure */
|
||||
int
|
||||
xfs_dir_isempty(
|
||||
xfs_inode_t *dp)
|
||||
{
|
||||
xfs_dir2_sf_t *sfp; /* shortform directory structure */
|
||||
xfs_dir2_sf_t *sfp;
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
/*
|
||||
* Might happen during shutdown.
|
||||
*/
|
||||
if (dp->i_d.di_size == 0) {
|
||||
if (dp->i_d.di_size == 0) /* might happen during shutdown. */
|
||||
return 1;
|
||||
}
|
||||
if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
|
||||
return 0;
|
||||
sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data;
|
||||
return !sfp->hdr.count;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a given inode number.
|
||||
*/
|
||||
int
|
||||
xfs_dir_ino_validate(
|
||||
xfs_mount_t *mp,
|
||||
xfs_ino_t ino)
|
||||
{
|
||||
xfs_agblock_t agblkno;
|
||||
xfs_agino_t agino;
|
||||
xfs_agnumber_t agno;
|
||||
int ino_ok;
|
||||
int ioff;
|
||||
|
||||
agno = XFS_INO_TO_AGNO(mp, ino);
|
||||
agblkno = XFS_INO_TO_AGBNO(mp, ino);
|
||||
ioff = XFS_INO_TO_OFFSET(mp, ino);
|
||||
agino = XFS_OFFBNO_TO_AGINO(mp, agblkno, ioff);
|
||||
ino_ok =
|
||||
agno < mp->m_sb.sb_agcount &&
|
||||
agblkno < mp->m_sb.sb_agblocks &&
|
||||
agblkno != 0 &&
|
||||
ioff < (1 << mp->m_sb.sb_inopblog) &&
|
||||
XFS_AGINO_TO_INO(mp, agno, agino) == ino;
|
||||
if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE,
|
||||
XFS_RANDOM_DIR_INO_VALIDATE))) {
|
||||
xfs_fs_cmn_err(CE_WARN, mp, "Invalid inode number 0x%Lx",
|
||||
(unsigned long long) ino);
|
||||
XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp);
|
||||
return XFS_ERROR(EFSCORRUPTED);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a directory with its "." and ".." entries.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_init(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
xfs_inode_t *pdp) /* incore parent directory inode */
|
||||
int
|
||||
xfs_dir_init(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
xfs_inode_t *pdp)
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int error; /* error return value */
|
||||
xfs_da_args_t args;
|
||||
int error;
|
||||
|
||||
memset((char *)&args, 0, sizeof(args));
|
||||
args.dp = dp;
|
||||
args.trans = tp;
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
if ((error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino))) {
|
||||
if ((error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino)))
|
||||
return error;
|
||||
}
|
||||
return xfs_dir2_sf_create(&args, pdp->i_ino);
|
||||
}
|
||||
|
||||
/*
|
||||
Enter a name in a directory.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_createname(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
char *name, /* new entry name */
|
||||
int namelen, /* new entry name length */
|
||||
int
|
||||
xfs_dir_createname(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t inum, /* new entry inode number */
|
||||
xfs_fsblock_t *first, /* bmap's firstblock */
|
||||
xfs_bmap_free_t *flist, /* bmap's freeblock list */
|
||||
xfs_extlen_t total) /* bmap's total block count */
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int rval; /* return value */
|
||||
xfs_da_args_t args;
|
||||
int rval;
|
||||
int v; /* type-checking value */
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) {
|
||||
if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum)))
|
||||
return rval;
|
||||
}
|
||||
XFS_STATS_INC(xs_dir_create);
|
||||
/*
|
||||
* Fill in the arg structure for this request.
|
||||
*/
|
||||
|
||||
args.name = name;
|
||||
args.namelen = namelen;
|
||||
args.hashval = xfs_da_hashname(name, namelen);
|
||||
@ -207,18 +175,16 @@ xfs_dir2_createname(
|
||||
args.trans = tp;
|
||||
args.justcheck = 0;
|
||||
args.addname = args.oknoent = 1;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_addname(&args);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_addname(&args);
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_leaf_addname(&args);
|
||||
else
|
||||
rval = xfs_dir2_node_addname(&args);
|
||||
@ -228,24 +194,21 @@ xfs_dir2_createname(
|
||||
/*
|
||||
* Lookup a name in a directory, give back the inode number.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_lookup(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
char *name, /* lookup name */
|
||||
int namelen, /* lookup name length */
|
||||
int
|
||||
xfs_dir_lookup(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t *inum) /* out: inode number */
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int rval; /* return value */
|
||||
xfs_da_args_t args;
|
||||
int rval;
|
||||
int v; /* type-checking value */
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
XFS_STATS_INC(xs_dir_lookup);
|
||||
|
||||
/*
|
||||
* Fill in the arg structure for this request.
|
||||
*/
|
||||
args.name = name;
|
||||
args.namelen = namelen;
|
||||
args.hashval = xfs_da_hashname(name, namelen);
|
||||
@ -258,18 +221,16 @@ xfs_dir2_lookup(
|
||||
args.trans = tp;
|
||||
args.justcheck = args.addname = 0;
|
||||
args.oknoent = 1;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_lookup(&args);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_lookup(&args);
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_leaf_lookup(&args);
|
||||
else
|
||||
rval = xfs_dir2_node_lookup(&args);
|
||||
@ -283,26 +244,24 @@ xfs_dir2_lookup(
|
||||
/*
|
||||
* Remove an entry from a directory.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_removename(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
char *name, /* name of entry to remove */
|
||||
int namelen, /* name length of entry to remove */
|
||||
xfs_ino_t ino, /* inode number of entry to remove */
|
||||
int
|
||||
xfs_dir_removename(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
char *name,
|
||||
int namelen,
|
||||
xfs_ino_t ino,
|
||||
xfs_fsblock_t *first, /* bmap's firstblock */
|
||||
xfs_bmap_free_t *flist, /* bmap's freeblock list */
|
||||
xfs_extlen_t total) /* bmap's total block count */
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int rval; /* return value */
|
||||
xfs_da_args_t args;
|
||||
int rval;
|
||||
int v; /* type-checking value */
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
XFS_STATS_INC(xs_dir_remove);
|
||||
/*
|
||||
* Fill in the arg structure for this request.
|
||||
*/
|
||||
|
||||
args.name = name;
|
||||
args.namelen = namelen;
|
||||
args.hashval = xfs_da_hashname(name, namelen);
|
||||
@ -314,18 +273,16 @@ xfs_dir2_removename(
|
||||
args.whichfork = XFS_DATA_FORK;
|
||||
args.trans = tp;
|
||||
args.justcheck = args.addname = args.oknoent = 0;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_removename(&args);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_removename(&args);
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_leaf_removename(&args);
|
||||
else
|
||||
rval = xfs_dir2_node_removename(&args);
|
||||
@ -335,10 +292,10 @@ xfs_dir2_removename(
|
||||
/*
|
||||
* Read a directory.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_getdents(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
int
|
||||
xfs_dir_getdents(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
uio_t *uio, /* caller's buffer control */
|
||||
int *eofp) /* out: eof reached */
|
||||
{
|
||||
@ -367,14 +324,11 @@ xfs_dir2_getdents(
|
||||
}
|
||||
|
||||
*eofp = 0;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_getdents(dp, uio, eofp, dbp, put);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_getdents(tp, dp, uio, eofp, dbp, put);
|
||||
else
|
||||
rval = xfs_dir2_leaf_getdents(tp, dp, uio, eofp, dbp, put);
|
||||
@ -386,29 +340,26 @@ xfs_dir2_getdents(
|
||||
/*
|
||||
* Replace the inode number of a directory entry.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_replace(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
int
|
||||
xfs_dir_replace(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
char *name, /* name of entry to replace */
|
||||
int namelen, /* name length of entry to replace */
|
||||
int namelen,
|
||||
xfs_ino_t inum, /* new inode number */
|
||||
xfs_fsblock_t *first, /* bmap's firstblock */
|
||||
xfs_bmap_free_t *flist, /* bmap's freeblock list */
|
||||
xfs_extlen_t total) /* bmap's total block count */
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int rval; /* return value */
|
||||
xfs_da_args_t args;
|
||||
int rval;
|
||||
int v; /* type-checking value */
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
|
||||
if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) {
|
||||
if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum)))
|
||||
return rval;
|
||||
}
|
||||
/*
|
||||
* Fill in the arg structure for this request.
|
||||
*/
|
||||
|
||||
args.name = name;
|
||||
args.namelen = namelen;
|
||||
args.hashval = xfs_da_hashname(name, namelen);
|
||||
@ -420,18 +371,16 @@ xfs_dir2_replace(
|
||||
args.whichfork = XFS_DATA_FORK;
|
||||
args.trans = tp;
|
||||
args.justcheck = args.addname = args.oknoent = 0;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_replace(&args);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_replace(&args);
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_leaf_replace(&args);
|
||||
else
|
||||
rval = xfs_dir2_node_replace(&args);
|
||||
@ -441,21 +390,19 @@ xfs_dir2_replace(
|
||||
/*
|
||||
* See if this entry can be added to the directory without allocating space.
|
||||
*/
|
||||
static int /* error */
|
||||
xfs_dir2_canenter(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
int
|
||||
xfs_dir_canenter(
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
char *name, /* name of entry to add */
|
||||
int namelen) /* name length of entry to add */
|
||||
int namelen)
|
||||
{
|
||||
xfs_da_args_t args; /* operation arguments */
|
||||
int rval; /* return value */
|
||||
xfs_da_args_t args;
|
||||
int rval;
|
||||
int v; /* type-checking value */
|
||||
|
||||
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
|
||||
/*
|
||||
* Fill in the arg structure for this request.
|
||||
*/
|
||||
|
||||
args.name = name;
|
||||
args.namelen = namelen;
|
||||
args.hashval = xfs_da_hashname(name, namelen);
|
||||
@ -467,37 +414,22 @@ xfs_dir2_canenter(
|
||||
args.whichfork = XFS_DATA_FORK;
|
||||
args.trans = tp;
|
||||
args.justcheck = args.addname = args.oknoent = 1;
|
||||
/*
|
||||
* Decide on what work routines to call based on the inode size.
|
||||
*/
|
||||
|
||||
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
|
||||
rval = xfs_dir2_sf_addname(&args);
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isblock(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_block_addname(&args);
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v))) {
|
||||
else if ((rval = xfs_dir2_isleaf(tp, dp, &v)))
|
||||
return rval;
|
||||
} else if (v)
|
||||
else if (v)
|
||||
rval = xfs_dir2_leaf_addname(&args);
|
||||
else
|
||||
rval = xfs_dir2_node_addname(&args);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dummy routine for shortform inode validation.
|
||||
* Can't really do this.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int /* error */
|
||||
xfs_dir2_shortform_validate_ondisk(
|
||||
xfs_mount_t *mp, /* filesystem mount point */
|
||||
xfs_dinode_t *dip) /* ondisk inode */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility routines.
|
||||
*/
|
||||
@ -507,24 +439,24 @@ xfs_dir2_shortform_validate_ondisk(
|
||||
* This routine is for data and free blocks, not leaf/node blocks
|
||||
* which are handled by xfs_da_grow_inode.
|
||||
*/
|
||||
int /* error */
|
||||
int
|
||||
xfs_dir2_grow_inode(
|
||||
xfs_da_args_t *args, /* operation arguments */
|
||||
xfs_da_args_t *args,
|
||||
int space, /* v2 dir's space XFS_DIR2_xxx_SPACE */
|
||||
xfs_dir2_db_t *dbp) /* out: block number added */
|
||||
{
|
||||
xfs_fileoff_t bno; /* directory offset of new block */
|
||||
int count; /* count of filesystem blocks */
|
||||
xfs_inode_t *dp; /* incore directory inode */
|
||||
int error; /* error return value */
|
||||
int error;
|
||||
int got; /* blocks actually mapped */
|
||||
int i; /* temp mapping index */
|
||||
int i;
|
||||
xfs_bmbt_irec_t map; /* single structure for bmap */
|
||||
int mapi; /* mapping index */
|
||||
xfs_bmbt_irec_t *mapp; /* bmap mapping structure(s) */
|
||||
xfs_mount_t *mp; /* filesystem mount point */
|
||||
xfs_mount_t *mp;
|
||||
int nmap; /* number of bmap entries */
|
||||
xfs_trans_t *tp; /* transaction pointer */
|
||||
xfs_trans_t *tp;
|
||||
|
||||
xfs_dir2_trace_args_s("grow_inode", args, space);
|
||||
dp = args->dp;
|
||||
@ -538,9 +470,8 @@ xfs_dir2_grow_inode(
|
||||
/*
|
||||
* Find the first hole for our block.
|
||||
*/
|
||||
if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, XFS_DATA_FORK))) {
|
||||
if ((error = xfs_bmap_first_unused(tp, dp, count, &bno, XFS_DATA_FORK)))
|
||||
return error;
|
||||
}
|
||||
nmap = 1;
|
||||
ASSERT(args->firstblock != NULL);
|
||||
/*
|
||||
@ -549,13 +480,9 @@ xfs_dir2_grow_inode(
|
||||
if ((error = xfs_bmapi(tp, dp, bno, count,
|
||||
XFS_BMAPI_WRITE|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
|
||||
args->firstblock, args->total, &map, &nmap,
|
||||
args->flist, NULL))) {
|
||||
args->flist, NULL)))
|
||||
return error;
|
||||
}
|
||||
ASSERT(nmap <= 1);
|
||||
/*
|
||||
* Got it in 1.
|
||||
*/
|
||||
if (nmap == 1) {
|
||||
mapp = ↦
|
||||
mapi = 1;
|
||||
@ -646,20 +573,19 @@ xfs_dir2_grow_inode(
|
||||
/*
|
||||
* See if the directory is a single-block form directory.
|
||||
*/
|
||||
int /* error */
|
||||
int
|
||||
xfs_dir2_isblock(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
int *vp) /* out: 1 is block, 0 is not block */
|
||||
{
|
||||
xfs_fileoff_t last; /* last file offset */
|
||||
xfs_mount_t *mp; /* filesystem mount point */
|
||||
int rval; /* return value */
|
||||
xfs_mount_t *mp;
|
||||
int rval;
|
||||
|
||||
mp = dp->i_mount;
|
||||
if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK))) {
|
||||
if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK)))
|
||||
return rval;
|
||||
}
|
||||
rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize;
|
||||
ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize);
|
||||
*vp = rval;
|
||||
@ -669,20 +595,19 @@ xfs_dir2_isblock(
|
||||
/*
|
||||
* See if the directory is a single-leaf form directory.
|
||||
*/
|
||||
int /* error */
|
||||
int
|
||||
xfs_dir2_isleaf(
|
||||
xfs_trans_t *tp, /* transaction pointer */
|
||||
xfs_inode_t *dp, /* incore directory inode */
|
||||
xfs_trans_t *tp,
|
||||
xfs_inode_t *dp,
|
||||
int *vp) /* out: 1 is leaf, 0 is not leaf */
|
||||
{
|
||||
xfs_fileoff_t last; /* last file offset */
|
||||
xfs_mount_t *mp; /* filesystem mount point */
|
||||
int rval; /* return value */
|
||||
xfs_mount_t *mp;
|
||||
int rval;
|
||||
|
||||
mp = dp->i_mount;
|
||||
if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK))) {
|
||||
if ((rval = xfs_bmap_last_offset(tp, dp, &last, XFS_DATA_FORK)))
|
||||
return rval;
|
||||
}
|
||||
*vp = last == mp->m_dirleafblk + (1 << mp->m_sb.sb_dirblklog);
|
||||
return 0;
|
||||
}
|
||||
@ -690,9 +615,9 @@ xfs_dir2_isleaf(
|
||||
/*
|
||||
* Getdents put routine for 64-bit ABI, direct form.
|
||||
*/
|
||||
static int /* error */
|
||||
static int
|
||||
xfs_dir2_put_dirent64_direct(
|
||||
xfs_dir2_put_args_t *pa) /* argument bundle */
|
||||
xfs_dir2_put_args_t *pa)
|
||||
{
|
||||
xfs_dirent_t *idbp; /* dirent pointer */
|
||||
iovec_t *iovp; /* io vector */
|
||||
@ -727,9 +652,9 @@ xfs_dir2_put_dirent64_direct(
|
||||
/*
|
||||
* Getdents put routine for 64-bit ABI, uio form.
|
||||
*/
|
||||
static int /* error */
|
||||
static int
|
||||
xfs_dir2_put_dirent64_uio(
|
||||
xfs_dir2_put_args_t *pa) /* argument bundle */
|
||||
xfs_dir2_put_args_t *pa)
|
||||
{
|
||||
xfs_dirent_t *idbp; /* dirent pointer */
|
||||
int namelen; /* entry name length */
|
||||
@ -765,17 +690,17 @@ xfs_dir2_put_dirent64_uio(
|
||||
*/
|
||||
int
|
||||
xfs_dir2_shrink_inode(
|
||||
xfs_da_args_t *args, /* operation arguments */
|
||||
xfs_dir2_db_t db, /* directory block number */
|
||||
xfs_dabuf_t *bp) /* block's buffer */
|
||||
xfs_da_args_t *args,
|
||||
xfs_dir2_db_t db,
|
||||
xfs_dabuf_t *bp)
|
||||
{
|
||||
xfs_fileoff_t bno; /* directory file offset */
|
||||
xfs_dablk_t da; /* directory file offset */
|
||||
int done; /* bunmap is finished */
|
||||
xfs_inode_t *dp; /* incore directory inode */
|
||||
int error; /* error return value */
|
||||
xfs_mount_t *mp; /* filesystem mount point */
|
||||
xfs_trans_t *tp; /* transaction pointer */
|
||||
xfs_inode_t *dp;
|
||||
int error;
|
||||
xfs_mount_t *mp;
|
||||
xfs_trans_t *tp;
|
||||
|
||||
xfs_dir2_trace_args_db("shrink_inode", args, db, bp);
|
||||
dp = args->dp;
|
||||
|
@ -22,7 +22,9 @@ struct uio;
|
||||
struct xfs_dabuf;
|
||||
struct xfs_da_args;
|
||||
struct xfs_dir2_put_args;
|
||||
struct xfs_bmap_free;
|
||||
struct xfs_inode;
|
||||
struct xfs_mount;
|
||||
struct xfs_trans;
|
||||
|
||||
/*
|
||||
@ -73,7 +75,35 @@ typedef struct xfs_dir2_put_args {
|
||||
} xfs_dir2_put_args_t;
|
||||
|
||||
/*
|
||||
* Other interfaces used by the rest of the dir v2 code.
|
||||
* Generic directory interface routines
|
||||
*/
|
||||
extern void xfs_dir_startup(void);
|
||||
extern void xfs_dir_mount(struct xfs_mount *mp);
|
||||
extern int xfs_dir_isempty(struct xfs_inode *dp);
|
||||
extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
struct xfs_inode *pdp);
|
||||
extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
char *name, int namelen, xfs_ino_t inum,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist, xfs_extlen_t tot);
|
||||
extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
char *name, int namelen, xfs_ino_t *inum);
|
||||
extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
char *name, int namelen, xfs_ino_t ino,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist, xfs_extlen_t tot);
|
||||
extern int xfs_dir_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
uio_t *uio, int *eofp);
|
||||
extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
char *name, int namelen, xfs_ino_t inum,
|
||||
xfs_fsblock_t *first,
|
||||
struct xfs_bmap_free *flist, xfs_extlen_t tot);
|
||||
extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
|
||||
char *name, int namelen);
|
||||
extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
|
||||
|
||||
/*
|
||||
* Utility routines for v2 directories.
|
||||
*/
|
||||
extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
|
||||
xfs_dir2_db_t *dbp);
|
||||
|
@ -22,19 +22,16 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_inode_item.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
#include "xfs_dir2_block.h"
|
||||
@ -51,6 +48,18 @@ static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **bpp,
|
||||
int *entno);
|
||||
static int xfs_dir2_block_sort(const void *a, const void *b);
|
||||
|
||||
static xfs_dahash_t xfs_dir_hash_dot, xfs_dir_hash_dotdot;
|
||||
|
||||
/*
|
||||
* One-time startup routine called from xfs_init().
|
||||
*/
|
||||
void
|
||||
xfs_dir_startup(void)
|
||||
{
|
||||
xfs_dir_hash_dot = xfs_da_hashname(".", 1);
|
||||
xfs_dir_hash_dotdot = xfs_da_hashname("..", 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add an entry to a block directory.
|
||||
*/
|
||||
|
@ -22,18 +22,15 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
#include "xfs_dir2_block.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
|
@ -22,13 +22,11 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -22,19 +22,16 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_inode_item.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_error.h"
|
||||
#include "xfs_dir2_data.h"
|
||||
#include "xfs_dir2_leaf.h"
|
||||
|
@ -19,11 +19,9 @@
|
||||
#include "xfs_fs.h"
|
||||
#include "xfs_types.h"
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef __XFS_DIR_LEAF_H__
|
||||
#define __XFS_DIR_LEAF_H__
|
||||
|
||||
/*
|
||||
* Directory layout, internal structure, access macros, etc.
|
||||
*
|
||||
* Large directories are structured around Btrees where all the data
|
||||
* elements are in the leaf nodes. Filenames are hashed into an int,
|
||||
* then that int is used as the index into the Btree. Since the hashval
|
||||
* of a filename may not be unique, we may have duplicate keys. The
|
||||
* internal links in the Btree are logical block offsets into the file.
|
||||
*/
|
||||
|
||||
struct uio;
|
||||
struct xfs_bmap_free;
|
||||
struct xfs_dabuf;
|
||||
struct xfs_da_args;
|
||||
struct xfs_da_state;
|
||||
struct xfs_da_state_blk;
|
||||
struct xfs_dir_put_args;
|
||||
struct xfs_inode;
|
||||
struct xfs_mount;
|
||||
struct xfs_trans;
|
||||
|
||||
/*========================================================================
|
||||
* Directory Structure when equal to XFS_LBSIZE(mp) bytes.
|
||||
*========================================================================*/
|
||||
|
||||
/*
|
||||
* This is the structure of the leaf nodes in the Btree.
|
||||
*
|
||||
* Struct leaf_entry's are packed from the top. Names grow from the bottom
|
||||
* but are not packed. The freemap contains run-length-encoded entries
|
||||
* for the free bytes after the leaf_entry's, but only the N largest such,
|
||||
* smaller runs are dropped. When the freemap doesn't show enough space
|
||||
* for an allocation, we compact the namelist area and try again. If we
|
||||
* still don't have enough space, then we have to split the block.
|
||||
*
|
||||
* Since we have duplicate hash keys, for each key that matches, compare
|
||||
* the actual string. The root and intermediate node search always takes
|
||||
* the first-in-the-block key match found, so we should only have to work
|
||||
* "forw"ard. If none matches, continue with the "forw"ard leaf nodes
|
||||
* until the hash key changes or the filename is found.
|
||||
*
|
||||
* The parent directory and the self-pointer are explicitly represented
|
||||
* (ie: there are entries for "." and "..").
|
||||
*
|
||||
* Note that the count being a __uint16_t limits us to something like a
|
||||
* blocksize of 1.3MB in the face of worst case (short) filenames.
|
||||
*/
|
||||
#define XFS_DIR_LEAF_MAPSIZE 3 /* how many freespace slots */
|
||||
|
||||
typedef struct xfs_dir_leaf_map { /* RLE map of free bytes */
|
||||
__be16 base; /* base of free region */
|
||||
__be16 size; /* run length of free region */
|
||||
} xfs_dir_leaf_map_t;
|
||||
|
||||
typedef struct xfs_dir_leaf_hdr { /* constant-structure header block */
|
||||
xfs_da_blkinfo_t info; /* block type, links, etc. */
|
||||
__be16 count; /* count of active leaf_entry's */
|
||||
__be16 namebytes; /* num bytes of name strings stored */
|
||||
__be16 firstused; /* first used byte in name area */
|
||||
__u8 holes; /* != 0 if blk needs compaction */
|
||||
__u8 pad1;
|
||||
xfs_dir_leaf_map_t freemap[XFS_DIR_LEAF_MAPSIZE];
|
||||
} xfs_dir_leaf_hdr_t;
|
||||
|
||||
typedef struct xfs_dir_leaf_entry { /* sorted on key, not name */
|
||||
__be32 hashval; /* hash value of name */
|
||||
__be16 nameidx; /* index into buffer of name */
|
||||
__u8 namelen; /* length of name string */
|
||||
__u8 pad2;
|
||||
} xfs_dir_leaf_entry_t;
|
||||
|
||||
typedef struct xfs_dir_leaf_name {
|
||||
xfs_dir_ino_t inumber; /* inode number for this key */
|
||||
__uint8_t name[1]; /* name string itself */
|
||||
} xfs_dir_leaf_name_t;
|
||||
|
||||
typedef struct xfs_dir_leafblock {
|
||||
xfs_dir_leaf_hdr_t hdr; /* constant-structure header block */
|
||||
xfs_dir_leaf_entry_t entries[1]; /* var sized array */
|
||||
xfs_dir_leaf_name_t namelist[1]; /* grows from bottom of buf */
|
||||
} xfs_dir_leafblock_t;
|
||||
|
||||
/*
|
||||
* Length of name for which a 512-byte block filesystem
|
||||
* can get a double split.
|
||||
*/
|
||||
#define XFS_DIR_LEAF_CAN_DOUBLE_SPLIT_LEN \
|
||||
(512 - (uint)sizeof(xfs_dir_leaf_hdr_t) - \
|
||||
(uint)sizeof(xfs_dir_leaf_entry_t) * 2 - \
|
||||
(uint)sizeof(xfs_dir_leaf_name_t) * 2 - (MAXNAMELEN - 2) + 1 + 1)
|
||||
|
||||
typedef int (*xfs_dir_put_t)(struct xfs_dir_put_args *pa);
|
||||
|
||||
typedef union {
|
||||
xfs_off_t o; /* offset (cookie) */
|
||||
/*
|
||||
* Watch the order here (endian-ness dependent).
|
||||
*/
|
||||
struct {
|
||||
#ifndef XFS_NATIVE_HOST
|
||||
xfs_dahash_t h; /* hash value */
|
||||
__uint32_t be; /* block and entry */
|
||||
#else
|
||||
__uint32_t be; /* block and entry */
|
||||
xfs_dahash_t h; /* hash value */
|
||||
#endif /* XFS_NATIVE_HOST */
|
||||
} s;
|
||||
} xfs_dircook_t;
|
||||
|
||||
#define XFS_PUT_COOKIE(c,mp,bno,entry,hash) \
|
||||
((c).s.be = XFS_DA_MAKE_BNOENTRY(mp, bno, entry), (c).s.h = (hash))
|
||||
|
||||
typedef struct xfs_dir_put_args {
|
||||
xfs_dircook_t cook; /* cookie of (next) entry */
|
||||
xfs_intino_t ino; /* inode number */
|
||||
struct xfs_dirent *dbp; /* buffer pointer */
|
||||
char *name; /* directory entry name */
|
||||
int namelen; /* length of name */
|
||||
int done; /* output: set if value was stored */
|
||||
xfs_dir_put_t put; /* put function ptr (i/o) */
|
||||
struct uio *uio; /* uio control structure */
|
||||
} xfs_dir_put_args_t;
|
||||
|
||||
#define XFS_DIR_LEAF_ENTSIZE_BYNAME(len) \
|
||||
xfs_dir_leaf_entsize_byname(len)
|
||||
static inline int xfs_dir_leaf_entsize_byname(int len)
|
||||
{
|
||||
return (uint)sizeof(xfs_dir_leaf_name_t)-1 + len;
|
||||
}
|
||||
|
||||
#define XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry) \
|
||||
xfs_dir_leaf_entsize_byentry(entry)
|
||||
static inline int xfs_dir_leaf_entsize_byentry(xfs_dir_leaf_entry_t *entry)
|
||||
{
|
||||
return (uint)sizeof(xfs_dir_leaf_name_t)-1 + (entry)->namelen;
|
||||
}
|
||||
|
||||
#define XFS_DIR_LEAF_NAMESTRUCT(leafp,offset) \
|
||||
xfs_dir_leaf_namestruct(leafp,offset)
|
||||
static inline xfs_dir_leaf_name_t *
|
||||
xfs_dir_leaf_namestruct(xfs_dir_leafblock_t *leafp, int offset)
|
||||
{
|
||||
return (xfs_dir_leaf_name_t *)&((char *)(leafp))[offset];
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
* Function prototypes for the kernel.
|
||||
*========================================================================*/
|
||||
|
||||
/*
|
||||
* Internal routines when dirsize < XFS_LITINO(mp).
|
||||
*/
|
||||
int xfs_dir_shortform_create(struct xfs_da_args *args, xfs_ino_t parent);
|
||||
int xfs_dir_shortform_addname(struct xfs_da_args *args);
|
||||
int xfs_dir_shortform_lookup(struct xfs_da_args *args);
|
||||
int xfs_dir_shortform_to_leaf(struct xfs_da_args *args);
|
||||
int xfs_dir_shortform_removename(struct xfs_da_args *args);
|
||||
int xfs_dir_shortform_getdents(struct xfs_inode *dp, struct uio *uio, int *eofp,
|
||||
struct xfs_dirent *dbp, xfs_dir_put_t put);
|
||||
int xfs_dir_shortform_replace(struct xfs_da_args *args);
|
||||
|
||||
/*
|
||||
* Internal routines when dirsize == XFS_LBSIZE(mp).
|
||||
*/
|
||||
int xfs_dir_leaf_to_node(struct xfs_da_args *args);
|
||||
int xfs_dir_leaf_to_shortform(struct xfs_da_args *args);
|
||||
|
||||
/*
|
||||
* Routines used for growing the Btree.
|
||||
*/
|
||||
int xfs_dir_leaf_split(struct xfs_da_state *state,
|
||||
struct xfs_da_state_blk *oldblk,
|
||||
struct xfs_da_state_blk *newblk);
|
||||
int xfs_dir_leaf_add(struct xfs_dabuf *leaf_buffer,
|
||||
struct xfs_da_args *args, int insertion_index);
|
||||
int xfs_dir_leaf_addname(struct xfs_da_args *args);
|
||||
int xfs_dir_leaf_lookup_int(struct xfs_dabuf *leaf_buffer,
|
||||
struct xfs_da_args *args,
|
||||
int *index_found_at);
|
||||
int xfs_dir_leaf_remove(struct xfs_trans *trans,
|
||||
struct xfs_dabuf *leaf_buffer,
|
||||
int index_to_remove);
|
||||
int xfs_dir_leaf_getdents_int(struct xfs_dabuf *bp, struct xfs_inode *dp,
|
||||
xfs_dablk_t bno, struct uio *uio,
|
||||
int *eobp, struct xfs_dirent *dbp,
|
||||
xfs_dir_put_t put, xfs_daddr_t nextda);
|
||||
|
||||
/*
|
||||
* Routines used for shrinking the Btree.
|
||||
*/
|
||||
int xfs_dir_leaf_toosmall(struct xfs_da_state *state, int *retval);
|
||||
void xfs_dir_leaf_unbalance(struct xfs_da_state *state,
|
||||
struct xfs_da_state_blk *drop_blk,
|
||||
struct xfs_da_state_blk *save_blk);
|
||||
|
||||
/*
|
||||
* Utility routines.
|
||||
*/
|
||||
uint xfs_dir_leaf_lasthash(struct xfs_dabuf *bp, int *count);
|
||||
int xfs_dir_leaf_order(struct xfs_dabuf *leaf1_bp,
|
||||
struct xfs_dabuf *leaf2_bp);
|
||||
int xfs_dir_put_dirent64_direct(xfs_dir_put_args_t *pa);
|
||||
int xfs_dir_put_dirent64_uio(xfs_dir_put_args_t *pa);
|
||||
int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
|
||||
|
||||
/*
|
||||
* Global data.
|
||||
*/
|
||||
extern xfs_dahash_t xfs_dir_hash_dot, xfs_dir_hash_dotdot;
|
||||
|
||||
#endif /* __XFS_DIR_LEAF_H__ */
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000,2005 Silicon Graphics, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef __XFS_DIR_SF_H__
|
||||
#define __XFS_DIR_SF_H__
|
||||
|
||||
/*
|
||||
* Directory layout when stored internal to an inode.
|
||||
*
|
||||
* Small directories are packed as tightly as possible so as to
|
||||
* fit into the literal area of the inode.
|
||||
*/
|
||||
|
||||
typedef struct { __uint8_t i[sizeof(xfs_ino_t)]; } xfs_dir_ino_t;
|
||||
|
||||
/*
|
||||
* The parent directory has a dedicated field, and the self-pointer must
|
||||
* be calculated on the fly.
|
||||
*
|
||||
* Entries are packed toward the top as tight as possible. The header
|
||||
* and the elements much be memcpy'd out into a work area to get correct
|
||||
* alignment for the inode number fields.
|
||||
*/
|
||||
typedef struct xfs_dir_sf_hdr { /* constant-structure header block */
|
||||
xfs_dir_ino_t parent; /* parent dir inode number */
|
||||
__uint8_t count; /* count of active entries */
|
||||
} xfs_dir_sf_hdr_t;
|
||||
|
||||
typedef struct xfs_dir_sf_entry {
|
||||
xfs_dir_ino_t inumber; /* referenced inode number */
|
||||
__uint8_t namelen; /* actual length of name (no NULL) */
|
||||
__uint8_t name[1]; /* name */
|
||||
} xfs_dir_sf_entry_t;
|
||||
|
||||
typedef struct xfs_dir_shortform {
|
||||
xfs_dir_sf_hdr_t hdr;
|
||||
xfs_dir_sf_entry_t list[1]; /* variable sized array */
|
||||
} xfs_dir_shortform_t;
|
||||
|
||||
/*
|
||||
* We generate this then sort it, so that readdirs are returned in
|
||||
* hash-order. Else seekdir won't work.
|
||||
*/
|
||||
typedef struct xfs_dir_sf_sort {
|
||||
__uint8_t entno; /* .=0, ..=1, else entry# + 2 */
|
||||
__uint8_t seqno; /* sequence # with same hash value */
|
||||
__uint8_t namelen; /* length of name value (no null) */
|
||||
xfs_dahash_t hash; /* this entry's hash value */
|
||||
xfs_intino_t ino; /* this entry's inode number */
|
||||
char *name; /* name value, pointer into buffer */
|
||||
} xfs_dir_sf_sort_t;
|
||||
|
||||
#define XFS_DIR_SF_GET_DIRINO(from,to) xfs_dir_sf_get_dirino(from, to)
|
||||
static inline void xfs_dir_sf_get_dirino(xfs_dir_ino_t *from, xfs_ino_t *to)
|
||||
{
|
||||
*(to) = XFS_GET_DIR_INO8(*from);
|
||||
}
|
||||
|
||||
#define XFS_DIR_SF_PUT_DIRINO(from,to) xfs_dir_sf_put_dirino(from, to)
|
||||
static inline void xfs_dir_sf_put_dirino(xfs_ino_t *from, xfs_dir_ino_t *to)
|
||||
{
|
||||
XFS_PUT_DIR_INO8(*(from), *(to));
|
||||
}
|
||||
|
||||
#define XFS_DIR_SF_ENTSIZE_BYNAME(len) xfs_dir_sf_entsize_byname(len)
|
||||
static inline int xfs_dir_sf_entsize_byname(int len)
|
||||
{
|
||||
return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (len);
|
||||
}
|
||||
|
||||
#define XFS_DIR_SF_ENTSIZE_BYENTRY(sfep) xfs_dir_sf_entsize_byentry(sfep)
|
||||
static inline int xfs_dir_sf_entsize_byentry(xfs_dir_sf_entry_t *sfep)
|
||||
{
|
||||
return (uint)sizeof(xfs_dir_sf_entry_t)-1 + (sfep)->namelen;
|
||||
}
|
||||
|
||||
#define XFS_DIR_SF_NEXTENTRY(sfep) xfs_dir_sf_nextentry(sfep)
|
||||
static inline xfs_dir_sf_entry_t *xfs_dir_sf_nextentry(xfs_dir_sf_entry_t *sfep)
|
||||
{
|
||||
return (xfs_dir_sf_entry_t *) \
|
||||
((char *)(sfep) + XFS_DIR_SF_ENTSIZE_BYENTRY(sfep));
|
||||
}
|
||||
|
||||
#define XFS_DIR_SF_ALLFIT(count,totallen) \
|
||||
xfs_dir_sf_allfit(count,totallen)
|
||||
static inline int xfs_dir_sf_allfit(int count, int totallen)
|
||||
{
|
||||
return ((uint)sizeof(xfs_dir_sf_hdr_t) + \
|
||||
((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen));
|
||||
}
|
||||
|
||||
#if defined(XFS_DIR_TRACE)
|
||||
|
||||
/*
|
||||
* Kernel tracing support for directories.
|
||||
*/
|
||||
struct uio;
|
||||
struct xfs_inode;
|
||||
struct xfs_da_intnode;
|
||||
struct xfs_dinode;
|
||||
struct xfs_dir_leafblock;
|
||||
struct xfs_dir_leaf_entry;
|
||||
|
||||
#define XFS_DIR_TRACE_SIZE 4096 /* size of global trace buffer */
|
||||
extern ktrace_t *xfs_dir_trace_buf;
|
||||
|
||||
/*
|
||||
* Trace record types.
|
||||
*/
|
||||
#define XFS_DIR_KTRACE_G_DU 1 /* dp, uio */
|
||||
#define XFS_DIR_KTRACE_G_DUB 2 /* dp, uio, bno */
|
||||
#define XFS_DIR_KTRACE_G_DUN 3 /* dp, uio, node */
|
||||
#define XFS_DIR_KTRACE_G_DUL 4 /* dp, uio, leaf */
|
||||
#define XFS_DIR_KTRACE_G_DUE 5 /* dp, uio, leaf entry */
|
||||
#define XFS_DIR_KTRACE_G_DUC 6 /* dp, uio, cookie */
|
||||
|
||||
void xfs_dir_trace_g_du(char *where, struct xfs_inode *dp, struct uio *uio);
|
||||
void xfs_dir_trace_g_dub(char *where, struct xfs_inode *dp, struct uio *uio,
|
||||
xfs_dablk_t bno);
|
||||
void xfs_dir_trace_g_dun(char *where, struct xfs_inode *dp, struct uio *uio,
|
||||
struct xfs_da_intnode *node);
|
||||
void xfs_dir_trace_g_dul(char *where, struct xfs_inode *dp, struct uio *uio,
|
||||
struct xfs_dir_leafblock *leaf);
|
||||
void xfs_dir_trace_g_due(char *where, struct xfs_inode *dp, struct uio *uio,
|
||||
struct xfs_dir_leaf_entry *entry);
|
||||
void xfs_dir_trace_g_duc(char *where, struct xfs_inode *dp, struct uio *uio,
|
||||
xfs_off_t cookie);
|
||||
void xfs_dir_trace_enter(int type, char *where,
|
||||
void *a0, void *a1, void *a2, void *a3,
|
||||
void *a4, void *a5, void *a6, void *a7,
|
||||
void *a8, void *a9, void *a10, void *a11);
|
||||
#else
|
||||
#define xfs_dir_trace_g_du(w,d,u)
|
||||
#define xfs_dir_trace_g_dub(w,d,u,b)
|
||||
#define xfs_dir_trace_g_dun(w,d,u,n)
|
||||
#define xfs_dir_trace_g_dul(w,d,u,l)
|
||||
#define xfs_dir_trace_g_due(w,d,u,e)
|
||||
#define xfs_dir_trace_g_duc(w,d,u,c)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#endif /* __XFS_DIR_SF_H__ */
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
|
@ -22,12 +22,10 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_buf_item.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_trans_priv.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -26,14 +26,12 @@
|
||||
#include "xfs_trans_priv.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -2925,13 +2923,6 @@ xfs_iflush_fork(
|
||||
ASSERT(ifp->if_bytes <= XFS_IFORK_SIZE(ip, whichfork));
|
||||
memcpy(cp, ifp->if_u1.if_data, ifp->if_bytes);
|
||||
}
|
||||
if (whichfork == XFS_DATA_FORK) {
|
||||
if (unlikely(XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp, dip))) {
|
||||
XFS_ERROR_REPORT("xfs_iflush_fork",
|
||||
XFS_ERRLEVEL_LOW, mp);
|
||||
return XFS_ERROR(EFSCORRUPTED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case XFS_DINODE_FMT_EXTENTS:
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "xfs_buf_item.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -33,7 +32,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dfrag.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_alloc.h"
|
||||
#include "xfs_dmapi.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -36,7 +35,6 @@
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_log_recover.h"
|
||||
#include "xfs_trans_priv.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -934,18 +932,7 @@ xfs_mountfs(
|
||||
vfsp->vfs_altfsid = (xfs_fsid_t *)mp->m_fixedfsid;
|
||||
mp->m_dmevmask = 0; /* not persistent; set after each mount */
|
||||
|
||||
/*
|
||||
* Select the right directory manager.
|
||||
*/
|
||||
mp->m_dirops =
|
||||
XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ?
|
||||
xfsv2_dirops :
|
||||
xfsv1_dirops;
|
||||
|
||||
/*
|
||||
* Initialize directory manager's entries.
|
||||
*/
|
||||
XFS_DIR_MOUNT(mp);
|
||||
xfs_dir_mount(mp);
|
||||
|
||||
/*
|
||||
* Initialize the attribute manager's entries.
|
||||
|
@ -403,8 +403,6 @@ typedef struct xfs_mount {
|
||||
__uint8_t m_inode_quiesce;/* call quiesce on new inodes.
|
||||
field governed by m_ilock */
|
||||
__uint8_t m_sectbb_log; /* sectlog - BBSHIFT */
|
||||
__uint8_t m_dirversion; /* 1 or 2 */
|
||||
xfs_dirops_t m_dirops; /* table of dir funcs */
|
||||
int m_dirblksize; /* directory block sz--bytes */
|
||||
int m_dirblkfsbs; /* directory block sz--fsbs */
|
||||
xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
|
@ -22,13 +22,11 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_da_btree.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -40,7 +38,6 @@
|
||||
#include "xfs_refcache.h"
|
||||
#include "xfs_utils.h"
|
||||
#include "xfs_trans_space.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -398,34 +395,29 @@ xfs_rename(
|
||||
* fit before actually inserting it.
|
||||
*/
|
||||
if (spaceres == 0 &&
|
||||
(error = XFS_DIR_CANENTER(mp, tp, target_dp, target_name,
|
||||
target_namelen))) {
|
||||
(error = xfs_dir_canenter(tp, target_dp, target_name,
|
||||
target_namelen)))
|
||||
goto error_return;
|
||||
}
|
||||
/*
|
||||
* If target does not exist and the rename crosses
|
||||
* directories, adjust the target directory link count
|
||||
* to account for the ".." reference from the new entry.
|
||||
*/
|
||||
error = XFS_DIR_CREATENAME(mp, tp, target_dp, target_name,
|
||||
error = xfs_dir_createname(tp, target_dp, target_name,
|
||||
target_namelen, src_ip->i_ino,
|
||||
&first_block, &free_list, spaceres);
|
||||
if (error == ENOSPC) {
|
||||
if (error == ENOSPC)
|
||||
goto error_return;
|
||||
}
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
|
||||
if (new_parent && src_is_directory) {
|
||||
error = xfs_bumplink(tp, target_dp);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
}
|
||||
} else { /* target_ip != NULL */
|
||||
|
||||
/*
|
||||
* If target exists and it's a directory, check that both
|
||||
* target and source are directories and that target can be
|
||||
@ -435,7 +427,7 @@ xfs_rename(
|
||||
/*
|
||||
* Make sure target dir is empty.
|
||||
*/
|
||||
if (!(XFS_DIR_ISEMPTY(target_ip->i_mount, target_ip)) ||
|
||||
if (!(xfs_dir_isempty(target_ip)) ||
|
||||
(target_ip->i_d.di_nlink > 2)) {
|
||||
error = XFS_ERROR(EEXIST);
|
||||
goto error_return;
|
||||
@ -451,12 +443,11 @@ xfs_rename(
|
||||
* In case there is already an entry with the same
|
||||
* name at the destination directory, remove it first.
|
||||
*/
|
||||
error = XFS_DIR_REPLACE(mp, tp, target_dp, target_name,
|
||||
target_namelen, src_ip->i_ino, &first_block,
|
||||
&free_list, spaceres);
|
||||
if (error) {
|
||||
error = xfs_dir_replace(tp, target_dp, target_name,
|
||||
target_namelen, src_ip->i_ino,
|
||||
&first_block, &free_list, spaceres);
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
|
||||
/*
|
||||
@ -464,9 +455,8 @@ xfs_rename(
|
||||
* dir no longer points to it.
|
||||
*/
|
||||
error = xfs_droplink(tp, target_ip);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
target_ip_dropped = 1;
|
||||
|
||||
if (src_is_directory) {
|
||||
@ -474,9 +464,8 @@ xfs_rename(
|
||||
* Drop the link from the old "." entry.
|
||||
*/
|
||||
error = xfs_droplink(tp, target_ip);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do this test while we still hold the locks */
|
||||
@ -488,18 +477,15 @@ xfs_rename(
|
||||
* Remove the source.
|
||||
*/
|
||||
if (new_parent && src_is_directory) {
|
||||
|
||||
/*
|
||||
* Rewrite the ".." entry to point to the new
|
||||
* directory.
|
||||
*/
|
||||
error = XFS_DIR_REPLACE(mp, tp, src_ip, "..", 2,
|
||||
target_dp->i_ino, &first_block,
|
||||
&free_list, spaceres);
|
||||
error = xfs_dir_replace(tp, src_ip, "..", 2, target_dp->i_ino,
|
||||
&first_block, &free_list, spaceres);
|
||||
ASSERT(error != EEXIST);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
|
||||
} else {
|
||||
@ -527,16 +513,14 @@ xfs_rename(
|
||||
* entry that's moved no longer points to it.
|
||||
*/
|
||||
error = xfs_droplink(tp, src_dp);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
}
|
||||
|
||||
error = XFS_DIR_REMOVENAME(mp, tp, src_dp, src_name, src_namelen,
|
||||
error = xfs_dir_removename(tp, src_dp, src_name, src_namelen,
|
||||
src_ip->i_ino, &first_block, &free_list, spaceres);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto abort_return;
|
||||
}
|
||||
xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
|
||||
/*
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -33,7 +32,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -805,12 +805,9 @@ typedef struct xfs_trans {
|
||||
((mp)->m_sb.sb_inodesize + \
|
||||
(mp)->m_sb.sb_sectsize * 2 + \
|
||||
(mp)->m_dirblksize + \
|
||||
(XFS_DIR_IS_V1(mp) ? 0 : \
|
||||
XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1))) + \
|
||||
XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1)) + \
|
||||
XFS_ALLOCFREE_LOG_RES(mp, 1) + \
|
||||
(128 * (4 + \
|
||||
(XFS_DIR_IS_V1(mp) ? 0 : \
|
||||
XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \
|
||||
(128 * (4 + (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \
|
||||
XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
|
||||
|
||||
#define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork)
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_trans_priv.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "xfs_inum.h"
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_trans_priv.h"
|
||||
|
@ -24,14 +24,12 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
|
@ -30,8 +30,7 @@
|
||||
XFS_EXTENTADD_SPACE_RES(mp,w))
|
||||
#define XFS_DAENTER_1B(mp,w) ((w) == XFS_DATA_FORK ? (mp)->m_dirblkfsbs : 1)
|
||||
#define XFS_DAENTER_DBS(mp,w) \
|
||||
(XFS_DA_NODE_MAXDEPTH + \
|
||||
((XFS_DIR_IS_V2(mp) && (w) == XFS_DATA_FORK) ? 2 : 0))
|
||||
(XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
|
||||
#define XFS_DAENTER_BLOCKS(mp,w) \
|
||||
(XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
|
||||
#define XFS_DAENTER_BMAP1B(mp,w) \
|
||||
@ -41,10 +40,7 @@
|
||||
#define XFS_DAENTER_SPACE_RES(mp,w) \
|
||||
(XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w))
|
||||
#define XFS_DAREMOVE_SPACE_RES(mp,w) XFS_DAENTER_BMAPS(mp,w)
|
||||
#define XFS_DIRENTER_MAX_SPLIT(mp,nl) \
|
||||
(((mp)->m_sb.sb_blocksize == 512 && \
|
||||
XFS_DIR_IS_V1(mp) && \
|
||||
(nl) >= XFS_DIR_LEAF_CAN_DOUBLE_SPLIT_LEN) ? 2 : 1)
|
||||
#define XFS_DIRENTER_MAX_SPLIT(mp,nl) 1
|
||||
#define XFS_DIRENTER_SPACE_RES(mp,nl) \
|
||||
(XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
|
||||
XFS_DIRENTER_MAX_SPLIT(mp,nl))
|
||||
@ -57,8 +53,7 @@
|
||||
* Space reservation values for various transactions.
|
||||
*/
|
||||
#define XFS_ADDAFORK_SPACE_RES(mp) \
|
||||
((mp)->m_dirblkfsbs + \
|
||||
(XFS_DIR_IS_V1(mp) ? 0 : XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK)))
|
||||
((mp)->m_dirblkfsbs + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK))
|
||||
#define XFS_ATTRRM_SPACE_RES(mp) \
|
||||
XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
|
||||
/* This macro is not used - see inline code in xfs_attr_set */
|
||||
|
@ -24,12 +24,10 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -82,8 +80,7 @@ xfs_dir_lookup_int(
|
||||
|
||||
dp = XFS_BHVTOI(dir_bdp);
|
||||
|
||||
error = XFS_DIR_LOOKUP(dp->i_mount, NULL, dp,
|
||||
VNAME(dentry), VNAMELEN(dentry), inum);
|
||||
error = xfs_dir_lookup(NULL, dp, VNAME(dentry), VNAMELEN(dentry), inum);
|
||||
if (!error) {
|
||||
/*
|
||||
* Unlock the directory. We do this because we can't
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -32,7 +31,6 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
@ -131,9 +129,6 @@ xfs_init(void)
|
||||
#ifdef XFS_BMBT_TRACE
|
||||
xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_SLEEP);
|
||||
#endif
|
||||
#ifdef XFS_DIR_TRACE
|
||||
xfs_dir_trace_buf = ktrace_alloc(XFS_DIR_TRACE_SIZE, KM_SLEEP);
|
||||
#endif
|
||||
#ifdef XFS_ATTR_TRACE
|
||||
xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_SLEEP);
|
||||
#endif
|
||||
@ -177,9 +172,6 @@ xfs_cleanup(void)
|
||||
#ifdef XFS_ATTR_TRACE
|
||||
ktrace_free(xfs_attr_trace_buf);
|
||||
#endif
|
||||
#ifdef XFS_DIR_TRACE
|
||||
ktrace_free(xfs_dir_trace_buf);
|
||||
#endif
|
||||
#ifdef XFS_BMBT_TRACE
|
||||
ktrace_free(xfs_bmbt_trace_buf);
|
||||
#endif
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "xfs_trans.h"
|
||||
#include "xfs_sb.h"
|
||||
#include "xfs_ag.h"
|
||||
#include "xfs_dir.h"
|
||||
#include "xfs_dir2.h"
|
||||
#include "xfs_dmapi.h"
|
||||
#include "xfs_mount.h"
|
||||
@ -33,13 +32,11 @@
|
||||
#include "xfs_bmap_btree.h"
|
||||
#include "xfs_alloc_btree.h"
|
||||
#include "xfs_ialloc_btree.h"
|
||||
#include "xfs_dir_sf.h"
|
||||
#include "xfs_dir2_sf.h"
|
||||
#include "xfs_attr_sf.h"
|
||||
#include "xfs_dinode.h"
|
||||
#include "xfs_inode.h"
|
||||
#include "xfs_inode_item.h"
|
||||
#include "xfs_dir_leaf.h"
|
||||
#include "xfs_itable.h"
|
||||
#include "xfs_btree.h"
|
||||
#include "xfs_ialloc.h"
|
||||
@ -1958,8 +1955,7 @@ xfs_create(
|
||||
if (error)
|
||||
goto error_return;
|
||||
|
||||
if (resblks == 0 &&
|
||||
(error = XFS_DIR_CANENTER(mp, tp, dp, name, namelen)))
|
||||
if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name, namelen)))
|
||||
goto error_return;
|
||||
rdev = (vap->va_mask & XFS_AT_RDEV) ? vap->va_rdev : 0;
|
||||
error = xfs_dir_ialloc(&tp, dp, vap->va_mode, 1,
|
||||
@ -1990,9 +1986,9 @@ xfs_create(
|
||||
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
|
||||
dp_joined_to_trans = B_TRUE;
|
||||
|
||||
error = XFS_DIR_CREATENAME(mp, tp, dp, name, namelen, ip->i_ino,
|
||||
&first_block, &free_list,
|
||||
resblks ? resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
|
||||
error = xfs_dir_createname(tp, dp, name, namelen, ip->i_ino,
|
||||
&first_block, &free_list, resblks ?
|
||||
resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
|
||||
if (error) {
|
||||
ASSERT(error != ENOSPC);
|
||||
goto abort_return;
|
||||
@ -2468,8 +2464,8 @@ xfs_remove(
|
||||
* Entry must exist since we did a lookup in xfs_lock_dir_and_entry.
|
||||
*/
|
||||
XFS_BMAP_INIT(&free_list, &first_block);
|
||||
error = XFS_DIR_REMOVENAME(mp, tp, dp, name, namelen, ip->i_ino,
|
||||
&first_block, &free_list, 0);
|
||||
error = xfs_dir_removename(tp, dp, name, namelen, ip->i_ino,
|
||||
&first_block, &free_list, 0);
|
||||
if (error) {
|
||||
ASSERT(error != ENOENT);
|
||||
REMOVE_DEBUG_TRACE(__LINE__);
|
||||
@ -2688,13 +2684,12 @@ xfs_link(
|
||||
}
|
||||
|
||||
if (resblks == 0 &&
|
||||
(error = XFS_DIR_CANENTER(mp, tp, tdp, target_name,
|
||||
target_namelen)))
|
||||
(error = xfs_dir_canenter(tp, tdp, target_name, target_namelen)))
|
||||
goto error_return;
|
||||
|
||||
XFS_BMAP_INIT(&free_list, &first_block);
|
||||
|
||||
error = XFS_DIR_CREATENAME(mp, tp, tdp, target_name, target_namelen,
|
||||
error = xfs_dir_createname(tp, tdp, target_name, target_namelen,
|
||||
sip->i_ino, &first_block, &free_list,
|
||||
resblks);
|
||||
if (error)
|
||||
@ -2860,7 +2855,7 @@ xfs_mkdir(
|
||||
goto error_return;
|
||||
|
||||
if (resblks == 0 &&
|
||||
(error = XFS_DIR_CANENTER(mp, tp, dp, dir_name, dir_namelen)))
|
||||
(error = xfs_dir_canenter(tp, dp, dir_name, dir_namelen)))
|
||||
goto error_return;
|
||||
/*
|
||||
* create the directory inode.
|
||||
@ -2887,9 +2882,9 @@ xfs_mkdir(
|
||||
|
||||
XFS_BMAP_INIT(&free_list, &first_block);
|
||||
|
||||
error = XFS_DIR_CREATENAME(mp, tp, dp, dir_name, dir_namelen,
|
||||
cdp->i_ino, &first_block, &free_list,
|
||||
resblks ? resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
|
||||
error = xfs_dir_createname(tp, dp, dir_name, dir_namelen, cdp->i_ino,
|
||||
&first_block, &free_list, resblks ?
|
||||
resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
|
||||
if (error) {
|
||||
ASSERT(error != ENOSPC);
|
||||
goto error1;
|
||||
@ -2903,16 +2898,14 @@ xfs_mkdir(
|
||||
*/
|
||||
dp->i_gen++;
|
||||
|
||||
error = XFS_DIR_INIT(mp, tp, cdp, dp);
|
||||
if (error) {
|
||||
error = xfs_dir_init(tp, cdp, dp);
|
||||
if (error)
|
||||
goto error2;
|
||||
}
|
||||
|
||||
cdp->i_gen = 1;
|
||||
error = xfs_bumplink(tp, dp);
|
||||
if (error) {
|
||||
if (error)
|
||||
goto error2;
|
||||
}
|
||||
|
||||
cvp = XFS_ITOV(cdp);
|
||||
|
||||
@ -3121,16 +3114,15 @@ xfs_rmdir(
|
||||
error = XFS_ERROR(ENOTEMPTY);
|
||||
goto error_return;
|
||||
}
|
||||
if (!XFS_DIR_ISEMPTY(mp, cdp)) {
|
||||
if (!xfs_dir_isempty(cdp)) {
|
||||
error = XFS_ERROR(ENOTEMPTY);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
error = XFS_DIR_REMOVENAME(mp, tp, dp, name, namelen, cdp->i_ino,
|
||||
&first_block, &free_list, resblks);
|
||||
if (error) {
|
||||
error = xfs_dir_removename(tp, dp, name, namelen, cdp->i_ino,
|
||||
&first_block, &free_list, resblks);
|
||||
if (error)
|
||||
goto error1;
|
||||
}
|
||||
|
||||
xfs_ichgtime(dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
|
||||
@ -3229,8 +3221,6 @@ xfs_rmdir(
|
||||
|
||||
|
||||
/*
|
||||
* xfs_readdir
|
||||
*
|
||||
* Read dp's entries starting at uiop->uio_offset and translate them into
|
||||
* bufsize bytes worth of struct dirents starting at bufbase.
|
||||
*/
|
||||
@ -3250,21 +3240,16 @@ xfs_readdir(
|
||||
(inst_t *)__return_address);
|
||||
dp = XFS_BHVTOI(dir_bdp);
|
||||
|
||||
if (XFS_FORCED_SHUTDOWN(dp->i_mount)) {
|
||||
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
|
||||
return XFS_ERROR(EIO);
|
||||
}
|
||||
|
||||
lock_mode = xfs_ilock_map_shared(dp);
|
||||
error = XFS_DIR_GETDENTS(dp->i_mount, tp, dp, uiop, eofp);
|
||||
error = xfs_dir_getdents(tp, dp, uiop, eofp);
|
||||
xfs_iunlock_map_shared(dp, lock_mode);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* xfs_symlink
|
||||
*
|
||||
*/
|
||||
STATIC int
|
||||
xfs_symlink(
|
||||
bhv_desc_t *dir_bdp,
|
||||
@ -3328,7 +3313,7 @@ xfs_symlink(
|
||||
int len, total;
|
||||
char *path;
|
||||
|
||||
for(total = 0, path = target_path; total < pathlen;) {
|
||||
for (total = 0, path = target_path; total < pathlen;) {
|
||||
/*
|
||||
* Skip any slashes.
|
||||
*/
|
||||
@ -3422,7 +3407,7 @@ xfs_symlink(
|
||||
* Check for ability to enter directory entry, if no space reserved.
|
||||
*/
|
||||
if (resblks == 0 &&
|
||||
(error = XFS_DIR_CANENTER(mp, tp, dp, link_name, link_namelen)))
|
||||
(error = xfs_dir_canenter(tp, dp, link_name, link_namelen)))
|
||||
goto error_return;
|
||||
/*
|
||||
* Initialize the bmap freelist prior to calling either
|
||||
@ -3509,11 +3494,10 @@ xfs_symlink(
|
||||
/*
|
||||
* Create the directory entry for the symlink.
|
||||
*/
|
||||
error = XFS_DIR_CREATENAME(mp, tp, dp, link_name, link_namelen,
|
||||
ip->i_ino, &first_block, &free_list, resblks);
|
||||
if (error) {
|
||||
error = xfs_dir_createname(tp, dp, link_name, link_namelen, ip->i_ino,
|
||||
&first_block, &free_list, resblks);
|
||||
if (error)
|
||||
goto error1;
|
||||
}
|
||||
xfs_ichgtime(dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
|
||||
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user