···103 */104#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */105#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */0106#ifdef CONFIG_SMP107#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */108#else
···103 */104#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */105#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */106+#define HAVE_SPLICE /* a splice(2) exists in 2.6, but not in 2.4 */107#ifdef CONFIG_SMP108#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */109#else
+96-30
fs/xfs/linux-2.6/xfs_lrw.c
···301 void *target,302 cred_t *credp)303{00304 ssize_t ret;305- xfs_fsize_t n;306- xfs_inode_t *ip;307- xfs_mount_t *mp;308- vnode_t *vp;309-310- ip = XFS_BHVTOI(bdp);311- vp = BHV_TO_VNODE(bdp);312- mp = ip->i_mount;313314 XFS_STATS_INC(xs_read_calls);315-316- n = XFS_MAXIOFFSET(mp) - *offset;317- if ((n <= 0) || (count == 0))318- return 0;319-320- if (n < count)321- count = n;322-323- if (XFS_FORCED_SHUTDOWN(ip->i_mount))324 return -EIO;325326 xfs_ilock(ip, XFS_IOLOCK_SHARED);327328- if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&329 (!(ioflags & IO_INVIS))) {330 vrwlock_t locktype = VRWLOCK_READ;331 int error;332333- error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,0334 FILP_DELAY_FLAG(filp), &locktype);335 if (error) {336 xfs_iunlock(ip, XFS_IOLOCK_SHARED);···327 xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,328 (void *)(unsigned long)target, count, *offset, ioflags);329 ret = generic_file_sendfile(filp, offset, count, actor, target);330-331- xfs_iunlock(ip, XFS_IOLOCK_SHARED);332-333 if (ret > 0)334 XFS_STATS_ADD(xs_read_bytes, ret);335000000000000000000000000000000000000000000000000000000000000000000000000000000000000000336 return ret;337}338···434 xfs_fsize_t end_size)435{436 xfs_fileoff_t last_fsb;437- xfs_mount_t *mp;438 int nimaps;439 int zero_offset;440 int zero_len;···443 loff_t loff;444445 ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);446-447- mp = io->io_mount;448449 zero_offset = XFS_B_FSB_OFFSET(mp, isize);450 if (zero_offset == 0) {···474 * don't deadlock when the buffer cache calls back to us.475 */476 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);0477 loff = XFS_FSB_TO_B(mp, last_fsb);478-479 zero_len = mp->m_sb.sb_blocksize - zero_offset;480-481 error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);482483 XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);···509 xfs_fileoff_t zero_count_fsb;510 xfs_fileoff_t last_fsb;511 xfs_extlen_t buf_len_fsb;512- xfs_mount_t *mp;513 int nimaps;514 int error = 0;515 xfs_bmbt_irec_t imap;···517 ASSERT(ismrlocked(io->io_lock, MR_UPDATE));518 ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));519 ASSERT(offset > isize);520-521- mp = io->io_mount;522523 /*524 * First handle zeroing the block on which isize resides.
···301 void *target,302 cred_t *credp)303{304+ xfs_inode_t *ip = XFS_BHVTOI(bdp);305+ xfs_mount_t *mp = ip->i_mount;306 ssize_t ret;00000000307308 XFS_STATS_INC(xs_read_calls);309+ if (XFS_FORCED_SHUTDOWN(mp))00000000310 return -EIO;311312 xfs_ilock(ip, XFS_IOLOCK_SHARED);313314+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&315 (!(ioflags & IO_INVIS))) {316 vrwlock_t locktype = VRWLOCK_READ;317 int error;318319+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),320+ *offset, count,321 FILP_DELAY_FLAG(filp), &locktype);322 if (error) {323 xfs_iunlock(ip, XFS_IOLOCK_SHARED);···340 xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,341 (void *)(unsigned long)target, count, *offset, ioflags);342 ret = generic_file_sendfile(filp, offset, count, actor, target);000343 if (ret > 0)344 XFS_STATS_ADD(xs_read_bytes, ret);345346+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);347+ return ret;348+}349+350+ssize_t351+xfs_splice_read(352+ bhv_desc_t *bdp,353+ struct file *infilp,354+ struct inode *pipe,355+ size_t count,356+ int flags,357+ int ioflags,358+ cred_t *credp)359+{360+ xfs_inode_t *ip = XFS_BHVTOI(bdp);361+ xfs_mount_t *mp = ip->i_mount;362+ ssize_t ret;363+364+ XFS_STATS_INC(xs_read_calls);365+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))366+ return -EIO;367+368+ xfs_ilock(ip, XFS_IOLOCK_SHARED);369+370+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_READ) &&371+ (!(ioflags & IO_INVIS))) {372+ vrwlock_t locktype = VRWLOCK_READ;373+ int error;374+375+ error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp),376+ infilp->f_pos, count,377+ FILP_DELAY_FLAG(infilp), &locktype);378+ if (error) {379+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);380+ return -error;381+ }382+ }383+ xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, &ip->i_iocore,384+ pipe, count, infilp->f_pos, ioflags);385+ ret = generic_file_splice_read(infilp, pipe, count, flags);386+ if (ret > 0)387+ XFS_STATS_ADD(xs_read_bytes, ret);388+389+ xfs_iunlock(ip, XFS_IOLOCK_SHARED);390+ return ret;391+}392+393+ssize_t394+xfs_splice_write(395+ bhv_desc_t *bdp,396+ struct inode *pipe,397+ struct file *outfilp,398+ size_t count,399+ int flags,400+ int ioflags,401+ cred_t *credp)402+{403+ xfs_inode_t *ip = XFS_BHVTOI(bdp);404+ xfs_mount_t *mp = ip->i_mount;405+ ssize_t ret;406+407+ XFS_STATS_INC(xs_write_calls);408+ if (XFS_FORCED_SHUTDOWN(ip->i_mount))409+ return -EIO;410+411+ xfs_ilock(ip, XFS_IOLOCK_EXCL);412+413+ if (DM_EVENT_ENABLED(BHV_TO_VNODE(bdp)->v_vfsp, ip, DM_EVENT_WRITE) &&414+ (!(ioflags & IO_INVIS))) {415+ vrwlock_t locktype = VRWLOCK_WRITE;416+ int error;417+418+ error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, BHV_TO_VNODE(bdp),419+ outfilp->f_pos, count,420+ FILP_DELAY_FLAG(outfilp), &locktype);421+ if (error) {422+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);423+ return -error;424+ }425+ }426+ xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,427+ pipe, count, outfilp->f_pos, ioflags);428+ ret = generic_file_splice_write(pipe, outfilp, count, flags);429+ if (ret > 0)430+ XFS_STATS_ADD(xs_write_bytes, ret);431+432+ xfs_iunlock(ip, XFS_IOLOCK_EXCL);433 return ret;434}435···363 xfs_fsize_t end_size)364{365 xfs_fileoff_t last_fsb;366+ xfs_mount_t *mp = io->io_mount;367 int nimaps;368 int zero_offset;369 int zero_len;···372 loff_t loff;373374 ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);00375376 zero_offset = XFS_B_FSB_OFFSET(mp, isize);377 if (zero_offset == 0) {···405 * don't deadlock when the buffer cache calls back to us.406 */407 XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);408+409 loff = XFS_FSB_TO_B(mp, last_fsb);0410 zero_len = mp->m_sb.sb_blocksize - zero_offset;0411 error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);412413 XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);···441 xfs_fileoff_t zero_count_fsb;442 xfs_fileoff_t last_fsb;443 xfs_extlen_t buf_len_fsb;444+ xfs_mount_t *mp = io->io_mount;445 int nimaps;446 int error = 0;447 xfs_bmbt_irec_t imap;···449 ASSERT(ismrlocked(io->io_lock, MR_UPDATE));450 ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));451 ASSERT(offset > isize);00452453 /*454 * First handle zeroing the block on which isize resides.