Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+81 -56
+7 -7
fs/iomap.c
··· 1009 1009 WARN_ON_ONCE(ret); 1010 1010 ret = 0; 1011 1011 1012 + if (iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) && 1013 + !inode->i_sb->s_dio_done_wq) { 1014 + ret = sb_init_dio_done_wq(inode->i_sb); 1015 + if (ret < 0) 1016 + goto out_free_dio; 1017 + } 1018 + 1012 1019 inode_dio_begin(inode); 1013 1020 1014 1021 blk_start_plug(&plug); ··· 1037 1030 1038 1031 if (ret < 0) 1039 1032 iomap_dio_set_error(dio, ret); 1040 - 1041 - if (ret >= 0 && iov_iter_rw(iter) == WRITE && !is_sync_kiocb(iocb) && 1042 - !inode->i_sb->s_dio_done_wq) { 1043 - ret = sb_init_dio_done_wq(inode->i_sb); 1044 - if (ret < 0) 1045 - iomap_dio_set_error(dio, ret); 1046 - } 1047 1033 1048 1034 if (!atomic_dec_and_test(&dio->ref)) { 1049 1035 if (!is_sync_kiocb(iocb))
+10 -2
fs/xfs/libxfs/xfs_ag_resv.c
··· 156 156 trace_xfs_ag_resv_free(pag, type, 0); 157 157 158 158 resv = xfs_perag_resv(pag, type); 159 - pag->pag_mount->m_ag_max_usable += resv->ar_asked; 159 + if (pag->pag_agno == 0) 160 + pag->pag_mount->m_ag_max_usable += resv->ar_asked; 160 161 /* 161 162 * AGFL blocks are always considered "free", so whatever 162 163 * was reserved at mount time must be given back at umount. ··· 217 216 return error; 218 217 } 219 218 220 - mp->m_ag_max_usable -= ask; 219 + /* 220 + * Reduce the maximum per-AG allocation length by however much we're 221 + * trying to reserve for an AG. Since this is a filesystem-wide 222 + * counter, we only make the adjustment for AG 0. This assumes that 223 + * there aren't any AGs hungrier for per-AG reservation than AG 0. 224 + */ 225 + if (pag->pag_agno == 0) 226 + mp->m_ag_max_usable -= ask; 221 227 222 228 resv = xfs_perag_resv(pag, type); 223 229 resv->ar_asked = ask;
+2 -15
fs/xfs/libxfs/xfs_bmap.c
··· 49 49 #include "xfs_rmap.h" 50 50 #include "xfs_ag_resv.h" 51 51 #include "xfs_refcount.h" 52 - #include "xfs_rmap_btree.h" 53 52 #include "xfs_icache.h" 54 53 55 54 ··· 191 192 int maxrecs; /* maximum record count at this level */ 192 193 xfs_mount_t *mp; /* mount structure */ 193 194 xfs_filblks_t rval; /* return value */ 194 - xfs_filblks_t orig_len; 195 195 196 196 mp = ip->i_mount; 197 - 198 - /* Calculate the worst-case size of the bmbt. */ 199 - orig_len = len; 200 197 maxrecs = mp->m_bmap_dmxr[0]; 201 198 for (level = 0, rval = 0; 202 199 level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK); ··· 200 205 len += maxrecs - 1; 201 206 do_div(len, maxrecs); 202 207 rval += len; 203 - if (len == 1) { 204 - rval += XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 208 + if (len == 1) 209 + return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 205 210 level - 1; 206 - break; 207 - } 208 211 if (level == 0) 209 212 maxrecs = mp->m_bmap_dmxr[1]; 210 213 } 211 - 212 - /* Calculate the worst-case size of the rmapbt. */ 213 - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) 214 - rval += 1 + xfs_rmapbt_calc_size(mp, orig_len) + 215 - mp->m_rmap_maxlevels; 216 - 217 214 return rval; 218 215 } 219 216
+2 -1
fs/xfs/xfs_aops.c
··· 343 343 error = xfs_reflink_end_cow(ip, offset, size); 344 344 break; 345 345 case XFS_IO_UNWRITTEN: 346 - error = xfs_iomap_write_unwritten(ip, offset, size); 346 + /* writeback should never update isize */ 347 + error = xfs_iomap_write_unwritten(ip, offset, size, false); 347 348 break; 348 349 default: 349 350 ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_append_trans);
+13 -1
fs/xfs/xfs_bmap_util.c
··· 1459 1459 return error; 1460 1460 1461 1461 /* 1462 - * The extent shiting code works on extent granularity. So, if 1462 + * Clean out anything hanging around in the cow fork now that 1463 + * we've flushed all the dirty data out to disk to avoid having 1464 + * CoW extents at the wrong offsets. 1465 + */ 1466 + if (xfs_is_reflink_inode(ip)) { 1467 + error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF, 1468 + true); 1469 + if (error) 1470 + return error; 1471 + } 1472 + 1473 + /* 1474 + * The extent shifting code works on extent granularity. So, if 1463 1475 * stop_fsb is not the starting block of extent, we need to split 1464 1476 * the extent at stop_fsb. 1465 1477 */
-2
fs/xfs/xfs_buf.c
··· 1258 1258 int size; 1259 1259 int offset; 1260 1260 1261 - total_nr_pages = bp->b_page_count; 1262 - 1263 1261 /* skip the pages in the buffer before the start offset */ 1264 1262 page_index = 0; 1265 1263 offset = *buf_offset;
+1 -1
fs/xfs/xfs_error.c
··· 347 347 { 348 348 struct xfs_mount *mp = bp->b_target->bt_mount; 349 349 350 - xfs_alert(mp, "Metadata %s detected at %pF, %s block 0x%llx", 350 + xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx", 351 351 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", 352 352 __return_address, bp->b_ops->name, bp->b_bn); 353 353
+21 -18
fs/xfs/xfs_file.c
··· 58 58 xfs_off_t count, 59 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 64 64 int ··· 377 377 */ 378 378 spin_lock(&ip->i_flags_lock); 379 379 if (iocb->ki_pos > i_size_read(inode)) { 380 - bool zero = false; 381 - 382 380 spin_unlock(&ip->i_flags_lock); 383 381 if (!drained_dio) { 384 382 if (*iolock == XFS_IOLOCK_SHARED) { ··· 397 399 drained_dio = true; 398 400 goto restart; 399 401 } 400 - error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero); 402 + error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), NULL); 401 403 if (error) 402 404 return error; 403 405 } else ··· 434 436 struct inode *inode = file_inode(iocb->ki_filp); 435 437 struct xfs_inode *ip = XFS_I(inode); 436 438 loff_t offset = iocb->ki_pos; 437 - bool update_size = false; 438 439 int error = 0; 439 440 440 441 trace_xfs_end_io_direct_write(ip, offset, size); ··· 443 446 444 447 if (size <= 0) 445 448 return size; 449 + 450 + if (flags & IOMAP_DIO_COW) { 451 + error = xfs_reflink_end_cow(ip, offset, size); 452 + if (error) 453 + return error; 454 + } 455 + 456 + /* 457 + * Unwritten conversion updates the in-core isize after extent 458 + * conversion but before updating the on-disk size. Updating isize any 459 + * earlier allows a racing dio read to find unwritten extents before 460 + * they are converted. 461 + */ 462 + if (flags & IOMAP_DIO_UNWRITTEN) 463 + return xfs_iomap_write_unwritten(ip, offset, size, true); 446 464 447 465 /* 448 466 * We need to update the in-core inode size here so that we don't end up ··· 473 461 spin_lock(&ip->i_flags_lock); 474 462 if (offset + size > i_size_read(inode)) { 475 463 i_size_write(inode, offset + size); 476 - update_size = true; 477 - } 478 - spin_unlock(&ip->i_flags_lock); 479 - 480 - if (flags & IOMAP_DIO_COW) { 481 - error = xfs_reflink_end_cow(ip, offset, size); 482 - if (error) 483 - return error; 484 - } 485 - 486 - if (flags & IOMAP_DIO_UNWRITTEN) 487 - error = xfs_iomap_write_unwritten(ip, offset, size); 488 - else if (update_size) 464 + spin_unlock(&ip->i_flags_lock); 489 465 error = xfs_setfilesize(ip, offset, size); 466 + } else { 467 + spin_unlock(&ip->i_flags_lock); 468 + } 490 469 491 470 return error; 492 471 }
+5 -3
fs/xfs/xfs_inode.c
··· 1624 1624 goto out; 1625 1625 1626 1626 /* 1627 - * Clear the reflink flag if we truncated everything. 1627 + * Clear the reflink flag if there are no data fork blocks and 1628 + * there are no extents staged in the cow fork. 1628 1629 */ 1629 - if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) { 1630 - ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; 1630 + if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) { 1631 + if (ip->i_d.di_nblocks == 0) 1632 + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; 1631 1633 xfs_inode_clear_cowblocks_tag(ip); 1632 1634 } 1633 1635
+1 -1
fs/xfs/xfs_inode_item.c
··· 745 745 */ 746 746 iip = INODE_ITEM(blip); 747 747 if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) || 748 - lip->li_flags & XFS_LI_FAILED) 748 + (blip->li_flags & XFS_LI_FAILED)) 749 749 need_ail++; 750 750 751 751 blip = next;
+2 -1
fs/xfs/xfs_ioctl.c
··· 1088 1088 int *join_flags) 1089 1089 { 1090 1090 struct inode *inode = VFS_I(ip); 1091 + struct super_block *sb = inode->i_sb; 1091 1092 int error; 1092 1093 1093 1094 *join_flags = 0; ··· 1101 1100 if (fa->fsx_xflags & FS_XFLAG_DAX) { 1102 1101 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) 1103 1102 return -EINVAL; 1104 - if (ip->i_mount->m_sb.sb_blocksize != PAGE_SIZE) 1103 + if (bdev_dax_supported(sb, sb->s_blocksize) < 0) 1105 1104 return -EINVAL; 1106 1105 } 1107 1106
+5 -2
fs/xfs/xfs_iomap.c
··· 829 829 xfs_iomap_write_unwritten( 830 830 xfs_inode_t *ip, 831 831 xfs_off_t offset, 832 - xfs_off_t count) 832 + xfs_off_t count, 833 + bool update_isize) 833 834 { 834 835 xfs_mount_t *mp = ip->i_mount; 835 836 xfs_fileoff_t offset_fsb; ··· 841 840 xfs_trans_t *tp; 842 841 xfs_bmbt_irec_t imap; 843 842 struct xfs_defer_ops dfops; 843 + struct inode *inode = VFS_I(ip); 844 844 xfs_fsize_t i_size; 845 845 uint resblks; 846 846 int error; ··· 901 899 i_size = XFS_FSB_TO_B(mp, offset_fsb + count_fsb); 902 900 if (i_size > offset + count) 903 901 i_size = offset + count; 904 - 902 + if (update_isize && i_size > i_size_read(inode)) 903 + i_size_write(inode, i_size); 905 904 i_size = xfs_new_eof(ip, i_size); 906 905 if (i_size) { 907 906 ip->i_d.di_size = i_size;
+1 -1
fs/xfs/xfs_iomap.h
··· 27 27 struct xfs_bmbt_irec *, int); 28 28 int xfs_iomap_write_allocate(struct xfs_inode *, int, xfs_off_t, 29 29 struct xfs_bmbt_irec *); 30 - int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t); 30 + int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t, bool); 31 31 32 32 void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *, 33 33 struct xfs_bmbt_irec *);
+1 -1
fs/xfs/xfs_pnfs.c
··· 274 274 (end - 1) >> PAGE_SHIFT); 275 275 WARN_ON_ONCE(error); 276 276 277 - error = xfs_iomap_write_unwritten(ip, start, length); 277 + error = xfs_iomap_write_unwritten(ip, start, length, false); 278 278 if (error) 279 279 goto out_drop_iolock; 280 280 }
+10
fs/xfs/xfs_super.c
··· 1654 1654 "DAX and reflink have not been tested together!"); 1655 1655 } 1656 1656 1657 + if (mp->m_flags & XFS_MOUNT_DISCARD) { 1658 + struct request_queue *q = bdev_get_queue(sb->s_bdev); 1659 + 1660 + if (!blk_queue_discard(q)) { 1661 + xfs_warn(mp, "mounting with \"discard\" option, but " 1662 + "the device does not support discard"); 1663 + mp->m_flags &= ~XFS_MOUNT_DISCARD; 1664 + } 1665 + } 1666 + 1657 1667 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { 1658 1668 if (mp->m_sb.sb_rblocks) { 1659 1669 xfs_alert(mp,