Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12190
b: refs/heads/master
c: aa82daa
h: refs/heads/master
v: v3
  • Loading branch information
Nathan Scott committed Nov 1, 2005
1 parent 73d1d9f commit acb9db7
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 100 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e8c8b3a79d85c22d3665b97dde843dc4d8d7ae37
refs/heads/master: aa82daa06198b27963fe3d6ee8035855b29f6524
117 changes: 64 additions & 53 deletions trunk/fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* 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 version 2 of the GNU General Public License as
Expand Down Expand Up @@ -200,40 +200,18 @@ xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp,
return(error);
}

/*ARGSUSED*/
int /* error */
xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
struct cred *cred)
int
xfs_attr_set_int(xfs_inode_t *dp, char *name, int namelen,
char *value, int valuelen, int flags)
{
xfs_da_args_t args;
xfs_inode_t *dp;
xfs_fsblock_t firstblock;
xfs_bmap_free_t flist;
int error, err2, committed;
int local, size;
uint nblks;
xfs_mount_t *mp;
xfs_mount_t *mp = dp->i_mount;
int rsvd = (flags & ATTR_ROOT) != 0;
int namelen;

namelen = strlen(name);
if (namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */

XFS_STATS_INC(xs_attr_set);

dp = XFS_BHVTOI(bdp);
mp = dp->i_mount;
if (XFS_FORCED_SHUTDOWN(mp))
return (EIO);

xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!(flags & ATTR_SECURE) &&
(error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error));
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);

/*
* Attach the dquots to the inode.
Expand Down Expand Up @@ -270,7 +248,8 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
/* Determine space new attribute will use, and if it will be inline
* or out of line.
*/
size = xfs_attr_leaf_newentsize(&args, mp->m_sb.sb_blocksize, &local);
size = xfs_attr_leaf_newentsize(namelen, valuelen,
mp->m_sb.sb_blocksize, &local);

nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
if (local) {
Expand Down Expand Up @@ -456,47 +435,47 @@ xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
return(error);
}

/*
* Generic handler routine to remove a name from an attribute list.
* Transitions attribute list from Btree to shortform as necessary.
*/
/*ARGSUSED*/
int /* error */
xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
int
xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
struct cred *cred)
{
xfs_da_args_t args;
xfs_inode_t *dp;
xfs_fsblock_t firstblock;
xfs_bmap_free_t flist;
int error;
xfs_mount_t *mp;
int namelen;
xfs_inode_t *dp;
int namelen, error;

ASSERT(MAXNAMELEN-1<=0xff); /* length is stored in uint8 */
namelen = strlen(name);
if (namelen>=MAXNAMELEN)
return EFAULT; /* match irix behaviour */
if (namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */

XFS_STATS_INC(xs_attr_remove);
XFS_STATS_INC(xs_attr_set);

dp = XFS_BHVTOI(bdp);
mp = dp->i_mount;
if (XFS_FORCED_SHUTDOWN(mp))
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);

xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!(flags & ATTR_SECURE) &&
(error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error));
} else if (XFS_IFORK_Q(dp) == 0 ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(ENOATTR));
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);

return xfs_attr_set_int(dp, name, namelen, value, valuelen, flags);
}

/*
* Generic handler routine to remove a name from an attribute list.
* Transitions attribute list from Btree to shortform as necessary.
*/
int
xfs_attr_remove_int(xfs_inode_t *dp, char *name, int namelen, int flags)
{
xfs_da_args_t args;
xfs_fsblock_t firstblock;
xfs_bmap_free_t flist;
int error;
xfs_mount_t *mp = dp->i_mount;

/*
* Fill in the arg structure for this request.
*/
Expand Down Expand Up @@ -612,6 +591,38 @@ xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
return(error);
}

int
xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
{
xfs_inode_t *dp;
int namelen, error;

namelen = strlen(name);
if (namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */

XFS_STATS_INC(xs_attr_remove);

dp = XFS_BHVTOI(bdp);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);

xfs_ilock(dp, XFS_ILOCK_SHARED);
if (!(flags & ATTR_SECURE) &&
(error = xfs_iaccess(dp, S_IWUSR, cred))) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(error));
} else if (XFS_IFORK_Q(dp) == 0 ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(ENOATTR));
}
xfs_iunlock(dp, XFS_ILOCK_SHARED);

return xfs_attr_remove_int(dp, name, namelen, flags);
}

/*
* Generate a list of extended attribute names and optionally
* also value lengths. Positive return value follows the XFS
Expand Down
39 changes: 22 additions & 17 deletions trunk/fs/xfs/xfs_attr_leaf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
* 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 version 2 of the GNU General Public License as
Expand Down Expand Up @@ -898,7 +898,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
ASSERT((args->index >= 0)
&& (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr;
entsize = xfs_attr_leaf_newentsize(args,
entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
args->trans->t_mountp->m_sb.sb_blocksize, NULL);

/*
Expand Down Expand Up @@ -995,13 +995,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
mp = args->trans->t_mountp;
ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
ASSERT(INT_GET(map->size, ARCH_CONVERT)
>= xfs_attr_leaf_newentsize(args,
mp->m_sb.sb_blocksize, NULL));
ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, NULL));
ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
INT_MOD(map->size, ARCH_CONVERT,
-xfs_attr_leaf_newentsize(args, mp->m_sb.sb_blocksize, &tmp));
-xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, &tmp));
INT_SET(entry->nameidx, ARCH_CONVERT,
INT_GET(map->base, ARCH_CONVERT)
+ INT_GET(map->size, ARCH_CONVERT));
Expand Down Expand Up @@ -1357,8 +1358,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
half = (max+1) * sizeof(*entry);
half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
+ INT_GET(hdr2->usedbytes, ARCH_CONVERT)
+ xfs_attr_leaf_newentsize(state->args,
state->blocksize, NULL);
+ xfs_attr_leaf_newentsize(
state->args->namelen,
state->args->valuelen,
state->blocksize, NULL);
half /= 2;
lastdelta = state->blocksize;
entry = &leaf1->entries[0];
Expand All @@ -1370,9 +1373,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
*/
if (count == blk1->index) {
tmp = totallen + sizeof(*entry) +
xfs_attr_leaf_newentsize(state->args,
state->blocksize,
NULL);
xfs_attr_leaf_newentsize(
state->args->namelen,
state->args->valuelen,
state->blocksize, NULL);
if (XFS_ATTR_ABS(half - tmp) > lastdelta)
break;
lastdelta = XFS_ATTR_ABS(half - tmp);
Expand Down Expand Up @@ -1408,9 +1412,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
totallen -= count * sizeof(*entry);
if (foundit) {
totallen -= sizeof(*entry) +
xfs_attr_leaf_newentsize(state->args,
state->blocksize,
NULL);
xfs_attr_leaf_newentsize(
state->args->namelen,
state->args->valuelen,
state->blocksize, NULL);
}

*countarg = count;
Expand Down Expand Up @@ -2253,17 +2258,17 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
* a "local" or a "remote" attribute.
*/
int
xfs_attr_leaf_newentsize(xfs_da_args_t *args, int blocksize, int *local)
xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
{
int size;

size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(args->namelen, args->valuelen);
size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen);
if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) {
if (local) {
*local = 1;
}
} else {
size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(args->namelen);
size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen);
if (local) {
*local = 0;
}
Expand Down
5 changes: 3 additions & 2 deletions trunk/fs/xfs/xfs_attr_leaf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc. All Rights Reserved.
* Copyright (c) 2000, 2002-2003, 2005 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
Expand Down Expand Up @@ -289,7 +290,7 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count);
int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp,
struct xfs_dabuf *leaf2_bp);
int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize,
int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
int *local);
int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);

Expand Down
Loading

0 comments on commit acb9db7

Please sign in to comment.