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 *,
...@@ -401,7 +401,7 @@ typedef struct xfs_mount { ...@@ -401,7 +401,7 @@ typedef struct xfs_mount {
/* /*
* Allow large block sizes to be reported to userspace programs if the * Allow large block sizes to be reported to userspace programs if the
* "largeio" mount option is used. * "largeio" mount option is used.
* *
* If compatibility mode is specified, simply return the basic unit of caching * If compatibility mode is specified, simply return the basic unit of caching
* so that we don't get inefficient read/modify/write I/O from user apps. * so that we don't get inefficient read/modify/write I/O from user apps.
......
...@@ -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,
......
This diff is collapsed.
...@@ -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