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-5.17-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs updates from Darrick Wong:
"The big new feature here is that the mount code now only bothers to
try to free stale COW staging extents if the fs unmounted uncleanly.
This should reduce mount times, particularly on filesystems supporting
reflink and containing a large number of allocation groups.

Everything else this cycle are bugfixes, as the iomap folios
conversion should be plenty enough excitement for anyone. That and I
ran out of brain bandwidth after Thanksgiving last year.

Summary:

- Fix log recovery with da btree buffers when metauuid is in use.

- Fix type coercion problems in xattr buffer size validation.

- Fix a bug in online scrub dir leaf bestcount checking.

- Only run COW recovery when recovering the log.

- Fix symlink target buffer UAF problems and symlink locking problems
by not exposing xfs innards to the VFS.

- Fix incorrect quotaoff lock usage.

- Don't let transactions cancel cleanly if they have deferred work
items attached.

- Fix a UAF when we're deciding if we need to relog an intent item.

- Reduce kvmalloc overhead for log shadow buffers.

- Clean up sysfs attr group usage.

- Fix a bug where scrub's bmap/rmap checking could race with a quota
file block allocation due to insufficient locking.

- Teach scrub to complain about invalid project ids"

* tag 'xfs-5.17-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
xfs: warn about inodes with project id of -1
xfs: hold quota inode ILOCK_EXCL until the end of dqalloc
xfs: Remove redundant assignment of mp
xfs: reduce kvmalloc overhead for CIL shadow buffers
xfs: sysfs: use default_groups in kobj_type
xfs: prevent UAF in xfs_log_item_in_current_chkpt
xfs: prevent a WARN_ONCE() in xfs_ioc_attr_list()
xfs: Fix comments mentioning xfs_ialloc
xfs: check sb_meta_uuid for dabuf buffer recovery
xfs: fix a bug in the online fsck directory leaf1 bestcount check
xfs: only run COW extent recovery when there are no live extents
xfs: don't expose internal symlink metadata buffers to the vfs
xfs: fix quotaoff mutex usage now that we don't support disabling it
xfs: shut down filesystem if we xfs_trans_cancel with deferred work items

+175 -167
+11 -4
fs/xfs/scrub/dir.c
··· 497 497 xchk_directory_leaf1_bestfree( 498 498 struct xfs_scrub *sc, 499 499 struct xfs_da_args *args, 500 + xfs_dir2_db_t last_data_db, 500 501 xfs_dablk_t lblk) 501 502 { 502 503 struct xfs_dir3_icleaf_hdr leafhdr; ··· 535 534 } 536 535 537 536 /* 538 - * There should be as many bestfree slots as there are dir data 539 - * blocks that can fit under i_size. 537 + * There must be enough bestfree slots to cover all the directory data 538 + * blocks that we scanned. It is possible for there to be a hole 539 + * between the last data block and i_disk_size. This seems like an 540 + * oversight to the scrub author, but as we have been writing out 541 + * directories like this (and xfs_repair doesn't mind them) for years, 542 + * that's what we have to check. 540 543 */ 541 - if (bestcount != xfs_dir2_byte_to_db(geo, sc->ip->i_disk_size)) { 544 + if (bestcount != last_data_db + 1) { 542 545 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk); 543 546 goto out; 544 547 } ··· 674 669 xfs_fileoff_t lblk; 675 670 struct xfs_iext_cursor icur; 676 671 xfs_dablk_t dabno; 672 + xfs_dir2_db_t last_data_db = 0; 677 673 bool found; 678 674 int is_block = 0; 679 675 int error; ··· 718 712 args.geo->fsbcount); 719 713 lblk < got.br_startoff + got.br_blockcount; 720 714 lblk += args.geo->fsbcount) { 715 + last_data_db = xfs_dir2_da_to_db(args.geo, lblk); 721 716 error = xchk_directory_data_bestfree(sc, lblk, 722 717 is_block); 723 718 if (error) ··· 741 734 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk); 742 735 goto out; 743 736 } 744 - error = xchk_directory_leaf1_bestfree(sc, &args, 737 + error = xchk_directory_leaf1_bestfree(sc, &args, last_data_db, 745 738 leaf_lblk); 746 739 if (error) 747 740 goto out;
+14
fs/xfs/scrub/inode.c
··· 233 233 unsigned long long isize; 234 234 uint64_t flags2; 235 235 uint32_t nextents; 236 + prid_t prid; 236 237 uint16_t flags; 237 238 uint16_t mode; 238 239 ··· 268 267 * so just mark this inode for preening. 269 268 */ 270 269 xchk_ino_set_preen(sc, ino); 270 + prid = 0; 271 271 break; 272 272 case 2: 273 273 case 3: ··· 281 279 if (dip->di_projid_hi != 0 && 282 280 !xfs_has_projid32(mp)) 283 281 xchk_ino_set_corrupt(sc, ino); 282 + 283 + prid = be16_to_cpu(dip->di_projid_lo); 284 284 break; 285 285 default: 286 286 xchk_ino_set_corrupt(sc, ino); 287 287 return; 288 288 } 289 + 290 + if (xfs_has_projid32(mp)) 291 + prid |= (prid_t)be16_to_cpu(dip->di_projid_hi) << 16; 289 292 290 293 /* 291 294 * di_uid/di_gid -- -1 isn't invalid, but there's no way that ··· 298 291 */ 299 292 if (dip->di_uid == cpu_to_be32(-1U) || 300 293 dip->di_gid == cpu_to_be32(-1U)) 294 + xchk_ino_set_warning(sc, ino); 295 + 296 + /* 297 + * project id of -1 isn't supposed to be valid, but the kernel didn't 298 + * always validate that. 299 + */ 300 + if (prid == -1U) 301 301 xchk_ino_set_warning(sc, ino); 302 302 303 303 /* di_format */
+2 -2
fs/xfs/scrub/quota.c
··· 48 48 dqtype = xchk_quota_to_dqtype(sc); 49 49 if (dqtype == 0) 50 50 return -EINVAL; 51 - sc->flags |= XCHK_HAS_QUOTAOFFLOCK; 52 - mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock); 51 + 53 52 if (!xfs_this_quota_on(sc->mp, dqtype)) 54 53 return -ENOENT; 54 + 55 55 error = xchk_setup_fs(sc); 56 56 if (error) 57 57 return error;
+3
fs/xfs/scrub/repair.c
··· 25 25 #include "xfs_ag.h" 26 26 #include "xfs_ag_resv.h" 27 27 #include "xfs_quota.h" 28 + #include "xfs_qm.h" 28 29 #include "scrub/scrub.h" 29 30 #include "scrub/common.h" 30 31 #include "scrub/trace.h" ··· 913 912 if (!(flag & sc->mp->m_qflags)) 914 913 return; 915 914 915 + mutex_lock(&sc->mp->m_quotainfo->qi_quotaofflock); 916 916 sc->mp->m_qflags &= ~flag; 917 917 spin_lock(&sc->mp->m_sb_lock); 918 918 sc->mp->m_sb.sb_qflags &= ~flag; 919 919 spin_unlock(&sc->mp->m_sb_lock); 920 920 xfs_log_sb(sc->tp); 921 + mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock); 921 922 } 922 923 923 924 /*
-4
fs/xfs/scrub/scrub.c
··· 173 173 mnt_drop_write_file(sc->file); 174 174 if (sc->flags & XCHK_REAPING_DISABLED) 175 175 xchk_start_reaping(sc); 176 - if (sc->flags & XCHK_HAS_QUOTAOFFLOCK) { 177 - mutex_unlock(&sc->mp->m_quotainfo->qi_quotaofflock); 178 - sc->flags &= ~XCHK_HAS_QUOTAOFFLOCK; 179 - } 180 176 if (sc->buf) { 181 177 kmem_free(sc->buf); 182 178 sc->buf = NULL;
-1
fs/xfs/scrub/scrub.h
··· 88 88 89 89 /* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */ 90 90 #define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */ 91 - #define XCHK_HAS_QUOTAOFFLOCK (1 << 1) /* we hold the quotaoff lock */ 92 91 #define XCHK_REAPING_DISABLED (1 << 2) /* background block reaping paused */ 93 92 #define XREP_ALREADY_FIXED (1 << 31) /* checking our repair work */ 94 93
+1 -1
fs/xfs/xfs_buf_item_recover.c
··· 816 816 } 817 817 818 818 if (lsn != (xfs_lsn_t)-1) { 819 - if (!uuid_equal(&mp->m_sb.sb_uuid, uuid)) 819 + if (!uuid_equal(&mp->m_sb.sb_meta_uuid, uuid)) 820 820 goto recover_immediately; 821 821 return lsn; 822 822 }
+28 -51
fs/xfs/xfs_dquot.c
··· 289 289 */ 290 290 STATIC int 291 291 xfs_dquot_disk_alloc( 292 - struct xfs_trans **tpp, 293 292 struct xfs_dquot *dqp, 294 293 struct xfs_buf **bpp) 295 294 { 296 295 struct xfs_bmbt_irec map; 297 - struct xfs_trans *tp = *tpp; 298 - struct xfs_mount *mp = tp->t_mountp; 296 + struct xfs_trans *tp; 297 + struct xfs_mount *mp = dqp->q_mount; 299 298 struct xfs_buf *bp; 300 299 xfs_dqtype_t qtype = xfs_dquot_type(dqp); 301 300 struct xfs_inode *quotip = xfs_quota_inode(mp, qtype); ··· 303 304 304 305 trace_xfs_dqalloc(dqp); 305 306 307 + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc, 308 + XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp); 309 + if (error) 310 + return error; 311 + 306 312 xfs_ilock(quotip, XFS_ILOCK_EXCL); 313 + xfs_trans_ijoin(tp, quotip, 0); 314 + 307 315 if (!xfs_this_quota_on(dqp->q_mount, qtype)) { 308 316 /* 309 317 * Return if this type of quotas is turned off while we didn't 310 318 * have an inode lock 311 319 */ 312 - xfs_iunlock(quotip, XFS_ILOCK_EXCL); 313 - return -ESRCH; 320 + error = -ESRCH; 321 + goto err_cancel; 314 322 } 315 - 316 - xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL); 317 323 318 324 error = xfs_iext_count_may_overflow(quotip, XFS_DATA_FORK, 319 325 XFS_IEXT_ADD_NOSPLIT_CNT); 320 326 if (error) 321 - return error; 327 + goto err_cancel; 322 328 323 329 /* Create the block mapping. */ 324 330 error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset, 325 331 XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, 0, &map, 326 332 &nmaps); 327 333 if (error) 328 - return error; 334 + goto err_cancel; 335 + 329 336 ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); 330 337 ASSERT(nmaps == 1); 331 338 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ··· 346 341 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, 347 342 mp->m_quotainfo->qi_dqchunklen, 0, &bp); 348 343 if (error) 349 - return error; 344 + goto err_cancel; 350 345 bp->b_ops = &xfs_dquot_buf_ops; 351 346 352 347 /* ··· 376 371 * is responsible for unlocking any buffer passed back, either 377 372 * manually or by committing the transaction. On error, the buffer is 378 373 * released and not passed back. 374 + * 375 + * Keep the quota inode ILOCKed until after the transaction commit to 376 + * maintain the atomicity of bmap/rmap updates. 379 377 */ 380 378 xfs_trans_bhold(tp, bp); 381 - error = xfs_defer_finish(tpp); 379 + error = xfs_trans_commit(tp); 380 + xfs_iunlock(quotip, XFS_ILOCK_EXCL); 382 381 if (error) { 383 - xfs_trans_bhold_release(*tpp, bp); 384 - xfs_trans_brelse(*tpp, bp); 382 + xfs_buf_relse(bp); 385 383 return error; 386 384 } 385 + 387 386 *bpp = bp; 388 387 return 0; 388 + 389 + err_cancel: 390 + xfs_trans_cancel(tp); 391 + xfs_iunlock(quotip, XFS_ILOCK_EXCL); 392 + return error; 389 393 } 390 394 391 395 /* ··· 643 629 ddqp->d_rtbtimer = xfs_dquot_to_disk_ts(dqp, dqp->q_rtb.timer); 644 630 } 645 631 646 - /* Allocate and initialize the dquot buffer for this in-core dquot. */ 647 - static int 648 - xfs_qm_dqread_alloc( 649 - struct xfs_mount *mp, 650 - struct xfs_dquot *dqp, 651 - struct xfs_buf **bpp) 652 - { 653 - struct xfs_trans *tp; 654 - int error; 655 - 656 - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc, 657 - XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp); 658 - if (error) 659 - goto err; 660 - 661 - error = xfs_dquot_disk_alloc(&tp, dqp, bpp); 662 - if (error) 663 - goto err_cancel; 664 - 665 - error = xfs_trans_commit(tp); 666 - if (error) { 667 - /* 668 - * Buffer was held to the transaction, so we have to unlock it 669 - * manually here because we're not passing it back. 670 - */ 671 - xfs_buf_relse(*bpp); 672 - *bpp = NULL; 673 - goto err; 674 - } 675 - return 0; 676 - 677 - err_cancel: 678 - xfs_trans_cancel(tp); 679 - err: 680 - return error; 681 - } 682 - 683 632 /* 684 633 * Read in the ondisk dquot using dqtobp() then copy it to an incore version, 685 634 * and release the buffer immediately. If @can_alloc is true, fill any ··· 666 689 /* Try to read the buffer, allocating if necessary. */ 667 690 error = xfs_dquot_disk_read(mp, dqp, &bp); 668 691 if (error == -ENOENT && can_alloc) 669 - error = xfs_qm_dqread_alloc(mp, dqp, &bp); 692 + error = xfs_dquot_disk_alloc(dqp, &bp); 670 693 if (error) 671 694 goto err; 672 695
+2 -1
fs/xfs/xfs_error.c
··· 213 213 XFS_ERRORTAG_ATTR_LIST(ag_resv_fail), 214 214 NULL, 215 215 }; 216 + ATTRIBUTE_GROUPS(xfs_errortag); 216 217 217 218 static struct kobj_type xfs_errortag_ktype = { 218 219 .release = xfs_sysfs_release, 219 220 .sysfs_ops = &xfs_errortag_sysfs_ops, 220 - .default_attrs = xfs_errortag_attrs, 221 + .default_groups = xfs_errortag_groups, 221 222 }; 222 223 223 224 int
+2 -1
fs/xfs/xfs_icache.c
··· 749 749 750 750 /* 751 751 * If we have a real type for an on-disk inode, we can setup the inode 752 - * now. If it's a new inode being created, xfs_ialloc will handle it. 752 + * now. If it's a new inode being created, xfs_init_new_inode will 753 + * handle it. 753 754 */ 754 755 if (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0) 755 756 xfs_setup_existing_inode(ip);
+1 -1
fs/xfs/xfs_ioctl.c
··· 372 372 xfs_ioc_attr_list( 373 373 struct xfs_inode *dp, 374 374 void __user *ubuf, 375 - int bufsize, 375 + size_t bufsize, 376 376 int flags, 377 377 struct xfs_attrlist_cursor __user *ucursor) 378 378 {
+3 -2
fs/xfs/xfs_ioctl.h
··· 38 38 int xfs_ioc_attrmulti_one(struct file *parfilp, struct inode *inode, 39 39 uint32_t opcode, void __user *uname, void __user *value, 40 40 uint32_t *len, uint32_t flags); 41 - int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, int bufsize, 42 - int flags, struct xfs_attrlist_cursor __user *ucursor); 41 + int xfs_ioc_attr_list(struct xfs_inode *dp, void __user *ubuf, 42 + size_t bufsize, int flags, 43 + struct xfs_attrlist_cursor __user *ucursor); 43 44 44 45 extern struct dentry * 45 46 xfs_handle_to_dentry(
+4 -36
fs/xfs/xfs_iops.c
··· 511 511 return ERR_PTR(error); 512 512 } 513 513 514 - STATIC const char * 515 - xfs_vn_get_link_inline( 516 - struct dentry *dentry, 517 - struct inode *inode, 518 - struct delayed_call *done) 519 - { 520 - struct xfs_inode *ip = XFS_I(inode); 521 - char *link; 522 - 523 - ASSERT(ip->i_df.if_format == XFS_DINODE_FMT_LOCAL); 524 - 525 - /* 526 - * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if 527 - * if_data is junk. 528 - */ 529 - link = ip->i_df.if_u1.if_data; 530 - if (XFS_IS_CORRUPT(ip->i_mount, !link)) 531 - return ERR_PTR(-EFSCORRUPTED); 532 - return link; 533 - } 534 - 535 514 static uint32_t 536 515 xfs_stat_blksize( 537 516 struct xfs_inode *ip) ··· 1229 1250 .update_time = xfs_vn_update_time, 1230 1251 }; 1231 1252 1232 - static const struct inode_operations xfs_inline_symlink_inode_operations = { 1233 - .get_link = xfs_vn_get_link_inline, 1234 - .getattr = xfs_vn_getattr, 1235 - .setattr = xfs_vn_setattr, 1236 - .listxattr = xfs_vn_listxattr, 1237 - .update_time = xfs_vn_update_time, 1238 - }; 1239 - 1240 1253 /* Figure out if this file actually supports DAX. */ 1241 1254 static bool 1242 1255 xfs_inode_supports_dax( ··· 1303 1332 * Initialize the Linux inode. 1304 1333 * 1305 1334 * When reading existing inodes from disk this is called directly from xfs_iget, 1306 - * when creating a new inode it is called from xfs_ialloc after setting up the 1307 - * inode. These callers have different criteria for clearing XFS_INEW, so leave 1308 - * it up to the caller to deal with unlocking the inode appropriately. 1335 + * when creating a new inode it is called from xfs_init_new_inode after setting 1336 + * up the inode. These callers have different criteria for clearing XFS_INEW, so 1337 + * leave it up to the caller to deal with unlocking the inode appropriately. 1309 1338 */ 1310 1339 void 1311 1340 xfs_setup_inode( ··· 1379 1408 inode->i_fop = &xfs_dir_file_operations; 1380 1409 break; 1381 1410 case S_IFLNK: 1382 - if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) 1383 - inode->i_op = &xfs_inline_symlink_inode_operations; 1384 - else 1385 - inode->i_op = &xfs_symlink_inode_operations; 1411 + inode->i_op = &xfs_symlink_inode_operations; 1386 1412 break; 1387 1413 default: 1388 1414 inode->i_op = &xfs_inode_operations;
+38 -14
fs/xfs/xfs_log_cil.c
··· 103 103 } 104 104 105 105 /* 106 + * shadow buffers can be large, so we need to use kvmalloc() here to ensure 107 + * success. Unfortunately, kvmalloc() only allows GFP_KERNEL contexts to fall 108 + * back to vmalloc, so we can't actually do anything useful with gfp flags to 109 + * control the kmalloc() behaviour within kvmalloc(). Hence kmalloc() will do 110 + * direct reclaim and compaction in the slow path, both of which are 111 + * horrendously expensive. We just want kmalloc to fail fast and fall back to 112 + * vmalloc if it can't get somethign straight away from the free lists or buddy 113 + * allocator. Hence we have to open code kvmalloc outselves here. 114 + * 115 + * Also, we are in memalloc_nofs_save task context here, so despite the use of 116 + * GFP_KERNEL here, we are actually going to be doing GFP_NOFS allocations. This 117 + * is actually the only way to make vmalloc() do GFP_NOFS allocations, so lets 118 + * just all pretend this is a GFP_KERNEL context operation.... 119 + */ 120 + static inline void * 121 + xlog_cil_kvmalloc( 122 + size_t buf_size) 123 + { 124 + gfp_t flags = GFP_KERNEL; 125 + void *p; 126 + 127 + flags &= ~__GFP_DIRECT_RECLAIM; 128 + flags |= __GFP_NOWARN | __GFP_NORETRY; 129 + do { 130 + p = kmalloc(buf_size, flags); 131 + if (!p) 132 + p = vmalloc(buf_size); 133 + } while (!p); 134 + 135 + return p; 136 + } 137 + 138 + /* 106 139 * Allocate or pin log vector buffers for CIL insertion. 107 140 * 108 141 * The CIL currently uses disposable buffers for copying a snapshot of the ··· 236 203 */ 237 204 if (!lip->li_lv_shadow || 238 205 buf_size > lip->li_lv_shadow->lv_size) { 239 - 240 206 /* 241 207 * We free and allocate here as a realloc would copy 242 - * unnecessary data. We don't use kmem_zalloc() for the 208 + * unnecessary data. We don't use kvzalloc() for the 243 209 * same reason - we don't need to zero the data area in 244 210 * the buffer, only the log vector header and the iovec 245 211 * storage. 246 212 */ 247 213 kmem_free(lip->li_lv_shadow); 214 + lv = xlog_cil_kvmalloc(buf_size); 248 215 249 - /* 250 - * We are in transaction context, which means this 251 - * allocation will pick up GFP_NOFS from the 252 - * memalloc_nofs_save/restore context the transaction 253 - * holds. This means we can use GFP_KERNEL here so the 254 - * generic kvmalloc() code will run vmalloc on 255 - * contiguous page allocation failure as we require. 256 - */ 257 - lv = kvmalloc(buf_size, GFP_KERNEL); 258 216 memset(lv, 0, xlog_cil_iovec_space(niovecs)); 259 217 260 218 lv->lv_item = lip; ··· 1466 1442 */ 1467 1443 bool 1468 1444 xfs_log_item_in_current_chkpt( 1469 - struct xfs_log_item *lip) 1445 + struct xfs_log_item *lip) 1470 1446 { 1471 - struct xfs_cil_ctx *ctx = lip->li_mountp->m_log->l_cilp->xc_ctx; 1447 + struct xfs_cil *cil = lip->li_mountp->m_log->l_cilp; 1472 1448 1473 1449 if (list_empty(&lip->li_cil)) 1474 1450 return false; ··· 1478 1454 * first checkpoint it is written to. Hence if it is different to the 1479 1455 * current sequence, we're in a new checkpoint. 1480 1456 */ 1481 - return lip->li_seq == ctx->sequence; 1457 + return lip->li_seq == READ_ONCE(cil->xc_current_sequence); 1482 1458 } 1483 1459 1484 1460 /*
+23 -3
fs/xfs/xfs_log_recover.c
··· 27 27 #include "xfs_buf_item.h" 28 28 #include "xfs_ag.h" 29 29 #include "xfs_quota.h" 30 - 30 + #include "xfs_reflink.h" 31 31 32 32 #define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1) 33 33 ··· 3498 3498 3499 3499 xlog_recover_process_iunlinks(log); 3500 3500 xlog_recover_check_summary(log); 3501 + 3502 + /* 3503 + * Recover any CoW staging blocks that are still referenced by the 3504 + * ondisk refcount metadata. During mount there cannot be any live 3505 + * staging extents as we have not permitted any user modifications. 3506 + * Therefore, it is safe to free them all right now, even on a 3507 + * read-only mount. 3508 + */ 3509 + error = xfs_reflink_recover_cow(log->l_mp); 3510 + if (error) { 3511 + xfs_alert(log->l_mp, 3512 + "Failed to recover leftover CoW staging extents, err %d.", 3513 + error); 3514 + /* 3515 + * If we get an error here, make sure the log is shut down 3516 + * but return zero so that any log items committed since the 3517 + * end of intents processing can be pushed through the CIL 3518 + * and AIL. 3519 + */ 3520 + xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); 3521 + } 3522 + 3501 3523 return 0; 3502 3524 } 3503 3525 ··· 3549 3527 uint64_t itotal; 3550 3528 uint64_t ifree; 3551 3529 int error; 3552 - 3553 - mp = log->l_mp; 3554 3530 3555 3531 freeblks = 0LL; 3556 3532 itotal = 0LL;
-10
fs/xfs/xfs_mount.c
··· 936 936 xfs_warn(mp, 937 937 "Unable to allocate reserve blocks. Continuing without reserve pool."); 938 938 939 - /* Recover any CoW blocks that never got remapped. */ 940 - error = xfs_reflink_recover_cow(mp); 941 - if (error) { 942 - xfs_err(mp, 943 - "Error %d recovering leftover CoW allocations.", error); 944 - xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 945 - goto out_quota; 946 - } 947 - 948 939 /* Reserve AG blocks for future btree expansion. */ 949 940 error = xfs_fs_reserve_ag_blocks(mp); 950 941 if (error && error != -ENOSPC) ··· 946 955 947 956 out_agresv: 948 957 xfs_fs_unreserve_ag_blocks(mp); 949 - out_quota: 950 958 xfs_qm_unmount_quotas(mp); 951 959 out_rtunmount: 952 960 xfs_rtunmount_inodes(mp);
+1 -10
fs/xfs/xfs_qm_syscalls.c
··· 303 303 return 0; 304 304 305 305 /* 306 - * We don't want to race with a quotaoff so take the quotaoff lock. 307 - * We don't hold an inode lock, so there's nothing else to stop 308 - * a quotaoff from happening. 309 - */ 310 - mutex_lock(&q->qi_quotaofflock); 311 - 312 - /* 313 306 * Get the dquot (locked) before we start, as we need to do a 314 307 * transaction to allocate it if it doesn't exist. Once we have the 315 308 * dquot, unlock it so we can start the next transaction safely. We hold ··· 312 319 error = xfs_qm_dqget(mp, id, type, true, &dqp); 313 320 if (error) { 314 321 ASSERT(error != -ENOENT); 315 - goto out_unlock; 322 + return error; 316 323 } 317 324 318 325 defq = xfs_get_defquota(q, xfs_dquot_type(dqp)); ··· 408 415 409 416 out_rele: 410 417 xfs_qm_dqrele(dqp); 411 - out_unlock: 412 - mutex_unlock(&q->qi_quotaofflock); 413 418 return error; 414 419 } 415 420
+4 -1
fs/xfs/xfs_reflink.c
··· 749 749 } 750 750 751 751 /* 752 - * Free leftover CoW reservations that didn't get cleaned out. 752 + * Free all CoW staging blocks that are still referenced by the ondisk refcount 753 + * metadata. The ondisk metadata does not track which inode created the 754 + * staging extent, so callers must ensure that there are no cached inodes with 755 + * live CoW staging extents. 753 756 */ 754 757 int 755 758 xfs_reflink_recover_cow(
-9
fs/xfs/xfs_super.c
··· 1739 1739 */ 1740 1740 xfs_restore_resvblks(mp); 1741 1741 xfs_log_work_queue(mp); 1742 - 1743 - /* Recover any CoW blocks that never got remapped. */ 1744 - error = xfs_reflink_recover_cow(mp); 1745 - if (error) { 1746 - xfs_err(mp, 1747 - "Error %d recovering leftover CoW allocations.", error); 1748 - xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 1749 - return error; 1750 - } 1751 1742 xfs_blockgc_start(mp); 1752 1743 1753 1744 /* Create the per-AG metadata reservation pool .*/
+18 -9
fs/xfs/xfs_symlink.c
··· 22 22 #include "xfs_trace.h" 23 23 #include "xfs_trans.h" 24 24 #include "xfs_ialloc.h" 25 + #include "xfs_error.h" 25 26 26 27 /* ----- Kernel only functions below ----- */ 27 28 int ··· 97 96 98 97 int 99 98 xfs_readlink( 100 - struct xfs_inode *ip, 101 - char *link) 99 + struct xfs_inode *ip, 100 + char *link) 102 101 { 103 - struct xfs_mount *mp = ip->i_mount; 104 - xfs_fsize_t pathlen; 105 - int error = 0; 102 + struct xfs_mount *mp = ip->i_mount; 103 + xfs_fsize_t pathlen; 104 + int error = -EFSCORRUPTED; 106 105 107 106 trace_xfs_readlink(ip); 108 - 109 - ASSERT(ip->i_df.if_format != XFS_DINODE_FMT_LOCAL); 110 107 111 108 if (xfs_is_shutdown(mp)) 112 109 return -EIO; ··· 120 121 __func__, (unsigned long long) ip->i_ino, 121 122 (long long) pathlen); 122 123 ASSERT(0); 123 - error = -EFSCORRUPTED; 124 124 goto out; 125 125 } 126 126 127 + if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { 128 + /* 129 + * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED 130 + * if if_data is junk. 131 + */ 132 + if (XFS_IS_CORRUPT(ip->i_mount, !ip->i_df.if_u1.if_data)) 133 + goto out; 127 134 128 - error = xfs_readlink_bmap_ilocked(ip, link); 135 + memcpy(link, ip->i_df.if_u1.if_data, pathlen + 1); 136 + error = 0; 137 + } else { 138 + error = xfs_readlink_bmap_ilocked(ip, link); 139 + } 129 140 130 141 out: 131 142 xfs_iunlock(ip, XFS_ILOCK_SHARED);
+10 -6
fs/xfs/xfs_sysfs.c
··· 67 67 static struct attribute *xfs_mp_attrs[] = { 68 68 NULL, 69 69 }; 70 + ATTRIBUTE_GROUPS(xfs_mp); 70 71 71 72 struct kobj_type xfs_mp_ktype = { 72 73 .release = xfs_sysfs_release, 73 74 .sysfs_ops = &xfs_sysfs_ops, 74 - .default_attrs = xfs_mp_attrs, 75 + .default_groups = xfs_mp_groups, 75 76 }; 76 77 77 78 #ifdef DEBUG ··· 240 239 #endif 241 240 NULL, 242 241 }; 242 + ATTRIBUTE_GROUPS(xfs_dbg); 243 243 244 244 struct kobj_type xfs_dbg_ktype = { 245 245 .release = xfs_sysfs_release, 246 246 .sysfs_ops = &xfs_sysfs_ops, 247 - .default_attrs = xfs_dbg_attrs, 247 + .default_groups = xfs_dbg_groups, 248 248 }; 249 249 250 250 #endif /* DEBUG */ ··· 298 296 ATTR_LIST(stats_clear), 299 297 NULL, 300 298 }; 299 + ATTRIBUTE_GROUPS(xfs_stats); 301 300 302 301 struct kobj_type xfs_stats_ktype = { 303 302 .release = xfs_sysfs_release, 304 303 .sysfs_ops = &xfs_sysfs_ops, 305 - .default_attrs = xfs_stats_attrs, 304 + .default_groups = xfs_stats_groups, 306 305 }; 307 306 308 307 /* xlog */ ··· 384 381 ATTR_LIST(write_grant_head), 385 382 NULL, 386 383 }; 384 + ATTRIBUTE_GROUPS(xfs_log); 387 385 388 386 struct kobj_type xfs_log_ktype = { 389 387 .release = xfs_sysfs_release, 390 388 .sysfs_ops = &xfs_sysfs_ops, 391 - .default_attrs = xfs_log_attrs, 389 + .default_groups = xfs_log_groups, 392 390 }; 393 391 394 392 /* ··· 538 534 ATTR_LIST(retry_timeout_seconds), 539 535 NULL, 540 536 }; 541 - 537 + ATTRIBUTE_GROUPS(xfs_error); 542 538 543 539 static struct kobj_type xfs_error_cfg_ktype = { 544 540 .release = xfs_sysfs_release, 545 541 .sysfs_ops = &xfs_sysfs_ops, 546 - .default_attrs = xfs_error_attrs, 542 + .default_groups = xfs_error_groups, 547 543 }; 548 544 549 545 static struct kobj_type xfs_error_ktype = {
+10 -1
fs/xfs/xfs_trans.c
··· 942 942 943 943 trace_xfs_trans_cancel(tp, _RET_IP_); 944 944 945 - if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) 945 + /* 946 + * It's never valid to cancel a transaction with deferred ops attached, 947 + * because the transaction is effectively dirty. Complain about this 948 + * loudly before freeing the in-memory defer items. 949 + */ 950 + if (!list_empty(&tp->t_dfops)) { 951 + ASSERT(xfs_is_shutdown(mp) || list_empty(&tp->t_dfops)); 952 + ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 953 + dirty = true; 946 954 xfs_defer_cancel(tp); 955 + } 947 956 948 957 /* 949 958 * See if the caller is relying on us to shut down the