aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-28 16:27:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-28 16:27:23 -0400
commit02a2b05395dde2f49e7777b67b51a5fbc6606943 (patch)
tree5d1aceee6e5a987772db092b27c49be67360fdb0 /fs/xfs/xfs_file.c
parente49aa15ef6c179f69e5578a271801f31a09e9a3f (diff)
parent5e5c943c1f257c2b3424fc3f8a7b18570152dab3 (diff)
Merge tag 'xfs-4.14-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: - fix various problems with the copy-on-write extent maps getting freed at the wrong time - fix printk format specifier problems - report zeroing operation outcomes instead of dropping them on the floor - fix some crashes when dio operations partially fail - fix a race condition between unwritten extent conversion & dio read - fix some incorrect tests in the inode log item processing - correct the delayed allocation space reservations on rmap filesystems - fix some problems checking for dax support * tag 'xfs-4.14-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: revert "xfs: factor rmap btree size into the indlen calculations" xfs: Capture state of the right inode in xfs_iflush_done xfs: perag initialization should only touch m_ag_max_usable for AG 0 xfs: update i_size after unwritten conversion in dio completion iomap_dio_rw: Allocate AIO completion queue before submitting dio xfs: validate bdev support for DAX inode flag xfs: remove redundant re-initialization of total_nr_pages xfs: Output warning message when discard option was enabled even though the device does not support discard xfs: report zeroed or not correctly in xfs_zero_range() xfs: kill meaningless variable 'zero' fs/xfs: Use %pS printk format for direct addresses xfs: evict CoW fork extents when performing finsert/fcollapse xfs: don't unconditionally clear the reflink flag on zero-block files
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r--fs/xfs/xfs_file.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index ebdd0bd2b261..309e26c9dddb 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -58,7 +58,7 @@ xfs_zero_range(
58 xfs_off_t count, 58 xfs_off_t count,
59 bool *did_zero) 59 bool *did_zero)
60{ 60{
61 return iomap_zero_range(VFS_I(ip), pos, count, NULL, &xfs_iomap_ops); 61 return iomap_zero_range(VFS_I(ip), pos, count, did_zero, &xfs_iomap_ops);
62} 62}
63 63
64int 64int
@@ -377,8 +377,6 @@ restart:
377 */ 377 */
378 spin_lock(&ip->i_flags_lock); 378 spin_lock(&ip->i_flags_lock);
379 if (iocb->ki_pos > i_size_read(inode)) { 379 if (iocb->ki_pos > i_size_read(inode)) {
380 bool zero = false;
381
382 spin_unlock(&ip->i_flags_lock); 380 spin_unlock(&ip->i_flags_lock);
383 if (!drained_dio) { 381 if (!drained_dio) {
384 if (*iolock == XFS_IOLOCK_SHARED) { 382 if (*iolock == XFS_IOLOCK_SHARED) {
@@ -399,7 +397,7 @@ restart:
399 drained_dio = true; 397 drained_dio = true;
400 goto restart; 398 goto restart;
401 } 399 }
402 error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero); 400 error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), NULL);
403 if (error) 401 if (error)
404 return error; 402 return error;
405 } else 403 } else
@@ -436,7 +434,6 @@ xfs_dio_write_end_io(
436 struct inode *inode = file_inode(iocb->ki_filp); 434 struct inode *inode = file_inode(iocb->ki_filp);
437 struct xfs_inode *ip = XFS_I(inode); 435 struct xfs_inode *ip = XFS_I(inode);
438 loff_t offset = iocb->ki_pos; 436 loff_t offset = iocb->ki_pos;
439 bool update_size = false;
440 int error = 0; 437 int error = 0;
441 438
442 trace_xfs_end_io_direct_write(ip, offset, size); 439 trace_xfs_end_io_direct_write(ip, offset, size);
@@ -447,6 +444,21 @@ xfs_dio_write_end_io(
447 if (size <= 0) 444 if (size <= 0)
448 return size; 445 return size;
449 446
447 if (flags & IOMAP_DIO_COW) {
448 error = xfs_reflink_end_cow(ip, offset, size);
449 if (error)
450 return error;
451 }
452
453 /*
454 * Unwritten conversion updates the in-core isize after extent
455 * conversion but before updating the on-disk size. Updating isize any
456 * earlier allows a racing dio read to find unwritten extents before
457 * they are converted.
458 */
459 if (flags & IOMAP_DIO_UNWRITTEN)
460 return xfs_iomap_write_unwritten(ip, offset, size, true);
461
450 /* 462 /*
451 * We need to update the in-core inode size here so that we don't end up 463 * We need to update the in-core inode size here so that we don't end up
452 * with the on-disk inode size being outside the in-core inode size. We 464 * with the on-disk inode size being outside the in-core inode size. We
@@ -461,20 +473,11 @@ xfs_dio_write_end_io(
461 spin_lock(&ip->i_flags_lock); 473 spin_lock(&ip->i_flags_lock);
462 if (offset + size > i_size_read(inode)) { 474 if (offset + size > i_size_read(inode)) {
463 i_size_write(inode, offset + size); 475 i_size_write(inode, offset + size);
464 update_size = true; 476 spin_unlock(&ip->i_flags_lock);
465 }
466 spin_unlock(&ip->i_flags_lock);
467
468 if (flags & IOMAP_DIO_COW) {
469 error = xfs_reflink_end_cow(ip, offset, size);
470 if (error)
471 return error;
472 }
473
474 if (flags & IOMAP_DIO_UNWRITTEN)
475 error = xfs_iomap_write_unwritten(ip, offset, size);
476 else if (update_size)
477 error = xfs_setfilesize(ip, offset, size); 477 error = xfs_setfilesize(ip, offset, size);
478 } else {
479 spin_unlock(&ip->i_flags_lock);
480 }
478 481
479 return error; 482 return error;
480} 483}