提交 993386c1 编写于 作者: C Christoph Hellwig 提交者: Tim Shimmin

[XFS] decontaminate vnode operations from behavior details

All vnode ops now take struct xfs_inode pointers and the behaviour related
glue is split out into methods of it's own. This required fixing
xfs_create/mkdir/symlink to not mess with the inode pointer but rather use
a separate boolean for error handling. Thanks to Dave Chinner for that
fix.

SGI-PV: 969608
SGI-Modid: xfs-linux-melb:xfs-kern:29492a
Signed-off-by: NChristoph Hellwig <hch@infradead.org>
Signed-off-by: NDavid Chinner <dgc@sgi.com>
Signed-off-by: NTim Shimmin <tes@sgi.com>
上级 b93bd20c
......@@ -89,6 +89,7 @@ xfs-y += xfs_alloc.o \
xfs_utils.o \
xfs_vfsops.o \
xfs_vnodeops.o \
xfs_vnodeops_bhv.o \
xfs_rw.o \
xfs_dmops.o \
xfs_qmops.o
......
......@@ -16,66 +16,80 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xfs.h"
#include "xfs_vnodeops.h"
/*
* The following six includes are needed so that we can include
* xfs_inode.h. What a mess..
*/
#include "xfs_bmap_btree.h"
#include "xfs_inum.h"
#include "xfs_dir2.h"
#include "xfs_dir2_sf.h"
#include "xfs_attr_sf.h"
#include "xfs_dinode.h"
#include "xfs_inode.h"
int fs_noerr(void) { return 0; }
int fs_nosys(void) { return ENOSYS; }
void fs_noval(void) { return; }
void
fs_tosspages(
bhv_desc_t *bdp,
xfs_tosspages(
xfs_inode_t *ip,
xfs_off_t first,
xfs_off_t last,
int fiopt)
{
bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
struct inode *ip = vn_to_inode(vp);
bhv_vnode_t *vp = XFS_ITOV(ip);
struct inode *inode = vn_to_inode(vp);
if (VN_CACHED(vp))
truncate_inode_pages(ip->i_mapping, first);
truncate_inode_pages(inode->i_mapping, first);
}
int
fs_flushinval_pages(
bhv_desc_t *bdp,
xfs_flushinval_pages(
xfs_inode_t *ip,
xfs_off_t first,
xfs_off_t last,
int fiopt)
{
bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
struct inode *ip = vn_to_inode(vp);
bhv_vnode_t *vp = XFS_ITOV(ip);
struct inode *inode = vn_to_inode(vp);
int ret = 0;
if (VN_CACHED(vp)) {
if (VN_TRUNC(vp))
VUNTRUNCATE(vp);
ret = filemap_write_and_wait(ip->i_mapping);
ret = filemap_write_and_wait(inode->i_mapping);
if (!ret)
truncate_inode_pages(ip->i_mapping, first);
truncate_inode_pages(inode->i_mapping, first);
}
return ret;
}
int
fs_flush_pages(
bhv_desc_t *bdp,
xfs_flush_pages(
xfs_inode_t *ip,
xfs_off_t first,
xfs_off_t last,
uint64_t flags,
int fiopt)
{
bhv_vnode_t *vp = BHV_TO_VNODE(bdp);
struct inode *ip = vn_to_inode(vp);
bhv_vnode_t *vp = XFS_ITOV(ip);
struct inode *inode = vn_to_inode(vp);
int ret = 0;
int ret2;
if (VN_DIRTY(vp)) {
if (VN_TRUNC(vp))
VUNTRUNCATE(vp);
ret = filemap_fdatawrite(ip->i_mapping);
ret = filemap_fdatawrite(inode->i_mapping);
if (flags & XFS_B_ASYNC)
return ret;
ret2 = filemap_fdatawait(ip->i_mapping);
ret2 = filemap_fdatawait(inode->i_mapping);
if (!ret)
ret = ret2;
}
......
......@@ -18,12 +18,8 @@
#ifndef __XFS_FS_SUBR_H__
#define __XFS_FS_SUBR_H__
struct cred;
extern int fs_noerr(void);
extern int fs_nosys(void);
extern void fs_noval(void);
extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
extern int fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
#endif /* __XFS_FS_SUBR_H__ */
......@@ -47,6 +47,7 @@
#include "xfs_utils.h"
#include "xfs_dfrag.h"
#include "xfs_fsops.h"
#include "xfs_vnodeops.h"
#include <linux/capability.h>
#include <linux/dcache.h>
......@@ -436,7 +437,6 @@ xfs_fssetdm_by_handle(
struct fsdmidata fsd;
xfs_fsop_setdm_handlereq_t dmhreq;
struct inode *inode;
bhv_desc_t *bdp;
bhv_vnode_t *vp;
if (!capable(CAP_MKNOD))
......@@ -458,8 +458,8 @@ xfs_fssetdm_by_handle(
return -XFS_ERROR(EFAULT);
}
bdp = bhv_base_unlocked(VN_BHV_HEAD(vp));
error = xfs_set_dmattrs(bdp, fsd.fsd_dmevmask, fsd.fsd_dmstate, NULL);
error = xfs_set_dmattrs(xfs_vtoi(vp),
fsd.fsd_dmevmask, fsd.fsd_dmstate);
VN_RELE(vp);
if (error)
......@@ -676,7 +676,7 @@ xfs_attrmulti_by_handle(
STATIC int
xfs_ioc_space(
bhv_desc_t *bdp,
struct xfs_inode *ip,
struct inode *inode,
struct file *filp,
int flags,
......@@ -709,37 +709,31 @@ xfs_ioc_xattr(
STATIC int
xfs_ioc_getbmap(
bhv_desc_t *bdp,
struct xfs_inode *ip,
int flags,
unsigned int cmd,
void __user *arg);
STATIC int
xfs_ioc_getbmapx(
bhv_desc_t *bdp,
struct xfs_inode *ip,
void __user *arg);
int
xfs_ioctl(
bhv_desc_t *bdp,
struct inode *inode,
xfs_inode_t *ip,
struct file *filp,
int ioflags,
unsigned int cmd,
void __user *arg)
{
struct inode *inode = filp->f_path.dentry->d_inode;
bhv_vnode_t *vp = vn_from_inode(inode);
xfs_mount_t *mp = ip->i_mount;
int error;
bhv_vnode_t *vp;
xfs_inode_t *ip;
xfs_mount_t *mp;
vp = vn_from_inode(inode);
vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
ip = XFS_BHVTOI(bdp);
mp = ip->i_mount;
switch (cmd) {
case XFS_IOC_ALLOCSP:
......@@ -758,7 +752,7 @@ xfs_ioctl(
!capable(CAP_SYS_ADMIN))
return -EPERM;
return xfs_ioc_space(bdp, inode, filp, ioflags, cmd, arg);
return xfs_ioc_space(ip, inode, filp, ioflags, cmd, arg);
case XFS_IOC_DIOINFO: {
struct dioattr da;
......@@ -801,17 +795,17 @@ xfs_ioctl(
if (copy_from_user(&dmi, arg, sizeof(dmi)))
return -XFS_ERROR(EFAULT);
error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate,
NULL);
error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask,
dmi.fsd_dmstate);
return -error;
}
case XFS_IOC_GETBMAP:
case XFS_IOC_GETBMAPA:
return xfs_ioc_getbmap(bdp, ioflags, cmd, arg);
return xfs_ioc_getbmap(ip, ioflags, cmd, arg);
case XFS_IOC_GETBMAPX:
return xfs_ioc_getbmapx(bdp, arg);
return xfs_ioc_getbmapx(ip, arg);
case XFS_IOC_FD_TO_HANDLE:
case XFS_IOC_PATH_TO_HANDLE:
......@@ -981,7 +975,7 @@ xfs_ioctl(
STATIC int
xfs_ioc_space(
bhv_desc_t *bdp,
struct xfs_inode *ip,
struct inode *inode,
struct file *filp,
int ioflags,
......@@ -1009,7 +1003,7 @@ xfs_ioc_space(
if (ioflags & IO_INVIS)
attr_flags |= ATTR_DMI;
error = xfs_change_file_space(bdp, cmd, &bf, filp->f_pos,
error = xfs_change_file_space(ip, cmd, &bf, filp->f_pos,
NULL, attr_flags);
return -error;
}
......@@ -1295,7 +1289,7 @@ xfs_ioc_xattr(
STATIC int
xfs_ioc_getbmap(
bhv_desc_t *bdp,
struct xfs_inode *ip,
int ioflags,
unsigned int cmd,
void __user *arg)
......@@ -1314,7 +1308,7 @@ xfs_ioc_getbmap(
if (ioflags & IO_INVIS)
iflags |= BMV_IF_NO_DMAPI_READ;
error = xfs_getbmap(bdp, &bm, (struct getbmap __user *)arg+1, iflags);
error = xfs_getbmap(ip, &bm, (struct getbmap __user *)arg+1, iflags);
if (error)
return -error;
......@@ -1325,7 +1319,7 @@ xfs_ioc_getbmap(
STATIC int
xfs_ioc_getbmapx(
bhv_desc_t *bdp,
struct xfs_inode *ip,
void __user *arg)
{
struct getbmapx bmx;
......@@ -1352,7 +1346,7 @@ xfs_ioc_getbmapx(
iflags |= BMV_IF_EXTENDED;
error = xfs_getbmap(bdp, &bm, (struct getbmapx __user *)arg+1, iflags);
error = xfs_getbmap(ip, &bm, (struct getbmapx __user *)arg+1, iflags);
if (error)
return -error;
......
......@@ -26,8 +26,6 @@ extern const struct file_operations xfs_file_operations;
extern const struct file_operations xfs_dir_file_operations;
extern const struct file_operations xfs_invis_file_operations;
extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
int, unsigned int, void __user *);
struct xfs_inode;
extern void xfs_ichgtime(struct xfs_inode *, int);
......
......@@ -48,6 +48,7 @@
#include "xfs_buf_item.h"
#include "xfs_utils.h"
#include "xfs_iomap.h"
#include "xfs_vnodeops.h"
#include <linux/capability.h>
#include <linux/writeback.h>
......@@ -180,27 +181,22 @@ xfs_iozero(
ssize_t /* bytes read, or (-) error */
xfs_read(
bhv_desc_t *bdp,
xfs_inode_t *ip,
struct kiocb *iocb,
const struct iovec *iovp,
unsigned int segs,
loff_t *offset,
int ioflags,
cred_t *credp)
int ioflags)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
size_t size = 0;
ssize_t ret = 0;
xfs_fsize_t n;
xfs_inode_t *ip;
xfs_mount_t *mp;
bhv_vnode_t *vp;
unsigned long seg;
ip = XFS_BHVTOI(bdp);
vp = BHV_TO_VNODE(bdp);
mp = ip->i_mount;
XFS_STATS_INC(xs_read_calls);
......@@ -249,8 +245,7 @@ xfs_read(
bhv_vrwlock_t locktype = VRWLOCK_READ;
int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
ret = -XFS_SEND_DATA(mp, DM_EVENT_READ,
BHV_TO_VNODE(bdp), *offset, size,
ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *offset, size,
dmflags, &locktype);
if (ret) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
......@@ -287,16 +282,15 @@ xfs_read(
ssize_t
xfs_splice_read(
bhv_desc_t *bdp,
xfs_inode_t *ip,
struct file *infilp,
loff_t *ppos,
struct pipe_inode_info *pipe,
size_t count,
int flags,
int ioflags,
cred_t *credp)
int ioflags)
{
xfs_inode_t *ip = XFS_BHVTOI(bdp);
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
ssize_t ret;
......@@ -310,8 +304,7 @@ xfs_splice_read(
bhv_vrwlock_t locktype = VRWLOCK_READ;
int error;
error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),
*ppos, count,
error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *ppos, count,
FILP_DELAY_FLAG(infilp), &locktype);
if (error) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
......@@ -330,16 +323,15 @@ xfs_splice_read(
ssize_t
xfs_splice_write(
bhv_desc_t *bdp,
xfs_inode_t *ip,
struct pipe_inode_info *pipe,
struct file *outfilp,
loff_t *ppos,
size_t count,
int flags,
int ioflags,
cred_t *credp)
int ioflags)
{
xfs_inode_t *ip = XFS_BHVTOI(bdp);
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
xfs_iocore_t *io = &ip->i_iocore;
ssize_t ret;
......@@ -356,8 +348,7 @@ xfs_splice_write(
bhv_vrwlock_t locktype = VRWLOCK_WRITE;
int error;
error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp),
*ppos, count,
error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp, *ppos, count,
FILP_DELAY_FLAG(outfilp), &locktype);
if (error) {
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
......@@ -591,24 +582,22 @@ xfs_zero_eof(
ssize_t /* bytes written, or (-) error */
xfs_write(
bhv_desc_t *bdp,
struct xfs_inode *xip,
struct kiocb *iocb,
const struct iovec *iovp,
unsigned int nsegs,
loff_t *offset,
int ioflags,
cred_t *credp)
int ioflags)
{
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
bhv_vnode_t *vp = XFS_ITOV(xip);
unsigned long segs = nsegs;
xfs_inode_t *xip;
xfs_mount_t *mp;
ssize_t ret = 0, error = 0;
xfs_fsize_t isize, new_size;
xfs_iocore_t *io;
bhv_vnode_t *vp;
int iolock;
int eventsent = 0;
bhv_vrwlock_t locktype;
......@@ -618,9 +607,6 @@ xfs_write(
XFS_STATS_INC(xs_write_calls);
vp = BHV_TO_VNODE(bdp);
xip = XFS_BHVTOI(bdp);
error = generic_segment_checks(iovp, &segs, &ocount, VERIFY_READ);
if (error)
return error;
......@@ -730,7 +716,7 @@ xfs_write(
*/
if (pos > xip->i_size) {
error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, pos, xip->i_size);
error = xfs_zero_eof(vp, io, pos, xip->i_size);
if (error) {
xfs_iunlock(xip, XFS_ILOCK_EXCL);
goto out_unlock_internal;
......@@ -815,7 +801,7 @@ xfs_write(
if (ret == -ENOSPC &&
DM_EVENT_ENABLED(xip, DM_EVENT_NOSPACE) && !(ioflags & IO_INVIS)) {
xfs_rwunlock(bdp, locktype);
xfs_rwunlock(xip, locktype);
if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
......@@ -823,7 +809,7 @@ xfs_write(
0, 0, 0); /* Delay flag intentionally unused */
if (need_i_mutex)
mutex_lock(&inode->i_mutex);
xfs_rwlock(bdp, locktype);
xfs_rwlock(xip, locktype);
if (error)
goto out_unlock_internal;
pos = xip->i_size;
......@@ -854,7 +840,7 @@ xfs_write(
if (error)
goto out_unlock_internal;
xfs_rwunlock(bdp, locktype);
xfs_rwunlock(xip, locktype);
if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
......@@ -863,7 +849,7 @@ xfs_write(
error = -ret;
if (need_i_mutex)
mutex_lock(&inode->i_mutex);
xfs_rwlock(bdp, locktype);
xfs_rwlock(xip, locktype);
}
out_unlock_internal:
......@@ -881,7 +867,7 @@ xfs_write(
xip->i_d.di_size = xip->i_size;
xfs_iunlock(xip, XFS_ILOCK_EXCL);
}
xfs_rwunlock(bdp, locktype);
xfs_rwunlock(xip, locktype);
out_unlock_mutex:
if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
......@@ -920,14 +906,14 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
int
xfs_bmap(bhv_desc_t *bdp,
xfs_bmap(
xfs_inode_t *ip,
xfs_off_t offset,
ssize_t count,
int flags,
xfs_iomap_t *iomapp,
int *niomaps)
{
xfs_inode_t *ip = XFS_BHVTOI(bdp);
xfs_iocore_t *io = &ip->i_iocore;
ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
......
......@@ -71,25 +71,11 @@ extern void xfs_inval_cached_trace(struct xfs_iocore *,
#define xfs_inval_cached_trace(io, offset, len, first, last)
#endif
extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
struct xfs_iomap *, int *);
extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
extern int xfs_bdstrat_cb(struct xfs_buf *);
extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
extern int xfs_zero_eof(struct bhv_vnode *, struct xfs_iocore *, xfs_off_t,
xfs_fsize_t);
extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
const struct iovec *, unsigned int,
loff_t *, int, struct cred *);
extern ssize_t xfs_write(struct bhv_desc *, struct kiocb *,
const struct iovec *, unsigned int,
loff_t *, int, struct cred *);
extern ssize_t xfs_splice_read(struct bhv_desc *, struct file *, loff_t *,
struct pipe_inode_info *, size_t, int, int,
struct cred *);
extern ssize_t xfs_splice_write(struct bhv_desc *, struct pipe_inode_info *,
struct file *, loff_t *, size_t, int, int,
struct cred *);
#endif /* __XFS_LRW_H__ */
......@@ -156,10 +156,14 @@ xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
}
int
xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp,
int flags, struct cred *cred)
xfs_attr_get(
xfs_inode_t *ip,
const char *name,
char *value,
int *valuelenp,
int flags,
cred_t *cred)
{
xfs_inode_t *ip = XFS_BHVTOI(bdp);
int error, namelen;
XFS_STATS_INC(xs_attr_get);
......@@ -417,10 +421,13 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
}
int
xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int flags,
struct cred *cred)
xfs_attr_set(
xfs_inode_t *dp,
const char *name,
char *value,
int valuelen,
int flags)
{
xfs_inode_t *dp;
int namelen;
namelen = strlen(name);
......@@ -429,7 +436,6 @@ xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int f
XFS_STATS_INC(xs_attr_set);
dp = XFS_BHVTOI(bdp);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);
......@@ -563,9 +569,11 @@ xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
}
int
xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
xfs_attr_remove(
xfs_inode_t *dp,
const char *name,
int flags)
{
xfs_inode_t *dp;
int namelen;
namelen = strlen(name);
......@@ -574,7 +582,6 @@ xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
XFS_STATS_INC(xs_attr_remove);
dp = XFS_BHVTOI(bdp);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return (EIO);
......@@ -702,11 +709,14 @@ xfs_attr_kern_list_sizes(xfs_attr_list_context_t *context, attrnames_t *namesp,
* success.
*/
int
xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags,
attrlist_cursor_kern_t *cursor, struct cred *cred)
xfs_attr_list(
xfs_inode_t *dp,
char *buffer,
int bufsize,
int flags,
attrlist_cursor_kern_t *cursor)
{
xfs_attr_list_context_t context;
xfs_inode_t *dp;
int error;
XFS_STATS_INC(xs_attr_list);
......@@ -731,7 +741,7 @@ xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags,
/*
* Initialize the output buffer.
*/
context.dp = dp = XFS_BHVTOI(bdp);
context.dp = dp;
context.cursor = cursor;
context.count = 0;
context.dupcnt = 0;
......
......@@ -159,12 +159,8 @@ struct xfs_da_args;
/*
* Overall external interface routines.
*/
int xfs_attr_get(bhv_desc_t *, const char *, char *, int *, int, struct cred *);
int xfs_attr_set(bhv_desc_t *, const char *, char *, int, int, struct cred *);
int xfs_attr_set_int(struct xfs_inode *, const char *, int, char *, int, int);
int xfs_attr_remove(bhv_desc_t *, const char *, int, struct cred *);
int xfs_attr_remove_int(struct xfs_inode *, const char *, int, int);
int xfs_attr_list(bhv_desc_t *, char *, int, int, struct attrlist_cursor_kern *, struct cred *);
int xfs_attr_list_int(struct xfs_attr_list_context *);
int xfs_attr_inactive(struct xfs_inode *dp);
......
......@@ -5764,7 +5764,7 @@ xfs_getbmapx_fix_eof_hole(
*/
int /* error code */
xfs_getbmap(
bhv_desc_t *bdp, /* XFS behavior descriptor*/
xfs_inode_t *ip,
struct getbmap *bmv, /* user bmap structure */
void __user *ap, /* pointer to user's array */
int interface) /* interface flags */
......@@ -5773,7 +5773,6 @@ xfs_getbmap(
int error; /* return value */
__int64_t fixlen; /* length for -1 case */
int i; /* extent number */
xfs_inode_t *ip; /* xfs incore inode pointer */
bhv_vnode_t *vp; /* corresponding vnode */
int lock; /* lock state */
xfs_bmbt_irec_t *map; /* buffer for user's data */
......@@ -5791,8 +5790,7 @@ xfs_getbmap(
int bmapi_flags; /* flags for xfs_bmapi */
__int32_t oflags; /* getbmapx bmv_oflags field */
vp = BHV_TO_VNODE(bdp);
ip = XFS_BHVTOI(bdp);
vp = XFS_ITOV(ip);
mp = ip->i_mount;
whichfork = interface & BMV_IF_ATTRFORK ? XFS_ATTR_FORK : XFS_DATA_FORK;
......
......@@ -335,7 +335,7 @@ xfs_bunmapi(
*/
int /* error code */
xfs_getbmap(
bhv_desc_t *bdp, /* XFS behavior descriptor*/
xfs_inode_t *ip,
struct getbmap *bmv, /* user bmap structure */
void __user *ap, /* pointer to user's array */
int iflags); /* interface flags */
......
......@@ -292,18 +292,16 @@ xfs_dir_removename(
*/
int
xfs_readdir(
bhv_desc_t *dir_bdp,
xfs_inode_t *dp,
void *dirent,
size_t bufsize,
xfs_off_t *offset,
filldir_t filldir)
{
xfs_inode_t *dp = XFS_BHVTOI(dir_bdp);
int rval; /* return value */
int v; /* type-checking value */
vn_trace_entry(BHV_TO_VNODE(dir_bdp), __FUNCTION__,
(inst_t *)__return_address);
vn_trace_entry(XFS_ITOV(dp), __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return XFS_ERROR(EIO);
......
......@@ -84,8 +84,6 @@ extern int xfs_dir_replace(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);
extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
extern int xfs_readdir(bhv_desc_t *dir_bdp, void *dirent, size_t bufsize,
xfs_off_t *offset, filldir_t filldir);
/*
* Utility routines for v2 directories.
......
......@@ -129,8 +129,7 @@ xfs_lock_for_rename(
lock_mode = xfs_ilock_map_shared(dp2);
}
error = xfs_dir_lookup_int(XFS_ITOBHV(dp2), lock_mode,
vname2, &inum2, &ip2);
error = xfs_dir_lookup_int(dp2, lock_mode, vname2, &inum2, &ip2);
if (error == ENOENT) { /* target does not need to exist. */
inum2 = 0;
} else if (error) {
......@@ -222,15 +221,15 @@ xfs_lock_for_rename(
*/
int
xfs_rename(
bhv_desc_t *src_dir_bdp,
xfs_inode_t *src_dp,
bhv_vname_t *src_vname,
bhv_vnode_t *target_dir_vp,
bhv_vname_t *target_vname,
cred_t *credp)
bhv_vname_t *target_vname)
{
bhv_vnode_t *src_dir_vp = XFS_ITOV(src_dp);
xfs_trans_t *tp;
xfs_inode_t *src_dp, *target_dp, *src_ip, *target_ip;
xfs_mount_t *mp;
xfs_inode_t *target_dp, *src_ip, *target_ip;
xfs_mount_t *mp = src_dp->i_mount;
int new_parent; /* moving to a new dir */
int src_is_directory; /* src_name is a directory */
int error;
......@@ -240,7 +239,6 @@ xfs_rename(
int committed;
xfs_inode_t *inodes[4];
int target_ip_dropped = 0; /* dropped target_ip link? */
bhv_vnode_t *src_dir_vp;
int spaceres;
int target_link_zero = 0;
int num_inodes;
......@@ -249,7 +247,6 @@ xfs_rename(
int src_namelen = VNAMELEN(src_vname);
int target_namelen = VNAMELEN(target_vname);
src_dir_vp = BHV_TO_VNODE(src_dir_bdp);
vn_trace_entry(src_dir_vp, "xfs_rename", (inst_t *)__return_address);
vn_trace_entry(target_dir_vp, "xfs_rename", (inst_t *)__return_address);
......@@ -262,9 +259,6 @@ xfs_rename(
return XFS_ERROR(EXDEV);
}
src_dp = XFS_BHVTOI(src_dir_bdp);
mp = src_dp->i_mount;
if (DM_EVENT_ENABLED(src_dp, DM_EVENT_RENAME) ||
DM_EVENT_ENABLED(target_dp, DM_EVENT_RENAME)) {
error = XFS_SEND_NAMESP(mp, DM_EVENT_RENAME,
......
......@@ -90,14 +90,6 @@ extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
/*
* Prototypes for functions in xfs_vnodeops.c.
*/
extern int xfs_rwlock(bhv_desc_t *bdp, bhv_vrwlock_t write_lock);
extern void xfs_rwunlock(bhv_desc_t *bdp, bhv_vrwlock_t write_lock);
extern int xfs_setattr(bhv_desc_t *, bhv_vattr_t *vap, int flags,
cred_t *credp);
extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf,
xfs_off_t offset, cred_t *credp, int flags);
extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state,
cred_t *credp);
extern int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip,
int flags);
......
......@@ -65,20 +65,15 @@ xfs_get_dir_entry(
int
xfs_dir_lookup_int(
bhv_desc_t *dir_bdp,
xfs_inode_t *dp,
uint lock_mode,
bhv_vname_t *dentry,
xfs_ino_t *inum,
xfs_inode_t **ipp)
{
bhv_vnode_t *dir_vp;
xfs_inode_t *dp;
int error;
dir_vp = BHV_TO_VNODE(dir_bdp);
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
dp = XFS_BHVTOI(dir_bdp);
vn_trace_entry(XFS_ITOV(dp), __FUNCTION__, (inst_t *)__return_address);
error = xfs_dir_lookup(NULL, dp, VNAME(dentry), VNAMELEN(dentry), inum);
if (!error) {
......
......@@ -23,10 +23,8 @@
#define ITRACE(ip) vn_trace_ref(XFS_ITOV(ip), __FILE__, __LINE__, \
(inst_t *)__return_address)
extern int xfs_rename (bhv_desc_t *, bhv_vname_t *, bhv_vnode_t *,
bhv_vname_t *, cred_t *);
extern int xfs_get_dir_entry (bhv_vname_t *, xfs_inode_t **);
extern int xfs_dir_lookup_int (bhv_desc_t *, uint, bhv_vname_t *, xfs_ino_t *,
extern int xfs_dir_lookup_int (xfs_inode_t *, uint, bhv_vname_t *, xfs_ino_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,
......
此差异已折叠。
#ifndef _XFS_VNODEOPS_H
#define _XFS_VNODEOPS_H 1
struct attrlist_cursor_kern;
struct bhv_vattr;
struct cred;
struct file;
struct inode;
struct iovec;
struct kiocb;
struct pipe_inode_info;
struct uio;
struct xfs_inode;
struct xfs_iomap;
int xfs_open(struct xfs_inode *ip);
int xfs_getattr(struct xfs_inode *ip, struct bhv_vattr *vap, int flags);
int xfs_setattr(struct xfs_inode *ip, struct bhv_vattr *vap, int flags,
struct cred *credp);
int xfs_access(struct xfs_inode *ip, int mode, struct cred *credp);
int xfs_readlink(struct xfs_inode *ip, char *link);
int xfs_fsync(struct xfs_inode *ip, int flag, xfs_off_t start,
xfs_off_t stop);
int xfs_release(struct xfs_inode *ip);
int xfs_inactive(struct xfs_inode *ip);
int xfs_lookup(struct xfs_inode *dp, bhv_vname_t *dentry,
bhv_vnode_t **vpp);
int xfs_create(struct xfs_inode *dp, bhv_vname_t *dentry,
struct bhv_vattr *vap, bhv_vnode_t **vpp, struct cred *credp);
int xfs_remove(struct xfs_inode *dp, bhv_vname_t *dentry);
int xfs_link(struct xfs_inode *tdp, bhv_vnode_t *src_vp,
bhv_vname_t *dentry);
int xfs_mkdir(struct xfs_inode *dp, bhv_vname_t *dentry,
struct bhv_vattr *vap, bhv_vnode_t **vpp, struct cred *credp);
int xfs_rmdir(struct xfs_inode *dp, bhv_vname_t *dentry);
int xfs_readdir(struct xfs_inode *dp, void *dirent, size_t bufsize,
xfs_off_t *offset, filldir_t filldir);
int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry,
struct bhv_vattr *vap, char *target_path,
bhv_vnode_t **vpp, struct cred *credp);
int xfs_fid2(struct xfs_inode *ip, fid_t *fidp);
int xfs_rwlock(struct xfs_inode *ip, bhv_vrwlock_t locktype);
void xfs_rwunlock(struct xfs_inode *ip, bhv_vrwlock_t locktype);
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_reclaim(struct xfs_inode *ip);
int xfs_change_file_space(struct xfs_inode *ip, int cmd,
xfs_flock64_t *bf, xfs_off_t offset,
struct cred *credp, int attr_flags);
int xfs_rename(struct xfs_inode *src_dp, bhv_vname_t *src_vname,
bhv_vnode_t *target_dir_vp, bhv_vname_t *target_vname);
int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value,
int *valuelenp, int flags, cred_t *cred);
int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
int valuelen, int flags);
int xfs_attr_remove(struct xfs_inode *dp, const char *name, int flags);
int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
int flags, struct attrlist_cursor_kern *cursor);
int xfs_ioctl(struct xfs_inode *ip, struct file *filp,
int ioflags, unsigned int cmd, void __user *arg);
ssize_t xfs_read(struct xfs_inode *ip, struct kiocb *iocb,
const struct iovec *iovp, unsigned int segs,
loff_t *offset, int ioflags);
ssize_t xfs_sendfile(struct xfs_inode *ip, struct file *filp,
loff_t *offset, int ioflags, size_t count,
read_actor_t actor, void *target);
ssize_t xfs_splice_read(struct xfs_inode *ip, struct file *infilp,
loff_t *ppos, struct pipe_inode_info *pipe, size_t count,
int flags, int ioflags);
ssize_t xfs_splice_write(struct xfs_inode *ip,
struct pipe_inode_info *pipe, struct file *outfilp,
loff_t *ppos, size_t count, int flags, int ioflags);
ssize_t xfs_write(struct xfs_inode *xip, struct kiocb *iocb,
const struct iovec *iovp, unsigned int nsegs,
loff_t *offset, int ioflags);
int xfs_bmap(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,
int flags, struct xfs_iomap *iomapp, int *niomaps);
void xfs_tosspages(struct xfs_inode *inode, xfs_off_t first,
xfs_off_t last, int fiopt);
int xfs_flushinval_pages(struct xfs_inode *ip, xfs_off_t first,
xfs_off_t last, int fiopt);
int xfs_flush_pages(struct xfs_inode *ip, xfs_off_t first,
xfs_off_t last, uint64_t flags, int fiopt);
#endif /* _XFS_VNODEOPS_H */
#include "xfs_linux.h"
#include "xfs_vnodeops.h"
#include "xfs_bmap_btree.h"
#include "xfs_inode.h"
STATIC int
xfs_bhv_open(
bhv_desc_t *bdp,
cred_t *credp)
{
return xfs_open(XFS_BHVTOI(bdp));
}
STATIC int
xfs_bhv_getattr(
bhv_desc_t *bdp,
bhv_vattr_t *vap,
int flags,
cred_t *credp)
{
return xfs_getattr(XFS_BHVTOI(bdp), vap, flags);
}
int
xfs_bhv_setattr(
bhv_desc_t *bdp,
bhv_vattr_t *vap,
int flags,
cred_t *credp)
{
return xfs_setattr(XFS_BHVTOI(bdp), vap, flags, credp);
}
STATIC int
xfs_bhv_access(
bhv_desc_t *bdp,
int mode,
cred_t *credp)
{
return xfs_access(XFS_BHVTOI(bdp), mode, credp);
}
STATIC int
xfs_bhv_readlink(
bhv_desc_t *bdp,
char *link)
{
return xfs_readlink(XFS_BHVTOI(bdp), link);
}
STATIC int
xfs_bhv_fsync(
bhv_desc_t *bdp,
int flag,
cred_t *credp,
xfs_off_t start,
xfs_off_t stop)
{
return xfs_fsync(XFS_BHVTOI(bdp), flag, start, stop);
}
STATIC int
xfs_bhv_release(
bhv_desc_t *bdp)
{
return xfs_release(XFS_BHVTOI(bdp));
}
STATIC int
xfs_bhv_inactive(
bhv_desc_t *bdp,
cred_t *credp)
{
return xfs_inactive(XFS_BHVTOI(bdp));
}
STATIC int
xfs_bhv_lookup(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
bhv_vnode_t **vpp,
int flags,
bhv_vnode_t *rdir,
cred_t *credp)
{
return xfs_lookup(XFS_BHVTOI(dir_bdp), dentry, vpp);
}
STATIC int
xfs_bhv_create(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
bhv_vattr_t *vap,
bhv_vnode_t **vpp,
cred_t *credp)
{
return xfs_create(XFS_BHVTOI(dir_bdp), dentry, vap, vpp, credp);
}
STATIC int
xfs_bhv_remove(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
cred_t *credp)
{
return xfs_remove(XFS_BHVTOI(dir_bdp), dentry);
}
STATIC int
xfs_bhv_link(
bhv_desc_t *target_dir_bdp,
bhv_vnode_t *src_vp,
bhv_vname_t *dentry,
cred_t *credp)
{
return xfs_link(XFS_BHVTOI(target_dir_bdp), src_vp, dentry);
}
STATIC int
xfs_bhv_mkdir(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
bhv_vattr_t *vap,
bhv_vnode_t **vpp,
cred_t *credp)
{
return xfs_mkdir(XFS_BHVTOI(dir_bdp), dentry, vap, vpp, credp);
}
STATIC int
xfs_bhv_rmdir(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
cred_t *credp)
{
return xfs_rmdir(XFS_BHVTOI(dir_bdp), dentry);
}
STATIC int
xfs_bhv_readdir(
bhv_desc_t *dir_bdp,
void *dirent,
size_t bufsize,
xfs_off_t *offset,
filldir_t filldir)
{
return xfs_readdir(XFS_BHVTOI(dir_bdp), dirent, bufsize, offset, filldir);
}
STATIC int
xfs_bhv_symlink(
bhv_desc_t *dir_bdp,
bhv_vname_t *dentry,
bhv_vattr_t *vap,
char *target_path,
bhv_vnode_t **vpp,
cred_t *credp)
{
return xfs_symlink(XFS_BHVTOI(dir_bdp), dentry, vap, target_path, vpp, credp);
}
STATIC int
xfs_bhv_fid2(
bhv_desc_t *bdp,
fid_t *fidp)
{
return xfs_fid2(XFS_BHVTOI(bdp), fidp);
}
STATIC int
xfs_bhv_rwlock(
bhv_desc_t *bdp,
bhv_vrwlock_t locktype)
{
return xfs_rwlock(XFS_BHVTOI(bdp), locktype);
}
STATIC void
xfs_bhv_rwunlock(
bhv_desc_t *bdp,
bhv_vrwlock_t locktype)
{
xfs_rwunlock(XFS_BHVTOI(bdp), locktype);
}
STATIC int
xfs_bhv_inode_flush(
bhv_desc_t *bdp,
int flags)
{
return xfs_inode_flush(XFS_BHVTOI(bdp), flags);
}
STATIC int
xfs_bhv_reclaim(
bhv_desc_t *bdp)
{
return xfs_reclaim(XFS_BHVTOI(bdp));
}
STATIC int
xfs_bhv_rename(
bhv_desc_t *src_dir_bdp,
bhv_vname_t *src_vname,
bhv_vnode_t *target_dir_vp,
bhv_vname_t *target_vname,
cred_t *credp)
{
return xfs_rename(XFS_BHVTOI(src_dir_bdp), src_vname,
target_dir_vp, target_vname);
}
STATIC int
xfs_bhv_attr_get(
bhv_desc_t *bdp,
const char *name,
char *value,
int *valuelenp,
int flags,
cred_t *cred)
{
return xfs_attr_get(XFS_BHVTOI(bdp), name, value, valuelenp,
flags, cred);
}
STATIC int
xfs_bhv_attr_set(
bhv_desc_t *bdp,
const char *name,
char *value,
int valuelen,
int flags,
cred_t *cred)
{
return xfs_attr_set(XFS_BHVTOI(bdp), name, value, valuelen,
flags);
}
STATIC int
xfs_bhv_attr_remove(
bhv_desc_t *bdp,
const char *name,
int flags,
cred_t *cred)
{
return xfs_attr_remove(XFS_BHVTOI(bdp), name, flags);
}
STATIC int
xfs_bhv_attr_list(
bhv_desc_t *bdp,
char *buffer,
int bufsize,
int flags,
struct attrlist_cursor_kern *cursor,
cred_t *cred)
{
return xfs_attr_list(XFS_BHVTOI(bdp), buffer, bufsize, flags,
cursor);
}
STATIC int
xfs_bhv_ioctl(
bhv_desc_t *bdp,
struct inode *inode,
struct file *filp,
int ioflags,
unsigned int cmd,
void __user *arg)
{
return xfs_ioctl(XFS_BHVTOI(bdp), filp, ioflags, cmd, arg);
}
STATIC ssize_t
xfs_bhv_read(
bhv_desc_t *bdp,
struct kiocb *iocb,
const struct iovec *iovp,
unsigned int segs,
loff_t *offset,
int ioflags,
cred_t *credp)
{
return xfs_read(XFS_BHVTOI(bdp), iocb, iovp, segs,
offset, ioflags);
}
STATIC ssize_t
xfs_bhv_sendfile(
bhv_desc_t *bdp,
struct file *filp,
loff_t *offset,
int ioflags,
size_t count,
read_actor_t actor,
void *target,
cred_t *credp)
{
return xfs_sendfile(XFS_BHVTOI(bdp), filp, offset, ioflags,
count, actor, target);
}
STATIC ssize_t
xfs_bhv_splice_read(
bhv_desc_t *bdp,
struct file *infilp,
loff_t *ppos,
struct pipe_inode_info *pipe,
size_t count,
int flags,
int ioflags,
cred_t *credp)
{
return xfs_splice_read(XFS_BHVTOI(bdp), infilp, ppos, pipe,
count, flags, ioflags);
}
STATIC ssize_t
xfs_bhv_splice_write(
bhv_desc_t *bdp,
struct pipe_inode_info *pipe,
struct file *outfilp,
loff_t *ppos,
size_t count,
int flags,
int ioflags,
cred_t *credp)
{
return xfs_splice_write(XFS_BHVTOI(bdp), pipe, outfilp, ppos,
count, flags, ioflags);
}
STATIC ssize_t
xfs_bhv_write(
bhv_desc_t *bdp,
struct kiocb *iocb,
const struct iovec *iovp,
unsigned int nsegs,
loff_t *offset,
int ioflags,
cred_t *credp)
{
return xfs_write(XFS_BHVTOI(bdp), iocb, iovp, nsegs, offset,
ioflags);
}
STATIC int
xfs_bhv_bmap(bhv_desc_t *bdp,
xfs_off_t offset,
ssize_t count,
int flags,
struct xfs_iomap *iomapp,
int *niomaps)
{
return xfs_bmap(XFS_BHVTOI(bdp), offset, count, flags,
iomapp, niomaps);
}
STATIC void
fs_tosspages(
bhv_desc_t *bdp,
xfs_off_t first,
xfs_off_t last,
int fiopt)
{
xfs_tosspages(XFS_BHVTOI(bdp), first, last, fiopt);
}
STATIC int
fs_flushinval_pages(
bhv_desc_t *bdp,
xfs_off_t first,
xfs_off_t last,
int fiopt)
{
return xfs_flushinval_pages(XFS_BHVTOI(bdp), first, last,
fiopt);
}
STATIC int
fs_flush_pages(
bhv_desc_t *bdp,
xfs_off_t first,
xfs_off_t last,
uint64_t flags,
int fiopt)
{
return xfs_flush_pages(XFS_BHVTOI(bdp), first, last, flags,
fiopt);
}
bhv_vnodeops_t xfs_vnodeops = {
BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS),
.vop_open = xfs_bhv_open,
.vop_read = xfs_bhv_read,
#ifdef HAVE_SENDFILE
.vop_sendfile = xfs_bhv_sendfile,
#endif
#ifdef HAVE_SPLICE
.vop_splice_read = xfs_bhv_splice_read,
.vop_splice_write = xfs_bhv_splice_write,
#endif
.vop_write = xfs_bhv_write,
.vop_ioctl = xfs_bhv_ioctl,
.vop_getattr = xfs_bhv_getattr,
.vop_setattr = xfs_bhv_setattr,
.vop_access = xfs_bhv_access,
.vop_lookup = xfs_bhv_lookup,
.vop_create = xfs_bhv_create,
.vop_remove = xfs_bhv_remove,
.vop_link = xfs_bhv_link,
.vop_rename = xfs_bhv_rename,
.vop_mkdir = xfs_bhv_mkdir,
.vop_rmdir = xfs_bhv_rmdir,
.vop_readdir = xfs_bhv_readdir,
.vop_symlink = xfs_bhv_symlink,
.vop_readlink = xfs_bhv_readlink,
.vop_fsync = xfs_bhv_fsync,
.vop_inactive = xfs_bhv_inactive,
.vop_fid2 = xfs_bhv_fid2,
.vop_rwlock = xfs_bhv_rwlock,
.vop_rwunlock = xfs_bhv_rwunlock,
.vop_bmap = xfs_bhv_bmap,
.vop_reclaim = xfs_bhv_reclaim,
.vop_attr_get = xfs_bhv_attr_get,
.vop_attr_set = xfs_bhv_attr_set,
.vop_attr_remove = xfs_bhv_attr_remove,
.vop_attr_list = xfs_bhv_attr_list,
.vop_link_removed = (vop_link_removed_t)fs_noval,
.vop_vnode_change = (vop_vnode_change_t)fs_noval,
.vop_tosspages = fs_tosspages,
.vop_flushinval_pages = fs_flushinval_pages,
.vop_flush_pages = fs_flush_pages,
.vop_release = xfs_bhv_release,
.vop_iflush = xfs_bhv_inode_flush,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册