Commit 556b8b16 authored by Barry Naujok's avatar Barry Naujok Committed by Lachlan McIlroy

[XFS] remove bhv_vname_t and xfs_rename code

SGI-PV: 976035
SGI-Modid: xfs-linux-melb:xfs-kern:30804a
Signed-off-by: default avatarBarry Naujok <bnaujok@sgi.com>
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent 7c9ef85c
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "xfs_trans.h" #include "xfs_trans.h"
#include "xfs_sb.h" #include "xfs_sb.h"
#include "xfs_ag.h" #include "xfs_ag.h"
#include "xfs_dir2.h"
#include "xfs_dmapi.h" #include "xfs_dmapi.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_export.h" #include "xfs_export.h"
...@@ -30,8 +31,6 @@ ...@@ -30,8 +31,6 @@
#include "xfs_inode.h" #include "xfs_inode.h"
#include "xfs_vfsops.h" #include "xfs_vfsops.h"
static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
/* /*
* Note that we only accept fileids which are long enough rather than allow * Note that we only accept fileids which are long enough rather than allow
* the parent generation number to default to zero. XFS considers zero a * the parent generation number to default to zero. XFS considers zero a
...@@ -216,7 +215,7 @@ xfs_fs_get_parent( ...@@ -216,7 +215,7 @@ xfs_fs_get_parent(
struct xfs_inode *cip; struct xfs_inode *cip;
struct dentry *parent; struct dentry *parent;
error = xfs_lookup(XFS_I(child->d_inode), &dotdot, &cip); error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip);
if (unlikely(error)) if (unlikely(error))
return ERR_PTR(-error); return ERR_PTR(-error);
......
...@@ -239,6 +239,15 @@ xfs_init_security( ...@@ -239,6 +239,15 @@ xfs_init_security(
return error; return error;
} }
static void
xfs_dentry_to_name(
struct xfs_name *namep,
struct dentry *dentry)
{
namep->name = dentry->d_name.name;
namep->len = dentry->d_name.len;
}
STATIC void STATIC void
xfs_cleanup_inode( xfs_cleanup_inode(
struct inode *dir, struct inode *dir,
...@@ -246,20 +255,19 @@ xfs_cleanup_inode( ...@@ -246,20 +255,19 @@ xfs_cleanup_inode(
struct dentry *dentry, struct dentry *dentry,
int mode) int mode)
{ {
struct dentry teardown = {}; struct xfs_name teardown;
/* Oh, the horror. /* Oh, the horror.
* If we can't add the ACL or we fail in * If we can't add the ACL or we fail in
* xfs_init_security we must back out. * xfs_init_security we must back out.
* ENOSPC can hit here, among other things. * ENOSPC can hit here, among other things.
*/ */
teardown.d_inode = inode; xfs_dentry_to_name(&teardown, dentry);
teardown.d_name = dentry->d_name;
if (S_ISDIR(mode)) if (S_ISDIR(mode))
xfs_rmdir(XFS_I(dir), &teardown); xfs_rmdir(XFS_I(dir), &teardown, XFS_I(inode));
else else
xfs_remove(XFS_I(dir), &teardown); xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
iput(inode); iput(inode);
} }
...@@ -273,6 +281,7 @@ xfs_vn_mknod( ...@@ -273,6 +281,7 @@ xfs_vn_mknod(
struct inode *inode; struct inode *inode;
struct xfs_inode *ip = NULL; struct xfs_inode *ip = NULL;
xfs_acl_t *default_acl = NULL; xfs_acl_t *default_acl = NULL;
struct xfs_name name;
attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
int error; int error;
...@@ -293,6 +302,8 @@ xfs_vn_mknod( ...@@ -293,6 +302,8 @@ xfs_vn_mknod(
} }
} }
xfs_dentry_to_name(&name, dentry);
if (IS_POSIXACL(dir) && !default_acl) if (IS_POSIXACL(dir) && !default_acl)
mode &= ~current->fs->umask; mode &= ~current->fs->umask;
...@@ -303,10 +314,10 @@ xfs_vn_mknod( ...@@ -303,10 +314,10 @@ xfs_vn_mknod(
case S_IFSOCK: case S_IFSOCK:
rdev = sysv_encode_dev(rdev); rdev = sysv_encode_dev(rdev);
case S_IFREG: case S_IFREG:
error = xfs_create(XFS_I(dir), dentry, mode, rdev, &ip, NULL); error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
break; break;
case S_IFDIR: case S_IFDIR:
error = xfs_mkdir(XFS_I(dir), dentry, mode, &ip, NULL); error = xfs_mkdir(XFS_I(dir), &name, mode, &ip, NULL);
break; break;
default: default:
error = EINVAL; error = EINVAL;
...@@ -371,12 +382,14 @@ xfs_vn_lookup( ...@@ -371,12 +382,14 @@ xfs_vn_lookup(
struct nameidata *nd) struct nameidata *nd)
{ {
struct xfs_inode *cip; struct xfs_inode *cip;
struct xfs_name name;
int error; int error;
if (dentry->d_name.len >= MAXNAMELEN) if (dentry->d_name.len >= MAXNAMELEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
error = xfs_lookup(XFS_I(dir), dentry, &cip); xfs_dentry_to_name(&name, dentry);
error = xfs_lookup(XFS_I(dir), &name, &cip);
if (unlikely(error)) { if (unlikely(error)) {
if (unlikely(error != ENOENT)) if (unlikely(error != ENOENT))
return ERR_PTR(-error); return ERR_PTR(-error);
...@@ -394,12 +407,14 @@ xfs_vn_link( ...@@ -394,12 +407,14 @@ xfs_vn_link(
struct dentry *dentry) struct dentry *dentry)
{ {
struct inode *inode; /* inode of guy being linked to */ struct inode *inode; /* inode of guy being linked to */
struct xfs_name name;
int error; int error;
inode = old_dentry->d_inode; inode = old_dentry->d_inode;
xfs_dentry_to_name(&name, dentry);
igrab(inode); igrab(inode);
error = xfs_link(XFS_I(dir), XFS_I(inode), dentry); error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
if (unlikely(error)) { if (unlikely(error)) {
iput(inode); iput(inode);
return -error; return -error;
...@@ -417,11 +432,13 @@ xfs_vn_unlink( ...@@ -417,11 +432,13 @@ xfs_vn_unlink(
struct dentry *dentry) struct dentry *dentry)
{ {
struct inode *inode; struct inode *inode;
struct xfs_name name;
int error; int error;
inode = dentry->d_inode; inode = dentry->d_inode;
xfs_dentry_to_name(&name, dentry);
error = xfs_remove(XFS_I(dir), dentry); error = xfs_remove(XFS_I(dir), &name, XFS_I(inode));
if (likely(!error)) { if (likely(!error)) {
xfs_validate_fields(dir); /* size needs update */ xfs_validate_fields(dir); /* size needs update */
xfs_validate_fields(inode); xfs_validate_fields(inode);
...@@ -437,14 +454,15 @@ xfs_vn_symlink( ...@@ -437,14 +454,15 @@ xfs_vn_symlink(
{ {
struct inode *inode; struct inode *inode;
struct xfs_inode *cip = NULL; struct xfs_inode *cip = NULL;
struct xfs_name name;
int error; int error;
mode_t mode; mode_t mode;
mode = S_IFLNK | mode = S_IFLNK |
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
xfs_dentry_to_name(&name, dentry);
error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode, error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
&cip, NULL);
if (unlikely(error)) if (unlikely(error))
goto out; goto out;
...@@ -471,9 +489,12 @@ xfs_vn_rmdir( ...@@ -471,9 +489,12 @@ xfs_vn_rmdir(
struct dentry *dentry) struct dentry *dentry)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct xfs_name name;
int error; int error;
error = xfs_rmdir(XFS_I(dir), dentry); xfs_dentry_to_name(&name, dentry);
error = xfs_rmdir(XFS_I(dir), &name, XFS_I(inode));
if (likely(!error)) { if (likely(!error)) {
xfs_validate_fields(inode); xfs_validate_fields(inode);
xfs_validate_fields(dir); xfs_validate_fields(dir);
...@@ -489,9 +510,15 @@ xfs_vn_rename( ...@@ -489,9 +510,15 @@ xfs_vn_rename(
struct dentry *ndentry) struct dentry *ndentry)
{ {
struct inode *new_inode = ndentry->d_inode; struct inode *new_inode = ndentry->d_inode;
struct xfs_name oname;
struct xfs_name nname;
int error; int error;
error = xfs_rename(XFS_I(odir), odentry, XFS_I(ndir), ndentry); xfs_dentry_to_name(&oname, odentry);
xfs_dentry_to_name(&nname, ndentry);
error = xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
XFS_I(ndir), &nname);
if (likely(!error)) { if (likely(!error)) {
if (new_inode) if (new_inode)
xfs_validate_fields(new_inode); xfs_validate_fields(new_inode);
......
...@@ -23,8 +23,6 @@ struct bhv_vattr; ...@@ -23,8 +23,6 @@ struct bhv_vattr;
struct xfs_iomap; struct xfs_iomap;
struct attrlist_cursor_kern; struct attrlist_cursor_kern;
typedef struct dentry bhv_vname_t;
typedef __u64 bhv_vnumber_t;
typedef struct inode bhv_vnode_t; typedef struct inode bhv_vnode_t;
#define VN_ISLNK(vp) S_ISLNK((vp)->i_mode) #define VN_ISLNK(vp) S_ISLNK((vp)->i_mode)
...@@ -210,13 +208,6 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp) ...@@ -210,13 +208,6 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
return inode ? vn_from_inode(inode) : NULL; return inode ? vn_from_inode(inode) : NULL;
} }
/*
* Vname handling macros.
*/
#define VNAME(dentry) ((char *) (dentry)->d_name.name)
#define VNAMELEN(dentry) ((dentry)->d_name.len)
#define VNAME_TO_INODE(dentry) (XFS_I((dentry)->d_inode))
/* /*
* Dealing with bad inodes * Dealing with bad inodes
*/ */
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "xfs_error.h" #include "xfs_error.h"
#include "xfs_vnodeops.h" #include "xfs_vnodeops.h"
struct xfs_name xfs_name_dotdot = {"..", 2};
void void
xfs_dir_mount( xfs_dir_mount(
...@@ -146,8 +147,7 @@ int ...@@ -146,8 +147,7 @@ int
xfs_dir_createname( xfs_dir_createname(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
char *name, struct xfs_name *name,
int namelen,
xfs_ino_t inum, /* new entry inode number */ xfs_ino_t inum, /* new entry inode number */
xfs_fsblock_t *first, /* bmap's firstblock */ xfs_fsblock_t *first, /* bmap's firstblock */
xfs_bmap_free_t *flist, /* bmap's freeblock list */ xfs_bmap_free_t *flist, /* bmap's freeblock list */
...@@ -162,9 +162,9 @@ xfs_dir_createname( ...@@ -162,9 +162,9 @@ xfs_dir_createname(
return rval; return rval;
XFS_STATS_INC(xs_dir_create); XFS_STATS_INC(xs_dir_create);
args.name = name; args.name = name->name;
args.namelen = namelen; args.namelen = name->len;
args.hashval = xfs_da_hashname(name, namelen); args.hashval = xfs_da_hashname(name->name, name->len);
args.inumber = inum; args.inumber = inum;
args.dp = dp; args.dp = dp;
args.firstblock = first; args.firstblock = first;
...@@ -197,8 +197,7 @@ int ...@@ -197,8 +197,7 @@ int
xfs_dir_lookup( xfs_dir_lookup(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
char *name, struct xfs_name *name,
int namelen,
xfs_ino_t *inum) /* out: inode number */ xfs_ino_t *inum) /* out: inode number */
{ {
xfs_da_args_t args; xfs_da_args_t args;
...@@ -207,18 +206,14 @@ xfs_dir_lookup( ...@@ -207,18 +206,14 @@ xfs_dir_lookup(
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
XFS_STATS_INC(xs_dir_lookup); XFS_STATS_INC(xs_dir_lookup);
memset(&args, 0, sizeof(xfs_da_args_t));
args.name = name; args.name = name->name;
args.namelen = namelen; args.namelen = name->len;
args.hashval = xfs_da_hashname(name, namelen); args.hashval = xfs_da_hashname(name->name, name->len);
args.inumber = 0;
args.dp = dp; args.dp = dp;
args.firstblock = NULL;
args.flist = NULL;
args.total = 0;
args.whichfork = XFS_DATA_FORK; args.whichfork = XFS_DATA_FORK;
args.trans = tp; args.trans = tp;
args.justcheck = args.addname = 0;
args.oknoent = 1; args.oknoent = 1;
if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
...@@ -247,8 +242,7 @@ int ...@@ -247,8 +242,7 @@ int
xfs_dir_removename( xfs_dir_removename(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
char *name, struct xfs_name *name,
int namelen,
xfs_ino_t ino, xfs_ino_t ino,
xfs_fsblock_t *first, /* bmap's firstblock */ xfs_fsblock_t *first, /* bmap's firstblock */
xfs_bmap_free_t *flist, /* bmap's freeblock list */ xfs_bmap_free_t *flist, /* bmap's freeblock list */
...@@ -261,9 +255,9 @@ xfs_dir_removename( ...@@ -261,9 +255,9 @@ xfs_dir_removename(
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
XFS_STATS_INC(xs_dir_remove); XFS_STATS_INC(xs_dir_remove);
args.name = name; args.name = name->name;
args.namelen = namelen; args.namelen = name->len;
args.hashval = xfs_da_hashname(name, namelen); args.hashval = xfs_da_hashname(name->name, name->len);
args.inumber = ino; args.inumber = ino;
args.dp = dp; args.dp = dp;
args.firstblock = first; args.firstblock = first;
...@@ -329,8 +323,7 @@ int ...@@ -329,8 +323,7 @@ int
xfs_dir_replace( xfs_dir_replace(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
char *name, /* name of entry to replace */ struct xfs_name *name, /* name of entry to replace */
int namelen,
xfs_ino_t inum, /* new inode number */ xfs_ino_t inum, /* new inode number */
xfs_fsblock_t *first, /* bmap's firstblock */ xfs_fsblock_t *first, /* bmap's firstblock */
xfs_bmap_free_t *flist, /* bmap's freeblock list */ xfs_bmap_free_t *flist, /* bmap's freeblock list */
...@@ -345,9 +338,9 @@ xfs_dir_replace( ...@@ -345,9 +338,9 @@ xfs_dir_replace(
if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum)))
return rval; return rval;
args.name = name; args.name = name->name;
args.namelen = namelen; args.namelen = name->len;
args.hashval = xfs_da_hashname(name, namelen); args.hashval = xfs_da_hashname(name->name, name->len);
args.inumber = inum; args.inumber = inum;
args.dp = dp; args.dp = dp;
args.firstblock = first; args.firstblock = first;
...@@ -374,28 +367,29 @@ xfs_dir_replace( ...@@ -374,28 +367,29 @@ xfs_dir_replace(
/* /*
* See if this entry can be added to the directory without allocating space. * See if this entry can be added to the directory without allocating space.
* First checks that the caller couldn't reserve enough space (resblks = 0).
*/ */
int int
xfs_dir_canenter( xfs_dir_canenter(
xfs_trans_t *tp, xfs_trans_t *tp,
xfs_inode_t *dp, xfs_inode_t *dp,
char *name, /* name of entry to add */ struct xfs_name *name, /* name of entry to add */
int namelen) uint resblks)
{ {
xfs_da_args_t args; xfs_da_args_t args;
int rval; int rval;
int v; /* type-checking value */ int v; /* type-checking value */
if (resblks)
return 0;
ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
memset(&args, 0, sizeof(xfs_da_args_t));
args.name = name; args.name = name->name;
args.namelen = namelen; args.namelen = name->len;
args.hashval = xfs_da_hashname(name, namelen); args.hashval = xfs_da_hashname(name->name, name->len);
args.inumber = 0;
args.dp = dp; args.dp = dp;
args.firstblock = NULL;
args.flist = NULL;
args.total = 0;
args.whichfork = XFS_DATA_FORK; args.whichfork = XFS_DATA_FORK;
args.trans = tp; args.trans = tp;
args.justcheck = args.addname = args.oknoent = 1; args.justcheck = args.addname = args.oknoent = 1;
......
...@@ -59,6 +59,8 @@ typedef __uint32_t xfs_dir2_db_t; ...@@ -59,6 +59,8 @@ typedef __uint32_t xfs_dir2_db_t;
*/ */
typedef xfs_off_t xfs_dir2_off_t; typedef xfs_off_t xfs_dir2_off_t;
extern struct xfs_name xfs_name_dotdot;
/* /*
* Generic directory interface routines * Generic directory interface routines
*/ */
...@@ -68,21 +70,21 @@ extern int xfs_dir_isempty(struct xfs_inode *dp); ...@@ -68,21 +70,21 @@ extern int xfs_dir_isempty(struct xfs_inode *dp);
extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_inode *pdp); struct xfs_inode *pdp);
extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
char *name, int namelen, xfs_ino_t inum, struct xfs_name *name, xfs_ino_t inum,
xfs_fsblock_t *first, xfs_fsblock_t *first,
struct xfs_bmap_free *flist, xfs_extlen_t tot); struct xfs_bmap_free *flist, xfs_extlen_t tot);
extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
char *name, int namelen, xfs_ino_t *inum); struct xfs_name *name, xfs_ino_t *inum);
extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
char *name, int namelen, xfs_ino_t ino, struct xfs_name *name, xfs_ino_t ino,
xfs_fsblock_t *first, xfs_fsblock_t *first,
struct xfs_bmap_free *flist, xfs_extlen_t tot); struct xfs_bmap_free *flist, xfs_extlen_t tot);
extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
char *name, int namelen, xfs_ino_t inum, struct xfs_name *name, xfs_ino_t inum,
xfs_fsblock_t *first, xfs_fsblock_t *first,
struct xfs_bmap_free *flist, xfs_extlen_t tot); struct xfs_bmap_free *flist, xfs_extlen_t tot);
extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
char *name, int namelen); struct xfs_name *name, uint resblks);
extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
/* /*
......
...@@ -73,7 +73,7 @@ typedef int (*xfs_send_destroy_t)(struct xfs_inode *, dm_right_t); ...@@ -73,7 +73,7 @@ typedef int (*xfs_send_destroy_t)(struct xfs_inode *, dm_right_t);
typedef int (*xfs_send_namesp_t)(dm_eventtype_t, struct xfs_mount *, typedef int (*xfs_send_namesp_t)(dm_eventtype_t, struct xfs_mount *,
struct xfs_inode *, dm_right_t, struct xfs_inode *, dm_right_t,
struct xfs_inode *, dm_right_t, struct xfs_inode *, dm_right_t,
char *, char *, mode_t, int, int); const char *, const char *, mode_t, int, int);
typedef int (*xfs_send_mount_t)(struct xfs_mount *, dm_right_t, typedef int (*xfs_send_mount_t)(struct xfs_mount *, dm_right_t,
char *, char *); char *, char *);
typedef void (*xfs_send_unmount_t)(struct xfs_mount *, struct xfs_inode *, typedef void (*xfs_send_unmount_t)(struct xfs_mount *, struct xfs_inode *,
......
...@@ -83,26 +83,23 @@ int xfs_rename_skip, xfs_rename_nskip; ...@@ -83,26 +83,23 @@ int xfs_rename_skip, xfs_rename_nskip;
*/ */
STATIC int STATIC int
xfs_lock_for_rename( xfs_lock_for_rename(
xfs_inode_t *dp1, /* old (source) directory inode */ xfs_inode_t *dp1, /* in: old (source) directory inode */
xfs_inode_t *dp2, /* new (target) directory inode */ xfs_inode_t *dp2, /* in: new (target) directory inode */
bhv_vname_t *vname1,/* old entry name */ xfs_inode_t *ip1, /* in: inode of old entry */
bhv_vname_t *vname2,/* new entry name */ struct xfs_name *name2, /* in: new entry name */
xfs_inode_t **ipp1, /* inode of old entry */ xfs_inode_t **ipp2, /* out: inode of new entry, if it
xfs_inode_t **ipp2, /* inode of new entry, if it
already exists, NULL otherwise. */ already exists, NULL otherwise. */
xfs_inode_t **i_tab,/* array of inode returned, sorted */ xfs_inode_t **i_tab,/* out: array of inode returned, sorted */
int *num_inodes) /* number of inodes in array */ int *num_inodes) /* out: number of inodes in array */
{ {
xfs_inode_t *ip1 = VNAME_TO_INODE(vname1); xfs_inode_t *ip2 = NULL;
xfs_inode_t *ip2, *temp; xfs_inode_t *temp;
xfs_ino_t inum1, inum2; xfs_ino_t inum1, inum2;
int error; int error;
int i, j; int i, j;
uint lock_mode; uint lock_mode;
int diff_dirs = (dp1 != dp2); int diff_dirs = (dp1 != dp2);
ip2 = NULL;
/* /*
* First, find out the current inums of the entries so that we * First, find out the current inums of the entries so that we
* can determine the initial locking order. We'll have to * can determine the initial locking order. We'll have to
...@@ -115,17 +112,15 @@ xfs_lock_for_rename( ...@@ -115,17 +112,15 @@ xfs_lock_for_rename(
inum1 = ip1->i_ino; inum1 = ip1->i_ino;
/* /*
* Unlock dp1 and lock dp2 if they are different. * Unlock dp1 and lock dp2 if they are different.
*/ */
if (diff_dirs) { if (diff_dirs) {
xfs_iunlock_map_shared(dp1, lock_mode); xfs_iunlock_map_shared(dp1, lock_mode);
lock_mode = xfs_ilock_map_shared(dp2); lock_mode = xfs_ilock_map_shared(dp2);
} }
error = xfs_dir_lookup_int(dp2, lock_mode, vname2, &inum2, &ip2); error = xfs_dir_lookup_int(dp2, lock_mode, name2, &inum2, &ip2);
if (error == ENOENT) { /* target does not need to exist. */ if (error == ENOENT) { /* target does not need to exist. */
inum2 = 0; inum2 = 0;
} else if (error) { } else if (error) {
...@@ -157,6 +152,7 @@ xfs_lock_for_rename( ...@@ -157,6 +152,7 @@ xfs_lock_for_rename(
*num_inodes = 4; *num_inodes = 4;
i_tab[3] = ip2; i_tab[3] = ip2;
} }
*ipp2 = i_tab[3];
/* /*
* Sort the elements via bubble sort. (Remember, there are at * Sort the elements via bubble sort. (Remember, there are at
...@@ -194,21 +190,6 @@ xfs_lock_for_rename( ...@@ -194,21 +190,6 @@ xfs_lock_for_rename(
xfs_lock_inodes(i_tab, *num_inodes, 0, XFS_ILOCK_SHARED); xfs_lock_inodes(i_tab, *num_inodes, 0, XFS_ILOCK_SHARED);
} }
/*
* Set the return value. Null out any unused entries in i_tab.
*/
*ipp1 = *ipp2 = NULL;
for (i=0; i < *num_inodes; i++) {
if (i_tab[i]->i_ino == inum1) {
*ipp1 = i_tab[i];
}
if (i_tab[i]->i_ino == inum2) {
*ipp2 = i_tab[i];
}
}
for (;i < 4; i++) {
i_tab[i] = NULL;
}
return 0; return 0;
} }
...@@ -218,12 +199,13 @@ xfs_lock_for_rename( ...@@ -218,12 +199,13 @@ xfs_lock_for_rename(
int int
xfs_rename( xfs_rename(
xfs_inode_t *src_dp, xfs_inode_t *src_dp,
bhv_vname_t *src_vname, struct xfs_name *src_name,
xfs_inode_t *src_ip,
xfs_inode_t *target_dp, xfs_inode_t *target_dp,
bhv_vname_t *target_vname) struct xfs_name *target_name)
{ {
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_inode_t *src_ip, *target_ip; xfs_inode_t *target_ip;
xfs_mount_t *mp = src_dp->i_mount; xfs_mount_t *mp = src_dp->i_mount;
int new_parent; /* moving to a new dir */ int new_parent; /* moving to a new dir */
int src_is_directory; /* src_name is a directory */ int src_is_directory; /* src_name is a directory */
...@@ -237,10 +219,6 @@ xfs_rename( ...@@ -237,10 +219,6 @@ xfs_rename(
int spaceres; int spaceres;
int target_link_zero = 0; int target_link_zero = 0;
int num_inodes; int num_inodes;
char *src_name = VNAME(src_vname);
char *target_name = VNAME(target_vname);
int src_namelen = VNAMELEN(src_vname);
int target_namelen = VNAMELEN(target_vname);
xfs_itrace_entry(src_dp); xfs_itrace_entry(src_dp);
xfs_itrace_entry(target_dp); xfs_itrace_entry(target_dp);
...@@ -250,7 +228,7 @@ xfs_rename( ...@@ -250,7 +228,7 @@ xfs_rename(
error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME, error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME,
src_dp, DM_RIGHT_NULL, src_dp, DM_RIGHT_NULL,
target_dp, DM_RIGHT_NULL, target_dp, DM_RIGHT_NULL,
src_name, target_name, src_name->name, target_name->name,
0, 0, 0); 0, 0, 0);
if (error) { if (error) {
return error; return error;
...@@ -267,10 +245,8 @@ xfs_rename( ...@@ -267,10 +245,8 @@ xfs_rename(
* does not exist in the source directory. * does not exist in the source directory.
*/ */
tp = NULL; tp = NULL;
error = xfs_lock_for_rename(src_dp, target_dp, src_vname, error = xfs_lock_for_rename(src_dp, target_dp, src_ip, target_name,
target_vname, &src_ip, &target_ip, inodes, &target_ip, inodes, &num_inodes);
&num_inodes);
if (error) { if (error) {
/* /*
* We have nothing locked, no inode references, and * We have nothing locked, no inode references, and
...@@ -316,7 +292,7 @@ xfs_rename( ...@@ -316,7 +292,7 @@ xfs_rename(
XFS_BMAP_INIT(&free_list, &first_block); XFS_BMAP_INIT(&free_list, &first_block);
tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME); tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
spaceres = XFS_RENAME_SPACE_RES(mp, target_namelen); spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
error = xfs_trans_reserve(tp, spaceres, XFS_RENAME_LOG_RES(mp), 0, error = xfs_trans_reserve(tp, spaceres, XFS_RENAME_LOG_RES(mp), 0,
XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT); XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
if (error == ENOSPC) { if (error == ENOSPC) {
...@@ -374,9 +350,8 @@ xfs_rename( ...@@ -374,9 +350,8 @@ xfs_rename(
* If there's no space reservation, check the entry will * If there's no space reservation, check the entry will
* fit before actually inserting it. * fit before actually inserting it.
*/ */
if (spaceres == 0 && error = xfs_dir_canenter(tp, target_dp, target_name, spaceres);
(error = xfs_dir_canenter(tp, target_dp, target_name, if (error)
target_namelen)))
goto error_return; goto error_return;
/* /*
* If target does not exist and the rename crosses * If target does not exist and the rename crosses
...@@ -384,8 +359,8 @@ xfs_rename( ...@@ -384,8 +359,8 @@ xfs_rename(
* to account for the ".." reference from the new entry. * to account for the ".." reference from the new entry.
*/ */
error = xfs_dir_createname(tp, target_dp, target_name, error = xfs_dir_createname(tp, target_dp, target_name,
target_namelen, src_ip->i_ino, src_ip->i_ino, &first_block,
&first_block, &free_list, spaceres); &free_list, spaceres);
if (error == ENOSPC) if (error == ENOSPC)
goto error_return; goto error_return;
if (error) if (error)
...@@ -424,7 +399,7 @@ xfs_rename( ...@@ -424,7 +399,7 @@ xfs_rename(
* name at the destination directory, remove it first. * name at the destination directory, remove it first.
*/ */
error = xfs_dir_replace(tp, target_dp, target_name, error = xfs_dir_replace(tp, target_dp, target_name,
target_namelen, src_ip->i_ino, src_ip->i_ino,
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
if (error) if (error)
goto abort_return; goto abort_return;
...@@ -461,7 +436,8 @@ xfs_rename( ...@@ -461,7 +436,8 @@ xfs_rename(
* Rewrite the ".." entry to point to the new * Rewrite the ".." entry to point to the new
* directory. * directory.
*/ */
error = xfs_dir_replace(tp, src_ip, "..", 2, target_dp->i_ino, error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
target_dp->i_ino,
&first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
ASSERT(error != EEXIST); ASSERT(error != EEXIST);
if (error) if (error)
...@@ -497,8 +473,8 @@ xfs_rename( ...@@ -497,8 +473,8 @@ xfs_rename(
goto abort_return; goto abort_return;
} }
error = xfs_dir_removename(tp, src_dp, src_name, src_namelen, error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
src_ip->i_ino, &first_block, &free_list, spaceres); &first_block, &free_list, spaceres);
if (error) if (error)
goto abort_return; goto abort_return;
xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -583,7 +559,7 @@ xfs_rename( ...@@ -583,7 +559,7 @@ xfs_rename(
(void) XFS_SEND_NAMESP (mp, DM_EVENT_POSTRENAME, (void) XFS_SEND_NAMESP (mp, DM_EVENT_POSTRENAME,
src_dp, DM_RIGHT_NULL, src_dp, DM_RIGHT_NULL,
target_dp, DM_RIGHT_NULL, target_dp, DM_RIGHT_NULL,
src_name, target_name, src_name->name, target_name->name,
0, error, 0); 0, error, 0);
} }
return error; return error;
......
...@@ -160,4 +160,9 @@ typedef enum { ...@@ -160,4 +160,9 @@ typedef enum {
XFS_BTNUM_MAX XFS_BTNUM_MAX
} xfs_btnum_t; } xfs_btnum_t;
struct xfs_name {
const char *name;
int len;
};
#endif /* __XFS_TYPES_H__ */ #endif /* __XFS_TYPES_H__ */
...@@ -45,7 +45,7 @@ int ...@@ -45,7 +45,7 @@ int
xfs_dir_lookup_int( xfs_dir_lookup_int(
xfs_inode_t *dp, xfs_inode_t *dp,
uint lock_mode, uint lock_mode,
bhv_vname_t *dentry, struct xfs_name *name,
xfs_ino_t *inum, xfs_ino_t *inum,
xfs_inode_t **ipp) xfs_inode_t **ipp)
{ {
...@@ -53,7 +53,7 @@ xfs_dir_lookup_int( ...@@ -53,7 +53,7 @@ xfs_dir_lookup_int(
xfs_itrace_entry(dp); xfs_itrace_entry(dp);
error = xfs_dir_lookup(NULL, dp, VNAME(dentry), VNAMELEN(dentry), inum); error = xfs_dir_lookup(NULL, dp, name, inum);
if (!error) { if (!error) {
/* /*
* Unlock the directory. We do this because we can't * Unlock the directory. We do this because we can't
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#define IRELE(ip) VN_RELE(XFS_ITOV(ip)) #define IRELE(ip) VN_RELE(XFS_ITOV(ip))
#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip)) #define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
extern int xfs_dir_lookup_int(xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_t *, extern int xfs_dir_lookup_int(xfs_inode_t *, uint, struct xfs_name *,
xfs_inode_t **); xfs_ino_t *, xfs_inode_t **);
extern int xfs_truncate_file(xfs_mount_t *, xfs_inode_t *); extern int xfs_truncate_file(xfs_mount_t *, xfs_inode_t *);
extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t, extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t,
xfs_dev_t, cred_t *, prid_t, int, xfs_dev_t, cred_t *, prid_t, int,
......
...@@ -1764,7 +1764,7 @@ xfs_inactive( ...@@ -1764,7 +1764,7 @@ xfs_inactive(
int int
xfs_lookup( xfs_lookup(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, struct xfs_name *name,
xfs_inode_t **ipp) xfs_inode_t **ipp)
{ {
xfs_inode_t *ip; xfs_inode_t *ip;
...@@ -1778,7 +1778,7 @@ xfs_lookup( ...@@ -1778,7 +1778,7 @@ xfs_lookup(
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
lock_mode = xfs_ilock_map_shared(dp); lock_mode = xfs_ilock_map_shared(dp);
error = xfs_dir_lookup_int(dp, lock_mode, dentry, &e_inum, &ip); error = xfs_dir_lookup_int(dp, lock_mode, name, &e_inum, &ip);
if (!error) { if (!error) {
*ipp = ip; *ipp = ip;
xfs_itrace_ref(ip); xfs_itrace_ref(ip);
...@@ -1790,13 +1790,12 @@ xfs_lookup( ...@@ -1790,13 +1790,12 @@ xfs_lookup(
int int
xfs_create( xfs_create(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, struct xfs_name *name,
mode_t mode, mode_t mode,
xfs_dev_t rdev, xfs_dev_t rdev,
xfs_inode_t **ipp, xfs_inode_t **ipp,
cred_t *credp) cred_t *credp)
{ {
char *name = VNAME(dentry);
xfs_mount_t *mp = dp->i_mount; xfs_mount_t *mp = dp->i_mount;
xfs_inode_t *ip; xfs_inode_t *ip;
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -1810,17 +1809,14 @@ xfs_create( ...@@ -1810,17 +1809,14 @@ xfs_create(
xfs_prid_t prid; xfs_prid_t prid;
struct xfs_dquot *udqp, *gdqp; struct xfs_dquot *udqp, *gdqp;
uint resblks; uint resblks;
int namelen;
ASSERT(!*ipp); ASSERT(!*ipp);
xfs_itrace_entry(dp); xfs_itrace_entry(dp);
namelen = VNAMELEN(dentry);
if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE, error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
dp, DM_RIGHT_NULL, NULL, dp, DM_RIGHT_NULL, NULL,
DM_RIGHT_NULL, name, NULL, DM_RIGHT_NULL, name->name, NULL,
mode, 0, 0); mode, 0, 0);
if (error) if (error)
...@@ -1852,7 +1848,7 @@ xfs_create( ...@@ -1852,7 +1848,7 @@ xfs_create(
tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
resblks = XFS_CREATE_SPACE_RES(mp, namelen); resblks = XFS_CREATE_SPACE_RES(mp, name->len);
/* /*
* Initially assume that the file does not exist and * Initially assume that the file does not exist and
* reserve the resources for that case. If that is not * reserve the resources for that case. If that is not
...@@ -1885,7 +1881,8 @@ xfs_create( ...@@ -1885,7 +1881,8 @@ xfs_create(
if (error) if (error)
goto error_return; goto error_return;
if (resblks == 0 && (error = xfs_dir_canenter(tp, dp, name, namelen))) error = xfs_dir_canenter(tp, dp, name, resblks);
if (error)
goto error_return; goto error_return;
error = xfs_dir_ialloc(&tp, dp, mode, 1, error = xfs_dir_ialloc(&tp, dp, mode, 1,
rdev, credp, prid, resblks > 0, rdev, credp, prid, resblks > 0,
...@@ -1915,7 +1912,7 @@ xfs_create( ...@@ -1915,7 +1912,7 @@ xfs_create(
xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
unlock_dp_on_error = B_FALSE; unlock_dp_on_error = B_FALSE;
error = xfs_dir_createname(tp, dp, name, namelen, ip->i_ino, error = xfs_dir_createname(tp, dp, name, ip->i_ino,
&first_block, &free_list, resblks ? &first_block, &free_list, resblks ?
resblks - XFS_IALLOC_SPACE_RES(mp) : 0); resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
if (error) { if (error) {
...@@ -1976,7 +1973,7 @@ xfs_create( ...@@ -1976,7 +1973,7 @@ xfs_create(
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE, (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTCREATE,
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
*ipp ? ip : NULL, *ipp ? ip : NULL,
DM_RIGHT_NULL, name, NULL, DM_RIGHT_NULL, name->name, NULL,
mode, error, 0); mode, error, 0);
} }
return error; return error;
...@@ -2268,12 +2265,10 @@ int remove_which_error_return = 0; ...@@ -2268,12 +2265,10 @@ int remove_which_error_return = 0;
int int
xfs_remove( xfs_remove(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry) struct xfs_name *name,
xfs_inode_t *ip)
{ {
char *name = VNAME(dentry);
xfs_mount_t *mp = dp->i_mount; xfs_mount_t *mp = dp->i_mount;
xfs_inode_t *ip = VNAME_TO_INODE(dentry);
int namelen = VNAMELEN(dentry);
xfs_trans_t *tp = NULL; xfs_trans_t *tp = NULL;
int error = 0; int error = 0;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
...@@ -2289,9 +2284,9 @@ xfs_remove( ...@@ -2289,9 +2284,9 @@ xfs_remove(
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dp, error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, dp, DM_RIGHT_NULL,
DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, name->name, NULL,
name, NULL, ip->i_d.di_mode, 0, 0); ip->i_d.di_mode, 0, 0);
if (error) if (error)
return error; return error;
} }
...@@ -2376,7 +2371,7 @@ xfs_remove( ...@@ -2376,7 +2371,7 @@ xfs_remove(
* Entry must exist since we did a lookup in xfs_lock_dir_and_entry. * Entry must exist since we did a lookup in xfs_lock_dir_and_entry.
*/ */
XFS_BMAP_INIT(&free_list, &first_block); XFS_BMAP_INIT(&free_list, &first_block);
error = xfs_dir_removename(tp, dp, name, namelen, ip->i_ino, error = xfs_dir_removename(tp, dp, name, ip->i_ino,
&first_block, &free_list, 0); &first_block, &free_list, 0);
if (error) { if (error) {
ASSERT(error != ENOENT); ASSERT(error != ENOENT);
...@@ -2444,7 +2439,7 @@ xfs_remove( ...@@ -2444,7 +2439,7 @@ xfs_remove(
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
NULL, DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
name, NULL, ip->i_d.di_mode, error, 0); name->name, NULL, ip->i_d.di_mode, error, 0);
} }
return error; return error;
...@@ -2474,7 +2469,7 @@ int ...@@ -2474,7 +2469,7 @@ int
xfs_link( xfs_link(
xfs_inode_t *tdp, xfs_inode_t *tdp,
xfs_inode_t *sip, xfs_inode_t *sip,
bhv_vname_t *dentry) struct xfs_name *target_name)
{ {
xfs_mount_t *mp = tdp->i_mount; xfs_mount_t *mp = tdp->i_mount;
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -2485,13 +2480,10 @@ xfs_link( ...@@ -2485,13 +2480,10 @@ xfs_link(
int cancel_flags; int cancel_flags;
int committed; int committed;
int resblks; int resblks;
char *target_name = VNAME(dentry);
int target_namelen;
xfs_itrace_entry(tdp); xfs_itrace_entry(tdp);
xfs_itrace_entry(sip); xfs_itrace_entry(sip);
target_namelen = VNAMELEN(dentry);
ASSERT(!S_ISDIR(sip->i_d.di_mode)); ASSERT(!S_ISDIR(sip->i_d.di_mode));
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
...@@ -2501,7 +2493,7 @@ xfs_link( ...@@ -2501,7 +2493,7 @@ xfs_link(
error = XFS_SEND_NAMESP(mp, DM_EVENT_LINK, error = XFS_SEND_NAMESP(mp, DM_EVENT_LINK,
tdp, DM_RIGHT_NULL, tdp, DM_RIGHT_NULL,
sip, DM_RIGHT_NULL, sip, DM_RIGHT_NULL,
target_name, NULL, 0, 0, 0); target_name->name, NULL, 0, 0, 0);
if (error) if (error)
return error; return error;
} }
...@@ -2516,7 +2508,7 @@ xfs_link( ...@@ -2516,7 +2508,7 @@ xfs_link(
tp = xfs_trans_alloc(mp, XFS_TRANS_LINK); tp = xfs_trans_alloc(mp, XFS_TRANS_LINK);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
resblks = XFS_LINK_SPACE_RES(mp, target_namelen); resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
error = xfs_trans_reserve(tp, resblks, XFS_LINK_LOG_RES(mp), 0, error = xfs_trans_reserve(tp, resblks, XFS_LINK_LOG_RES(mp), 0,
XFS_TRANS_PERM_LOG_RES, XFS_LINK_LOG_COUNT); XFS_TRANS_PERM_LOG_RES, XFS_LINK_LOG_COUNT);
if (error == ENOSPC) { if (error == ENOSPC) {
...@@ -2568,15 +2560,14 @@ xfs_link( ...@@ -2568,15 +2560,14 @@ xfs_link(
goto error_return; goto error_return;
} }
if (resblks == 0 && error = xfs_dir_canenter(tp, tdp, target_name, resblks);
(error = xfs_dir_canenter(tp, tdp, target_name, target_namelen))) if (error)
goto error_return; goto error_return;
XFS_BMAP_INIT(&free_list, &first_block); XFS_BMAP_INIT(&free_list, &first_block);
error = xfs_dir_createname(tp, tdp, target_name, target_namelen, error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
sip->i_ino, &first_block, &free_list, &first_block, &free_list, resblks);
resblks);
if (error) if (error)
goto abort_return; goto abort_return;
xfs_ichgtime(tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_ichgtime(tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -2612,7 +2603,7 @@ xfs_link( ...@@ -2612,7 +2603,7 @@ xfs_link(
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTLINK, (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTLINK,
tdp, DM_RIGHT_NULL, tdp, DM_RIGHT_NULL,
sip, DM_RIGHT_NULL, sip, DM_RIGHT_NULL,
target_name, NULL, 0, error, 0); target_name->name, NULL, 0, error, 0);
} }
return error; return error;
...@@ -2629,13 +2620,11 @@ xfs_link( ...@@ -2629,13 +2620,11 @@ xfs_link(
int int
xfs_mkdir( xfs_mkdir(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, struct xfs_name *dir_name,
mode_t mode, mode_t mode,
xfs_inode_t **ipp, xfs_inode_t **ipp,
cred_t *credp) cred_t *credp)
{ {
char *dir_name = VNAME(dentry);
int dir_namelen = VNAMELEN(dentry);
xfs_mount_t *mp = dp->i_mount; xfs_mount_t *mp = dp->i_mount;
xfs_inode_t *cdp; /* inode of created dir */ xfs_inode_t *cdp; /* inode of created dir */
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -2659,7 +2648,7 @@ xfs_mkdir( ...@@ -2659,7 +2648,7 @@ xfs_mkdir(
if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_CREATE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE, error = XFS_SEND_NAMESP(mp, DM_EVENT_CREATE,
dp, DM_RIGHT_NULL, NULL, dp, DM_RIGHT_NULL, NULL,
DM_RIGHT_NULL, dir_name, NULL, DM_RIGHT_NULL, dir_name->name, NULL,
mode, 0, 0); mode, 0, 0);
if (error) if (error)
return error; return error;
...@@ -2688,7 +2677,7 @@ xfs_mkdir( ...@@ -2688,7 +2677,7 @@ xfs_mkdir(
tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES; cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
resblks = XFS_MKDIR_SPACE_RES(mp, dir_namelen); resblks = XFS_MKDIR_SPACE_RES(mp, dir_name->len);
error = xfs_trans_reserve(tp, resblks, XFS_MKDIR_LOG_RES(mp), 0, error = xfs_trans_reserve(tp, resblks, XFS_MKDIR_LOG_RES(mp), 0,
XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT); XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT);
if (error == ENOSPC) { if (error == ENOSPC) {
...@@ -2720,8 +2709,8 @@ xfs_mkdir( ...@@ -2720,8 +2709,8 @@ xfs_mkdir(
if (error) if (error)
goto error_return; goto error_return;
if (resblks == 0 && error = xfs_dir_canenter(tp, dp, dir_name, resblks);
(error = xfs_dir_canenter(tp, dp, dir_name, dir_namelen))) if (error)
goto error_return; goto error_return;
/* /*
* create the directory inode. * create the directory inode.
...@@ -2750,7 +2739,7 @@ xfs_mkdir( ...@@ -2750,7 +2739,7 @@ xfs_mkdir(
XFS_BMAP_INIT(&free_list, &first_block); XFS_BMAP_INIT(&free_list, &first_block);
error = xfs_dir_createname(tp, dp, dir_name, dir_namelen, cdp->i_ino, error = xfs_dir_createname(tp, dp, dir_name, cdp->i_ino,
&first_block, &free_list, resblks ? &first_block, &free_list, resblks ?
resblks - XFS_IALLOC_SPACE_RES(mp) : 0); resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
if (error) { if (error) {
...@@ -2817,7 +2806,7 @@ xfs_mkdir( ...@@ -2817,7 +2806,7 @@ xfs_mkdir(
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
created ? cdp : NULL, created ? cdp : NULL,
DM_RIGHT_NULL, DM_RIGHT_NULL,
dir_name, NULL, dir_name->name, NULL,
mode, error, 0); mode, error, 0);
} }
return error; return error;
...@@ -2841,13 +2830,11 @@ xfs_mkdir( ...@@ -2841,13 +2830,11 @@ xfs_mkdir(
int int
xfs_rmdir( xfs_rmdir(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry) struct xfs_name *name,
xfs_inode_t *cdp)
{ {
bhv_vnode_t *dir_vp = XFS_ITOV(dp); bhv_vnode_t *dir_vp = XFS_ITOV(dp);
char *name = VNAME(dentry);
int namelen = VNAMELEN(dentry);
xfs_mount_t *mp = dp->i_mount; xfs_mount_t *mp = dp->i_mount;
xfs_inode_t *cdp = VNAME_TO_INODE(dentry);
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
xfs_bmap_free_t free_list; xfs_bmap_free_t free_list;
...@@ -2865,8 +2852,8 @@ xfs_rmdir( ...@@ -2865,8 +2852,8 @@ xfs_rmdir(
if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_REMOVE)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE, error = XFS_SEND_NAMESP(mp, DM_EVENT_REMOVE,
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
NULL, DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, name->name,
name, NULL, cdp->i_d.di_mode, 0, 0); NULL, cdp->i_d.di_mode, 0, 0);
if (error) if (error)
return XFS_ERROR(error); return XFS_ERROR(error);
} }
...@@ -2960,7 +2947,7 @@ xfs_rmdir( ...@@ -2960,7 +2947,7 @@ xfs_rmdir(
goto error_return; goto error_return;
} }
error = xfs_dir_removename(tp, dp, name, namelen, cdp->i_ino, error = xfs_dir_removename(tp, dp, name, cdp->i_ino,
&first_block, &free_list, resblks); &first_block, &free_list, resblks);
if (error) if (error)
goto error1; goto error1;
...@@ -3040,7 +3027,7 @@ xfs_rmdir( ...@@ -3040,7 +3027,7 @@ xfs_rmdir(
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
NULL, DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
name, NULL, cdp->i_d.di_mode, name->name, NULL, cdp->i_d.di_mode,
error, 0); error, 0);
} }
return error; return error;
...@@ -3058,8 +3045,8 @@ xfs_rmdir( ...@@ -3058,8 +3045,8 @@ xfs_rmdir(
int int
xfs_symlink( xfs_symlink(
xfs_inode_t *dp, xfs_inode_t *dp,
bhv_vname_t *dentry, struct xfs_name *link_name,
char *target_path, const char *target_path,
mode_t mode, mode_t mode,
xfs_inode_t **ipp, xfs_inode_t **ipp,
cred_t *credp) cred_t *credp)
...@@ -3079,15 +3066,13 @@ xfs_symlink( ...@@ -3079,15 +3066,13 @@ xfs_symlink(
int nmaps; int nmaps;
xfs_bmbt_irec_t mval[SYMLINK_MAPS]; xfs_bmbt_irec_t mval[SYMLINK_MAPS];
xfs_daddr_t d; xfs_daddr_t d;
char *cur_chunk; const char *cur_chunk;
int byte_cnt; int byte_cnt;
int n; int n;
xfs_buf_t *bp; xfs_buf_t *bp;
xfs_prid_t prid; xfs_prid_t prid;
struct xfs_dquot *udqp, *gdqp; struct xfs_dquot *udqp, *gdqp;
uint resblks; uint resblks;
char *link_name = VNAME(dentry);
int link_namelen;
*ipp = NULL; *ipp = NULL;
error = 0; error = 0;
...@@ -3099,8 +3084,6 @@ xfs_symlink( ...@@ -3099,8 +3084,6 @@ xfs_symlink(
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
link_namelen = VNAMELEN(dentry);
/* /*
* Check component lengths of the target path name. * Check component lengths of the target path name.
*/ */
...@@ -3111,7 +3094,7 @@ xfs_symlink( ...@@ -3111,7 +3094,7 @@ xfs_symlink(
if (DM_EVENT_ENABLED(dp, DM_EVENT_SYMLINK)) { if (DM_EVENT_ENABLED(dp, DM_EVENT_SYMLINK)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_SYMLINK, dp, error = XFS_SEND_NAMESP(mp, DM_EVENT_SYMLINK, dp,
DM_RIGHT_NULL, NULL, DM_RIGHT_NULL, DM_RIGHT_NULL, NULL, DM_RIGHT_NULL,
link_name, target_path, 0, 0, 0); link_name->name, target_path, 0, 0, 0);
if (error) if (error)
return error; return error;
} }
...@@ -3143,7 +3126,7 @@ xfs_symlink( ...@@ -3143,7 +3126,7 @@ xfs_symlink(
fs_blocks = 0; fs_blocks = 0;
else else
fs_blocks = XFS_B_TO_FSB(mp, pathlen); fs_blocks = XFS_B_TO_FSB(mp, pathlen);
resblks = XFS_SYMLINK_SPACE_RES(mp, link_namelen, fs_blocks); resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks);
error = xfs_trans_reserve(tp, resblks, XFS_SYMLINK_LOG_RES(mp), 0, error = xfs_trans_reserve(tp, resblks, XFS_SYMLINK_LOG_RES(mp), 0,
XFS_TRANS_PERM_LOG_RES, XFS_SYMLINK_LOG_COUNT); XFS_TRANS_PERM_LOG_RES, XFS_SYMLINK_LOG_COUNT);
if (error == ENOSPC && fs_blocks == 0) { if (error == ENOSPC && fs_blocks == 0) {
...@@ -3177,8 +3160,8 @@ xfs_symlink( ...@@ -3177,8 +3160,8 @@ xfs_symlink(
/* /*
* Check for ability to enter directory entry, if no space reserved. * Check for ability to enter directory entry, if no space reserved.
*/ */
if (resblks == 0 && error = xfs_dir_canenter(tp, dp, link_name, resblks);
(error = xfs_dir_canenter(tp, dp, link_name, link_namelen))) if (error)
goto error_return; goto error_return;
/* /*
* Initialize the bmap freelist prior to calling either * Initialize the bmap freelist prior to calling either
...@@ -3270,7 +3253,7 @@ xfs_symlink( ...@@ -3270,7 +3253,7 @@ xfs_symlink(
/* /*
* Create the directory entry for the symlink. * Create the directory entry for the symlink.
*/ */
error = xfs_dir_createname(tp, dp, link_name, link_namelen, ip->i_ino, error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
&first_block, &free_list, resblks); &first_block, &free_list, resblks);
if (error) if (error)
goto error1; goto error1;
...@@ -3315,8 +3298,8 @@ xfs_symlink( ...@@ -3315,8 +3298,8 @@ xfs_symlink(
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTSYMLINK, (void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTSYMLINK,
dp, DM_RIGHT_NULL, dp, DM_RIGHT_NULL,
error ? NULL : ip, error ? NULL : ip,
DM_RIGHT_NULL, link_name, target_path, DM_RIGHT_NULL, link_name->name,
0, error, 0); target_path, 0, error, 0);
} }
if (!error) if (!error)
......
...@@ -23,20 +23,22 @@ int xfs_fsync(struct xfs_inode *ip, int flag, xfs_off_t start, ...@@ -23,20 +23,22 @@ int xfs_fsync(struct xfs_inode *ip, int flag, xfs_off_t start,
xfs_off_t stop); xfs_off_t stop);
int xfs_release(struct xfs_inode *ip); int xfs_release(struct xfs_inode *ip);
int xfs_inactive(struct xfs_inode *ip); int xfs_inactive(struct xfs_inode *ip);
int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
struct xfs_inode **ipp); struct xfs_inode **ipp);
int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry, mode_t mode, int xfs_create(struct xfs_inode *dp, struct xfs_name *name, mode_t mode,
xfs_dev_t rdev, struct xfs_inode **ipp, struct cred *credp); xfs_dev_t rdev, struct xfs_inode **ipp, struct cred *credp);
int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry); int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
struct xfs_inode *ip);
int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
bhv_vname_t *dentry); struct xfs_name *target_name);
int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_mkdir(struct xfs_inode *dp, struct xfs_name *dir_name,
mode_t mode, struct xfs_inode **ipp, struct cred *credp); mode_t mode, struct xfs_inode **ipp, struct cred *credp);
int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry); int xfs_rmdir(struct xfs_inode *dp, struct xfs_name *name,
struct xfs_inode *cdp);
int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize, int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
xfs_off_t *offset, filldir_t filldir); xfs_off_t *offset, filldir_t filldir);
int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name,
char *target_path, mode_t mode, struct xfs_inode **ipp, const char *target_path, mode_t mode, struct xfs_inode **ipp,
struct cred *credp); struct cred *credp);
int xfs_inode_flush(struct xfs_inode *ip, int flags); int xfs_inode_flush(struct xfs_inode *ip, int flags);
int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state); int xfs_set_dmattrs(struct xfs_inode *ip, u_int evmask, u_int16_t state);
...@@ -44,8 +46,9 @@ int xfs_reclaim(struct xfs_inode *ip); ...@@ -44,8 +46,9 @@ int xfs_reclaim(struct xfs_inode *ip);
int xfs_change_file_space(struct xfs_inode *ip, int cmd, int xfs_change_file_space(struct xfs_inode *ip, int cmd,
xfs_flock64_t *bf, xfs_off_t offset, xfs_flock64_t *bf, xfs_off_t offset,
struct cred *credp, int attr_flags); struct cred *credp, int attr_flags);
int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname, int xfs_rename(struct xfs_inode *src_dp, struct xfs_name *src_name,
struct xfs_inode *target_dp, bhv_vname_t *target_vname); struct xfs_inode *src_ip, struct xfs_inode *target_dp,
struct xfs_name *target_name);
int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value, int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value,
int *valuelenp, int flags, cred_t *cred); int *valuelenp, int flags, cred_t *cred);
int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value, int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment