X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fxfs%2Flinux-2.6%2Fxfs_iops.c;h=d2ac9c6c6fde6c608e026bf549ecb3cd968278cc;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=a9a289b254b4434ff4e8df08475212a3ab21ef6e;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index a9a289b25..d2ac9c6c6 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c @@ -107,7 +107,7 @@ xfs_ichgtime( xfs_inode_t *ip, int flags) { - struct inode *inode = vn_to_inode(XFS_ITOV(ip)); + struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); timespec_t tv; nanotime(&tv); @@ -199,22 +199,22 @@ xfs_ichgtime_fast( * Pull the link count and size up from the xfs inode to the linux inode */ STATIC void -xfs_validate_fields( - struct inode *ip, - struct vattr *vattr) +validate_fields( + struct inode *ip) { - vnode_t *vp = vn_from_inode(ip); + vnode_t *vp = LINVFS_GET_VP(ip); + vattr_t va; int error; - vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS; - VOP_GETATTR(vp, vattr, ATTR_LAZY, NULL, error); - if (likely(!error)) { - ip->i_nlink = vattr->va_nlink; - ip->i_blocks = vattr->va_nblocks; + va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS; + VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error); + if (likely(!error)) { + ip->i_nlink = va.va_nlink; + ip->i_blocks = va.va_nblocks; - /* we're under i_sem so i_size can't change under us */ - if (i_size_read(ip) != vattr->va_size) - i_size_write(ip, vattr->va_size); + /* we're under i_mutex so i_size can't change under us */ + if (i_size_read(ip) != va.va_size) + i_size_write(ip, va.va_size); } } @@ -225,11 +225,11 @@ xfs_validate_fields( * inode, of course, such that log replay can't cause these to be lost). */ STATIC int -xfs_init_security( +linvfs_init_security( struct vnode *vp, struct inode *dir) { - struct inode *ip = vn_to_inode(vp); + struct inode *ip = LINVFS_GET_IP(vp); size_t length; void *value; char *name; @@ -258,46 +258,46 @@ xfs_init_security( * XXX(hch): nfsd is broken, better fix it instead. */ STATIC inline int -xfs_has_fs_struct(struct task_struct *task) +has_fs_struct(struct task_struct *task) { return (task->fs != init_task.fs); } STATIC inline void -xfs_cleanup_inode( +cleanup_inode( vnode_t *dvp, vnode_t *vp, - struct dentry *dentry, + struct dentry *dentry, int mode) { struct dentry teardown = {}; - int error; + int err2; /* Oh, the horror. - * If we can't add the ACL or we fail in - * xfs_init_security we must back out. + * If we can't add the ACL or we fail in + * linvfs_init_security we must back out. * ENOSPC can hit here, among other things. */ - teardown.d_inode = vn_to_inode(vp); + teardown.d_inode = LINVFS_GET_IP(vp); teardown.d_name = dentry->d_name; if (S_ISDIR(mode)) - VOP_RMDIR(dvp, &teardown, NULL, error); + VOP_RMDIR(dvp, &teardown, NULL, err2); else - VOP_REMOVE(dvp, &teardown, NULL, error); + VOP_REMOVE(dvp, &teardown, NULL, err2); VN_RELE(vp); } STATIC int -xfs_vn_mknod( +linvfs_mknod( struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) { struct inode *ip; - vattr_t vattr = { 0 }; - vnode_t *vp = NULL, *dvp = vn_from_inode(dir); + vattr_t va; + vnode_t *vp = NULL, *dvp = LINVFS_GET_VP(dir); xfs_acl_t *default_acl = NULL; attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; int error; @@ -306,98 +306,99 @@ xfs_vn_mknod( * Irix uses Missed'em'V split, but doesn't want to see * the upper 5 bits of (14bit) major. */ - if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) + if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff) return -EINVAL; - if (unlikely(test_default_acl && test_default_acl(dvp))) { - if (!_ACL_ALLOC(default_acl)) { + if (test_default_acl && test_default_acl(dvp)) { + if (!_ACL_ALLOC(default_acl)) return -ENOMEM; - } if (!_ACL_GET_DEFAULT(dvp, default_acl)) { _ACL_FREE(default_acl); default_acl = NULL; } } - if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current)) + if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current)) mode &= ~current->fs->umask; - vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE; - vattr.va_mode = mode; + memset(&va, 0, sizeof(va)); + va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; + va.va_mode = mode; switch (mode & S_IFMT) { case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: - vattr.va_rdev = sysv_encode_dev(rdev); - vattr.va_mask |= XFS_AT_RDEV; + va.va_rdev = sysv_encode_dev(rdev); + va.va_mask |= XFS_AT_RDEV; /*FALLTHROUGH*/ case S_IFREG: - VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error); + VOP_CREATE(dvp, dentry, &va, &vp, NULL, error); break; case S_IFDIR: - VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error); + VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error); break; default: error = EINVAL; break; } - if (unlikely(!error)) { - error = xfs_init_security(vp, dir); + if (!error) + { + error = linvfs_init_security(vp, dir); if (error) - xfs_cleanup_inode(dvp, vp, dentry, mode); + cleanup_inode(dvp, vp, dentry, mode); } - if (unlikely(default_acl)) { + if (default_acl) { if (!error) { - error = _ACL_INHERIT(vp, &vattr, default_acl); - if (!error) + error = _ACL_INHERIT(vp, &va, default_acl); + if (!error) VMODIFY(vp); else - xfs_cleanup_inode(dvp, vp, dentry, mode); + cleanup_inode(dvp, vp, dentry, mode); } _ACL_FREE(default_acl); } - if (likely(!error)) { + if (!error) { ASSERT(vp); - ip = vn_to_inode(vp); + ip = LINVFS_GET_IP(vp); if (S_ISCHR(mode) || S_ISBLK(mode)) ip->i_rdev = rdev; else if (S_ISDIR(mode)) - xfs_validate_fields(ip, &vattr); + validate_fields(ip); d_instantiate(dentry, ip); - xfs_validate_fields(dir, &vattr); + validate_fields(dir); } return -error; } STATIC int -xfs_vn_create( +linvfs_create( struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) { - return xfs_vn_mknod(dir, dentry, mode, 0); + return linvfs_mknod(dir, dentry, mode, 0); } STATIC int -xfs_vn_mkdir( +linvfs_mkdir( struct inode *dir, struct dentry *dentry, int mode) { - return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0); + return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0); } STATIC struct dentry * -xfs_vn_lookup( +linvfs_lookup( struct inode *dir, struct dentry *dentry, struct nameidata *nd) { - struct vnode *vp = vn_from_inode(dir), *cvp; + struct vnode *vp = LINVFS_GET_VP(dir), *cvp; int error; if (dentry->d_name.len >= MAXNAMELEN) @@ -410,13 +411,13 @@ xfs_vn_lookup( d_add(dentry, NULL); return NULL; } - vx_propagate_xid(nd, vn_to_inode(cvp)); + vx_propagate_xid(nd, LINVFS_GET_IP(cvp)); - return d_splice_alias(vn_to_inode(cvp), dentry); + return d_splice_alias(LINVFS_GET_IP(cvp), dentry); } STATIC int -xfs_vn_link( +linvfs_link( struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) @@ -424,102 +425,99 @@ xfs_vn_link( struct inode *ip; /* inode of guy being linked to */ vnode_t *tdvp; /* target directory for new name/link */ vnode_t *vp; /* vp of name being linked */ - vattr_t vattr; int error; ip = old_dentry->d_inode; /* inode being linked to */ if (S_ISDIR(ip->i_mode)) return -EPERM; - tdvp = vn_from_inode(dir); - vp = vn_from_inode(ip); + tdvp = LINVFS_GET_VP(dir); + vp = LINVFS_GET_VP(ip); VOP_LINK(tdvp, vp, dentry, NULL, error); - if (likely(!error)) { + if (!error) { VMODIFY(tdvp); VN_HOLD(vp); - xfs_validate_fields(ip, &vattr); + validate_fields(ip); d_instantiate(dentry, ip); } return -error; } STATIC int -xfs_vn_unlink( +linvfs_unlink( struct inode *dir, struct dentry *dentry) { struct inode *inode; vnode_t *dvp; /* directory containing name to remove */ - vattr_t vattr; int error; inode = dentry->d_inode; - dvp = vn_from_inode(dir); + dvp = LINVFS_GET_VP(dir); VOP_REMOVE(dvp, dentry, NULL, error); - if (likely(!error)) { - xfs_validate_fields(dir, &vattr); /* size needs update */ - xfs_validate_fields(inode, &vattr); + if (!error) { + validate_fields(dir); /* For size only */ + validate_fields(inode); } + return -error; } STATIC int -xfs_vn_symlink( +linvfs_symlink( struct inode *dir, struct dentry *dentry, const char *symname) { struct inode *ip; - vattr_t vattr = { 0 }; + vattr_t va; vnode_t *dvp; /* directory containing name of symlink */ vnode_t *cvp; /* used to lookup symlink to put in dentry */ int error; - dvp = vn_from_inode(dir); + dvp = LINVFS_GET_VP(dir); cvp = NULL; - vattr.va_mode = S_IFLNK | + memset(&va, 0, sizeof(va)); + va.va_mode = S_IFLNK | (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); - vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE; + va.va_mask = XFS_AT_TYPE|XFS_AT_MODE; error = 0; - VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error); + VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error); if (likely(!error && cvp)) { - error = xfs_init_security(cvp, dir); + error = linvfs_init_security(cvp, dir); if (likely(!error)) { - ip = vn_to_inode(cvp); + ip = LINVFS_GET_IP(cvp); d_instantiate(dentry, ip); - xfs_validate_fields(dir, &vattr); - xfs_validate_fields(ip, &vattr); - } else { - xfs_cleanup_inode(dvp, cvp, dentry, 0); + validate_fields(dir); + validate_fields(ip); } } return -error; } STATIC int -xfs_vn_rmdir( +linvfs_rmdir( struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; - vnode_t *dvp = vn_from_inode(dir); - vattr_t vattr; + vnode_t *dvp = LINVFS_GET_VP(dir); int error; VOP_RMDIR(dvp, dentry, NULL, error); - if (likely(!error)) { - xfs_validate_fields(inode, &vattr); - xfs_validate_fields(dir, &vattr); + if (!error) { + validate_fields(inode); + validate_fields(dir); } return -error; } STATIC int -xfs_vn_rename( +linvfs_rename( struct inode *odir, struct dentry *odentry, struct inode *ndir, @@ -528,21 +526,22 @@ xfs_vn_rename( struct inode *new_inode = ndentry->d_inode; vnode_t *fvp; /* from directory */ vnode_t *tvp; /* target directory */ - vattr_t vattr; int error; - fvp = vn_from_inode(odir); - tvp = vn_from_inode(ndir); + fvp = LINVFS_GET_VP(odir); + tvp = LINVFS_GET_VP(ndir); VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error); - if (likely(!error)) { - if (new_inode) - xfs_validate_fields(new_inode, &vattr); - xfs_validate_fields(odir, &vattr); - if (ndir != odir) - xfs_validate_fields(ndir, &vattr); - } - return -error; + if (error) + return -error; + + if (new_inode) + validate_fields(new_inode); + + validate_fields(odir); + if (ndir != odir) + validate_fields(ndir); + return 0; } /* @@ -551,7 +550,7 @@ xfs_vn_rename( * uio is kmalloced for this reason... */ STATIC void * -xfs_vn_follow_link( +linvfs_follow_link( struct dentry *dentry, struct nameidata *nd) { @@ -577,7 +576,7 @@ xfs_vn_follow_link( return NULL; } - vp = vn_from_inode(dentry->d_inode); + vp = LINVFS_GET_VP(dentry->d_inode); iov.iov_base = link; iov.iov_len = MAXPATHLEN; @@ -602,7 +601,7 @@ xfs_vn_follow_link( } STATIC void -xfs_vn_put_link( +linvfs_put_link( struct dentry *dentry, struct nameidata *nd, void *p) @@ -615,12 +614,12 @@ xfs_vn_put_link( #ifdef CONFIG_XFS_POSIX_ACL STATIC int -xfs_vn_permission( +linvfs_permission( struct inode *inode, int mode, struct nameidata *nd) { - vnode_t *vp = vn_from_inode(inode); + vnode_t *vp = LINVFS_GET_VP(inode); int error; mode <<= 6; /* convert from linux to vnode access bits */ @@ -628,17 +627,17 @@ xfs_vn_permission( return -error; } #else -#define xfs_vn_permission NULL +#define linvfs_permission NULL #endif STATIC int -xfs_vn_getattr( +linvfs_getattr( struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct inode *inode = dentry->d_inode; - vnode_t *vp = vn_from_inode(inode); + vnode_t *vp = LINVFS_GET_VP(inode); int error = 0; if (unlikely(vp->v_flag & VMODIFIED)) @@ -649,14 +648,49 @@ xfs_vn_getattr( } STATIC int -xfs_vn_setattr( +linvfs_sync_flags(struct inode *inode) +{ + unsigned int oldflags, newflags; + vattr_t vattr; + int flags = 0; + int error; + vnode_t *vp = LINVFS_GET_VP(inode); + + memset(&vattr, 0, sizeof(vattr_t)); + + vattr.va_mask = XFS_AT_XFLAGS; + VOP_GETATTR(vp, &vattr, 0, NULL, error); + if (error) + return error; + oldflags = vattr.va_xflags; + newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE | + XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER); + + if (IS_IMMUTABLE(inode)) + newflags |= XFS_XFLAG_IMMUTABLE; + if (IS_IUNLINK(inode)) + newflags |= XFS_XFLAG_IUNLINK; + if (IS_BARRIER(inode)) + newflags |= XFS_XFLAG_BARRIER; + + if (oldflags ^ newflags) { + vattr.va_xflags = newflags; + vattr.va_mask |= XFS_AT_XFLAGS; + VOP_SETATTR(vp, &vattr, flags, NULL, error); + } + vn_revalidate(vp); + return error; +} + +STATIC int +linvfs_setattr( struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; unsigned int ia_valid = attr->ia_valid; - vnode_t *vp = vn_from_inode(inode); - vattr_t vattr = { 0 }; + vnode_t *vp = LINVFS_GET_VP(inode); + vattr_t vattr; int flags = 0; int error; @@ -664,6 +698,7 @@ xfs_vn_setattr( if (error) return error; + memset(&vattr, 0, sizeof(vattr_t)); if (ia_valid & ATTR_UID) { vattr.va_mask |= XFS_AT_UID; vattr.va_uid = attr->ia_uid; @@ -708,62 +743,28 @@ xfs_vn_setattr( #endif VOP_SETATTR(vp, &vattr, flags, NULL, error); - if (likely(!error)) - __vn_revalidate(vp, &vattr); - return -error; + if (error) + return -error; + vn_revalidate(vp); + return error; } STATIC void -xfs_vn_truncate( +linvfs_truncate( struct inode *inode) { - block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_blocks); -} - -STATIC int -xfs_vn_sync_flags(struct inode *inode) -{ - unsigned int oldflags, newflags; - vattr_t vattr; - int flags = 0; - int error; - vnode_t *vp = vn_from_inode(inode); - - memset(&vattr, 0, sizeof(vattr_t)); - - vattr.va_mask = XFS_AT_XFLAGS; - VOP_GETATTR(vp, &vattr, 0, NULL, error); - if (error) - return error; - oldflags = vattr.va_xflags; - newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE | - XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER); - - if (IS_IMMUTABLE(inode)) - newflags |= XFS_XFLAG_IMMUTABLE; - if (IS_IUNLINK(inode)) - newflags |= XFS_XFLAG_IUNLINK; - if (IS_BARRIER(inode)) - newflags |= XFS_XFLAG_BARRIER; - - if (oldflags ^ newflags) { - vattr.va_xflags = newflags; - vattr.va_mask |= XFS_AT_XFLAGS; - VOP_SETATTR(vp, &vattr, flags, NULL, error); - } - vn_revalidate(vp); - return error; + block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block); } STATIC int -xfs_vn_setxattr( +linvfs_setxattr( struct dentry *dentry, const char *name, const void *data, size_t size, int flags) { - vnode_t *vp = vn_from_inode(dentry->d_inode); + vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); char *attr = (char *)name; attrnames_t *namesp; int xflags = 0; @@ -787,13 +788,13 @@ xfs_vn_setxattr( } STATIC ssize_t -xfs_vn_getxattr( +linvfs_getxattr( struct dentry *dentry, const char *name, void *data, size_t size) { - vnode_t *vp = vn_from_inode(dentry->d_inode); + vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); char *attr = (char *)name; attrnames_t *namesp; int xflags = 0; @@ -817,12 +818,12 @@ xfs_vn_getxattr( } STATIC ssize_t -xfs_vn_listxattr( +linvfs_listxattr( struct dentry *dentry, char *data, size_t size) { - vnode_t *vp = vn_from_inode(dentry->d_inode); + vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); int error, xflags = ATTR_KERNAMELS; ssize_t result; @@ -837,11 +838,11 @@ xfs_vn_listxattr( } STATIC int -xfs_vn_removexattr( +linvfs_removexattr( struct dentry *dentry, const char *name) { - vnode_t *vp = vn_from_inode(dentry->d_inode); + vnode_t *vp = LINVFS_GET_VP(dentry->d_inode); char *attr = (char *)name; attrnames_t *namesp; int xflags = 0; @@ -859,48 +860,48 @@ xfs_vn_removexattr( } -struct inode_operations xfs_inode_operations = { - .permission = xfs_vn_permission, - .truncate = xfs_vn_truncate, - .getattr = xfs_vn_getattr, - .setattr = xfs_vn_setattr, - .setxattr = xfs_vn_setxattr, - .getxattr = xfs_vn_getxattr, - .listxattr = xfs_vn_listxattr, - .removexattr = xfs_vn_removexattr, - .sync_flags = xfs_vn_sync_flags, +struct inode_operations linvfs_file_inode_operations = { + .permission = linvfs_permission, + .truncate = linvfs_truncate, + .getattr = linvfs_getattr, + .setattr = linvfs_setattr, + .setxattr = linvfs_setxattr, + .getxattr = linvfs_getxattr, + .listxattr = linvfs_listxattr, + .removexattr = linvfs_removexattr, + .sync_flags = linvfs_sync_flags, }; -struct inode_operations xfs_dir_inode_operations = { - .create = xfs_vn_create, - .lookup = xfs_vn_lookup, - .link = xfs_vn_link, - .unlink = xfs_vn_unlink, - .symlink = xfs_vn_symlink, - .mkdir = xfs_vn_mkdir, - .rmdir = xfs_vn_rmdir, - .mknod = xfs_vn_mknod, - .rename = xfs_vn_rename, - .permission = xfs_vn_permission, - .getattr = xfs_vn_getattr, - .setattr = xfs_vn_setattr, - .setxattr = xfs_vn_setxattr, - .getxattr = xfs_vn_getxattr, - .listxattr = xfs_vn_listxattr, - .removexattr = xfs_vn_removexattr, - .sync_flags = xfs_vn_sync_flags, +struct inode_operations linvfs_dir_inode_operations = { + .create = linvfs_create, + .lookup = linvfs_lookup, + .link = linvfs_link, + .unlink = linvfs_unlink, + .symlink = linvfs_symlink, + .mkdir = linvfs_mkdir, + .rmdir = linvfs_rmdir, + .mknod = linvfs_mknod, + .rename = linvfs_rename, + .permission = linvfs_permission, + .getattr = linvfs_getattr, + .setattr = linvfs_setattr, + .setxattr = linvfs_setxattr, + .getxattr = linvfs_getxattr, + .listxattr = linvfs_listxattr, + .removexattr = linvfs_removexattr, + .sync_flags = linvfs_sync_flags, }; -struct inode_operations xfs_symlink_inode_operations = { +struct inode_operations linvfs_symlink_inode_operations = { .readlink = generic_readlink, - .follow_link = xfs_vn_follow_link, - .put_link = xfs_vn_put_link, - .permission = xfs_vn_permission, - .getattr = xfs_vn_getattr, - .setattr = xfs_vn_setattr, - .setxattr = xfs_vn_setxattr, - .getxattr = xfs_vn_getxattr, - .listxattr = xfs_vn_listxattr, - .removexattr = xfs_vn_removexattr, - .sync_flags = xfs_vn_sync_flags, + .follow_link = linvfs_follow_link, + .put_link = linvfs_put_link, + .permission = linvfs_permission, + .getattr = linvfs_getattr, + .setattr = linvfs_setattr, + .setxattr = linvfs_setxattr, + .getxattr = linvfs_getxattr, + .listxattr = linvfs_listxattr, + .removexattr = linvfs_removexattr, + .sync_flags = linvfs_sync_flags, };