Commit 4619f2ed authored by Christoph Hellwig's avatar Christoph Hellwig

[XFS] final sendfile bits

SGI Modid: 2.5.x-xfs:slinx:134450a
parent 5882eeaf
...@@ -215,54 +215,46 @@ xfs_sendfile( ...@@ -215,54 +215,46 @@ xfs_sendfile(
void *target, void *target,
cred_t *credp) cred_t *credp)
{ {
size_t size = 0;
ssize_t ret; ssize_t ret;
xfs_fsize_t n; xfs_fsize_t n;
xfs_inode_t *ip; xfs_inode_t *ip;
xfs_mount_t *mp;
vnode_t *vp; vnode_t *vp;
int invisible = (filp->f_mode & FINVIS);
ip = XFS_BHVTOI(bdp); ip = XFS_BHVTOI(bdp);
vp = BHV_TO_VNODE(bdp); vp = BHV_TO_VNODE(bdp);
mp = ip->i_mount;
vn_trace_entry(vp, "xfs_sendfile", (inst_t *)__return_address); vn_trace_entry(vp, "xfs_sendfile", (inst_t *)__return_address);
XFS_STATS_INC(xfsstats.xs_read_calls); XFS_STATS_INC(xfsstats.xs_read_calls);
n = XFS_MAX_FILE_OFFSET - *offp; n = XFS_MAX_FILE_OFFSET - *offp;
if ((n <= 0) || (size == 0)) if ((n <= 0) || (count == 0))
return 0; return 0;
if (n < size) if (n < count)
size = n; count = n;
if (XFS_FORCED_SHUTDOWN(mp)) { if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return -EIO; return -EIO;
}
xfs_ilock(ip, XFS_IOLOCK_SHARED); xfs_ilock(ip, XFS_IOLOCK_SHARED);
if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) && !invisible) {
if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
!(filp->f_mode & FINVIS)) {
int error;
vrwlock_t locktype = VRWLOCK_READ; vrwlock_t locktype = VRWLOCK_READ;
int error;
error = xfs_dm_send_data_event(DM_EVENT_READ, bdp, *offp, error = xfs_dm_send_data_event(DM_EVENT_READ, bdp, *offp,
size, FILP_DELAY_FLAG(filp), &locktype); count, FILP_DELAY_FLAG(filp), &locktype);
if (error) { if (error) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
return -error; return -error;
} }
} }
ret = generic_file_sendfile(filp, offp, count, actor, target); ret = generic_file_sendfile(filp, offp, count, actor, target);
xfs_iunlock(ip, XFS_IOLOCK_SHARED); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
XFS_STATS_ADD(xfsstats.xs_read_bytes, ret); XFS_STATS_ADD(xfsstats.xs_read_bytes, ret);
if (!invisible)
if (!(filp->f_mode & FINVIS))
xfs_ichgtime(ip, XFS_ICHGTIME_ACC); xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
return ret; return ret;
} }
......
...@@ -58,6 +58,9 @@ extern ssize_t xfs_read (struct bhv_desc *, struct file *, ...@@ -58,6 +58,9 @@ extern ssize_t xfs_read (struct bhv_desc *, struct file *,
extern ssize_t xfs_write (struct bhv_desc *, struct file *, extern ssize_t xfs_write (struct bhv_desc *, struct file *,
const struct iovec *, unsigned long, const struct iovec *, unsigned long,
loff_t *, struct cred *); loff_t *, struct cred *);
extern ssize_t xfs_sendfile (struct bhv_desc *, struct file *,
loff_t *, size_t, read_actor_t,
void *, struct cred *);
extern int xfs_dev_is_read_only (struct xfs_mount *, char *); extern int xfs_dev_is_read_only (struct xfs_mount *, char *);
......
...@@ -4870,6 +4870,7 @@ vnodeops_t xfs_vnodeops = { ...@@ -4870,6 +4870,7 @@ vnodeops_t xfs_vnodeops = {
BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS), BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS),
.vop_open = xfs_open, .vop_open = xfs_open,
.vop_read = xfs_read, .vop_read = xfs_read,
.vop_sendfile = xfs_sendfile,
.vop_write = xfs_write, .vop_write = xfs_write,
.vop_ioctl = xfs_ioctl, .vop_ioctl = xfs_ioctl,
.vop_getattr = xfs_getattr, .vop_getattr = xfs_getattr,
......
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