···103103 */104104#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */105105#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */106106+#define HAVE_SPLICE /* a splice(2) exists in 2.6, but not in 2.4 */106107#ifdef CONFIG_SMP107108#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */108109#else
+96-30
fs/xfs/linux-2.6/xfs_lrw.c
···301301 void *target,302302 cred_t *credp)303303{304304+ xfs_inode_t *ip = XFS_BHVTOI(bdp);305305+ xfs_mount_t *mp = ip->i_mount;304306 ssize_t ret;305305- xfs_fsize_t n;306306- xfs_inode_t *ip;307307- xfs_mount_t *mp;308308- vnode_t *vp;309309-310310- ip = XFS_BHVTOI(bdp);311311- vp = BHV_TO_VNODE(bdp);312312- mp = ip->i_mount;313307314308 XFS_STATS_INC(xs_read_calls);315315-316316- n = XFS_MAXIOFFSET(mp) - *offset;317317- if ((n <= 0) || (count == 0))318318- return 0;319319-320320- if (n < count)321321- count = n;322322-323323- if (XFS_FORCED_SHUTDOWN(ip->i_mount))309309+ if (XFS_FORCED_SHUTDOWN(mp))324310 return -EIO;325311326312 xfs_ilock(ip, XFS_IOLOCK_SHARED);327313328328- if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&314314+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&329315 (!(ioflags & IO_INVIS))) {330316 vrwlock_t locktype = VRWLOCK_READ;331317 int error;332318333333- error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,319319+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),320320+ *offset, count,334321 FILP_DELAY_FLAG(filp), &locktype);335322 if (error) {336323 xfs_iunlock(ip, XFS_IOLOCK_SHARED);···327340 xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,328341 (void *)(unsigned long)target, count, *offset, ioflags);329342 ret = generic_file_sendfile(filp, offset, count, actor, target);330330-331331- xfs_iunlock(ip, XFS_IOLOCK_SHARED);332332-333343 if (ret > 0)334344 XFS_STATS_ADD(xs_read_bytes, ret);335345346346+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);347347+ return ret;348348+}349349+350350+ssize_t351351+xfs_splice_read(352352+ bhv_desc_t *bdp,353353+ struct file *infilp,354354+ struct inode *pipe,355355+ size_t count,356356+ int flags,357357+ int ioflags,358358+ cred_t *credp)359359+{360360+ xfs_inode_t *ip = XFS_BHVTOI(bdp);361361+ xfs_mount_t *mp = ip->i_mount;362362+ ssize_t ret;363363+364364+ XFS_STATS_INC(xs_read_calls);365365+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))366366+ return -EIO;367367+368368+ xfs_ilock(ip, XFS_IOLOCK_SHARED);369369+370370+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&371371+ (!(ioflags & IO_INVIS))) {372372+ vrwlock_t locktype = VRWLOCK_READ;373373+ int error;374374+375375+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),376376+ infilp->f_pos, count,377377+ FILP_DELAY_FLAG(infilp), &locktype);378378+ if (error) {379379+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);380380+ return -error;381381+ }382382+ }383383+ xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, &ip->i_iocore,384384+ pipe, count, infilp->f_pos, ioflags);385385+ ret = generic_file_splice_read(infilp, pipe, count, flags);386386+ if (ret > 0)387387+ XFS_STATS_ADD(xs_read_bytes, ret);388388+389389+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);390390+ return ret;391391+}392392+393393+ssize_t394394+xfs_splice_write(395395+ bhv_desc_t *bdp,396396+ struct inode *pipe,397397+ struct file *outfilp,398398+ size_t count,399399+ int flags,400400+ int ioflags,401401+ cred_t *credp)402402+{403403+ xfs_inode_t *ip = XFS_BHVTOI(bdp);404404+ xfs_mount_t *mp = ip->i_mount;405405+ ssize_t ret;406406+407407+ XFS_STATS_INC(xs_write_calls);408408+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))409409+ return -EIO;410410+411411+ xfs_ilock(ip, XFS_IOLOCK_EXCL);412412+413413+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_WRITE) &&414414+ (!(ioflags & IO_INVIS))) {415415+ vrwlock_t locktype = VRWLOCK_WRITE;416416+ int error;417417+418418+ error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp),419419+ outfilp->f_pos, count,420420+ FILP_DELAY_FLAG(outfilp), &locktype);421421+ if (error) {422422+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);423423+ return -error;424424+ }425425+ }426426+ xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,427427+ pipe, count, outfilp->f_pos, ioflags);428428+ ret = generic_file_splice_write(pipe, outfilp, count, flags);429429+ if (ret > 0)430430+ XFS_STATS_ADD(xs_write_bytes, ret);431431+432432+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);336433 return ret;337434}338435···434363 xfs_fsize_t end_size)435364{436365 xfs_fileoff_t last_fsb;437437- xfs_mount_t *mp;366366+ xfs_mount_t *mp = io->io_mount;438367 int nimaps;439368 int zero_offset;440369 int zero_len;···443372 loff_t loff;444373445374 ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);446446-447447- mp = io->io_mount;448375449376 zero_offset = XFS_B_FSB_OFFSET(mp, isize);450377 if (zero_offset == 0) {···474405 * don't deadlock when the buffer cache calls back to us.475406 */476407 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);408408+477409 loff = XFS_FSB_TO_B(mp, last_fsb);478478-479410 zero_len = mp->m_sb.sb_blocksize - zero_offset;480480-481411 error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);482412483413 XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);···509441 xfs_fileoff_t zero_count_fsb;510442 xfs_fileoff_t last_fsb;511443 xfs_extlen_t buf_len_fsb;512512- xfs_mount_t *mp;444444+ xfs_mount_t *mp = io->io_mount;513445 int nimaps;514446 int error = 0;515447 xfs_bmbt_irec_t imap;···517449 ASSERT(ismrlocked(io->io_lock, MR_UPDATE));518450 ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));519451 ASSERT(offset > isize);520520-521521- mp = io->io_mount;522452523453 /*524454 * First handle zeroing the block on which isize resides.