diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_lrw.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_lrw.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 885dfafeabee..e0ab45fbfebd 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
@@ -233,8 +233,8 @@ xfs_read( | |||
233 | xfs_buftarg_t *target = | 233 | xfs_buftarg_t *target = |
234 | (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? | 234 | (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? |
235 | mp->m_rtdev_targp : mp->m_ddev_targp; | 235 | mp->m_rtdev_targp : mp->m_ddev_targp; |
236 | if ((*offset & target->pbr_smask) || | 236 | if ((*offset & target->bt_smask) || |
237 | (size & target->pbr_smask)) { | 237 | (size & target->bt_smask)) { |
238 | if (*offset == ip->i_d.di_size) { | 238 | if (*offset == ip->i_d.di_size) { |
239 | return (0); | 239 | return (0); |
240 | } | 240 | } |
@@ -281,9 +281,6 @@ xfs_read( | |||
281 | 281 | ||
282 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); | 282 | xfs_iunlock(ip, XFS_IOLOCK_SHARED); |
283 | 283 | ||
284 | if (likely(!(ioflags & IO_INVIS))) | ||
285 | xfs_ichgtime_fast(ip, inode, XFS_ICHGTIME_ACC); | ||
286 | |||
287 | unlock_isem: | 284 | unlock_isem: |
288 | if (unlikely(ioflags & IO_ISDIRECT)) | 285 | if (unlikely(ioflags & IO_ISDIRECT)) |
289 | mutex_unlock(&inode->i_mutex); | 286 | mutex_unlock(&inode->i_mutex); |
@@ -346,9 +343,6 @@ xfs_sendfile( | |||
346 | if (ret > 0) | 343 | if (ret > 0) |
347 | XFS_STATS_ADD(xs_read_bytes, ret); | 344 | XFS_STATS_ADD(xs_read_bytes, ret); |
348 | 345 | ||
349 | if (likely(!(ioflags & IO_INVIS))) | ||
350 | xfs_ichgtime_fast(ip, LINVFS_GET_IP(vp), XFS_ICHGTIME_ACC); | ||
351 | |||
352 | return ret; | 346 | return ret; |
353 | } | 347 | } |
354 | 348 | ||
@@ -362,7 +356,6 @@ STATIC int /* error (positive) */ | |||
362 | xfs_zero_last_block( | 356 | xfs_zero_last_block( |
363 | struct inode *ip, | 357 | struct inode *ip, |
364 | xfs_iocore_t *io, | 358 | xfs_iocore_t *io, |
365 | xfs_off_t offset, | ||
366 | xfs_fsize_t isize, | 359 | xfs_fsize_t isize, |
367 | xfs_fsize_t end_size) | 360 | xfs_fsize_t end_size) |
368 | { | 361 | { |
@@ -371,19 +364,16 @@ xfs_zero_last_block( | |||
371 | int nimaps; | 364 | int nimaps; |
372 | int zero_offset; | 365 | int zero_offset; |
373 | int zero_len; | 366 | int zero_len; |
374 | int isize_fsb_offset; | ||
375 | int error = 0; | 367 | int error = 0; |
376 | xfs_bmbt_irec_t imap; | 368 | xfs_bmbt_irec_t imap; |
377 | loff_t loff; | 369 | loff_t loff; |
378 | size_t lsize; | ||
379 | 370 | ||
380 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); | 371 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0); |
381 | ASSERT(offset > isize); | ||
382 | 372 | ||
383 | mp = io->io_mount; | 373 | mp = io->io_mount; |
384 | 374 | ||
385 | isize_fsb_offset = XFS_B_FSB_OFFSET(mp, isize); | 375 | zero_offset = XFS_B_FSB_OFFSET(mp, isize); |
386 | if (isize_fsb_offset == 0) { | 376 | if (zero_offset == 0) { |
387 | /* | 377 | /* |
388 | * There are no extra bytes in the last block on disk to | 378 | * There are no extra bytes in the last block on disk to |
389 | * zero, so return. | 379 | * zero, so return. |
@@ -413,10 +403,8 @@ xfs_zero_last_block( | |||
413 | */ | 403 | */ |
414 | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); | 404 | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD); |
415 | loff = XFS_FSB_TO_B(mp, last_fsb); | 405 | loff = XFS_FSB_TO_B(mp, last_fsb); |
416 | lsize = XFS_FSB_TO_B(mp, 1); | ||
417 | 406 | ||
418 | zero_offset = isize_fsb_offset; | 407 | zero_len = mp->m_sb.sb_blocksize - zero_offset; |
419 | zero_len = mp->m_sb.sb_blocksize - isize_fsb_offset; | ||
420 | 408 | ||
421 | error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size); | 409 | error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size); |
422 | 410 | ||
@@ -447,20 +435,17 @@ xfs_zero_eof( | |||
447 | struct inode *ip = LINVFS_GET_IP(vp); | 435 | struct inode *ip = LINVFS_GET_IP(vp); |
448 | xfs_fileoff_t start_zero_fsb; | 436 | xfs_fileoff_t start_zero_fsb; |
449 | xfs_fileoff_t end_zero_fsb; | 437 | xfs_fileoff_t end_zero_fsb; |
450 | xfs_fileoff_t prev_zero_fsb; | ||
451 | xfs_fileoff_t zero_count_fsb; | 438 | xfs_fileoff_t zero_count_fsb; |
452 | xfs_fileoff_t last_fsb; | 439 | xfs_fileoff_t last_fsb; |
453 | xfs_extlen_t buf_len_fsb; | 440 | xfs_extlen_t buf_len_fsb; |
454 | xfs_extlen_t prev_zero_count; | ||
455 | xfs_mount_t *mp; | 441 | xfs_mount_t *mp; |
456 | int nimaps; | 442 | int nimaps; |
457 | int error = 0; | 443 | int error = 0; |
458 | xfs_bmbt_irec_t imap; | 444 | xfs_bmbt_irec_t imap; |
459 | loff_t loff; | ||
460 | size_t lsize; | ||
461 | 445 | ||
462 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); | 446 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); |
463 | ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); | 447 | ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); |
448 | ASSERT(offset > isize); | ||
464 | 449 | ||
465 | mp = io->io_mount; | 450 | mp = io->io_mount; |
466 | 451 | ||
@@ -468,7 +453,7 @@ xfs_zero_eof( | |||
468 | * First handle zeroing the block on which isize resides. | 453 | * First handle zeroing the block on which isize resides. |
469 | * We only zero a part of that block so it is handled specially. | 454 | * We only zero a part of that block so it is handled specially. |
470 | */ | 455 | */ |
471 | error = xfs_zero_last_block(ip, io, offset, isize, end_size); | 456 | error = xfs_zero_last_block(ip, io, isize, end_size); |
472 | if (error) { | 457 | if (error) { |
473 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); | 458 | ASSERT(ismrlocked(io->io_lock, MR_UPDATE)); |
474 | ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); | 459 | ASSERT(ismrlocked(io->io_iolock, MR_UPDATE)); |
@@ -496,8 +481,6 @@ xfs_zero_eof( | |||
496 | } | 481 | } |
497 | 482 | ||
498 | ASSERT(start_zero_fsb <= end_zero_fsb); | 483 | ASSERT(start_zero_fsb <= end_zero_fsb); |
499 | prev_zero_fsb = NULLFILEOFF; | ||
500 | prev_zero_count = 0; | ||
501 | while (start_zero_fsb <= end_zero_fsb) { | 484 | while (start_zero_fsb <= end_zero_fsb) { |
502 | nimaps = 1; | 485 | nimaps = 1; |
503 | zero_count_fsb = end_zero_fsb - start_zero_fsb + 1; | 486 | zero_count_fsb = end_zero_fsb - start_zero_fsb + 1; |
@@ -519,10 +502,7 @@ xfs_zero_eof( | |||
519 | * that sits on a hole and sets the page as P_HOLE | 502 | * that sits on a hole and sets the page as P_HOLE |
520 | * and calls remapf if it is a mapped file. | 503 | * and calls remapf if it is a mapped file. |
521 | */ | 504 | */ |
522 | prev_zero_fsb = NULLFILEOFF; | 505 | start_zero_fsb = imap.br_startoff + imap.br_blockcount; |
523 | prev_zero_count = 0; | ||
524 | start_zero_fsb = imap.br_startoff + | ||
525 | imap.br_blockcount; | ||
526 | ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); | 506 | ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); |
527 | continue; | 507 | continue; |
528 | } | 508 | } |
@@ -543,17 +523,15 @@ xfs_zero_eof( | |||
543 | */ | 523 | */ |
544 | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); | 524 | XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD); |
545 | 525 | ||
546 | loff = XFS_FSB_TO_B(mp, start_zero_fsb); | 526 | error = xfs_iozero(ip, |
547 | lsize = XFS_FSB_TO_B(mp, buf_len_fsb); | 527 | XFS_FSB_TO_B(mp, start_zero_fsb), |
548 | 528 | XFS_FSB_TO_B(mp, buf_len_fsb), | |
549 | error = xfs_iozero(ip, loff, lsize, end_size); | 529 | end_size); |
550 | 530 | ||
551 | if (error) { | 531 | if (error) { |
552 | goto out_lock; | 532 | goto out_lock; |
553 | } | 533 | } |
554 | 534 | ||
555 | prev_zero_fsb = start_zero_fsb; | ||
556 | prev_zero_count = buf_len_fsb; | ||
557 | start_zero_fsb = imap.br_startoff + buf_len_fsb; | 535 | start_zero_fsb = imap.br_startoff + buf_len_fsb; |
558 | ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); | 536 | ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); |
559 | 537 | ||
@@ -640,7 +618,7 @@ xfs_write( | |||
640 | (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? | 618 | (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ? |
641 | mp->m_rtdev_targp : mp->m_ddev_targp; | 619 | mp->m_rtdev_targp : mp->m_ddev_targp; |
642 | 620 | ||
643 | if ((pos & target->pbr_smask) || (count & target->pbr_smask)) | 621 | if ((pos & target->bt_smask) || (count & target->bt_smask)) |
644 | return XFS_ERROR(-EINVAL); | 622 | return XFS_ERROR(-EINVAL); |
645 | 623 | ||
646 | if (!VN_CACHED(vp) && pos < i_size_read(inode)) | 624 | if (!VN_CACHED(vp) && pos < i_size_read(inode)) |
@@ -831,6 +809,10 @@ retry: | |||
831 | goto retry; | 809 | goto retry; |
832 | } | 810 | } |
833 | 811 | ||
812 | isize = i_size_read(inode); | ||
813 | if (unlikely(ret < 0 && ret != -EFAULT && *offset > isize)) | ||
814 | *offset = isize; | ||
815 | |||
834 | if (*offset > xip->i_d.di_size) { | 816 | if (*offset > xip->i_d.di_size) { |
835 | xfs_ilock(xip, XFS_ILOCK_EXCL); | 817 | xfs_ilock(xip, XFS_ILOCK_EXCL); |
836 | if (*offset > xip->i_d.di_size) { | 818 | if (*offset > xip->i_d.di_size) { |
@@ -956,7 +938,7 @@ xfs_bdstrat_cb(struct xfs_buf *bp) | |||
956 | 938 | ||
957 | mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *); | 939 | mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *); |
958 | if (!XFS_FORCED_SHUTDOWN(mp)) { | 940 | if (!XFS_FORCED_SHUTDOWN(mp)) { |
959 | pagebuf_iorequest(bp); | 941 | xfs_buf_iorequest(bp); |
960 | return 0; | 942 | return 0; |
961 | } else { | 943 | } else { |
962 | xfs_buftrace("XFS__BDSTRAT IOERROR", bp); | 944 | xfs_buftrace("XFS__BDSTRAT IOERROR", bp); |
@@ -1009,7 +991,7 @@ xfsbdstrat( | |||
1009 | * if (XFS_BUF_IS_GRIO(bp)) { | 991 | * if (XFS_BUF_IS_GRIO(bp)) { |
1010 | */ | 992 | */ |
1011 | 993 | ||
1012 | pagebuf_iorequest(bp); | 994 | xfs_buf_iorequest(bp); |
1013 | return 0; | 995 | return 0; |
1014 | } | 996 | } |
1015 | 997 | ||