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

Merge tag 'xfs-4.13-merge-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull XFS updates from Darrick Wong:
"Here are some changes for you for 4.13. For the most part it's fixes
for bugs and deadlock problems, and preparation for online fsck in
some future merge window.

- Avoid quotacheck deadlocks

- Fix transaction overflows when bunmapping fragmented files

- Refactor directory readahead

- Allow admin to configure if ASSERT is fatal

- Improve transaction usage detail logging during overflows

- Minor cleanups

- Don't leak log items when the log shuts down

- Remove double-underscore typedefs

- Various preparation for online scrubbing

- Introduce new error injection configuration sysfs knobs

- Refactor dq_get_next to use extent map directly

- Fix problems with iterating the page cache for unwritten data

- Implement SEEK_{HOLE,DATA} via iomap

- Refactor XFS to use iomap SEEK_HOLE and SEEK_DATA

- Don't use MAXPATHLEN to check on-disk symlink target lengths"

* tag 'xfs-4.13-merge-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (48 commits)
xfs: don't crash on unexpected holes in dir/attr btrees
xfs: rename MAXPATHLEN to XFS_SYMLINK_MAXLEN
xfs: fix contiguous dquot chunk iteration livelock
xfs: Switch to iomap for SEEK_HOLE / SEEK_DATA
vfs: Add iomap_seek_hole and iomap_seek_data helpers
vfs: Add page_cache_seek_hole_data helper
xfs: remove a whitespace-only line from xfs_fs_get_nextdqblk
xfs: rewrite xfs_dq_get_next_id using xfs_iext_lookup_extent
xfs: Check for m_errortag initialization in xfs_errortag_test
xfs: grab dquots without taking the ilock
xfs: fix semicolon.cocci warnings
xfs: Don't clear SGID when inheriting ACLs
xfs: free cowblocks and retry on buffered write ENOSPC
xfs: replace log_badcrc_factor knob with error injection tag
xfs: convert drop_writes to use the errortag mechanism
xfs: remove unneeded parameter from XFS_TEST_ERROR
xfs: expose errortag knobs via sysfs
xfs: make errortag a per-mountpoint structure
xfs: free uncommitted transactions during log recovery
xfs: don't allow bmap on rt files
...

+2147 -1886
+124
fs/buffer.c
··· 3501 3501 } 3502 3502 EXPORT_SYMBOL(bh_submit_read); 3503 3503 3504 + /* 3505 + * Seek for SEEK_DATA / SEEK_HOLE within @page, starting at @lastoff. 3506 + * 3507 + * Returns the offset within the file on success, and -ENOENT otherwise. 3508 + */ 3509 + static loff_t 3510 + page_seek_hole_data(struct page *page, loff_t lastoff, int whence) 3511 + { 3512 + loff_t offset = page_offset(page); 3513 + struct buffer_head *bh, *head; 3514 + bool seek_data = whence == SEEK_DATA; 3515 + 3516 + if (lastoff < offset) 3517 + lastoff = offset; 3518 + 3519 + bh = head = page_buffers(page); 3520 + do { 3521 + offset += bh->b_size; 3522 + if (lastoff >= offset) 3523 + continue; 3524 + 3525 + /* 3526 + * Unwritten extents that have data in the page cache covering 3527 + * them can be identified by the BH_Unwritten state flag. 3528 + * Pages with multiple buffers might have a mix of holes, data 3529 + * and unwritten extents - any buffer with valid data in it 3530 + * should have BH_Uptodate flag set on it. 3531 + */ 3532 + 3533 + if ((buffer_unwritten(bh) || buffer_uptodate(bh)) == seek_data) 3534 + return lastoff; 3535 + 3536 + lastoff = offset; 3537 + } while ((bh = bh->b_this_page) != head); 3538 + return -ENOENT; 3539 + } 3540 + 3541 + /* 3542 + * Seek for SEEK_DATA / SEEK_HOLE in the page cache. 3543 + * 3544 + * Within unwritten extents, the page cache determines which parts are holes 3545 + * and which are data: unwritten and uptodate buffer heads count as data; 3546 + * everything else counts as a hole. 3547 + * 3548 + * Returns the resulting offset on successs, and -ENOENT otherwise. 3549 + */ 3550 + loff_t 3551 + page_cache_seek_hole_data(struct inode *inode, loff_t offset, loff_t length, 3552 + int whence) 3553 + { 3554 + pgoff_t index = offset >> PAGE_SHIFT; 3555 + pgoff_t end = DIV_ROUND_UP(offset + length, PAGE_SIZE); 3556 + loff_t lastoff = offset; 3557 + struct pagevec pvec; 3558 + 3559 + if (length <= 0) 3560 + return -ENOENT; 3561 + 3562 + pagevec_init(&pvec, 0); 3563 + 3564 + do { 3565 + unsigned want, nr_pages, i; 3566 + 3567 + want = min_t(unsigned, end - index, PAGEVEC_SIZE); 3568 + nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, want); 3569 + if (nr_pages == 0) 3570 + break; 3571 + 3572 + for (i = 0; i < nr_pages; i++) { 3573 + struct page *page = pvec.pages[i]; 3574 + 3575 + /* 3576 + * At this point, the page may be truncated or 3577 + * invalidated (changing page->mapping to NULL), or 3578 + * even swizzled back from swapper_space to tmpfs file 3579 + * mapping. However, page->index will not change 3580 + * because we have a reference on the page. 3581 + * 3582 + * If current page offset is beyond where we've ended, 3583 + * we've found a hole. 3584 + */ 3585 + if (whence == SEEK_HOLE && 3586 + lastoff < page_offset(page)) 3587 + goto check_range; 3588 + 3589 + /* Searching done if the page index is out of range. */ 3590 + if (page->index >= end) 3591 + goto not_found; 3592 + 3593 + lock_page(page); 3594 + if (likely(page->mapping == inode->i_mapping) && 3595 + page_has_buffers(page)) { 3596 + lastoff = page_seek_hole_data(page, lastoff, whence); 3597 + if (lastoff >= 0) { 3598 + unlock_page(page); 3599 + goto check_range; 3600 + } 3601 + } 3602 + unlock_page(page); 3603 + lastoff = page_offset(page) + PAGE_SIZE; 3604 + } 3605 + 3606 + /* Searching done if fewer pages returned than wanted. */ 3607 + if (nr_pages < want) 3608 + break; 3609 + 3610 + index = pvec.pages[i - 1]->index + 1; 3611 + pagevec_release(&pvec); 3612 + } while (index < end); 3613 + 3614 + /* When no page at lastoff and we are not done, we found a hole. */ 3615 + if (whence != SEEK_HOLE) 3616 + goto not_found; 3617 + 3618 + check_range: 3619 + if (lastoff < offset + length) 3620 + goto out; 3621 + not_found: 3622 + lastoff = -ENOENT; 3623 + out: 3624 + pagevec_release(&pvec); 3625 + return lastoff; 3626 + } 3627 + 3504 3628 void __init buffer_init(void) 3505 3629 { 3506 3630 unsigned long nrpages;
+94
fs/iomap.c
··· 584 584 } 585 585 EXPORT_SYMBOL_GPL(iomap_fiemap); 586 586 587 + static loff_t 588 + iomap_seek_hole_actor(struct inode *inode, loff_t offset, loff_t length, 589 + void *data, struct iomap *iomap) 590 + { 591 + switch (iomap->type) { 592 + case IOMAP_UNWRITTEN: 593 + offset = page_cache_seek_hole_data(inode, offset, length, 594 + SEEK_HOLE); 595 + if (offset < 0) 596 + return length; 597 + /* fall through */ 598 + case IOMAP_HOLE: 599 + *(loff_t *)data = offset; 600 + return 0; 601 + default: 602 + return length; 603 + } 604 + } 605 + 606 + loff_t 607 + iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops) 608 + { 609 + loff_t size = i_size_read(inode); 610 + loff_t length = size - offset; 611 + loff_t ret; 612 + 613 + /* Nothing to be found beyond the end of the file. */ 614 + if (offset >= size) 615 + return -ENXIO; 616 + 617 + while (length > 0) { 618 + ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops, 619 + &offset, iomap_seek_hole_actor); 620 + if (ret < 0) 621 + return ret; 622 + if (ret == 0) 623 + break; 624 + 625 + offset += ret; 626 + length -= ret; 627 + } 628 + 629 + return offset; 630 + } 631 + EXPORT_SYMBOL_GPL(iomap_seek_hole); 632 + 633 + static loff_t 634 + iomap_seek_data_actor(struct inode *inode, loff_t offset, loff_t length, 635 + void *data, struct iomap *iomap) 636 + { 637 + switch (iomap->type) { 638 + case IOMAP_HOLE: 639 + return length; 640 + case IOMAP_UNWRITTEN: 641 + offset = page_cache_seek_hole_data(inode, offset, length, 642 + SEEK_DATA); 643 + if (offset < 0) 644 + return length; 645 + /*FALLTHRU*/ 646 + default: 647 + *(loff_t *)data = offset; 648 + return 0; 649 + } 650 + } 651 + 652 + loff_t 653 + iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops) 654 + { 655 + loff_t size = i_size_read(inode); 656 + loff_t length = size - offset; 657 + loff_t ret; 658 + 659 + /* Nothing to be found beyond the end of the file. */ 660 + if (offset >= size) 661 + return -ENXIO; 662 + 663 + while (length > 0) { 664 + ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops, 665 + &offset, iomap_seek_data_actor); 666 + if (ret < 0) 667 + return ret; 668 + if (ret == 0) 669 + break; 670 + 671 + offset += ret; 672 + length -= ret; 673 + } 674 + 675 + if (length <= 0) 676 + return -ENXIO; 677 + return offset; 678 + } 679 + EXPORT_SYMBOL_GPL(iomap_seek_data); 680 + 587 681 /* 588 682 * Private flags for iomap_dio, must not overlap with the public ones in 589 683 * iomap.h:
+13
fs/xfs/Kconfig
··· 96 96 not useful unless you are debugging a particular problem. 97 97 98 98 Say N unless you are an XFS developer, or you play one on TV. 99 + 100 + config XFS_ASSERT_FATAL 101 + bool "XFS fatal asserts" 102 + default y 103 + depends on XFS_FS && XFS_DEBUG 104 + help 105 + Set the default DEBUG mode ASSERT failure behavior. 106 + 107 + Say Y here to cause DEBUG mode ASSERT failures to result in fatal 108 + errors that BUG() the kernel by default. If you say N, ASSERT failures 109 + result in warnings. 110 + 111 + This behavior can be modified at runtime via sysfs.
+1 -2
fs/xfs/libxfs/xfs_ag_resv.c
··· 111 111 112 112 /* Critically low if less than 10% or max btree height remains. */ 113 113 return XFS_TEST_ERROR(avail < orig / 10 || avail < XFS_BTREE_MAXLEVELS, 114 - pag->pag_mount, XFS_ERRTAG_AG_RESV_CRITICAL, 115 - XFS_RANDOM_AG_RESV_CRITICAL); 114 + pag->pag_mount, XFS_ERRTAG_AG_RESV_CRITICAL); 116 115 } 117 116 118 117 /*
+3 -5
fs/xfs/libxfs/xfs_alloc.c
··· 606 606 /* 607 607 * Read in the allocation group free block array. 608 608 */ 609 - STATIC int /* error */ 609 + int /* error */ 610 610 xfs_alloc_read_agfl( 611 611 xfs_mount_t *mp, /* mount point structure */ 612 612 xfs_trans_t *tp, /* transaction pointer */ ··· 2454 2454 !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) 2455 2455 xfs_buf_ioerror(bp, -EFSBADCRC); 2456 2456 else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp, 2457 - XFS_ERRTAG_ALLOC_READ_AGF, 2458 - XFS_RANDOM_ALLOC_READ_AGF)) 2457 + XFS_ERRTAG_ALLOC_READ_AGF)) 2459 2458 xfs_buf_ioerror(bp, -EFSCORRUPTED); 2460 2459 2461 2460 if (bp->b_error) ··· 2841 2842 ASSERT(type != XFS_AG_RESV_AGFL); 2842 2843 2843 2844 if (XFS_TEST_ERROR(false, mp, 2844 - XFS_ERRTAG_FREE_EXTENT, 2845 - XFS_RANDOM_FREE_EXTENT)) 2845 + XFS_ERRTAG_FREE_EXTENT)) 2846 2846 return -EIO; 2847 2847 2848 2848 error = xfs_free_extent_fix_freelist(tp, agno, &agbp);
+2
fs/xfs/libxfs/xfs_alloc.h
··· 213 213 214 214 int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, 215 215 xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); 216 + int xfs_alloc_read_agfl(struct xfs_mount *mp, struct xfs_trans *tp, 217 + xfs_agnumber_t agno, struct xfs_buf **bpp); 216 218 int xfs_alloc_fix_freelist(struct xfs_alloc_arg *args, int flags); 217 219 int xfs_free_extent_fix_freelist(struct xfs_trans *tp, xfs_agnumber_t agno, 218 220 struct xfs_buf **agbp);
+10 -16
fs/xfs/libxfs/xfs_alloc_btree.c
··· 253 253 ptr->s = agf->agf_roots[cur->bc_btnum]; 254 254 } 255 255 256 - STATIC __int64_t 256 + STATIC int64_t 257 257 xfs_bnobt_key_diff( 258 258 struct xfs_btree_cur *cur, 259 259 union xfs_btree_key *key) ··· 261 261 xfs_alloc_rec_incore_t *rec = &cur->bc_rec.a; 262 262 xfs_alloc_key_t *kp = &key->alloc; 263 263 264 - return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; 264 + return (int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; 265 265 } 266 266 267 - STATIC __int64_t 267 + STATIC int64_t 268 268 xfs_cntbt_key_diff( 269 269 struct xfs_btree_cur *cur, 270 270 union xfs_btree_key *key) 271 271 { 272 272 xfs_alloc_rec_incore_t *rec = &cur->bc_rec.a; 273 273 xfs_alloc_key_t *kp = &key->alloc; 274 - __int64_t diff; 274 + int64_t diff; 275 275 276 - diff = (__int64_t)be32_to_cpu(kp->ar_blockcount) - rec->ar_blockcount; 276 + diff = (int64_t)be32_to_cpu(kp->ar_blockcount) - rec->ar_blockcount; 277 277 if (diff) 278 278 return diff; 279 279 280 - return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; 280 + return (int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; 281 281 } 282 282 283 - STATIC __int64_t 283 + STATIC int64_t 284 284 xfs_bnobt_diff_two_keys( 285 285 struct xfs_btree_cur *cur, 286 286 union xfs_btree_key *k1, 287 287 union xfs_btree_key *k2) 288 288 { 289 - return (__int64_t)be32_to_cpu(k1->alloc.ar_startblock) - 289 + return (int64_t)be32_to_cpu(k1->alloc.ar_startblock) - 290 290 be32_to_cpu(k2->alloc.ar_startblock); 291 291 } 292 292 293 - STATIC __int64_t 293 + STATIC int64_t 294 294 xfs_cntbt_diff_two_keys( 295 295 struct xfs_btree_cur *cur, 296 296 union xfs_btree_key *k1, 297 297 union xfs_btree_key *k2) 298 298 { 299 - __int64_t diff; 299 + int64_t diff; 300 300 301 301 diff = be32_to_cpu(k1->alloc.ar_blockcount) - 302 302 be32_to_cpu(k2->alloc.ar_blockcount); ··· 395 395 }; 396 396 397 397 398 - #if defined(DEBUG) || defined(XFS_WARN) 399 398 STATIC int 400 399 xfs_bnobt_keys_inorder( 401 400 struct xfs_btree_cur *cur, ··· 441 442 be32_to_cpu(r1->alloc.ar_startblock) < 442 443 be32_to_cpu(r2->alloc.ar_startblock)); 443 444 } 444 - #endif /* DEBUG */ 445 445 446 446 static const struct xfs_btree_ops xfs_bnobt_ops = { 447 447 .rec_len = sizeof(xfs_alloc_rec_t), ··· 460 462 .key_diff = xfs_bnobt_key_diff, 461 463 .buf_ops = &xfs_allocbt_buf_ops, 462 464 .diff_two_keys = xfs_bnobt_diff_two_keys, 463 - #if defined(DEBUG) || defined(XFS_WARN) 464 465 .keys_inorder = xfs_bnobt_keys_inorder, 465 466 .recs_inorder = xfs_bnobt_recs_inorder, 466 - #endif 467 467 }; 468 468 469 469 static const struct xfs_btree_ops xfs_cntbt_ops = { ··· 482 486 .key_diff = xfs_cntbt_key_diff, 483 487 .buf_ops = &xfs_allocbt_buf_ops, 484 488 .diff_two_keys = xfs_cntbt_diff_two_keys, 485 - #if defined(DEBUG) || defined(XFS_WARN) 486 489 .keys_inorder = xfs_cntbt_keys_inorder, 487 490 .recs_inorder = xfs_cntbt_recs_inorder, 488 - #endif 489 491 }; 490 492 491 493 /*
+18 -8
fs/xfs/libxfs/xfs_attr.c
··· 114 114 * Overall external interface routines. 115 115 *========================================================================*/ 116 116 117 + /* Retrieve an extended attribute and its value. Must have iolock. */ 118 + int 119 + xfs_attr_get_ilocked( 120 + struct xfs_inode *ip, 121 + struct xfs_da_args *args) 122 + { 123 + if (!xfs_inode_hasattr(ip)) 124 + return -ENOATTR; 125 + else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) 126 + return xfs_attr_shortform_getvalue(args); 127 + else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) 128 + return xfs_attr_leaf_get(args); 129 + else 130 + return xfs_attr_node_get(args); 131 + } 132 + 133 + /* Retrieve an extended attribute by name, and its value. */ 117 134 int 118 135 xfs_attr_get( 119 136 struct xfs_inode *ip, ··· 158 141 args.op_flags = XFS_DA_OP_OKNOENT; 159 142 160 143 lock_mode = xfs_ilock_attr_map_shared(ip); 161 - if (!xfs_inode_hasattr(ip)) 162 - error = -ENOATTR; 163 - else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) 164 - error = xfs_attr_shortform_getvalue(&args); 165 - else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) 166 - error = xfs_attr_leaf_get(&args); 167 - else 168 - error = xfs_attr_node_get(&args); 144 + error = xfs_attr_get_ilocked(ip, &args); 169 145 xfs_iunlock(ip, lock_mode); 170 146 171 147 *valuelenp = args.valuelen;
+1 -1
fs/xfs/libxfs/xfs_attr_leaf.c
··· 351 351 352 352 err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, 353 353 XFS_ATTR_FORK, &xfs_attr3_leaf_buf_ops); 354 - if (!err && tp) 354 + if (!err && tp && *bpp) 355 355 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF); 356 356 return err; 357 357 }
+7 -6
fs/xfs/libxfs/xfs_attr_remote.c
··· 253 253 xfs_ino_t ino, 254 254 int *offset, 255 255 int *valuelen, 256 - __uint8_t **dst) 256 + uint8_t **dst) 257 257 { 258 258 char *src = bp->b_addr; 259 259 xfs_daddr_t bno = bp->b_bn; ··· 301 301 xfs_ino_t ino, 302 302 int *offset, 303 303 int *valuelen, 304 - __uint8_t **src) 304 + uint8_t **src) 305 305 { 306 306 char *dst = bp->b_addr; 307 307 xfs_daddr_t bno = bp->b_bn; ··· 355 355 struct xfs_mount *mp = args->dp->i_mount; 356 356 struct xfs_buf *bp; 357 357 xfs_dablk_t lblkno = args->rmtblkno; 358 - __uint8_t *dst = args->value; 358 + uint8_t *dst = args->value; 359 359 int valuelen; 360 360 int nmap; 361 361 int error; ··· 386 386 (map[i].br_startblock != HOLESTARTBLOCK)); 387 387 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); 388 388 dblkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); 389 - error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 389 + error = xfs_trans_read_buf(mp, args->trans, 390 + mp->m_ddev_targp, 390 391 dblkno, dblkcnt, 0, &bp, 391 392 &xfs_attr3_rmt_buf_ops); 392 393 if (error) ··· 396 395 error = xfs_attr_rmtval_copyout(mp, bp, args->dp->i_ino, 397 396 &offset, &valuelen, 398 397 &dst); 399 - xfs_buf_relse(bp); 398 + xfs_trans_brelse(args->trans, bp); 400 399 if (error) 401 400 return error; 402 401 ··· 422 421 struct xfs_bmbt_irec map; 423 422 xfs_dablk_t lblkno; 424 423 xfs_fileoff_t lfileoff = 0; 425 - __uint8_t *src = args->value; 424 + uint8_t *src = args->value; 426 425 int blkcnt; 427 426 int valuelen; 428 427 int nmap;
+5 -5
fs/xfs/libxfs/xfs_attr_sf.h
··· 31 31 * We generate this then sort it, attr_list() must return things in hash-order. 32 32 */ 33 33 typedef struct xfs_attr_sf_sort { 34 - __uint8_t entno; /* entry number in original list */ 35 - __uint8_t namelen; /* length of name value (no null) */ 36 - __uint8_t valuelen; /* length of value */ 37 - __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 34 + uint8_t entno; /* entry number in original list */ 35 + uint8_t namelen; /* length of name value (no null) */ 36 + uint8_t valuelen; /* length of value */ 37 + uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 38 38 xfs_dahash_t hash; /* this entry's hash value */ 39 39 unsigned char *name; /* name value, pointer into buffer */ 40 40 } xfs_attr_sf_sort_t; ··· 42 42 #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \ 43 43 (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))) 44 44 #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \ 45 - ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1) 45 + ((1 << (NBBY*(int)sizeof(uint8_t))) - 1) 46 46 #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \ 47 47 ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen) 48 48 #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
+12 -12
fs/xfs/libxfs/xfs_bit.h
··· 25 25 /* 26 26 * masks with n high/low bits set, 64-bit values 27 27 */ 28 - static inline __uint64_t xfs_mask64hi(int n) 28 + static inline uint64_t xfs_mask64hi(int n) 29 29 { 30 - return (__uint64_t)-1 << (64 - (n)); 30 + return (uint64_t)-1 << (64 - (n)); 31 31 } 32 - static inline __uint32_t xfs_mask32lo(int n) 32 + static inline uint32_t xfs_mask32lo(int n) 33 33 { 34 - return ((__uint32_t)1 << (n)) - 1; 34 + return ((uint32_t)1 << (n)) - 1; 35 35 } 36 - static inline __uint64_t xfs_mask64lo(int n) 36 + static inline uint64_t xfs_mask64lo(int n) 37 37 { 38 - return ((__uint64_t)1 << (n)) - 1; 38 + return ((uint64_t)1 << (n)) - 1; 39 39 } 40 40 41 41 /* Get high bit set out of 32-bit argument, -1 if none set */ 42 - static inline int xfs_highbit32(__uint32_t v) 42 + static inline int xfs_highbit32(uint32_t v) 43 43 { 44 44 return fls(v) - 1; 45 45 } 46 46 47 47 /* Get high bit set out of 64-bit argument, -1 if none set */ 48 - static inline int xfs_highbit64(__uint64_t v) 48 + static inline int xfs_highbit64(uint64_t v) 49 49 { 50 50 return fls64(v) - 1; 51 51 } 52 52 53 53 /* Get low bit set out of 32-bit argument, -1 if none set */ 54 - static inline int xfs_lowbit32(__uint32_t v) 54 + static inline int xfs_lowbit32(uint32_t v) 55 55 { 56 56 return ffs(v) - 1; 57 57 } 58 58 59 59 /* Get low bit set out of 64-bit argument, -1 if none set */ 60 - static inline int xfs_lowbit64(__uint64_t v) 60 + static inline int xfs_lowbit64(uint64_t v) 61 61 { 62 - __uint32_t w = (__uint32_t)v; 62 + uint32_t w = (uint32_t)v; 63 63 int n = 0; 64 64 65 65 if (w) { /* lower bits */ 66 66 n = ffs(w); 67 67 } else { /* upper bits */ 68 - w = (__uint32_t)(v >> 32); 68 + w = (uint32_t)(v >> 32); 69 69 if (w) { 70 70 n = ffs(w); 71 71 if (n)
+36 -15
fs/xfs/libxfs/xfs_bmap.c
··· 3992 3992 if (unlikely(XFS_TEST_ERROR( 3993 3993 (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && 3994 3994 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 3995 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 3995 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 3996 3996 XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp); 3997 3997 return -EFSCORRUPTED; 3998 3998 } ··· 4473 4473 if (unlikely(XFS_TEST_ERROR( 4474 4474 (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && 4475 4475 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 4476 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 4476 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 4477 4477 XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp); 4478 4478 return -EFSCORRUPTED; 4479 4479 } ··· 4694 4694 if (unlikely(XFS_TEST_ERROR( 4695 4695 (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS && 4696 4696 XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), 4697 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 4697 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 4698 4698 XFS_ERROR_REPORT("xfs_bmapi_remap", XFS_ERRLEVEL_LOW, mp); 4699 4699 return -EFSCORRUPTED; 4700 4700 } ··· 5434 5434 int whichfork; /* data or attribute fork */ 5435 5435 xfs_fsblock_t sum; 5436 5436 xfs_filblks_t len = *rlen; /* length to unmap in file */ 5437 + xfs_fileoff_t max_len; 5437 5438 5438 5439 trace_xfs_bunmap(ip, bno, len, flags, _RET_IP_); 5439 5440 ··· 5455 5454 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 5456 5455 ASSERT(len > 0); 5457 5456 ASSERT(nexts >= 0); 5457 + 5458 + /* 5459 + * Guesstimate how many blocks we can unmap without running the risk of 5460 + * blowing out the transaction with a mix of EFIs and reflink 5461 + * adjustments. 5462 + */ 5463 + if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) 5464 + max_len = min(len, xfs_refcount_max_unmap(tp->t_log_res)); 5465 + else 5466 + max_len = len; 5458 5467 5459 5468 if (!(ifp->if_flags & XFS_IFEXTENTS) && 5460 5469 (error = xfs_iread_extents(tp, ip, whichfork))) ··· 5510 5499 5511 5500 extno = 0; 5512 5501 while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >= 0 && 5513 - (nexts == 0 || extno < nexts)) { 5502 + (nexts == 0 || extno < nexts) && max_len > 0) { 5514 5503 /* 5515 5504 * Is the found extent after a hole in which bno lives? 5516 5505 * Just back up to the previous extent, if so. ··· 5542 5531 } 5543 5532 if (del.br_startoff + del.br_blockcount > bno + 1) 5544 5533 del.br_blockcount = bno + 1 - del.br_startoff; 5534 + 5535 + /* How much can we safely unmap? */ 5536 + if (max_len < del.br_blockcount) { 5537 + del.br_startoff += del.br_blockcount - max_len; 5538 + if (!wasdel) 5539 + del.br_startblock += del.br_blockcount - max_len; 5540 + del.br_blockcount = max_len; 5541 + } 5542 + 5545 5543 sum = del.br_startblock + del.br_blockcount; 5546 5544 if (isrt && 5547 5545 (mod = do_mod(sum, mp->m_sb.sb_rextsize))) { ··· 5727 5707 if (!isrt && wasdel) 5728 5708 xfs_mod_fdblocks(mp, (int64_t)del.br_blockcount, false); 5729 5709 5710 + max_len -= del.br_blockcount; 5730 5711 bno = del.br_startoff - 1; 5731 5712 nodelete: 5732 5713 /* ··· 6098 6077 if (unlikely(XFS_TEST_ERROR( 6099 6078 (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && 6100 6079 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 6101 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 6080 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 6102 6081 XFS_ERROR_REPORT("xfs_bmap_shift_extents", 6103 6082 XFS_ERRLEVEL_LOW, mp); 6104 6083 return -EFSCORRUPTED; ··· 6250 6229 if (unlikely(XFS_TEST_ERROR( 6251 6230 (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && 6252 6231 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE), 6253 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 6232 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 6254 6233 XFS_ERROR_REPORT("xfs_bmap_split_extent_at", 6255 6234 XFS_ERRLEVEL_LOW, mp); 6256 6235 return -EFSCORRUPTED; ··· 6493 6472 int whichfork, 6494 6473 xfs_fileoff_t startoff, 6495 6474 xfs_fsblock_t startblock, 6496 - xfs_filblks_t blockcount, 6475 + xfs_filblks_t *blockcount, 6497 6476 xfs_exntst_t state) 6498 6477 { 6499 - int error = 0, done; 6478 + xfs_fsblock_t firstfsb; 6479 + int error = 0; 6500 6480 6501 6481 trace_xfs_bmap_deferred(tp->t_mountp, 6502 6482 XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type, 6503 6483 XFS_FSB_TO_AGBNO(tp->t_mountp, startblock), 6504 - ip->i_ino, whichfork, startoff, blockcount, state); 6484 + ip->i_ino, whichfork, startoff, *blockcount, state); 6505 6485 6506 6486 if (WARN_ON_ONCE(whichfork != XFS_DATA_FORK)) 6507 6487 return -EFSCORRUPTED; 6508 6488 6509 6489 if (XFS_TEST_ERROR(false, tp->t_mountp, 6510 - XFS_ERRTAG_BMAP_FINISH_ONE, 6511 - XFS_RANDOM_BMAP_FINISH_ONE)) 6490 + XFS_ERRTAG_BMAP_FINISH_ONE)) 6512 6491 return -EIO; 6513 6492 6514 6493 switch (type) { 6515 6494 case XFS_BMAP_MAP: 6516 - error = xfs_bmapi_remap(tp, ip, startoff, blockcount, 6495 + error = xfs_bmapi_remap(tp, ip, startoff, *blockcount, 6517 6496 startblock, dfops); 6497 + *blockcount = 0; 6518 6498 break; 6519 6499 case XFS_BMAP_UNMAP: 6520 - error = xfs_bunmapi(tp, ip, startoff, blockcount, 6521 - XFS_BMAPI_REMAP, 1, &startblock, dfops, &done); 6522 - ASSERT(done); 6500 + error = __xfs_bunmapi(tp, ip, startoff, blockcount, 6501 + XFS_BMAPI_REMAP, 1, &firstfsb, dfops); 6523 6502 break; 6524 6503 default: 6525 6504 ASSERT(0);
+1 -1
fs/xfs/libxfs/xfs_bmap.h
··· 271 271 int xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_defer_ops *dfops, 272 272 struct xfs_inode *ip, enum xfs_bmap_intent_type type, 273 273 int whichfork, xfs_fileoff_t startoff, xfs_fsblock_t startblock, 274 - xfs_filblks_t blockcount, xfs_exntst_t state); 274 + xfs_filblks_t *blockcount, xfs_exntst_t state); 275 275 int xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 276 276 struct xfs_inode *ip, struct xfs_bmbt_irec *imap); 277 277 int xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
+26 -8
fs/xfs/libxfs/xfs_bmap_btree.c
··· 94 94 */ 95 95 STATIC void 96 96 __xfs_bmbt_get_all( 97 - __uint64_t l0, 98 - __uint64_t l1, 97 + uint64_t l0, 98 + uint64_t l1, 99 99 xfs_bmbt_irec_t *s) 100 100 { 101 101 int ext_flag; ··· 573 573 } 574 574 575 575 STATIC void 576 + xfs_bmbt_init_high_key_from_rec( 577 + union xfs_btree_key *key, 578 + union xfs_btree_rec *rec) 579 + { 580 + key->bmbt.br_startoff = cpu_to_be64( 581 + xfs_bmbt_disk_get_startoff(&rec->bmbt) + 582 + xfs_bmbt_disk_get_blockcount(&rec->bmbt) - 1); 583 + } 584 + 585 + STATIC void 576 586 xfs_bmbt_init_rec_from_cur( 577 587 struct xfs_btree_cur *cur, 578 588 union xfs_btree_rec *rec) ··· 598 588 ptr->l = 0; 599 589 } 600 590 601 - STATIC __int64_t 591 + STATIC int64_t 602 592 xfs_bmbt_key_diff( 603 593 struct xfs_btree_cur *cur, 604 594 union xfs_btree_key *key) 605 595 { 606 - return (__int64_t)be64_to_cpu(key->bmbt.br_startoff) - 596 + return (int64_t)be64_to_cpu(key->bmbt.br_startoff) - 607 597 cur->bc_rec.b.br_startoff; 598 + } 599 + 600 + STATIC int64_t 601 + xfs_bmbt_diff_two_keys( 602 + struct xfs_btree_cur *cur, 603 + union xfs_btree_key *k1, 604 + union xfs_btree_key *k2) 605 + { 606 + return (int64_t)be64_to_cpu(k1->bmbt.br_startoff) - 607 + be64_to_cpu(k2->bmbt.br_startoff); 608 608 } 609 609 610 610 static bool ··· 707 687 }; 708 688 709 689 710 - #if defined(DEBUG) || defined(XFS_WARN) 711 690 STATIC int 712 691 xfs_bmbt_keys_inorder( 713 692 struct xfs_btree_cur *cur, ··· 727 708 xfs_bmbt_disk_get_blockcount(&r1->bmbt) <= 728 709 xfs_bmbt_disk_get_startoff(&r2->bmbt); 729 710 } 730 - #endif /* DEBUG */ 731 711 732 712 static const struct xfs_btree_ops xfs_bmbt_ops = { 733 713 .rec_len = sizeof(xfs_bmbt_rec_t), ··· 740 722 .get_minrecs = xfs_bmbt_get_minrecs, 741 723 .get_dmaxrecs = xfs_bmbt_get_dmaxrecs, 742 724 .init_key_from_rec = xfs_bmbt_init_key_from_rec, 725 + .init_high_key_from_rec = xfs_bmbt_init_high_key_from_rec, 743 726 .init_rec_from_cur = xfs_bmbt_init_rec_from_cur, 744 727 .init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur, 745 728 .key_diff = xfs_bmbt_key_diff, 729 + .diff_two_keys = xfs_bmbt_diff_two_keys, 746 730 .buf_ops = &xfs_bmbt_buf_ops, 747 - #if defined(DEBUG) || defined(XFS_WARN) 748 731 .keys_inorder = xfs_bmbt_keys_inorder, 749 732 .recs_inorder = xfs_bmbt_recs_inorder, 750 - #endif 751 733 }; 752 734 753 735 /*
+26 -26
fs/xfs/libxfs/xfs_btree.c
··· 43 43 /* 44 44 * Btree magic numbers. 45 45 */ 46 - static const __uint32_t xfs_magics[2][XFS_BTNUM_MAX] = { 46 + static const uint32_t xfs_magics[2][XFS_BTNUM_MAX] = { 47 47 { XFS_ABTB_MAGIC, XFS_ABTC_MAGIC, 0, XFS_BMAP_MAGIC, XFS_IBT_MAGIC, 48 48 XFS_FIBT_MAGIC, 0 }, 49 49 { XFS_ABTB_CRC_MAGIC, XFS_ABTC_CRC_MAGIC, XFS_RMAP_CRC_MAGIC, ··· 51 51 XFS_REFC_CRC_MAGIC } 52 52 }; 53 53 54 - __uint32_t 54 + uint32_t 55 55 xfs_btree_magic( 56 56 int crc, 57 57 xfs_btnum_t btnum) 58 58 { 59 - __uint32_t magic = xfs_magics[crc][btnum]; 59 + uint32_t magic = xfs_magics[crc][btnum]; 60 60 61 61 /* Ensure we asked for crc for crc-only magics. */ 62 62 ASSERT(magic != 0); ··· 101 101 be64_to_cpu(block->bb_u.l.bb_rightsib))); 102 102 103 103 if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, 104 - XFS_ERRTAG_BTREE_CHECK_LBLOCK, 105 - XFS_RANDOM_BTREE_CHECK_LBLOCK))) { 104 + XFS_ERRTAG_BTREE_CHECK_LBLOCK))) { 106 105 if (bp) 107 106 trace_xfs_btree_corrupt(bp, _RET_IP_); 108 107 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); ··· 152 153 block->bb_u.s.bb_rightsib; 153 154 154 155 if (unlikely(XFS_TEST_ERROR(!sblock_ok, mp, 155 - XFS_ERRTAG_BTREE_CHECK_SBLOCK, 156 - XFS_RANDOM_BTREE_CHECK_SBLOCK))) { 156 + XFS_ERRTAG_BTREE_CHECK_SBLOCK))) { 157 157 if (bp) 158 158 trace_xfs_btree_corrupt(bp, _RET_IP_); 159 159 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); ··· 566 568 /* 567 569 * Return a pointer to the n-th record in the btree block. 568 570 */ 569 - STATIC union xfs_btree_rec * 571 + union xfs_btree_rec * 570 572 xfs_btree_rec_addr( 571 573 struct xfs_btree_cur *cur, 572 574 int n, ··· 579 581 /* 580 582 * Return a pointer to the n-th key in the btree block. 581 583 */ 582 - STATIC union xfs_btree_key * 584 + union xfs_btree_key * 583 585 xfs_btree_key_addr( 584 586 struct xfs_btree_cur *cur, 585 587 int n, ··· 592 594 /* 593 595 * Return a pointer to the n-th high key in the btree block. 594 596 */ 595 - STATIC union xfs_btree_key * 597 + union xfs_btree_key * 596 598 xfs_btree_high_key_addr( 597 599 struct xfs_btree_cur *cur, 598 600 int n, ··· 605 607 /* 606 608 * Return a pointer to the n-th block pointer in the btree block. 607 609 */ 608 - STATIC union xfs_btree_ptr * 610 + union xfs_btree_ptr * 609 611 xfs_btree_ptr_addr( 610 612 struct xfs_btree_cur *cur, 611 613 int n, ··· 639 641 * Retrieve the block pointer from the cursor at the given level. 640 642 * This may be an inode btree root or from a buffer. 641 643 */ 642 - STATIC struct xfs_btree_block * /* generic btree block pointer */ 644 + struct xfs_btree_block * /* generic btree block pointer */ 643 645 xfs_btree_get_block( 644 646 struct xfs_btree_cur *cur, /* btree cursor */ 645 647 int level, /* level in btree */ ··· 776 778 */ 777 779 void 778 780 xfs_btree_offsets( 779 - __int64_t fields, /* bitmask of fields */ 781 + int64_t fields, /* bitmask of fields */ 780 782 const short *offsets, /* table of field offsets */ 781 783 int nbits, /* number of bits to inspect */ 782 784 int *first, /* output: first byte offset */ 783 785 int *last) /* output: last byte offset */ 784 786 { 785 787 int i; /* current bit number */ 786 - __int64_t imask; /* mask for current bit number */ 788 + int64_t imask; /* mask for current bit number */ 787 789 788 790 ASSERT(fields != 0); 789 791 /* ··· 1754 1756 return error; 1755 1757 } 1756 1758 1757 - STATIC int 1759 + int 1758 1760 xfs_btree_lookup_get_block( 1759 1761 struct xfs_btree_cur *cur, /* btree cursor */ 1760 1762 int level, /* level in the btree */ ··· 1844 1846 int *stat) /* success/failure */ 1845 1847 { 1846 1848 struct xfs_btree_block *block; /* current btree block */ 1847 - __int64_t diff; /* difference for the current key */ 1849 + int64_t diff; /* difference for the current key */ 1848 1850 int error; /* error return value */ 1849 1851 int keyno; /* current key number */ 1850 1852 int level; /* level in the btree */ ··· 4433 4435 * recovery completion writes the changes to disk. 4434 4436 */ 4435 4437 struct xfs_btree_block_change_owner_info { 4436 - __uint64_t new_owner; 4438 + uint64_t new_owner; 4437 4439 struct list_head *buffer_list; 4438 4440 }; 4439 4441 ··· 4479 4481 int 4480 4482 xfs_btree_change_owner( 4481 4483 struct xfs_btree_cur *cur, 4482 - __uint64_t new_owner, 4484 + uint64_t new_owner, 4483 4485 struct list_head *buffer_list) 4484 4486 { 4485 4487 struct xfs_btree_block_change_owner_info bbcoi; ··· 4583 4585 { 4584 4586 union xfs_btree_rec *recp; 4585 4587 union xfs_btree_key rec_key; 4586 - __int64_t diff; 4588 + int64_t diff; 4587 4589 int stat; 4588 4590 bool firstrec = true; 4589 4591 int error; ··· 4680 4682 union xfs_btree_key *hkp; 4681 4683 union xfs_btree_rec *recp; 4682 4684 struct xfs_btree_block *block; 4683 - __int64_t ldiff; 4684 - __int64_t hdiff; 4685 + int64_t ldiff; 4686 + int64_t hdiff; 4685 4687 int level; 4686 4688 struct xfs_buf *bp; 4687 4689 int i; ··· 4847 4849 xfs_btree_query_range_fn fn, 4848 4850 void *priv) 4849 4851 { 4850 - union xfs_btree_irec low_rec; 4851 - union xfs_btree_irec high_rec; 4852 + union xfs_btree_key low_key; 4853 + union xfs_btree_key high_key; 4852 4854 4853 - memset(&low_rec, 0, sizeof(low_rec)); 4854 - memset(&high_rec, 0xFF, sizeof(high_rec)); 4855 - return xfs_btree_query_range(cur, &low_rec, &high_rec, fn, priv); 4855 + memset(&cur->bc_rec, 0, sizeof(cur->bc_rec)); 4856 + memset(&low_key, 0, sizeof(low_key)); 4857 + memset(&high_key, 0xFF, sizeof(high_key)); 4858 + 4859 + return xfs_btree_simple_query_range(cur, &low_key, &high_key, fn, priv); 4856 4860 } 4857 4861 4858 4862 /*
+22 -11
fs/xfs/libxfs/xfs_btree.h
··· 76 76 #define XFS_BTNUM_RMAP ((xfs_btnum_t)XFS_BTNUM_RMAPi) 77 77 #define XFS_BTNUM_REFC ((xfs_btnum_t)XFS_BTNUM_REFCi) 78 78 79 - __uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum); 79 + uint32_t xfs_btree_magic(int crc, xfs_btnum_t btnum); 80 80 81 81 /* 82 82 * For logging record fields. ··· 150 150 union xfs_btree_rec *rec); 151 151 152 152 /* difference between key value and cursor value */ 153 - __int64_t (*key_diff)(struct xfs_btree_cur *cur, 153 + int64_t (*key_diff)(struct xfs_btree_cur *cur, 154 154 union xfs_btree_key *key); 155 155 156 156 /* 157 157 * Difference between key2 and key1 -- positive if key1 > key2, 158 158 * negative if key1 < key2, and zero if equal. 159 159 */ 160 - __int64_t (*diff_two_keys)(struct xfs_btree_cur *cur, 160 + int64_t (*diff_two_keys)(struct xfs_btree_cur *cur, 161 161 union xfs_btree_key *key1, 162 162 union xfs_btree_key *key2); 163 163 164 164 const struct xfs_buf_ops *buf_ops; 165 165 166 - #if defined(DEBUG) || defined(XFS_WARN) 167 166 /* check that k1 is lower than k2 */ 168 167 int (*keys_inorder)(struct xfs_btree_cur *cur, 169 168 union xfs_btree_key *k1, ··· 172 173 int (*recs_inorder)(struct xfs_btree_cur *cur, 173 174 union xfs_btree_rec *r1, 174 175 union xfs_btree_rec *r2); 175 - #endif 176 176 }; 177 177 178 178 /* ··· 211 213 union xfs_btree_irec bc_rec; /* current insert/search record value */ 212 214 struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */ 213 215 int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */ 214 - __uint8_t bc_ra[XFS_BTREE_MAXLEVELS]; /* readahead bits */ 216 + uint8_t bc_ra[XFS_BTREE_MAXLEVELS]; /* readahead bits */ 215 217 #define XFS_BTCUR_LEFTRA 1 /* left sibling has been read-ahead */ 216 218 #define XFS_BTCUR_RIGHTRA 2 /* right sibling has been read-ahead */ 217 - __uint8_t bc_nlevels; /* number of levels in the tree */ 218 - __uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ 219 + uint8_t bc_nlevels; /* number of levels in the tree */ 220 + uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ 219 221 xfs_btnum_t bc_btnum; /* identifies which btree type */ 220 222 int bc_statoff; /* offset of btre stats array */ 221 223 union { ··· 328 330 */ 329 331 void 330 332 xfs_btree_offsets( 331 - __int64_t fields, /* bitmask of fields */ 333 + int64_t fields, /* bitmask of fields */ 332 334 const short *offsets,/* table of field offsets */ 333 335 int nbits, /* number of bits to inspect */ 334 336 int *first, /* output: first byte offset */ ··· 406 408 int xfs_btree_insert(struct xfs_btree_cur *, int *); 407 409 int xfs_btree_delete(struct xfs_btree_cur *, int *); 408 410 int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *); 409 - int xfs_btree_change_owner(struct xfs_btree_cur *cur, __uint64_t new_owner, 411 + int xfs_btree_change_owner(struct xfs_btree_cur *cur, uint64_t new_owner, 410 412 struct list_head *buffer_list); 411 413 412 414 /* ··· 432 434 } 433 435 434 436 static inline void xfs_btree_set_numrecs(struct xfs_btree_block *block, 435 - __uint16_t numrecs) 437 + uint16_t numrecs) 436 438 { 437 439 block->bb_numrecs = cpu_to_be16(numrecs); 438 440 } ··· 503 505 xfs_btree_visit_blocks_fn fn, void *data); 504 506 505 507 int xfs_btree_count_blocks(struct xfs_btree_cur *cur, xfs_extlen_t *blocks); 508 + 509 + union xfs_btree_rec *xfs_btree_rec_addr(struct xfs_btree_cur *cur, int n, 510 + struct xfs_btree_block *block); 511 + union xfs_btree_key *xfs_btree_key_addr(struct xfs_btree_cur *cur, int n, 512 + struct xfs_btree_block *block); 513 + union xfs_btree_key *xfs_btree_high_key_addr(struct xfs_btree_cur *cur, int n, 514 + struct xfs_btree_block *block); 515 + union xfs_btree_ptr *xfs_btree_ptr_addr(struct xfs_btree_cur *cur, int n, 516 + struct xfs_btree_block *block); 517 + int xfs_btree_lookup_get_block(struct xfs_btree_cur *cur, int level, 518 + union xfs_btree_ptr *pp, struct xfs_btree_block **blkp); 519 + struct xfs_btree_block *xfs_btree_get_block(struct xfs_btree_cur *cur, 520 + int level, struct xfs_buf **bpp); 506 521 507 522 #endif /* __XFS_BTREE_H__ */
+8 -8
fs/xfs/libxfs/xfs_cksum.h
··· 1 1 #ifndef _XFS_CKSUM_H 2 2 #define _XFS_CKSUM_H 1 3 3 4 - #define XFS_CRC_SEED (~(__uint32_t)0) 4 + #define XFS_CRC_SEED (~(uint32_t)0) 5 5 6 6 /* 7 7 * Calculate the intermediate checksum for a buffer that has the CRC field ··· 9 9 * cksum_offset parameter. We do not modify the buffer during verification, 10 10 * hence we have to split the CRC calculation across the cksum_offset. 11 11 */ 12 - static inline __uint32_t 12 + static inline uint32_t 13 13 xfs_start_cksum_safe(char *buffer, size_t length, unsigned long cksum_offset) 14 14 { 15 - __uint32_t zero = 0; 16 - __uint32_t crc; 15 + uint32_t zero = 0; 16 + uint32_t crc; 17 17 18 18 /* Calculate CRC up to the checksum. */ 19 19 crc = crc32c(XFS_CRC_SEED, buffer, cksum_offset); ··· 30 30 * Fast CRC method where the buffer is modified. Callers must have exclusive 31 31 * access to the buffer while the calculation takes place. 32 32 */ 33 - static inline __uint32_t 33 + static inline uint32_t 34 34 xfs_start_cksum_update(char *buffer, size_t length, unsigned long cksum_offset) 35 35 { 36 36 /* zero the CRC field */ ··· 48 48 * so that it is consistent on disk. 49 49 */ 50 50 static inline __le32 51 - xfs_end_cksum(__uint32_t crc) 51 + xfs_end_cksum(uint32_t crc) 52 52 { 53 53 return ~cpu_to_le32(crc); 54 54 } ··· 62 62 static inline void 63 63 xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset) 64 64 { 65 - __uint32_t crc = xfs_start_cksum_update(buffer, length, cksum_offset); 65 + uint32_t crc = xfs_start_cksum_update(buffer, length, cksum_offset); 66 66 67 67 *(__le32 *)(buffer + cksum_offset) = xfs_end_cksum(crc); 68 68 } ··· 73 73 static inline int 74 74 xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset) 75 75 { 76 - __uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset); 76 + uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset); 77 77 78 78 return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc); 79 79 }
+7 -7
fs/xfs/libxfs/xfs_da_btree.c
··· 263 263 264 264 err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, 265 265 which_fork, &xfs_da3_node_buf_ops); 266 - if (!err && tp) { 266 + if (!err && tp && *bpp) { 267 267 struct xfs_da_blkinfo *info = (*bpp)->b_addr; 268 268 int type; 269 269 ··· 1282 1282 return; 1283 1283 break; 1284 1284 case XFS_DIR2_LEAFN_MAGIC: 1285 - lasthash = xfs_dir2_leafn_lasthash(dp, blk->bp, &count); 1285 + lasthash = xfs_dir2_leaf_lasthash(dp, blk->bp, &count); 1286 1286 if (count == 0) 1287 1287 return; 1288 1288 break; ··· 1502 1502 if (blk->magic == XFS_DIR2_LEAFN_MAGIC || 1503 1503 blk->magic == XFS_DIR3_LEAFN_MAGIC) { 1504 1504 blk->magic = XFS_DIR2_LEAFN_MAGIC; 1505 - blk->hashval = xfs_dir2_leafn_lasthash(args->dp, 1506 - blk->bp, NULL); 1505 + blk->hashval = xfs_dir2_leaf_lasthash(args->dp, 1506 + blk->bp, NULL); 1507 1507 break; 1508 1508 } 1509 1509 ··· 1929 1929 blk->magic = XFS_DIR2_LEAFN_MAGIC; 1930 1930 ASSERT(level == path->active-1); 1931 1931 blk->index = 0; 1932 - blk->hashval = xfs_dir2_leafn_lasthash(args->dp, 1933 - blk->bp, NULL); 1932 + blk->hashval = xfs_dir2_leaf_lasthash(args->dp, 1933 + blk->bp, NULL); 1934 1934 break; 1935 1935 default: 1936 1936 ASSERT(0); ··· 1952 1952 * This is implemented with some source-level loop unrolling. 1953 1953 */ 1954 1954 xfs_dahash_t 1955 - xfs_da_hashname(const __uint8_t *name, int namelen) 1955 + xfs_da_hashname(const uint8_t *name, int namelen) 1956 1956 { 1957 1957 xfs_dahash_t hash; 1958 1958
+4 -4
fs/xfs/libxfs/xfs_da_btree.h
··· 60 60 */ 61 61 typedef struct xfs_da_args { 62 62 struct xfs_da_geometry *geo; /* da block geometry */ 63 - const __uint8_t *name; /* string (maybe not NULL terminated) */ 63 + const uint8_t *name; /* string (maybe not NULL terminated) */ 64 64 int namelen; /* length of string (maybe no NULL) */ 65 - __uint8_t filetype; /* filetype of inode for directories */ 66 - __uint8_t *value; /* set of bytes (maybe contain NULLs) */ 65 + uint8_t filetype; /* filetype of inode for directories */ 66 + uint8_t *value; /* set of bytes (maybe contain NULLs) */ 67 67 int valuelen; /* length of value */ 68 68 int flags; /* argument flags (eg: ATTR_NOCREATE) */ 69 69 xfs_dahash_t hashval; /* hash value of name */ ··· 207 207 int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 208 208 struct xfs_buf *dead_buf); 209 209 210 - uint xfs_da_hashname(const __uint8_t *name_string, int name_length); 210 + uint xfs_da_hashname(const uint8_t *name_string, int name_length); 211 211 enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args, 212 212 const unsigned char *name, int len); 213 213
+14 -14
fs/xfs/libxfs/xfs_da_format.c
··· 49 49 struct xfs_dir2_sf_hdr *hdr, 50 50 int len) 51 51 { 52 - return xfs_dir2_sf_entsize(hdr, len) + sizeof(__uint8_t); 52 + return xfs_dir2_sf_entsize(hdr, len) + sizeof(uint8_t); 53 53 } 54 54 55 55 static struct xfs_dir2_sf_entry * ··· 77 77 * not necessary. For non-filetype enable directories, the type is always 78 78 * unknown and we never store the value. 79 79 */ 80 - static __uint8_t 80 + static uint8_t 81 81 xfs_dir2_sfe_get_ftype( 82 82 struct xfs_dir2_sf_entry *sfep) 83 83 { ··· 87 87 static void 88 88 xfs_dir2_sfe_put_ftype( 89 89 struct xfs_dir2_sf_entry *sfep, 90 - __uint8_t ftype) 90 + uint8_t ftype) 91 91 { 92 92 ASSERT(ftype < XFS_DIR3_FT_MAX); 93 93 } 94 94 95 - static __uint8_t 95 + static uint8_t 96 96 xfs_dir3_sfe_get_ftype( 97 97 struct xfs_dir2_sf_entry *sfep) 98 98 { 99 - __uint8_t ftype; 99 + uint8_t ftype; 100 100 101 101 ftype = sfep->name[sfep->namelen]; 102 102 if (ftype >= XFS_DIR3_FT_MAX) ··· 107 107 static void 108 108 xfs_dir3_sfe_put_ftype( 109 109 struct xfs_dir2_sf_entry *sfep, 110 - __uint8_t ftype) 110 + uint8_t ftype) 111 111 { 112 112 ASSERT(ftype < XFS_DIR3_FT_MAX); 113 113 ··· 124 124 static xfs_ino_t 125 125 xfs_dir2_sf_get_ino( 126 126 struct xfs_dir2_sf_hdr *hdr, 127 - __uint8_t *from) 127 + uint8_t *from) 128 128 { 129 129 if (hdr->i8count) 130 130 return get_unaligned_be64(from) & 0x00ffffffffffffffULL; ··· 135 135 static void 136 136 xfs_dir2_sf_put_ino( 137 137 struct xfs_dir2_sf_hdr *hdr, 138 - __uint8_t *to, 138 + uint8_t *to, 139 139 xfs_ino_t ino) 140 140 { 141 141 ASSERT((ino & 0xff00000000000000ULL) == 0); ··· 225 225 226 226 #define XFS_DIR3_DATA_ENTSIZE(n) \ 227 227 round_up((offsetof(struct xfs_dir2_data_entry, name[0]) + (n) + \ 228 - sizeof(xfs_dir2_data_off_t) + sizeof(__uint8_t)), \ 228 + sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)), \ 229 229 XFS_DIR2_DATA_ALIGN) 230 230 231 231 static int ··· 242 242 return XFS_DIR3_DATA_ENTSIZE(n); 243 243 } 244 244 245 - static __uint8_t 245 + static uint8_t 246 246 xfs_dir2_data_get_ftype( 247 247 struct xfs_dir2_data_entry *dep) 248 248 { ··· 252 252 static void 253 253 xfs_dir2_data_put_ftype( 254 254 struct xfs_dir2_data_entry *dep, 255 - __uint8_t ftype) 255 + uint8_t ftype) 256 256 { 257 257 ASSERT(ftype < XFS_DIR3_FT_MAX); 258 258 } 259 259 260 - static __uint8_t 260 + static uint8_t 261 261 xfs_dir3_data_get_ftype( 262 262 struct xfs_dir2_data_entry *dep) 263 263 { 264 - __uint8_t ftype = dep->name[dep->namelen]; 264 + uint8_t ftype = dep->name[dep->namelen]; 265 265 266 266 if (ftype >= XFS_DIR3_FT_MAX) 267 267 return XFS_DIR3_FT_UNKNOWN; ··· 271 271 static void 272 272 xfs_dir3_data_put_ftype( 273 273 struct xfs_dir2_data_entry *dep, 274 - __uint8_t type) 274 + uint8_t type) 275 275 { 276 276 ASSERT(type < XFS_DIR3_FT_MAX); 277 277 ASSERT(dep->namelen != 0);
+32 -32
fs/xfs/libxfs/xfs_da_format.h
··· 111 111 * appropriate. 112 112 */ 113 113 struct xfs_da3_icnode_hdr { 114 - __uint32_t forw; 115 - __uint32_t back; 116 - __uint16_t magic; 117 - __uint16_t count; 118 - __uint16_t level; 114 + uint32_t forw; 115 + uint32_t back; 116 + uint16_t magic; 117 + uint16_t count; 118 + uint16_t level; 119 119 }; 120 120 121 121 /* ··· 187 187 /* 188 188 * Byte offset in data block and shortform entry. 189 189 */ 190 - typedef __uint16_t xfs_dir2_data_off_t; 190 + typedef uint16_t xfs_dir2_data_off_t; 191 191 #define NULLDATAOFF 0xffffU 192 192 typedef uint xfs_dir2_data_aoff_t; /* argument form */ 193 193 194 194 /* 195 195 * Offset in data space of a data entry. 196 196 */ 197 - typedef __uint32_t xfs_dir2_dataptr_t; 197 + typedef uint32_t xfs_dir2_dataptr_t; 198 198 #define XFS_DIR2_MAX_DATAPTR ((xfs_dir2_dataptr_t)0xffffffff) 199 199 #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0) 200 200 ··· 206 206 /* 207 207 * Directory block number (logical dirblk in file) 208 208 */ 209 - typedef __uint32_t xfs_dir2_db_t; 209 + typedef uint32_t xfs_dir2_db_t; 210 210 211 211 #define XFS_INO32_SIZE 4 212 212 #define XFS_INO64_SIZE 8 ··· 226 226 * over them. 227 227 */ 228 228 typedef struct xfs_dir2_sf_hdr { 229 - __uint8_t count; /* count of entries */ 230 - __uint8_t i8count; /* count of 8-byte inode #s */ 231 - __uint8_t parent[8]; /* parent dir inode number */ 229 + uint8_t count; /* count of entries */ 230 + uint8_t i8count; /* count of 8-byte inode #s */ 231 + uint8_t parent[8]; /* parent dir inode number */ 232 232 } __packed xfs_dir2_sf_hdr_t; 233 233 234 234 typedef struct xfs_dir2_sf_entry { ··· 447 447 }; 448 448 449 449 struct xfs_dir3_icleaf_hdr { 450 - __uint32_t forw; 451 - __uint32_t back; 452 - __uint16_t magic; 453 - __uint16_t count; 454 - __uint16_t stale; 450 + uint32_t forw; 451 + uint32_t back; 452 + uint16_t magic; 453 + uint16_t count; 454 + uint16_t stale; 455 455 }; 456 456 457 457 /* ··· 538 538 * xfs_dir3_free_hdr_from_disk/xfs_dir3_free_hdr_to_disk. 539 539 */ 540 540 struct xfs_dir3_icfree_hdr { 541 - __uint32_t magic; 542 - __uint32_t firstdb; 543 - __uint32_t nvalid; 544 - __uint32_t nused; 541 + uint32_t magic; 542 + uint32_t firstdb; 543 + uint32_t nvalid; 544 + uint32_t nused; 545 545 546 546 }; 547 547 ··· 632 632 __u8 padding; 633 633 } hdr; 634 634 struct xfs_attr_sf_entry { 635 - __uint8_t namelen; /* actual length of name (no NULL) */ 636 - __uint8_t valuelen; /* actual length of value (no NULL) */ 637 - __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 638 - __uint8_t nameval[1]; /* name & value bytes concatenated */ 635 + uint8_t namelen; /* actual length of name (no NULL) */ 636 + uint8_t valuelen; /* actual length of value (no NULL) */ 637 + uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 638 + uint8_t nameval[1]; /* name & value bytes concatenated */ 639 639 } list[1]; /* variable sized array */ 640 640 } xfs_attr_shortform_t; 641 641 ··· 725 725 * incore, neutral version of the attribute leaf header 726 726 */ 727 727 struct xfs_attr3_icleaf_hdr { 728 - __uint32_t forw; 729 - __uint32_t back; 730 - __uint16_t magic; 731 - __uint16_t count; 732 - __uint16_t usedbytes; 728 + uint32_t forw; 729 + uint32_t back; 730 + uint16_t magic; 731 + uint16_t count; 732 + uint16_t usedbytes; 733 733 /* 734 734 * firstused is 32-bit here instead of 16-bit like the on-disk variant 735 735 * to support maximum fsb size of 64k without overflow issues throughout 736 736 * the attr code. Instead, the overflow condition is handled on 737 737 * conversion to/from disk. 738 738 */ 739 - __uint32_t firstused; 739 + uint32_t firstused; 740 740 __u8 holes; 741 741 struct { 742 - __uint16_t base; 743 - __uint16_t size; 742 + uint16_t base; 743 + uint16_t size; 744 744 } freemap[XFS_ATTR_LEAF_MAPSIZE]; 745 745 }; 746 746
+1 -2
fs/xfs/libxfs/xfs_dir2.c
··· 218 218 agblkno != 0 && 219 219 ioff < (1 << mp->m_sb.sb_inopblog) && 220 220 XFS_AGINO_TO_INO(mp, agno, agino) == ino; 221 - if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE, 222 - XFS_RANDOM_DIR_INO_VALIDATE))) { 221 + if (unlikely(XFS_TEST_ERROR(!ino_ok, mp, XFS_ERRTAG_DIR_INO_VALIDATE))) { 223 222 xfs_warn(mp, "Invalid inode number 0x%Lx", 224 223 (unsigned long long) ino); 225 224 XFS_ERROR_REPORT("xfs_dir_ino_validate", XFS_ERRLEVEL_LOW, mp);
+4 -4
fs/xfs/libxfs/xfs_dir2.h
··· 47 47 struct xfs_dir2_sf_entry * 48 48 (*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr, 49 49 struct xfs_dir2_sf_entry *sfep); 50 - __uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep); 50 + uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep); 51 51 void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep, 52 - __uint8_t ftype); 52 + uint8_t ftype); 53 53 xfs_ino_t (*sf_get_ino)(struct xfs_dir2_sf_hdr *hdr, 54 54 struct xfs_dir2_sf_entry *sfep); 55 55 void (*sf_put_ino)(struct xfs_dir2_sf_hdr *hdr, ··· 60 60 xfs_ino_t ino); 61 61 62 62 int (*data_entsize)(int len); 63 - __uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); 63 + uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); 64 64 void (*data_put_ftype)(struct xfs_dir2_data_entry *dep, 65 - __uint8_t ftype); 65 + uint8_t ftype); 66 66 __be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep); 67 67 struct xfs_dir2_data_free * 68 68 (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);
+1 -1
fs/xfs/libxfs/xfs_dir2_block.c
··· 139 139 140 140 err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp, 141 141 XFS_DATA_FORK, &xfs_dir3_block_buf_ops); 142 - if (!err && tp) 142 + if (!err && tp && *bpp) 143 143 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); 144 144 return err; 145 145 }
+9 -9
fs/xfs/libxfs/xfs_dir2_leaf.c
··· 145 145 static bool 146 146 xfs_dir3_leaf_verify( 147 147 struct xfs_buf *bp, 148 - __uint16_t magic) 148 + uint16_t magic) 149 149 { 150 150 struct xfs_mount *mp = bp->b_target->bt_mount; 151 151 struct xfs_dir2_leaf *leaf = bp->b_addr; ··· 154 154 155 155 if (xfs_sb_version_hascrc(&mp->m_sb)) { 156 156 struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr; 157 - __uint16_t magic3; 157 + uint16_t magic3; 158 158 159 159 magic3 = (magic == XFS_DIR2_LEAF1_MAGIC) ? XFS_DIR3_LEAF1_MAGIC 160 160 : XFS_DIR3_LEAFN_MAGIC; ··· 178 178 static void 179 179 __read_verify( 180 180 struct xfs_buf *bp, 181 - __uint16_t magic) 181 + uint16_t magic) 182 182 { 183 183 struct xfs_mount *mp = bp->b_target->bt_mount; 184 184 ··· 195 195 static void 196 196 __write_verify( 197 197 struct xfs_buf *bp, 198 - __uint16_t magic) 198 + uint16_t magic) 199 199 { 200 200 struct xfs_mount *mp = bp->b_target->bt_mount; 201 201 struct xfs_buf_log_item *bip = bp->b_fspriv; ··· 256 256 .verify_write = xfs_dir3_leafn_write_verify, 257 257 }; 258 258 259 - static int 259 + int 260 260 xfs_dir3_leaf_read( 261 261 struct xfs_trans *tp, 262 262 struct xfs_inode *dp, ··· 268 268 269 269 err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 270 270 XFS_DATA_FORK, &xfs_dir3_leaf1_buf_ops); 271 - if (!err && tp) 271 + if (!err && tp && *bpp) 272 272 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF); 273 273 return err; 274 274 } ··· 285 285 286 286 err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, 287 287 XFS_DATA_FORK, &xfs_dir3_leafn_buf_ops); 288 - if (!err && tp) 288 + if (!err && tp && *bpp) 289 289 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF); 290 290 return err; 291 291 } ··· 299 299 struct xfs_trans *tp, 300 300 struct xfs_buf *bp, 301 301 xfs_ino_t owner, 302 - __uint16_t type) 302 + uint16_t type) 303 303 { 304 304 struct xfs_dir2_leaf *leaf = bp->b_addr; 305 305 ··· 343 343 xfs_da_args_t *args, 344 344 xfs_dir2_db_t bno, 345 345 struct xfs_buf **bpp, 346 - __uint16_t magic) 346 + uint16_t magic) 347 347 { 348 348 struct xfs_inode *dp = args->dp; 349 349 struct xfs_trans *tp = args->trans;
+6 -4
fs/xfs/libxfs/xfs_dir2_node.c
··· 528 528 * Stale entries are ok. 529 529 */ 530 530 xfs_dahash_t /* hash value */ 531 - xfs_dir2_leafn_lasthash( 531 + xfs_dir2_leaf_lasthash( 532 532 struct xfs_inode *dp, 533 533 struct xfs_buf *bp, /* leaf buffer */ 534 534 int *count) /* count of entries in leaf */ ··· 540 540 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 541 541 542 542 ASSERT(leafhdr.magic == XFS_DIR2_LEAFN_MAGIC || 543 - leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); 543 + leafhdr.magic == XFS_DIR3_LEAFN_MAGIC || 544 + leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || 545 + leafhdr.magic == XFS_DIR3_LEAF1_MAGIC); 544 546 545 547 if (count) 546 548 *count = leafhdr.count; ··· 1407 1405 /* 1408 1406 * Update last hashval in each block since we added the name. 1409 1407 */ 1410 - oldblk->hashval = xfs_dir2_leafn_lasthash(dp, oldblk->bp, NULL); 1411 - newblk->hashval = xfs_dir2_leafn_lasthash(dp, newblk->bp, NULL); 1408 + oldblk->hashval = xfs_dir2_leaf_lasthash(dp, oldblk->bp, NULL); 1409 + newblk->hashval = xfs_dir2_leaf_lasthash(dp, newblk->bp, NULL); 1412 1410 xfs_dir3_leaf_check(dp, oldblk->bp); 1413 1411 xfs_dir3_leaf_check(dp, newblk->bp); 1414 1412 return error;
+6 -4
fs/xfs/libxfs/xfs_dir2_priv.h
··· 58 58 struct xfs_buf **bpp); 59 59 60 60 /* xfs_dir2_leaf.c */ 61 + extern int xfs_dir3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, 62 + xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); 61 63 extern int xfs_dir3_leafn_read(struct xfs_trans *tp, struct xfs_inode *dp, 62 64 xfs_dablk_t fbno, xfs_daddr_t mappedbno, struct xfs_buf **bpp); 63 65 extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, ··· 71 69 struct xfs_dir2_leaf_entry *ents, int *indexp, 72 70 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); 73 71 extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, 74 - struct xfs_buf **bpp, __uint16_t magic); 72 + struct xfs_buf **bpp, uint16_t magic); 75 73 extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args, 76 74 struct xfs_buf *bp, int first, int last); 77 75 extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args, ··· 95 93 /* xfs_dir2_node.c */ 96 94 extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, 97 95 struct xfs_buf *lbp); 98 - extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_inode *dp, 96 + extern xfs_dahash_t xfs_dir2_leaf_lasthash(struct xfs_inode *dp, 99 97 struct xfs_buf *bp, int *count); 100 98 extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp, 101 99 struct xfs_da_args *args, int *indexp, ··· 130 128 extern int xfs_dir2_sf_verify(struct xfs_inode *ip); 131 129 132 130 /* xfs_dir2_readdir.c */ 133 - extern int xfs_readdir(struct xfs_inode *dp, struct dir_context *ctx, 134 - size_t bufsize); 131 + extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp, 132 + struct dir_context *ctx, size_t bufsize); 135 133 136 134 #endif /* __XFS_DIR2_PRIV_H__ */
+1 -1
fs/xfs/libxfs/xfs_dir2_sf.c
··· 647 647 int offset; 648 648 int size; 649 649 int error; 650 - __uint8_t filetype; 650 + uint8_t filetype; 651 651 652 652 ASSERT(ip->i_d.di_format == XFS_DINODE_FMT_LOCAL); 653 653 /*
+57 -56
fs/xfs/libxfs/xfs_format.h
··· 103 103 * Must be padded to 64 bit alignment. 104 104 */ 105 105 typedef struct xfs_sb { 106 - __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ 107 - __uint32_t sb_blocksize; /* logical block size, bytes */ 106 + uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ 107 + uint32_t sb_blocksize; /* logical block size, bytes */ 108 108 xfs_rfsblock_t sb_dblocks; /* number of data blocks */ 109 109 xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ 110 110 xfs_rtblock_t sb_rextents; /* number of realtime extents */ ··· 118 118 xfs_agnumber_t sb_agcount; /* number of allocation groups */ 119 119 xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ 120 120 xfs_extlen_t sb_logblocks; /* number of log blocks */ 121 - __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ 122 - __uint16_t sb_sectsize; /* volume sector size, bytes */ 123 - __uint16_t sb_inodesize; /* inode size, bytes */ 124 - __uint16_t sb_inopblock; /* inodes per block */ 121 + uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ 122 + uint16_t sb_sectsize; /* volume sector size, bytes */ 123 + uint16_t sb_inodesize; /* inode size, bytes */ 124 + uint16_t sb_inopblock; /* inodes per block */ 125 125 char sb_fname[12]; /* file system name */ 126 - __uint8_t sb_blocklog; /* log2 of sb_blocksize */ 127 - __uint8_t sb_sectlog; /* log2 of sb_sectsize */ 128 - __uint8_t sb_inodelog; /* log2 of sb_inodesize */ 129 - __uint8_t sb_inopblog; /* log2 of sb_inopblock */ 130 - __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 131 - __uint8_t sb_rextslog; /* log2 of sb_rextents */ 132 - __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ 133 - __uint8_t sb_imax_pct; /* max % of fs for inode space */ 126 + uint8_t sb_blocklog; /* log2 of sb_blocksize */ 127 + uint8_t sb_sectlog; /* log2 of sb_sectsize */ 128 + uint8_t sb_inodelog; /* log2 of sb_inodesize */ 129 + uint8_t sb_inopblog; /* log2 of sb_inopblock */ 130 + uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 131 + uint8_t sb_rextslog; /* log2 of sb_rextents */ 132 + uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ 133 + uint8_t sb_imax_pct; /* max % of fs for inode space */ 134 134 /* statistics */ 135 135 /* 136 136 * These fields must remain contiguous. If you really 137 137 * want to change their layout, make sure you fix the 138 138 * code in xfs_trans_apply_sb_deltas(). 139 139 */ 140 - __uint64_t sb_icount; /* allocated inodes */ 141 - __uint64_t sb_ifree; /* free inodes */ 142 - __uint64_t sb_fdblocks; /* free data blocks */ 143 - __uint64_t sb_frextents; /* free realtime extents */ 140 + uint64_t sb_icount; /* allocated inodes */ 141 + uint64_t sb_ifree; /* free inodes */ 142 + uint64_t sb_fdblocks; /* free data blocks */ 143 + uint64_t sb_frextents; /* free realtime extents */ 144 144 /* 145 145 * End contiguous fields. 146 146 */ 147 147 xfs_ino_t sb_uquotino; /* user quota inode */ 148 148 xfs_ino_t sb_gquotino; /* group quota inode */ 149 - __uint16_t sb_qflags; /* quota flags */ 150 - __uint8_t sb_flags; /* misc. flags */ 151 - __uint8_t sb_shared_vn; /* shared version number */ 149 + uint16_t sb_qflags; /* quota flags */ 150 + uint8_t sb_flags; /* misc. flags */ 151 + uint8_t sb_shared_vn; /* shared version number */ 152 152 xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ 153 - __uint32_t sb_unit; /* stripe or raid unit */ 154 - __uint32_t sb_width; /* stripe or raid width */ 155 - __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ 156 - __uint8_t sb_logsectlog; /* log2 of the log sector size */ 157 - __uint16_t sb_logsectsize; /* sector size for the log, bytes */ 158 - __uint32_t sb_logsunit; /* stripe unit size for the log */ 159 - __uint32_t sb_features2; /* additional feature bits */ 153 + uint32_t sb_unit; /* stripe or raid unit */ 154 + uint32_t sb_width; /* stripe or raid width */ 155 + uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ 156 + uint8_t sb_logsectlog; /* log2 of the log sector size */ 157 + uint16_t sb_logsectsize; /* sector size for the log, bytes */ 158 + uint32_t sb_logsunit; /* stripe unit size for the log */ 159 + uint32_t sb_features2; /* additional feature bits */ 160 160 161 161 /* 162 162 * bad features2 field as a result of failing to pad the sb structure to ··· 167 167 * the value in sb_features2 when formatting the incore superblock to 168 168 * the disk buffer. 169 169 */ 170 - __uint32_t sb_bad_features2; 170 + uint32_t sb_bad_features2; 171 171 172 172 /* version 5 superblock fields start here */ 173 173 174 174 /* feature masks */ 175 - __uint32_t sb_features_compat; 176 - __uint32_t sb_features_ro_compat; 177 - __uint32_t sb_features_incompat; 178 - __uint32_t sb_features_log_incompat; 175 + uint32_t sb_features_compat; 176 + uint32_t sb_features_ro_compat; 177 + uint32_t sb_features_incompat; 178 + uint32_t sb_features_log_incompat; 179 179 180 - __uint32_t sb_crc; /* superblock crc */ 180 + uint32_t sb_crc; /* superblock crc */ 181 181 xfs_extlen_t sb_spino_align; /* sparse inode chunk alignment */ 182 182 183 183 xfs_ino_t sb_pquotino; /* project quota inode */ ··· 449 449 static inline bool 450 450 xfs_sb_has_compat_feature( 451 451 struct xfs_sb *sbp, 452 - __uint32_t feature) 452 + uint32_t feature) 453 453 { 454 454 return (sbp->sb_features_compat & feature) != 0; 455 455 } ··· 465 465 static inline bool 466 466 xfs_sb_has_ro_compat_feature( 467 467 struct xfs_sb *sbp, 468 - __uint32_t feature) 468 + uint32_t feature) 469 469 { 470 470 return (sbp->sb_features_ro_compat & feature) != 0; 471 471 } ··· 482 482 static inline bool 483 483 xfs_sb_has_incompat_feature( 484 484 struct xfs_sb *sbp, 485 - __uint32_t feature) 485 + uint32_t feature) 486 486 { 487 487 return (sbp->sb_features_incompat & feature) != 0; 488 488 } ··· 492 492 static inline bool 493 493 xfs_sb_has_incompat_log_feature( 494 494 struct xfs_sb *sbp, 495 - __uint32_t feature) 495 + uint32_t feature) 496 496 { 497 497 return (sbp->sb_features_log_incompat & feature) != 0; 498 498 } ··· 594 594 */ 595 595 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) 596 596 #define XFS_B_TO_FSB(mp,b) \ 597 - ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) 598 - #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) 597 + ((((uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) 598 + #define XFS_B_TO_FSBT(mp,b) (((uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) 599 599 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) 600 600 601 601 /* ··· 1072 1072 * next agno_log bits - ag number 1073 1073 * high agno_log-agblklog-inopblog bits - 0 1074 1074 */ 1075 - #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) 1075 + #define XFS_INO_MASK(k) (uint32_t)((1ULL << (k)) - 1) 1076 1076 #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog 1077 1077 #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog 1078 1078 #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log ··· 1211 1211 1212 1212 #define XFS_SYMLINK_CRC_OFF offsetof(struct xfs_dsymlink_hdr, sl_crc) 1213 1213 1214 + #define XFS_SYMLINK_MAXLEN 1024 1214 1215 /* 1215 1216 * The maximum pathlen is 1024 bytes. Since the minimum file system 1216 1217 * blocksize is 512 bytes, we can get a max of 3 extents back from ··· 1270 1269 #define XFS_FIBT_MAGIC 0x46494254 /* 'FIBT' */ 1271 1270 #define XFS_FIBT_CRC_MAGIC 0x46494233 /* 'FIB3' */ 1272 1271 1273 - typedef __uint64_t xfs_inofree_t; 1272 + typedef uint64_t xfs_inofree_t; 1274 1273 #define XFS_INODES_PER_CHUNK (NBBY * sizeof(xfs_inofree_t)) 1275 1274 #define XFS_INODES_PER_CHUNK_LOG (XFS_NBBYLOG + 3) 1276 1275 #define XFS_INOBT_ALL_FREE ((xfs_inofree_t)-1) 1277 1276 #define XFS_INOBT_MASK(i) ((xfs_inofree_t)1 << (i)) 1278 1277 1279 1278 #define XFS_INOBT_HOLEMASK_FULL 0 /* holemask for full chunk */ 1280 - #define XFS_INOBT_HOLEMASK_BITS (NBBY * sizeof(__uint16_t)) 1279 + #define XFS_INOBT_HOLEMASK_BITS (NBBY * sizeof(uint16_t)) 1281 1280 #define XFS_INODES_PER_HOLEMASK_BIT \ 1282 - (XFS_INODES_PER_CHUNK / (NBBY * sizeof(__uint16_t))) 1281 + (XFS_INODES_PER_CHUNK / (NBBY * sizeof(uint16_t))) 1283 1282 1284 1283 static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) 1285 1284 { ··· 1313 1312 1314 1313 typedef struct xfs_inobt_rec_incore { 1315 1314 xfs_agino_t ir_startino; /* starting inode number */ 1316 - __uint16_t ir_holemask; /* hole mask for sparse chunks */ 1317 - __uint8_t ir_count; /* total inode count */ 1318 - __uint8_t ir_freecount; /* count of free inodes (set bits) */ 1315 + uint16_t ir_holemask; /* hole mask for sparse chunks */ 1316 + uint8_t ir_count; /* total inode count */ 1317 + uint8_t ir_freecount; /* count of free inodes (set bits) */ 1319 1318 xfs_inofree_t ir_free; /* free inode mask */ 1320 1319 } xfs_inobt_rec_incore_t; 1321 1320 ··· 1398 1397 * rm_offset:54-60 aren't used and should be zero 1399 1398 * rm_offset:0-53 is the block offset within the inode 1400 1399 */ 1401 - #define XFS_RMAP_OFF_ATTR_FORK ((__uint64_t)1ULL << 63) 1402 - #define XFS_RMAP_OFF_BMBT_BLOCK ((__uint64_t)1ULL << 62) 1403 - #define XFS_RMAP_OFF_UNWRITTEN ((__uint64_t)1ULL << 61) 1400 + #define XFS_RMAP_OFF_ATTR_FORK ((uint64_t)1ULL << 63) 1401 + #define XFS_RMAP_OFF_BMBT_BLOCK ((uint64_t)1ULL << 62) 1402 + #define XFS_RMAP_OFF_UNWRITTEN ((uint64_t)1ULL << 61) 1404 1403 1405 - #define XFS_RMAP_LEN_MAX ((__uint32_t)~0U) 1404 + #define XFS_RMAP_LEN_MAX ((uint32_t)~0U) 1406 1405 #define XFS_RMAP_OFF_FLAGS (XFS_RMAP_OFF_ATTR_FORK | \ 1407 1406 XFS_RMAP_OFF_BMBT_BLOCK | \ 1408 1407 XFS_RMAP_OFF_UNWRITTEN) 1409 - #define XFS_RMAP_OFF_MASK ((__uint64_t)0x3FFFFFFFFFFFFFULL) 1408 + #define XFS_RMAP_OFF_MASK ((uint64_t)0x3FFFFFFFFFFFFFULL) 1410 1409 1411 1410 #define XFS_RMAP_OFF(off) ((off) & XFS_RMAP_OFF_MASK) 1412 1411 ··· 1432 1431 struct xfs_rmap_irec { 1433 1432 xfs_agblock_t rm_startblock; /* extent start block */ 1434 1433 xfs_extlen_t rm_blockcount; /* extent length */ 1435 - __uint64_t rm_owner; /* extent owner */ 1436 - __uint64_t rm_offset; /* offset within the owner */ 1434 + uint64_t rm_owner; /* extent owner */ 1435 + uint64_t rm_offset; /* offset within the owner */ 1437 1436 unsigned int rm_flags; /* state flags */ 1438 1437 }; 1439 1438 ··· 1545 1544 __be64 l0, l1; 1546 1545 } xfs_bmbt_rec_t; 1547 1546 1548 - typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */ 1547 + typedef uint64_t xfs_bmbt_rec_base_t; /* use this for casts */ 1549 1548 typedef xfs_bmbt_rec_t xfs_bmdr_rec_t; 1550 1549 1551 1550 typedef struct xfs_bmbt_rec_host { 1552 - __uint64_t l0, l1; 1551 + uint64_t l0, l1; 1553 1552 } xfs_bmbt_rec_host_t; 1554 1553 1555 1554 /*
+6 -10
fs/xfs/libxfs/xfs_fs.h
··· 302 302 * and using two 16bit values to hold new 32bit projid was choosen 303 303 * to retain compatibility with "old" filesystems). 304 304 */ 305 - static inline __uint32_t 305 + static inline uint32_t 306 306 bstat_get_projid(struct xfs_bstat *bs) 307 307 { 308 - return (__uint32_t)bs->bs_projid_hi << 16 | bs->bs_projid_lo; 308 + return (uint32_t)bs->bs_projid_hi << 16 | bs->bs_projid_lo; 309 309 } 310 310 311 311 /* ··· 446 446 } xfs_handle_t; 447 447 #define ha_fsid ha_u._ha_fsid 448 448 449 - #define XFS_HSIZE(handle) (((char *) &(handle).ha_fid.fid_pad \ 450 - - (char *) &(handle)) \ 451 - + (handle).ha_fid.fid_len) 452 - 453 449 /* 454 450 * Structure passed to XFS_IOC_SWAPEXT 455 451 */ 456 452 typedef struct xfs_swapext 457 453 { 458 - __int64_t sx_version; /* version */ 454 + int64_t sx_version; /* version */ 459 455 #define XFS_SX_VERSION 0 460 - __int64_t sx_fdtarget; /* fd of target file */ 461 - __int64_t sx_fdtmp; /* fd of tmp file */ 456 + int64_t sx_fdtarget; /* fd of target file */ 457 + int64_t sx_fdtmp; /* fd of tmp file */ 462 458 xfs_off_t sx_offset; /* offset into file */ 463 459 xfs_off_t sx_length; /* leng from offset */ 464 460 char sx_pad[16]; /* pad space, unused */ ··· 542 546 #define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq) 543 547 #define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq) 544 548 #define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom) 545 - #define XFS_IOC_GOINGDOWN _IOR ('X', 125, __uint32_t) 549 + #define XFS_IOC_GOINGDOWN _IOR ('X', 125, uint32_t) 546 550 /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ 547 551 548 552
+31 -22
fs/xfs/libxfs/xfs_ialloc.c
··· 46 46 /* 47 47 * Allocation group level functions. 48 48 */ 49 - static inline int 49 + int 50 50 xfs_ialloc_cluster_alignment( 51 51 struct xfs_mount *mp) 52 52 { ··· 98 98 return xfs_btree_update(cur, &rec); 99 99 } 100 100 101 - /* 102 - * Get the data from the pointed-to record. 103 - */ 104 - int /* error */ 105 - xfs_inobt_get_rec( 106 - struct xfs_btree_cur *cur, /* btree cursor */ 107 - xfs_inobt_rec_incore_t *irec, /* btree record */ 108 - int *stat) /* output: success/failure */ 101 + /* Convert on-disk btree record to incore inobt record. */ 102 + void 103 + xfs_inobt_btrec_to_irec( 104 + struct xfs_mount *mp, 105 + union xfs_btree_rec *rec, 106 + struct xfs_inobt_rec_incore *irec) 109 107 { 110 - union xfs_btree_rec *rec; 111 - int error; 112 - 113 - error = xfs_btree_get_rec(cur, &rec, stat); 114 - if (error || *stat == 0) 115 - return error; 116 - 117 108 irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino); 118 - if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) { 109 + if (xfs_sb_version_hassparseinodes(&mp->m_sb)) { 119 110 irec->ir_holemask = be16_to_cpu(rec->inobt.ir_u.sp.ir_holemask); 120 111 irec->ir_count = rec->inobt.ir_u.sp.ir_count; 121 112 irec->ir_freecount = rec->inobt.ir_u.sp.ir_freecount; ··· 121 130 be32_to_cpu(rec->inobt.ir_u.f.ir_freecount); 122 131 } 123 132 irec->ir_free = be64_to_cpu(rec->inobt.ir_free); 133 + } 134 + 135 + /* 136 + * Get the data from the pointed-to record. 137 + */ 138 + int 139 + xfs_inobt_get_rec( 140 + struct xfs_btree_cur *cur, 141 + struct xfs_inobt_rec_incore *irec, 142 + int *stat) 143 + { 144 + union xfs_btree_rec *rec; 145 + int error; 146 + 147 + error = xfs_btree_get_rec(cur, &rec, stat); 148 + if (error || *stat == 0) 149 + return error; 150 + 151 + xfs_inobt_btrec_to_irec(cur->bc_mp, rec, irec); 124 152 125 153 return 0; 126 154 } ··· 150 140 STATIC int 151 141 xfs_inobt_insert_rec( 152 142 struct xfs_btree_cur *cur, 153 - __uint16_t holemask, 154 - __uint8_t count, 155 - __int32_t freecount, 143 + uint16_t holemask, 144 + uint8_t count, 145 + int32_t freecount, 156 146 xfs_inofree_t free, 157 147 int *stat) 158 148 { ··· 2552 2542 !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF)) 2553 2543 xfs_buf_ioerror(bp, -EFSBADCRC); 2554 2544 else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp, 2555 - XFS_ERRTAG_IALLOC_READ_AGI, 2556 - XFS_RANDOM_IALLOC_READ_AGI)) 2545 + XFS_ERRTAG_IALLOC_READ_AGI)) 2557 2546 xfs_buf_ioerror(bp, -EFSCORRUPTED); 2558 2547 2559 2548 if (bp->b_error)
+5
fs/xfs/libxfs/xfs_ialloc.h
··· 168 168 int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, 169 169 xfs_agnumber_t agno, struct xfs_buf **bpp); 170 170 171 + union xfs_btree_rec; 172 + void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec, 173 + struct xfs_inobt_rec_incore *irec); 174 + 175 + int xfs_ialloc_cluster_alignment(struct xfs_mount *mp); 171 176 172 177 #endif /* __XFS_IALLOC_H__ */
+28 -8
fs/xfs/libxfs/xfs_ialloc_btree.c
··· 175 175 } 176 176 177 177 STATIC void 178 + xfs_inobt_init_high_key_from_rec( 179 + union xfs_btree_key *key, 180 + union xfs_btree_rec *rec) 181 + { 182 + __u32 x; 183 + 184 + x = be32_to_cpu(rec->inobt.ir_startino); 185 + x += XFS_INODES_PER_CHUNK - 1; 186 + key->inobt.ir_startino = cpu_to_be32(x); 187 + } 188 + 189 + STATIC void 178 190 xfs_inobt_init_rec_from_cur( 179 191 struct xfs_btree_cur *cur, 180 192 union xfs_btree_rec *rec) ··· 231 219 ptr->s = agi->agi_free_root; 232 220 } 233 221 234 - STATIC __int64_t 222 + STATIC int64_t 235 223 xfs_inobt_key_diff( 236 224 struct xfs_btree_cur *cur, 237 225 union xfs_btree_key *key) 238 226 { 239 - return (__int64_t)be32_to_cpu(key->inobt.ir_startino) - 227 + return (int64_t)be32_to_cpu(key->inobt.ir_startino) - 240 228 cur->bc_rec.i.ir_startino; 229 + } 230 + 231 + STATIC int64_t 232 + xfs_inobt_diff_two_keys( 233 + struct xfs_btree_cur *cur, 234 + union xfs_btree_key *k1, 235 + union xfs_btree_key *k2) 236 + { 237 + return (int64_t)be32_to_cpu(k1->inobt.ir_startino) - 238 + be32_to_cpu(k2->inobt.ir_startino); 241 239 } 242 240 243 241 static int ··· 324 302 .verify_write = xfs_inobt_write_verify, 325 303 }; 326 304 327 - #if defined(DEBUG) || defined(XFS_WARN) 328 305 STATIC int 329 306 xfs_inobt_keys_inorder( 330 307 struct xfs_btree_cur *cur, ··· 343 322 return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <= 344 323 be32_to_cpu(r2->inobt.ir_startino); 345 324 } 346 - #endif /* DEBUG */ 347 325 348 326 static const struct xfs_btree_ops xfs_inobt_ops = { 349 327 .rec_len = sizeof(xfs_inobt_rec_t), ··· 355 335 .get_minrecs = xfs_inobt_get_minrecs, 356 336 .get_maxrecs = xfs_inobt_get_maxrecs, 357 337 .init_key_from_rec = xfs_inobt_init_key_from_rec, 338 + .init_high_key_from_rec = xfs_inobt_init_high_key_from_rec, 358 339 .init_rec_from_cur = xfs_inobt_init_rec_from_cur, 359 340 .init_ptr_from_cur = xfs_inobt_init_ptr_from_cur, 360 341 .key_diff = xfs_inobt_key_diff, 361 342 .buf_ops = &xfs_inobt_buf_ops, 362 - #if defined(DEBUG) || defined(XFS_WARN) 343 + .diff_two_keys = xfs_inobt_diff_two_keys, 363 344 .keys_inorder = xfs_inobt_keys_inorder, 364 345 .recs_inorder = xfs_inobt_recs_inorder, 365 - #endif 366 346 }; 367 347 368 348 static const struct xfs_btree_ops xfs_finobt_ops = { ··· 376 356 .get_minrecs = xfs_inobt_get_minrecs, 377 357 .get_maxrecs = xfs_inobt_get_maxrecs, 378 358 .init_key_from_rec = xfs_inobt_init_key_from_rec, 359 + .init_high_key_from_rec = xfs_inobt_init_high_key_from_rec, 379 360 .init_rec_from_cur = xfs_inobt_init_rec_from_cur, 380 361 .init_ptr_from_cur = xfs_finobt_init_ptr_from_cur, 381 362 .key_diff = xfs_inobt_key_diff, 382 363 .buf_ops = &xfs_inobt_buf_ops, 383 - #if defined(DEBUG) || defined(XFS_WARN) 364 + .diff_two_keys = xfs_inobt_diff_two_keys, 384 365 .keys_inorder = xfs_inobt_keys_inorder, 385 366 .recs_inorder = xfs_inobt_recs_inorder, 386 - #endif 387 367 }; 388 368 389 369 /*
+3 -4
fs/xfs/libxfs/xfs_inode_buf.c
··· 105 105 di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && 106 106 xfs_dinode_good_version(mp, dip->di_version); 107 107 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, 108 - XFS_ERRTAG_ITOBP_INOTOBP, 109 - XFS_RANDOM_ITOBP_INOTOBP))) { 108 + XFS_ERRTAG_ITOBP_INOTOBP))) { 110 109 if (readahead) { 111 110 bp->b_flags &= ~XBF_DONE; 112 111 xfs_buf_ioerror(bp, -EIO); ··· 380 381 } 381 382 } 382 383 383 - static bool 384 + bool 384 385 xfs_dinode_verify( 385 386 struct xfs_mount *mp, 386 387 xfs_ino_t ino, ··· 443 444 struct xfs_mount *mp, 444 445 struct xfs_dinode *dip) 445 446 { 446 - __uint32_t crc; 447 + uint32_t crc; 447 448 448 449 if (dip->di_version < 3) 449 450 return;
+17 -14
fs/xfs/libxfs/xfs_inode_buf.h
··· 28 28 * format specific structures at the appropriate time. 29 29 */ 30 30 struct xfs_icdinode { 31 - __int8_t di_version; /* inode version */ 32 - __int8_t di_format; /* format of di_c data */ 33 - __uint16_t di_flushiter; /* incremented on flush */ 34 - __uint32_t di_uid; /* owner's user id */ 35 - __uint32_t di_gid; /* owner's group id */ 36 - __uint16_t di_projid_lo; /* lower part of owner's project id */ 37 - __uint16_t di_projid_hi; /* higher part of owner's project id */ 31 + int8_t di_version; /* inode version */ 32 + int8_t di_format; /* format of di_c data */ 33 + uint16_t di_flushiter; /* incremented on flush */ 34 + uint32_t di_uid; /* owner's user id */ 35 + uint32_t di_gid; /* owner's group id */ 36 + uint16_t di_projid_lo; /* lower part of owner's project id */ 37 + uint16_t di_projid_hi; /* higher part of owner's project id */ 38 38 xfs_fsize_t di_size; /* number of bytes in file */ 39 39 xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ 40 40 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ 41 41 xfs_extnum_t di_nextents; /* number of extents in data fork */ 42 42 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ 43 - __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 44 - __int8_t di_aformat; /* format of attr fork's data */ 45 - __uint32_t di_dmevmask; /* DMIG event mask */ 46 - __uint16_t di_dmstate; /* DMIG state info */ 47 - __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 43 + uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 44 + int8_t di_aformat; /* format of attr fork's data */ 45 + uint32_t di_dmevmask; /* DMIG event mask */ 46 + uint16_t di_dmstate; /* DMIG state info */ 47 + uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 48 48 49 - __uint64_t di_flags2; /* more random flags */ 50 - __uint32_t di_cowextsize; /* basic cow extent size for file */ 49 + uint64_t di_flags2; /* more random flags */ 50 + uint32_t di_cowextsize; /* basic cow extent size for file */ 51 51 52 52 xfs_ictimestamp_t di_crtime; /* time created */ 53 53 }; ··· 81 81 #else 82 82 #define xfs_inobp_check(mp, bp) 83 83 #endif /* DEBUG */ 84 + 85 + bool xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino, 86 + struct xfs_dinode *dip); 84 87 85 88 #endif /* __XFS_INODE_BUF_H__ */
+128 -128
fs/xfs/libxfs/xfs_log_format.h
··· 31 31 * through all the log items definitions and everything they encode into the 32 32 * log. 33 33 */ 34 - typedef __uint32_t xlog_tid_t; 34 + typedef uint32_t xlog_tid_t; 35 35 36 36 #define XLOG_MIN_ICLOGS 2 37 37 #define XLOG_MAX_ICLOGS 8 ··· 211 211 typedef struct xfs_trans_header { 212 212 uint th_magic; /* magic number */ 213 213 uint th_type; /* transaction type */ 214 - __int32_t th_tid; /* transaction id (unused) */ 214 + int32_t th_tid; /* transaction id (unused) */ 215 215 uint th_num_items; /* num items logged by trans */ 216 216 } xfs_trans_header_t; 217 217 ··· 265 265 * must be added on to the end. 266 266 */ 267 267 typedef struct xfs_inode_log_format { 268 - __uint16_t ilf_type; /* inode log item type */ 269 - __uint16_t ilf_size; /* size of this item */ 270 - __uint32_t ilf_fields; /* flags for fields logged */ 271 - __uint16_t ilf_asize; /* size of attr d/ext/root */ 272 - __uint16_t ilf_dsize; /* size of data/ext/root */ 273 - __uint64_t ilf_ino; /* inode number */ 268 + uint16_t ilf_type; /* inode log item type */ 269 + uint16_t ilf_size; /* size of this item */ 270 + uint32_t ilf_fields; /* flags for fields logged */ 271 + uint16_t ilf_asize; /* size of attr d/ext/root */ 272 + uint16_t ilf_dsize; /* size of data/ext/root */ 273 + uint64_t ilf_ino; /* inode number */ 274 274 union { 275 - __uint32_t ilfu_rdev; /* rdev value for dev inode*/ 275 + uint32_t ilfu_rdev; /* rdev value for dev inode*/ 276 276 uuid_t ilfu_uuid; /* mount point value */ 277 277 } ilf_u; 278 - __int64_t ilf_blkno; /* blkno of inode buffer */ 279 - __int32_t ilf_len; /* len of inode buffer */ 280 - __int32_t ilf_boffset; /* off of inode in buffer */ 278 + int64_t ilf_blkno; /* blkno of inode buffer */ 279 + int32_t ilf_len; /* len of inode buffer */ 280 + int32_t ilf_boffset; /* off of inode in buffer */ 281 281 } xfs_inode_log_format_t; 282 282 283 283 typedef struct xfs_inode_log_format_32 { 284 - __uint16_t ilf_type; /* inode log item type */ 285 - __uint16_t ilf_size; /* size of this item */ 286 - __uint32_t ilf_fields; /* flags for fields logged */ 287 - __uint16_t ilf_asize; /* size of attr d/ext/root */ 288 - __uint16_t ilf_dsize; /* size of data/ext/root */ 289 - __uint64_t ilf_ino; /* inode number */ 284 + uint16_t ilf_type; /* inode log item type */ 285 + uint16_t ilf_size; /* size of this item */ 286 + uint32_t ilf_fields; /* flags for fields logged */ 287 + uint16_t ilf_asize; /* size of attr d/ext/root */ 288 + uint16_t ilf_dsize; /* size of data/ext/root */ 289 + uint64_t ilf_ino; /* inode number */ 290 290 union { 291 - __uint32_t ilfu_rdev; /* rdev value for dev inode*/ 291 + uint32_t ilfu_rdev; /* rdev value for dev inode*/ 292 292 uuid_t ilfu_uuid; /* mount point value */ 293 293 } ilf_u; 294 - __int64_t ilf_blkno; /* blkno of inode buffer */ 295 - __int32_t ilf_len; /* len of inode buffer */ 296 - __int32_t ilf_boffset; /* off of inode in buffer */ 294 + int64_t ilf_blkno; /* blkno of inode buffer */ 295 + int32_t ilf_len; /* len of inode buffer */ 296 + int32_t ilf_boffset; /* off of inode in buffer */ 297 297 } __attribute__((packed)) xfs_inode_log_format_32_t; 298 298 299 299 typedef struct xfs_inode_log_format_64 { 300 - __uint16_t ilf_type; /* inode log item type */ 301 - __uint16_t ilf_size; /* size of this item */ 302 - __uint32_t ilf_fields; /* flags for fields logged */ 303 - __uint16_t ilf_asize; /* size of attr d/ext/root */ 304 - __uint16_t ilf_dsize; /* size of data/ext/root */ 305 - __uint32_t ilf_pad; /* pad for 64 bit boundary */ 306 - __uint64_t ilf_ino; /* inode number */ 300 + uint16_t ilf_type; /* inode log item type */ 301 + uint16_t ilf_size; /* size of this item */ 302 + uint32_t ilf_fields; /* flags for fields logged */ 303 + uint16_t ilf_asize; /* size of attr d/ext/root */ 304 + uint16_t ilf_dsize; /* size of data/ext/root */ 305 + uint32_t ilf_pad; /* pad for 64 bit boundary */ 306 + uint64_t ilf_ino; /* inode number */ 307 307 union { 308 - __uint32_t ilfu_rdev; /* rdev value for dev inode*/ 308 + uint32_t ilfu_rdev; /* rdev value for dev inode*/ 309 309 uuid_t ilfu_uuid; /* mount point value */ 310 310 } ilf_u; 311 - __int64_t ilf_blkno; /* blkno of inode buffer */ 312 - __int32_t ilf_len; /* len of inode buffer */ 313 - __int32_t ilf_boffset; /* off of inode in buffer */ 311 + int64_t ilf_blkno; /* blkno of inode buffer */ 312 + int32_t ilf_len; /* len of inode buffer */ 313 + int32_t ilf_boffset; /* off of inode in buffer */ 314 314 } xfs_inode_log_format_64_t; 315 315 316 316 ··· 379 379 * information. 380 380 */ 381 381 typedef struct xfs_ictimestamp { 382 - __int32_t t_sec; /* timestamp seconds */ 383 - __int32_t t_nsec; /* timestamp nanoseconds */ 382 + int32_t t_sec; /* timestamp seconds */ 383 + int32_t t_nsec; /* timestamp nanoseconds */ 384 384 } xfs_ictimestamp_t; 385 385 386 386 /* ··· 388 388 * kept identical to struct xfs_dinode except for the endianness annotations. 389 389 */ 390 390 struct xfs_log_dinode { 391 - __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 392 - __uint16_t di_mode; /* mode and type of file */ 393 - __int8_t di_version; /* inode version */ 394 - __int8_t di_format; /* format of di_c data */ 395 - __uint8_t di_pad3[2]; /* unused in v2/3 inodes */ 396 - __uint32_t di_uid; /* owner's user id */ 397 - __uint32_t di_gid; /* owner's group id */ 398 - __uint32_t di_nlink; /* number of links to file */ 399 - __uint16_t di_projid_lo; /* lower part of owner's project id */ 400 - __uint16_t di_projid_hi; /* higher part of owner's project id */ 401 - __uint8_t di_pad[6]; /* unused, zeroed space */ 402 - __uint16_t di_flushiter; /* incremented on flush */ 391 + uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 392 + uint16_t di_mode; /* mode and type of file */ 393 + int8_t di_version; /* inode version */ 394 + int8_t di_format; /* format of di_c data */ 395 + uint8_t di_pad3[2]; /* unused in v2/3 inodes */ 396 + uint32_t di_uid; /* owner's user id */ 397 + uint32_t di_gid; /* owner's group id */ 398 + uint32_t di_nlink; /* number of links to file */ 399 + uint16_t di_projid_lo; /* lower part of owner's project id */ 400 + uint16_t di_projid_hi; /* higher part of owner's project id */ 401 + uint8_t di_pad[6]; /* unused, zeroed space */ 402 + uint16_t di_flushiter; /* incremented on flush */ 403 403 xfs_ictimestamp_t di_atime; /* time last accessed */ 404 404 xfs_ictimestamp_t di_mtime; /* time last modified */ 405 405 xfs_ictimestamp_t di_ctime; /* time created/inode modified */ ··· 408 408 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ 409 409 xfs_extnum_t di_nextents; /* number of extents in data fork */ 410 410 xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ 411 - __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 412 - __int8_t di_aformat; /* format of attr fork's data */ 413 - __uint32_t di_dmevmask; /* DMIG event mask */ 414 - __uint16_t di_dmstate; /* DMIG state info */ 415 - __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 416 - __uint32_t di_gen; /* generation number */ 411 + uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ 412 + int8_t di_aformat; /* format of attr fork's data */ 413 + uint32_t di_dmevmask; /* DMIG event mask */ 414 + uint16_t di_dmstate; /* DMIG state info */ 415 + uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ 416 + uint32_t di_gen; /* generation number */ 417 417 418 418 /* di_next_unlinked is the only non-core field in the old dinode */ 419 419 xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ 420 420 421 421 /* start of the extended dinode, writable fields */ 422 - __uint32_t di_crc; /* CRC of the inode */ 423 - __uint64_t di_changecount; /* number of attribute changes */ 422 + uint32_t di_crc; /* CRC of the inode */ 423 + uint64_t di_changecount; /* number of attribute changes */ 424 424 xfs_lsn_t di_lsn; /* flush sequence */ 425 - __uint64_t di_flags2; /* more random flags */ 426 - __uint32_t di_cowextsize; /* basic cow extent size for file */ 427 - __uint8_t di_pad2[12]; /* more padding for future expansion */ 425 + uint64_t di_flags2; /* more random flags */ 426 + uint32_t di_cowextsize; /* basic cow extent size for file */ 427 + uint8_t di_pad2[12]; /* more padding for future expansion */ 428 428 429 429 /* fields only written to during inode creation */ 430 430 xfs_ictimestamp_t di_crtime; /* time created */ ··· 483 483 unsigned short blf_size; /* size of this item */ 484 484 unsigned short blf_flags; /* misc state */ 485 485 unsigned short blf_len; /* number of blocks in this buf */ 486 - __int64_t blf_blkno; /* starting blkno of this buf */ 486 + int64_t blf_blkno; /* starting blkno of this buf */ 487 487 unsigned int blf_map_size; /* used size of data bitmap in words */ 488 488 unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */ 489 489 } xfs_buf_log_format_t; ··· 533 533 blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK); 534 534 } 535 535 536 - static inline __uint16_t 536 + static inline uint16_t 537 537 xfs_blft_from_flags(struct xfs_buf_log_format *blf) 538 538 { 539 539 return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT; ··· 554 554 * conversion routine. 555 555 */ 556 556 typedef struct xfs_extent_32 { 557 - __uint64_t ext_start; 558 - __uint32_t ext_len; 557 + uint64_t ext_start; 558 + uint32_t ext_len; 559 559 } __attribute__((packed)) xfs_extent_32_t; 560 560 561 561 typedef struct xfs_extent_64 { 562 - __uint64_t ext_start; 563 - __uint32_t ext_len; 564 - __uint32_t ext_pad; 562 + uint64_t ext_start; 563 + uint32_t ext_len; 564 + uint32_t ext_pad; 565 565 } xfs_extent_64_t; 566 566 567 567 /* ··· 570 570 * size is given by efi_nextents. 571 571 */ 572 572 typedef struct xfs_efi_log_format { 573 - __uint16_t efi_type; /* efi log item type */ 574 - __uint16_t efi_size; /* size of this item */ 575 - __uint32_t efi_nextents; /* # extents to free */ 576 - __uint64_t efi_id; /* efi identifier */ 573 + uint16_t efi_type; /* efi log item type */ 574 + uint16_t efi_size; /* size of this item */ 575 + uint32_t efi_nextents; /* # extents to free */ 576 + uint64_t efi_id; /* efi identifier */ 577 577 xfs_extent_t efi_extents[1]; /* array of extents to free */ 578 578 } xfs_efi_log_format_t; 579 579 580 580 typedef struct xfs_efi_log_format_32 { 581 - __uint16_t efi_type; /* efi log item type */ 582 - __uint16_t efi_size; /* size of this item */ 583 - __uint32_t efi_nextents; /* # extents to free */ 584 - __uint64_t efi_id; /* efi identifier */ 581 + uint16_t efi_type; /* efi log item type */ 582 + uint16_t efi_size; /* size of this item */ 583 + uint32_t efi_nextents; /* # extents to free */ 584 + uint64_t efi_id; /* efi identifier */ 585 585 xfs_extent_32_t efi_extents[1]; /* array of extents to free */ 586 586 } __attribute__((packed)) xfs_efi_log_format_32_t; 587 587 588 588 typedef struct xfs_efi_log_format_64 { 589 - __uint16_t efi_type; /* efi log item type */ 590 - __uint16_t efi_size; /* size of this item */ 591 - __uint32_t efi_nextents; /* # extents to free */ 592 - __uint64_t efi_id; /* efi identifier */ 589 + uint16_t efi_type; /* efi log item type */ 590 + uint16_t efi_size; /* size of this item */ 591 + uint32_t efi_nextents; /* # extents to free */ 592 + uint64_t efi_id; /* efi identifier */ 593 593 xfs_extent_64_t efi_extents[1]; /* array of extents to free */ 594 594 } xfs_efi_log_format_64_t; 595 595 ··· 599 599 * size is given by efd_nextents; 600 600 */ 601 601 typedef struct xfs_efd_log_format { 602 - __uint16_t efd_type; /* efd log item type */ 603 - __uint16_t efd_size; /* size of this item */ 604 - __uint32_t efd_nextents; /* # of extents freed */ 605 - __uint64_t efd_efi_id; /* id of corresponding efi */ 602 + uint16_t efd_type; /* efd log item type */ 603 + uint16_t efd_size; /* size of this item */ 604 + uint32_t efd_nextents; /* # of extents freed */ 605 + uint64_t efd_efi_id; /* id of corresponding efi */ 606 606 xfs_extent_t efd_extents[1]; /* array of extents freed */ 607 607 } xfs_efd_log_format_t; 608 608 609 609 typedef struct xfs_efd_log_format_32 { 610 - __uint16_t efd_type; /* efd log item type */ 611 - __uint16_t efd_size; /* size of this item */ 612 - __uint32_t efd_nextents; /* # of extents freed */ 613 - __uint64_t efd_efi_id; /* id of corresponding efi */ 610 + uint16_t efd_type; /* efd log item type */ 611 + uint16_t efd_size; /* size of this item */ 612 + uint32_t efd_nextents; /* # of extents freed */ 613 + uint64_t efd_efi_id; /* id of corresponding efi */ 614 614 xfs_extent_32_t efd_extents[1]; /* array of extents freed */ 615 615 } __attribute__((packed)) xfs_efd_log_format_32_t; 616 616 617 617 typedef struct xfs_efd_log_format_64 { 618 - __uint16_t efd_type; /* efd log item type */ 619 - __uint16_t efd_size; /* size of this item */ 620 - __uint32_t efd_nextents; /* # of extents freed */ 621 - __uint64_t efd_efi_id; /* id of corresponding efi */ 618 + uint16_t efd_type; /* efd log item type */ 619 + uint16_t efd_size; /* size of this item */ 620 + uint32_t efd_nextents; /* # of extents freed */ 621 + uint64_t efd_efi_id; /* id of corresponding efi */ 622 622 xfs_extent_64_t efd_extents[1]; /* array of extents freed */ 623 623 } xfs_efd_log_format_64_t; 624 624 ··· 626 626 * RUI/RUD (reverse mapping) log format definitions 627 627 */ 628 628 struct xfs_map_extent { 629 - __uint64_t me_owner; 630 - __uint64_t me_startblock; 631 - __uint64_t me_startoff; 632 - __uint32_t me_len; 633 - __uint32_t me_flags; 629 + uint64_t me_owner; 630 + uint64_t me_startblock; 631 + uint64_t me_startoff; 632 + uint32_t me_len; 633 + uint32_t me_flags; 634 634 }; 635 635 636 636 /* rmap me_flags: upper bits are flags, lower byte is type code */ ··· 659 659 * size is given by rui_nextents. 660 660 */ 661 661 struct xfs_rui_log_format { 662 - __uint16_t rui_type; /* rui log item type */ 663 - __uint16_t rui_size; /* size of this item */ 664 - __uint32_t rui_nextents; /* # extents to free */ 665 - __uint64_t rui_id; /* rui identifier */ 662 + uint16_t rui_type; /* rui log item type */ 663 + uint16_t rui_size; /* size of this item */ 664 + uint32_t rui_nextents; /* # extents to free */ 665 + uint64_t rui_id; /* rui identifier */ 666 666 struct xfs_map_extent rui_extents[]; /* array of extents to rmap */ 667 667 }; 668 668 ··· 680 680 * size is given by rud_nextents; 681 681 */ 682 682 struct xfs_rud_log_format { 683 - __uint16_t rud_type; /* rud log item type */ 684 - __uint16_t rud_size; /* size of this item */ 685 - __uint32_t __pad; 686 - __uint64_t rud_rui_id; /* id of corresponding rui */ 683 + uint16_t rud_type; /* rud log item type */ 684 + uint16_t rud_size; /* size of this item */ 685 + uint32_t __pad; 686 + uint64_t rud_rui_id; /* id of corresponding rui */ 687 687 }; 688 688 689 689 /* 690 690 * CUI/CUD (refcount update) log format definitions 691 691 */ 692 692 struct xfs_phys_extent { 693 - __uint64_t pe_startblock; 694 - __uint32_t pe_len; 695 - __uint32_t pe_flags; 693 + uint64_t pe_startblock; 694 + uint32_t pe_len; 695 + uint32_t pe_flags; 696 696 }; 697 697 698 698 /* refcount pe_flags: upper bits are flags, lower byte is type code */ ··· 707 707 * size is given by cui_nextents. 708 708 */ 709 709 struct xfs_cui_log_format { 710 - __uint16_t cui_type; /* cui log item type */ 711 - __uint16_t cui_size; /* size of this item */ 712 - __uint32_t cui_nextents; /* # extents to free */ 713 - __uint64_t cui_id; /* cui identifier */ 710 + uint16_t cui_type; /* cui log item type */ 711 + uint16_t cui_size; /* size of this item */ 712 + uint32_t cui_nextents; /* # extents to free */ 713 + uint64_t cui_id; /* cui identifier */ 714 714 struct xfs_phys_extent cui_extents[]; /* array of extents */ 715 715 }; 716 716 ··· 728 728 * size is given by cud_nextents; 729 729 */ 730 730 struct xfs_cud_log_format { 731 - __uint16_t cud_type; /* cud log item type */ 732 - __uint16_t cud_size; /* size of this item */ 733 - __uint32_t __pad; 734 - __uint64_t cud_cui_id; /* id of corresponding cui */ 731 + uint16_t cud_type; /* cud log item type */ 732 + uint16_t cud_size; /* size of this item */ 733 + uint32_t __pad; 734 + uint64_t cud_cui_id; /* id of corresponding cui */ 735 735 }; 736 736 737 737 /* ··· 755 755 * size is given by bui_nextents. 756 756 */ 757 757 struct xfs_bui_log_format { 758 - __uint16_t bui_type; /* bui log item type */ 759 - __uint16_t bui_size; /* size of this item */ 760 - __uint32_t bui_nextents; /* # extents to free */ 761 - __uint64_t bui_id; /* bui identifier */ 758 + uint16_t bui_type; /* bui log item type */ 759 + uint16_t bui_size; /* size of this item */ 760 + uint32_t bui_nextents; /* # extents to free */ 761 + uint64_t bui_id; /* bui identifier */ 762 762 struct xfs_map_extent bui_extents[]; /* array of extents to bmap */ 763 763 }; 764 764 ··· 776 776 * size is given by bud_nextents; 777 777 */ 778 778 struct xfs_bud_log_format { 779 - __uint16_t bud_type; /* bud log item type */ 780 - __uint16_t bud_size; /* size of this item */ 781 - __uint32_t __pad; 782 - __uint64_t bud_bui_id; /* id of corresponding bui */ 779 + uint16_t bud_type; /* bud log item type */ 780 + uint16_t bud_size; /* size of this item */ 781 + uint32_t __pad; 782 + uint64_t bud_bui_id; /* id of corresponding bui */ 783 783 }; 784 784 785 785 /* ··· 789 789 * 32 bits : log_recovery code assumes that. 790 790 */ 791 791 typedef struct xfs_dq_logformat { 792 - __uint16_t qlf_type; /* dquot log item type */ 793 - __uint16_t qlf_size; /* size of this item */ 792 + uint16_t qlf_type; /* dquot log item type */ 793 + uint16_t qlf_size; /* size of this item */ 794 794 xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ 795 - __int64_t qlf_blkno; /* blkno of dquot buffer */ 796 - __int32_t qlf_len; /* len of dquot buffer */ 797 - __uint32_t qlf_boffset; /* off of dquot in buffer */ 795 + int64_t qlf_blkno; /* blkno of dquot buffer */ 796 + int32_t qlf_len; /* len of dquot buffer */ 797 + uint32_t qlf_boffset; /* off of dquot in buffer */ 798 798 } xfs_dq_logformat_t; 799 799 800 800 /* ··· 853 853 * decoding can be done correctly. 854 854 */ 855 855 struct xfs_icreate_log { 856 - __uint16_t icl_type; /* type of log format structure */ 857 - __uint16_t icl_size; /* size of log format structure */ 856 + uint16_t icl_type; /* type of log format structure */ 857 + uint16_t icl_size; /* size of log format structure */ 858 858 __be32 icl_ag; /* ag being allocated in */ 859 859 __be32 icl_agbno; /* start block of inode range */ 860 860 __be32 icl_count; /* number of inodes to initialise */
+1 -1
fs/xfs/libxfs/xfs_log_recover.h
··· 26 26 #define XLOG_RHASH_SIZE 16 27 27 #define XLOG_RHASH_SHIFT 2 28 28 #define XLOG_RHASH(tid) \ 29 - ((((__uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1)) 29 + ((((uint32_t)tid)>>XLOG_RHASH_SHIFT) & (XLOG_RHASH_SIZE-1)) 30 30 31 31 #define XLOG_MAX_REGIONS_IN_ITEM (XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK / 2 + 1) 32 32
+4 -2
fs/xfs/libxfs/xfs_quota_defs.h
··· 27 27 * they may need 64-bit accounting. Hence, 64-bit quota-counters, 28 28 * and quota-limits. This is a waste in the common case, but hey ... 29 29 */ 30 - typedef __uint64_t xfs_qcnt_t; 31 - typedef __uint16_t xfs_qwarncnt_t; 30 + typedef uint64_t xfs_qcnt_t; 31 + typedef uint16_t xfs_qwarncnt_t; 32 32 33 33 /* 34 34 * flags for q_flags field in the dquot. ··· 135 135 * flags for dqalloc. 136 136 */ 137 137 #define XFS_QMOPT_INHERIT 0x1000000 138 + 139 + #define XFS_QMOPT_NOLOCK 0x2000000 /* don't ilock during dqget */ 138 140 139 141 /* 140 142 * flags to xfs_trans_mod_dquot.
+3 -13
fs/xfs/libxfs/xfs_refcount.c
··· 784 784 } 785 785 786 786 /* 787 - * While we're adjusting the refcounts records of an extent, we have 788 - * to keep an eye on the number of extents we're dirtying -- run too 789 - * many in a single transaction and we'll exceed the transaction's 790 - * reservation and crash the fs. Each record adds 12 bytes to the 791 - * log (plus any key updates) so we'll conservatively assume 24 bytes 792 - * per record. We must also leave space for btree splits on both ends 793 - * of the range and space for the CUD and a new CUI. 794 - * 795 787 * XXX: This is a pretty hand-wavy estimate. The penalty for guessing 796 788 * true incorrectly is a shutdown FS; the penalty for guessing false 797 789 * incorrectly is more transaction rolls than might be necessary. ··· 805 813 */ 806 814 if (cur->bc_private.a.priv.refc.nr_ops > 2 && 807 815 XFS_TEST_ERROR(false, cur->bc_mp, 808 - XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE, 809 - XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE)) 816 + XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE)) 810 817 return false; 811 818 812 819 if (cur->bc_private.a.priv.refc.nr_ops == 0) ··· 813 822 else if (overhead > cur->bc_tp->t_log_res) 814 823 return false; 815 824 return cur->bc_tp->t_log_res - overhead > 816 - cur->bc_private.a.priv.refc.nr_ops * 32; 825 + cur->bc_private.a.priv.refc.nr_ops * XFS_REFCOUNT_ITEM_OVERHEAD; 817 826 } 818 827 819 828 /* ··· 1067 1076 blockcount); 1068 1077 1069 1078 if (XFS_TEST_ERROR(false, mp, 1070 - XFS_ERRTAG_REFCOUNT_FINISH_ONE, 1071 - XFS_RANDOM_REFCOUNT_FINISH_ONE)) 1079 + XFS_ERRTAG_REFCOUNT_FINISH_ONE)) 1072 1080 return -EIO; 1073 1081 1074 1082 /*
+16
fs/xfs/libxfs/xfs_refcount.h
··· 67 67 extern int xfs_refcount_recover_cow_leftovers(struct xfs_mount *mp, 68 68 xfs_agnumber_t agno); 69 69 70 + /* 71 + * While we're adjusting the refcounts records of an extent, we have 72 + * to keep an eye on the number of extents we're dirtying -- run too 73 + * many in a single transaction and we'll exceed the transaction's 74 + * reservation and crash the fs. Each record adds 12 bytes to the 75 + * log (plus any key updates) so we'll conservatively assume 32 bytes 76 + * per record. We must also leave space for btree splits on both ends 77 + * of the range and space for the CUD and a new CUI. 78 + */ 79 + #define XFS_REFCOUNT_ITEM_OVERHEAD 32 80 + 81 + static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res) 82 + { 83 + return (log_res * 3 / 4) / XFS_REFCOUNT_ITEM_OVERHEAD; 84 + } 85 + 70 86 #endif /* __XFS_REFCOUNT_H__ */
+4 -8
fs/xfs/libxfs/xfs_refcount_btree.c
··· 202 202 ptr->s = agf->agf_refcount_root; 203 203 } 204 204 205 - STATIC __int64_t 205 + STATIC int64_t 206 206 xfs_refcountbt_key_diff( 207 207 struct xfs_btree_cur *cur, 208 208 union xfs_btree_key *key) ··· 210 210 struct xfs_refcount_irec *rec = &cur->bc_rec.rc; 211 211 struct xfs_refcount_key *kp = &key->refc; 212 212 213 - return (__int64_t)be32_to_cpu(kp->rc_startblock) - rec->rc_startblock; 213 + return (int64_t)be32_to_cpu(kp->rc_startblock) - rec->rc_startblock; 214 214 } 215 215 216 - STATIC __int64_t 216 + STATIC int64_t 217 217 xfs_refcountbt_diff_two_keys( 218 218 struct xfs_btree_cur *cur, 219 219 union xfs_btree_key *k1, 220 220 union xfs_btree_key *k2) 221 221 { 222 - return (__int64_t)be32_to_cpu(k1->refc.rc_startblock) - 222 + return (int64_t)be32_to_cpu(k1->refc.rc_startblock) - 223 223 be32_to_cpu(k2->refc.rc_startblock); 224 224 } 225 225 ··· 285 285 .verify_write = xfs_refcountbt_write_verify, 286 286 }; 287 287 288 - #if defined(DEBUG) || defined(XFS_WARN) 289 288 STATIC int 290 289 xfs_refcountbt_keys_inorder( 291 290 struct xfs_btree_cur *cur, ··· 305 306 be32_to_cpu(r1->refc.rc_blockcount) <= 306 307 be32_to_cpu(r2->refc.rc_startblock); 307 308 } 308 - #endif 309 309 310 310 static const struct xfs_btree_ops xfs_refcountbt_ops = { 311 311 .rec_len = sizeof(struct xfs_refcount_rec), ··· 323 325 .key_diff = xfs_refcountbt_key_diff, 324 326 .buf_ops = &xfs_refcountbt_buf_ops, 325 327 .diff_two_keys = xfs_refcountbt_diff_two_keys, 326 - #if defined(DEBUG) || defined(XFS_WARN) 327 328 .keys_inorder = xfs_refcountbt_keys_inorder, 328 329 .recs_inorder = xfs_refcountbt_recs_inorder, 329 - #endif 330 330 }; 331 331 332 332 /*
+7 -7
fs/xfs/libxfs/xfs_rmap.c
··· 179 179 return error; 180 180 } 181 181 182 - static int 182 + /* Convert an internal btree record to an rmap record. */ 183 + int 183 184 xfs_rmap_btrec_to_irec( 184 185 union xfs_btree_rec *rec, 185 186 struct xfs_rmap_irec *irec) ··· 2062 2061 xfs_rmap_finish_one( 2063 2062 struct xfs_trans *tp, 2064 2063 enum xfs_rmap_intent_type type, 2065 - __uint64_t owner, 2064 + uint64_t owner, 2066 2065 int whichfork, 2067 2066 xfs_fileoff_t startoff, 2068 2067 xfs_fsblock_t startblock, ··· 2087 2086 startoff, blockcount, state); 2088 2087 2089 2088 if (XFS_TEST_ERROR(false, mp, 2090 - XFS_ERRTAG_RMAP_FINISH_ONE, 2091 - XFS_RANDOM_RMAP_FINISH_ONE)) 2089 + XFS_ERRTAG_RMAP_FINISH_ONE)) 2092 2090 return -EIO; 2093 2091 2094 2092 /* ··· 2182 2182 struct xfs_mount *mp, 2183 2183 struct xfs_defer_ops *dfops, 2184 2184 enum xfs_rmap_intent_type type, 2185 - __uint64_t owner, 2185 + uint64_t owner, 2186 2186 int whichfork, 2187 2187 struct xfs_bmbt_irec *bmap) 2188 2188 { ··· 2266 2266 xfs_agnumber_t agno, 2267 2267 xfs_agblock_t bno, 2268 2268 xfs_extlen_t len, 2269 - __uint64_t owner) 2269 + uint64_t owner) 2270 2270 { 2271 2271 struct xfs_bmbt_irec bmap; 2272 2272 ··· 2290 2290 xfs_agnumber_t agno, 2291 2291 xfs_agblock_t bno, 2292 2292 xfs_extlen_t len, 2293 - __uint64_t owner) 2293 + uint64_t owner) 2294 2294 { 2295 2295 struct xfs_bmbt_irec bmap; 2296 2296
+7 -4
fs/xfs/libxfs/xfs_rmap.h
··· 179 179 struct xfs_rmap_intent { 180 180 struct list_head ri_list; 181 181 enum xfs_rmap_intent_type ri_type; 182 - __uint64_t ri_owner; 182 + uint64_t ri_owner; 183 183 int ri_whichfork; 184 184 struct xfs_bmbt_irec ri_bmap; 185 185 }; ··· 196 196 struct xfs_bmbt_irec *imap); 197 197 int xfs_rmap_alloc_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 198 198 xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len, 199 - __uint64_t owner); 199 + uint64_t owner); 200 200 int xfs_rmap_free_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops, 201 201 xfs_agnumber_t agno, xfs_agblock_t bno, xfs_extlen_t len, 202 - __uint64_t owner); 202 + uint64_t owner); 203 203 204 204 void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp, 205 205 struct xfs_btree_cur *rcur, int error); 206 206 int xfs_rmap_finish_one(struct xfs_trans *tp, enum xfs_rmap_intent_type type, 207 - __uint64_t owner, int whichfork, xfs_fileoff_t startoff, 207 + uint64_t owner, int whichfork, xfs_fileoff_t startoff, 208 208 xfs_fsblock_t startblock, xfs_filblks_t blockcount, 209 209 xfs_exntst_t state, struct xfs_btree_cur **pcur); 210 210 ··· 216 216 struct xfs_rmap_irec *irec, int *stat); 217 217 int xfs_rmap_compare(const struct xfs_rmap_irec *a, 218 218 const struct xfs_rmap_irec *b); 219 + union xfs_btree_rec; 220 + int xfs_rmap_btrec_to_irec(union xfs_btree_rec *rec, 221 + struct xfs_rmap_irec *irec); 219 222 220 223 #endif /* __XFS_RMAP_H__ */
+15 -19
fs/xfs/libxfs/xfs_rmap_btree.c
··· 199 199 union xfs_btree_key *key, 200 200 union xfs_btree_rec *rec) 201 201 { 202 - __uint64_t off; 202 + uint64_t off; 203 203 int adj; 204 204 205 205 adj = be32_to_cpu(rec->rmap.rm_blockcount) - 1; ··· 241 241 ptr->s = agf->agf_roots[cur->bc_btnum]; 242 242 } 243 243 244 - STATIC __int64_t 244 + STATIC int64_t 245 245 xfs_rmapbt_key_diff( 246 246 struct xfs_btree_cur *cur, 247 247 union xfs_btree_key *key) ··· 249 249 struct xfs_rmap_irec *rec = &cur->bc_rec.r; 250 250 struct xfs_rmap_key *kp = &key->rmap; 251 251 __u64 x, y; 252 - __int64_t d; 252 + int64_t d; 253 253 254 - d = (__int64_t)be32_to_cpu(kp->rm_startblock) - rec->rm_startblock; 254 + d = (int64_t)be32_to_cpu(kp->rm_startblock) - rec->rm_startblock; 255 255 if (d) 256 256 return d; 257 257 ··· 271 271 return 0; 272 272 } 273 273 274 - STATIC __int64_t 274 + STATIC int64_t 275 275 xfs_rmapbt_diff_two_keys( 276 276 struct xfs_btree_cur *cur, 277 277 union xfs_btree_key *k1, ··· 279 279 { 280 280 struct xfs_rmap_key *kp1 = &k1->rmap; 281 281 struct xfs_rmap_key *kp2 = &k2->rmap; 282 - __int64_t d; 282 + int64_t d; 283 283 __u64 x, y; 284 284 285 - d = (__int64_t)be32_to_cpu(kp1->rm_startblock) - 285 + d = (int64_t)be32_to_cpu(kp1->rm_startblock) - 286 286 be32_to_cpu(kp2->rm_startblock); 287 287 if (d) 288 288 return d; ··· 377 377 .verify_write = xfs_rmapbt_write_verify, 378 378 }; 379 379 380 - #if defined(DEBUG) || defined(XFS_WARN) 381 380 STATIC int 382 381 xfs_rmapbt_keys_inorder( 383 382 struct xfs_btree_cur *cur, 384 383 union xfs_btree_key *k1, 385 384 union xfs_btree_key *k2) 386 385 { 387 - __uint32_t x; 388 - __uint32_t y; 389 - __uint64_t a; 390 - __uint64_t b; 386 + uint32_t x; 387 + uint32_t y; 388 + uint64_t a; 389 + uint64_t b; 391 390 392 391 x = be32_to_cpu(k1->rmap.rm_startblock); 393 392 y = be32_to_cpu(k2->rmap.rm_startblock); ··· 413 414 union xfs_btree_rec *r1, 414 415 union xfs_btree_rec *r2) 415 416 { 416 - __uint32_t x; 417 - __uint32_t y; 418 - __uint64_t a; 419 - __uint64_t b; 417 + uint32_t x; 418 + uint32_t y; 419 + uint64_t a; 420 + uint64_t b; 420 421 421 422 x = be32_to_cpu(r1->rmap.rm_startblock); 422 423 y = be32_to_cpu(r2->rmap.rm_startblock); ··· 436 437 return 1; 437 438 return 0; 438 439 } 439 - #endif /* DEBUG */ 440 440 441 441 static const struct xfs_btree_ops xfs_rmapbt_ops = { 442 442 .rec_len = sizeof(struct xfs_rmap_rec), ··· 454 456 .key_diff = xfs_rmapbt_key_diff, 455 457 .buf_ops = &xfs_rmapbt_buf_ops, 456 458 .diff_two_keys = xfs_rmapbt_diff_two_keys, 457 - #if defined(DEBUG) || defined(XFS_WARN) 458 459 .keys_inorder = xfs_rmapbt_keys_inorder, 459 460 .recs_inorder = xfs_rmapbt_recs_inorder, 460 - #endif 461 461 }; 462 462 463 463 /*
+2 -2
fs/xfs/libxfs/xfs_rtbitmap.c
··· 70 70 * Get a buffer for the bitmap or summary file block specified. 71 71 * The buffer is returned read and locked. 72 72 */ 73 - static int 73 + int 74 74 xfs_rtbuf_get( 75 75 xfs_mount_t *mp, /* file system mount structure */ 76 76 xfs_trans_t *tp, /* transaction pointer */ ··· 1011 1011 mp->m_sb.sb_rextents) { 1012 1012 if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) 1013 1013 mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; 1014 - *(__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0; 1014 + *(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0; 1015 1015 xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); 1016 1016 } 1017 1017 return 0;
+2 -2
fs/xfs/libxfs/xfs_sb.c
··· 448 448 struct xfs_dsb *to, 449 449 struct xfs_sb *from) 450 450 { 451 - __uint16_t qflags = from->sb_qflags; 451 + uint16_t qflags = from->sb_qflags; 452 452 453 453 to->sb_uquotino = cpu_to_be64(from->sb_uquotino); 454 454 if (xfs_sb_version_has_pquotino(from)) { ··· 756 756 mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2; 757 757 758 758 mp->m_bsize = XFS_FSB_TO_BB(mp, 1); 759 - mp->m_ialloc_inos = (int)MAX((__uint16_t)XFS_INODES_PER_CHUNK, 759 + mp->m_ialloc_inos = (int)MAX((uint16_t)XFS_INODES_PER_CHUNK, 760 760 sbp->sb_inopblock); 761 761 mp->m_ialloc_blks = mp->m_ialloc_inos >> sbp->sb_inopblog; 762 762
+2 -2
fs/xfs/libxfs/xfs_trans_resv.c
··· 477 477 /* 478 478 * Making a new symplink is the same as creating a new file, but 479 479 * with the added blocks for remote symlink data which can be up to 1kB in 480 - * length (MAXPATHLEN). 480 + * length (XFS_SYMLINK_MAXLEN). 481 481 */ 482 482 STATIC uint 483 483 xfs_calc_symlink_reservation( 484 484 struct xfs_mount *mp) 485 485 { 486 486 return xfs_calc_create_reservation(mp) + 487 - xfs_calc_buf_res(1, MAXPATHLEN); 487 + xfs_calc_buf_res(1, XFS_SYMLINK_MAXLEN); 488 488 } 489 489 490 490 /*
+23 -23
fs/xfs/libxfs/xfs_types.h
··· 18 18 #ifndef __XFS_TYPES_H__ 19 19 #define __XFS_TYPES_H__ 20 20 21 - typedef __uint32_t prid_t; /* project ID */ 21 + typedef uint32_t prid_t; /* project ID */ 22 22 23 - typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */ 24 - typedef __uint32_t xfs_agino_t; /* inode # within allocation grp */ 25 - typedef __uint32_t xfs_extlen_t; /* extent length in blocks */ 26 - typedef __uint32_t xfs_agnumber_t; /* allocation group number */ 27 - typedef __int32_t xfs_extnum_t; /* # of extents in a file */ 28 - typedef __int16_t xfs_aextnum_t; /* # extents in an attribute fork */ 29 - typedef __int64_t xfs_fsize_t; /* bytes in a file */ 30 - typedef __uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ 23 + typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ 24 + typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ 25 + typedef uint32_t xfs_extlen_t; /* extent length in blocks */ 26 + typedef uint32_t xfs_agnumber_t; /* allocation group number */ 27 + typedef int32_t xfs_extnum_t; /* # of extents in a file */ 28 + typedef int16_t xfs_aextnum_t; /* # extents in an attribute fork */ 29 + typedef int64_t xfs_fsize_t; /* bytes in a file */ 30 + typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ 31 31 32 - typedef __int32_t xfs_suminfo_t; /* type of bitmap summary info */ 33 - typedef __int32_t xfs_rtword_t; /* word type for bitmap manipulations */ 32 + typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */ 33 + typedef int32_t xfs_rtword_t; /* word type for bitmap manipulations */ 34 34 35 - typedef __int64_t xfs_lsn_t; /* log sequence number */ 36 - typedef __int32_t xfs_tid_t; /* transaction identifier */ 35 + typedef int64_t xfs_lsn_t; /* log sequence number */ 36 + typedef int32_t xfs_tid_t; /* transaction identifier */ 37 37 38 - typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ 39 - typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */ 38 + typedef uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ 39 + typedef uint32_t xfs_dahash_t; /* dir/attr hash value */ 40 40 41 - typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ 42 - typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ 43 - typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ 44 - typedef __uint64_t xfs_fileoff_t; /* block number in a file */ 45 - typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ 41 + typedef uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ 42 + typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ 43 + typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ 44 + typedef uint64_t xfs_fileoff_t; /* block number in a file */ 45 + typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ 46 46 47 - typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ 48 - typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ 47 + typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ 48 + typedef int64_t xfs_sfiloff_t; /* signed block number in a file */ 49 49 50 50 /* 51 51 * Null values for the types. ··· 125 125 * uid_t and gid_t are hard-coded to 32 bits in the inode. 126 126 * Hence, an 'id' in a dquot is 32 bits.. 127 127 */ 128 - typedef __uint32_t xfs_dqid_t; 128 + typedef uint32_t xfs_dqid_t; 129 129 130 130 /* 131 131 * Constants for bit manipulations.
+4
fs/xfs/xfs.h
··· 24 24 #define XFS_BUF_LOCK_TRACKING 1 25 25 #endif 26 26 27 + #ifdef CONFIG_XFS_ASSERT_FATAL 28 + #define XFS_ASSERT_FATAL 1 29 + #endif 30 + 27 31 #ifdef CONFIG_XFS_WARN 28 32 #define XFS_WARN 1 29 33 #endif
+3 -3
fs/xfs/xfs_acl.c
··· 170 170 return acl; 171 171 } 172 172 173 - STATIC int 174 - __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) 173 + int 174 + __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 175 175 { 176 176 struct xfs_inode *ip = XFS_I(inode); 177 177 unsigned char *ea_name; ··· 268 268 } 269 269 270 270 set_acl: 271 - return __xfs_set_acl(inode, type, acl); 271 + return __xfs_set_acl(inode, acl, type); 272 272 }
+1
fs/xfs/xfs_acl.h
··· 24 24 #ifdef CONFIG_XFS_POSIX_ACL 25 25 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); 26 26 extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 27 + extern int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 27 28 #else 28 29 static inline struct posix_acl *xfs_get_acl(struct inode *inode, int type) 29 30 {
+2 -2
fs/xfs/xfs_aops.c
··· 839 839 struct inode *inode, 840 840 struct page *page, 841 841 loff_t offset, 842 - __uint64_t end_offset) 842 + uint64_t end_offset) 843 843 { 844 844 LIST_HEAD(submit_list); 845 845 struct xfs_ioend *ioend, *next; ··· 994 994 struct xfs_writepage_ctx *wpc = data; 995 995 struct inode *inode = page->mapping->host; 996 996 loff_t offset; 997 - __uint64_t end_offset; 997 + uint64_t end_offset; 998 998 pgoff_t end_index; 999 999 1000 1000 trace_xfs_writepage(inode, page, 0, 0);
+3
fs/xfs/xfs_attr.h
··· 117 117 unsigned char *, int, int); 118 118 119 119 typedef struct xfs_attr_list_context { 120 + struct xfs_trans *tp; 120 121 struct xfs_inode *dp; /* inode */ 121 122 struct attrlist_cursor_kern *cursor; /* position in list */ 122 123 char *alist; /* output buffer */ ··· 141 140 * Overall external interface routines. 142 141 */ 143 142 int xfs_attr_inactive(struct xfs_inode *dp); 143 + int xfs_attr_list_int_ilocked(struct xfs_attr_list_context *); 144 144 int xfs_attr_list_int(struct xfs_attr_list_context *); 145 145 int xfs_inode_hasattr(struct xfs_inode *ip); 146 + int xfs_attr_get_ilocked(struct xfs_inode *ip, struct xfs_da_args *args); 146 147 int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name, 147 148 unsigned char *value, int *valuelenp, int flags); 148 149 int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name,
+34 -27
fs/xfs/xfs_attr_list.c
··· 230 230 */ 231 231 bp = NULL; 232 232 if (cursor->blkno > 0) { 233 - error = xfs_da3_node_read(NULL, dp, cursor->blkno, -1, 233 + error = xfs_da3_node_read(context->tp, dp, cursor->blkno, -1, 234 234 &bp, XFS_ATTR_FORK); 235 235 if ((error != 0) && (error != -EFSCORRUPTED)) 236 236 return error; ··· 242 242 case XFS_DA_NODE_MAGIC: 243 243 case XFS_DA3_NODE_MAGIC: 244 244 trace_xfs_attr_list_wrong_blk(context); 245 - xfs_trans_brelse(NULL, bp); 245 + xfs_trans_brelse(context->tp, bp); 246 246 bp = NULL; 247 247 break; 248 248 case XFS_ATTR_LEAF_MAGIC: ··· 254 254 if (cursor->hashval > be32_to_cpu( 255 255 entries[leafhdr.count - 1].hashval)) { 256 256 trace_xfs_attr_list_wrong_blk(context); 257 - xfs_trans_brelse(NULL, bp); 257 + xfs_trans_brelse(context->tp, bp); 258 258 bp = NULL; 259 259 } else if (cursor->hashval <= be32_to_cpu( 260 260 entries[0].hashval)) { 261 261 trace_xfs_attr_list_wrong_blk(context); 262 - xfs_trans_brelse(NULL, bp); 262 + xfs_trans_brelse(context->tp, bp); 263 263 bp = NULL; 264 264 } 265 265 break; 266 266 default: 267 267 trace_xfs_attr_list_wrong_blk(context); 268 - xfs_trans_brelse(NULL, bp); 268 + xfs_trans_brelse(context->tp, bp); 269 269 bp = NULL; 270 270 } 271 271 } ··· 279 279 if (bp == NULL) { 280 280 cursor->blkno = 0; 281 281 for (;;) { 282 - __uint16_t magic; 282 + uint16_t magic; 283 283 284 - error = xfs_da3_node_read(NULL, dp, 284 + error = xfs_da3_node_read(context->tp, dp, 285 285 cursor->blkno, -1, &bp, 286 286 XFS_ATTR_FORK); 287 287 if (error) ··· 297 297 XFS_ERRLEVEL_LOW, 298 298 context->dp->i_mount, 299 299 node); 300 - xfs_trans_brelse(NULL, bp); 300 + xfs_trans_brelse(context->tp, bp); 301 301 return -EFSCORRUPTED; 302 302 } 303 303 ··· 313 313 } 314 314 } 315 315 if (i == nodehdr.count) { 316 - xfs_trans_brelse(NULL, bp); 316 + xfs_trans_brelse(context->tp, bp); 317 317 return 0; 318 318 } 319 - xfs_trans_brelse(NULL, bp); 319 + xfs_trans_brelse(context->tp, bp); 320 320 } 321 321 } 322 322 ASSERT(bp != NULL); ··· 333 333 if (context->seen_enough || leafhdr.forw == 0) 334 334 break; 335 335 cursor->blkno = leafhdr.forw; 336 - xfs_trans_brelse(NULL, bp); 337 - error = xfs_attr3_leaf_read(NULL, dp, cursor->blkno, -1, &bp); 336 + xfs_trans_brelse(context->tp, bp); 337 + error = xfs_attr3_leaf_read(context->tp, dp, cursor->blkno, -1, &bp); 338 338 if (error) 339 339 return error; 340 340 } 341 - xfs_trans_brelse(NULL, bp); 341 + xfs_trans_brelse(context->tp, bp); 342 342 return 0; 343 343 } 344 344 ··· 448 448 trace_xfs_attr_leaf_list(context); 449 449 450 450 context->cursor->blkno = 0; 451 - error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp); 451 + error = xfs_attr3_leaf_read(context->tp, context->dp, 0, -1, &bp); 452 452 if (error) 453 453 return error; 454 454 455 455 xfs_attr3_leaf_list_int(bp, context); 456 - xfs_trans_brelse(NULL, bp); 456 + xfs_trans_brelse(context->tp, bp); 457 457 return 0; 458 + } 459 + 460 + int 461 + xfs_attr_list_int_ilocked( 462 + struct xfs_attr_list_context *context) 463 + { 464 + struct xfs_inode *dp = context->dp; 465 + 466 + /* 467 + * Decide on what work routines to call based on the inode size. 468 + */ 469 + if (!xfs_inode_hasattr(dp)) 470 + return 0; 471 + else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) 472 + return xfs_attr_shortform_list(context); 473 + else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) 474 + return xfs_attr_leaf_list(context); 475 + return xfs_attr_node_list(context); 458 476 } 459 477 460 478 int ··· 488 470 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 489 471 return -EIO; 490 472 491 - /* 492 - * Decide on what work routines to call based on the inode size. 493 - */ 494 473 lock_mode = xfs_ilock_attr_map_shared(dp); 495 - if (!xfs_inode_hasattr(dp)) { 496 - error = 0; 497 - } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { 498 - error = xfs_attr_shortform_list(context); 499 - } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { 500 - error = xfs_attr_leaf_list(context); 501 - } else { 502 - error = xfs_attr_node_list(context); 503 - } 474 + error = xfs_attr_list_int_ilocked(context); 504 475 xfs_iunlock(dp, lock_mode); 505 476 return error; 506 477 }
+15 -2
fs/xfs/xfs_bmap_item.c
··· 396 396 struct xfs_map_extent *bmap; 397 397 xfs_fsblock_t startblock_fsb; 398 398 xfs_fsblock_t inode_fsb; 399 + xfs_filblks_t count; 399 400 bool op_ok; 400 401 struct xfs_bud_log_item *budp; 401 402 enum xfs_bmap_intent_type type; ··· 405 404 struct xfs_trans *tp; 406 405 struct xfs_inode *ip = NULL; 407 406 struct xfs_defer_ops dfops; 407 + struct xfs_bmbt_irec irec; 408 408 xfs_fsblock_t firstfsb; 409 409 410 410 ASSERT(!test_bit(XFS_BUI_RECOVERED, &buip->bui_flags)); ··· 483 481 } 484 482 xfs_trans_ijoin(tp, ip, 0); 485 483 484 + count = bmap->me_len; 486 485 error = xfs_trans_log_finish_bmap_update(tp, budp, &dfops, type, 487 486 ip, whichfork, bmap->me_startoff, 488 - bmap->me_startblock, bmap->me_len, 489 - state); 487 + bmap->me_startblock, &count, state); 490 488 if (error) 491 489 goto err_dfops; 490 + 491 + if (count > 0) { 492 + ASSERT(type == XFS_BMAP_UNMAP); 493 + irec.br_startblock = bmap->me_startblock; 494 + irec.br_blockcount = count; 495 + irec.br_startoff = bmap->me_startoff; 496 + irec.br_state = state; 497 + error = xfs_bmap_unmap_extent(tp->t_mountp, &dfops, ip, &irec); 498 + if (error) 499 + goto err_dfops; 500 + } 492 501 493 502 /* Finish transaction, free inodes. */ 494 503 error = xfs_defer_finish(&tp, &dfops, NULL);
+95 -69
fs/xfs/xfs_bmap_util.c
··· 219 219 */ 220 220 221 221 /* 222 - * Count leaf blocks given a range of extent records. 222 + * Count leaf blocks given a range of extent records. Delayed allocation 223 + * extents are not counted towards the totals. 223 224 */ 224 225 STATIC void 225 226 xfs_bmap_count_leaves( 226 - xfs_ifork_t *ifp, 227 - xfs_extnum_t idx, 228 - int numrecs, 229 - int *count) 227 + struct xfs_ifork *ifp, 228 + xfs_extnum_t *numrecs, 229 + xfs_filblks_t *count) 230 230 { 231 - int b; 231 + xfs_extnum_t i; 232 + xfs_extnum_t nr_exts = xfs_iext_count(ifp); 232 233 233 - for (b = 0; b < numrecs; b++) { 234 - xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b); 235 - *count += xfs_bmbt_get_blockcount(frp); 234 + for (i = 0; i < nr_exts; i++) { 235 + xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, i); 236 + if (!isnullstartblock(xfs_bmbt_get_startblock(frp))) { 237 + (*numrecs)++; 238 + *count += xfs_bmbt_get_blockcount(frp); 239 + } 236 240 } 237 241 } 238 242 ··· 249 245 struct xfs_mount *mp, 250 246 struct xfs_btree_block *block, 251 247 int numrecs, 252 - int *count) 248 + xfs_filblks_t *count) 253 249 { 254 250 int b; 255 251 xfs_bmbt_rec_t *frp; ··· 264 260 * Recursively walks each level of a btree 265 261 * to count total fsblocks in use. 266 262 */ 267 - STATIC int /* error */ 263 + STATIC int 268 264 xfs_bmap_count_tree( 269 - xfs_mount_t *mp, /* file system mount point */ 270 - xfs_trans_t *tp, /* transaction pointer */ 271 - xfs_ifork_t *ifp, /* inode fork pointer */ 272 - xfs_fsblock_t blockno, /* file system block number */ 273 - int levelin, /* level in btree */ 274 - int *count) /* Count of blocks */ 265 + struct xfs_mount *mp, 266 + struct xfs_trans *tp, 267 + struct xfs_ifork *ifp, 268 + xfs_fsblock_t blockno, 269 + int levelin, 270 + xfs_extnum_t *nextents, 271 + xfs_filblks_t *count) 275 272 { 276 273 int error; 277 - xfs_buf_t *bp, *nbp; 274 + struct xfs_buf *bp, *nbp; 278 275 int level = levelin; 279 276 __be64 *pp; 280 277 xfs_fsblock_t bno = blockno; ··· 308 303 /* Dive to the next level */ 309 304 pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]); 310 305 bno = be64_to_cpu(*pp); 311 - if (unlikely((error = 312 - xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) { 306 + error = xfs_bmap_count_tree(mp, tp, ifp, bno, level, nextents, 307 + count); 308 + if (error) { 313 309 xfs_trans_brelse(tp, bp); 314 310 XFS_ERROR_REPORT("xfs_bmap_count_tree(1)", 315 311 XFS_ERRLEVEL_LOW, mp); ··· 322 316 for (;;) { 323 317 nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib); 324 318 numrecs = be16_to_cpu(block->bb_numrecs); 319 + (*nextents) += numrecs; 325 320 xfs_bmap_disk_count_leaves(mp, block, numrecs, count); 326 321 xfs_trans_brelse(tp, bp); 327 322 if (nextbno == NULLFSBLOCK) ··· 341 334 } 342 335 343 336 /* 344 - * Count fsblocks of the given fork. 337 + * Count fsblocks of the given fork. Delayed allocation extents are 338 + * not counted towards the totals. 345 339 */ 346 - static int /* error */ 340 + int 347 341 xfs_bmap_count_blocks( 348 - xfs_trans_t *tp, /* transaction pointer */ 349 - xfs_inode_t *ip, /* incore inode */ 350 - int whichfork, /* data or attr fork */ 351 - int *count) /* out: count of blocks */ 342 + struct xfs_trans *tp, 343 + struct xfs_inode *ip, 344 + int whichfork, 345 + xfs_extnum_t *nextents, 346 + xfs_filblks_t *count) 352 347 { 353 - struct xfs_btree_block *block; /* current btree block */ 354 - xfs_fsblock_t bno; /* block # of "block" */ 355 - xfs_ifork_t *ifp; /* fork structure */ 356 - int level; /* btree level, for checking */ 357 - xfs_mount_t *mp; /* file system mount structure */ 348 + struct xfs_mount *mp; /* file system mount structure */ 358 349 __be64 *pp; /* pointer to block address */ 350 + struct xfs_btree_block *block; /* current btree block */ 351 + struct xfs_ifork *ifp; /* fork structure */ 352 + xfs_fsblock_t bno; /* block # of "block" */ 353 + int level; /* btree level, for checking */ 354 + int error; 359 355 360 356 bno = NULLFSBLOCK; 361 357 mp = ip->i_mount; 358 + *nextents = 0; 359 + *count = 0; 362 360 ifp = XFS_IFORK_PTR(ip, whichfork); 363 - if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) { 364 - xfs_bmap_count_leaves(ifp, 0, xfs_iext_count(ifp), count); 361 + if (!ifp) 365 362 return 0; 366 - } 367 363 368 - /* 369 - * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. 370 - */ 371 - block = ifp->if_broot; 372 - level = be16_to_cpu(block->bb_level); 373 - ASSERT(level > 0); 374 - pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); 375 - bno = be64_to_cpu(*pp); 376 - ASSERT(bno != NULLFSBLOCK); 377 - ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); 378 - ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); 364 + switch (XFS_IFORK_FORMAT(ip, whichfork)) { 365 + case XFS_DINODE_FMT_EXTENTS: 366 + xfs_bmap_count_leaves(ifp, nextents, count); 367 + return 0; 368 + case XFS_DINODE_FMT_BTREE: 369 + if (!(ifp->if_flags & XFS_IFEXTENTS)) { 370 + error = xfs_iread_extents(tp, ip, whichfork); 371 + if (error) 372 + return error; 373 + } 379 374 380 - if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) { 381 - XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW, 382 - mp); 383 - return -EFSCORRUPTED; 375 + /* 376 + * Root level must use BMAP_BROOT_PTR_ADDR macro to get ptr out. 377 + */ 378 + block = ifp->if_broot; 379 + level = be16_to_cpu(block->bb_level); 380 + ASSERT(level > 0); 381 + pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, 1, ifp->if_broot_bytes); 382 + bno = be64_to_cpu(*pp); 383 + ASSERT(bno != NULLFSBLOCK); 384 + ASSERT(XFS_FSB_TO_AGNO(mp, bno) < mp->m_sb.sb_agcount); 385 + ASSERT(XFS_FSB_TO_AGBNO(mp, bno) < mp->m_sb.sb_agblocks); 386 + 387 + error = xfs_bmap_count_tree(mp, tp, ifp, bno, level, 388 + nextents, count); 389 + if (error) { 390 + XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", 391 + XFS_ERRLEVEL_LOW, mp); 392 + return -EFSCORRUPTED; 393 + } 394 + return 0; 384 395 } 385 396 386 397 return 0; ··· 414 389 struct getbmapx *out, /* output structure */ 415 390 int prealloced, /* this is a file with 416 391 * preallocated data space */ 417 - __int64_t end, /* last block requested */ 392 + int64_t end, /* last block requested */ 418 393 xfs_fsblock_t startblock, 419 394 bool moretocome) 420 395 { 421 - __int64_t fixlen; 396 + int64_t fixlen; 422 397 xfs_mount_t *mp; /* file system mount point */ 423 398 xfs_ifork_t *ifp; /* inode fork pointer */ 424 399 xfs_extnum_t lastx; /* last extent pointer */ ··· 480 455 481 456 agno = XFS_FSB_TO_AGNO(mp, map->br_startblock); 482 457 agbno = XFS_FSB_TO_AGBNO(mp, map->br_startblock); 483 - error = xfs_reflink_find_shared(mp, agno, agbno, map->br_blockcount, 484 - &ebno, &elen, true); 458 + error = xfs_reflink_find_shared(mp, NULL, agno, agbno, 459 + map->br_blockcount, &ebno, &elen, true); 485 460 if (error) 486 461 return error; 487 462 ··· 539 514 xfs_bmap_format_t formatter, /* format to user */ 540 515 void *arg) /* formatter arg */ 541 516 { 542 - __int64_t bmvend; /* last block requested */ 517 + int64_t bmvend; /* last block requested */ 543 518 int error = 0; /* return value */ 544 - __int64_t fixlen; /* length for -1 case */ 519 + int64_t fixlen; /* length for -1 case */ 545 520 int i; /* extent number */ 546 521 int lock; /* lock state */ 547 522 xfs_bmbt_irec_t *map; /* buffer for user's data */ ··· 630 605 if (bmv->bmv_length == -1) { 631 606 fixlen = XFS_FSB_TO_BB(mp, XFS_B_TO_FSB(mp, fixlen)); 632 607 bmv->bmv_length = 633 - max_t(__int64_t, fixlen - bmv->bmv_offset, 0); 608 + max_t(int64_t, fixlen - bmv->bmv_offset, 0); 634 609 } else if (bmv->bmv_length == 0) { 635 610 bmv->bmv_entries = 0; 636 611 return 0; ··· 767 742 out[cur_ext].bmv_offset + 768 743 out[cur_ext].bmv_length; 769 744 bmv->bmv_length = 770 - max_t(__int64_t, 0, bmvend - bmv->bmv_offset); 745 + max_t(int64_t, 0, bmvend - bmv->bmv_offset); 771 746 772 747 /* 773 748 * In case we don't want to return the hole, ··· 1642 1617 * extent format... 1643 1618 */ 1644 1619 if (tip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1645 - if (XFS_IFORK_BOFF(ip) && 1620 + if (XFS_IFORK_Q(ip) && 1646 1621 XFS_BMAP_BMDR_SPACE(tip->i_df.if_broot) > XFS_IFORK_BOFF(ip)) 1647 1622 return -EINVAL; 1648 1623 if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <= ··· 1652 1627 1653 1628 /* Reciprocal target->temp btree format checks */ 1654 1629 if (ip->i_d.di_format == XFS_DINODE_FMT_BTREE) { 1655 - if (XFS_IFORK_BOFF(tip) && 1630 + if (XFS_IFORK_Q(tip) && 1656 1631 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip)) 1657 1632 return -EINVAL; 1658 1633 if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <= ··· 1701 1676 xfs_filblks_t ilen; 1702 1677 xfs_filblks_t rlen; 1703 1678 int nimaps; 1704 - __uint64_t tip_flags2; 1679 + uint64_t tip_flags2; 1705 1680 1706 1681 /* 1707 1682 * If the source file has shared blocks, we must flag the donor ··· 1814 1789 int *target_log_flags) 1815 1790 { 1816 1791 struct xfs_ifork tempifp, *ifp, *tifp; 1817 - int aforkblks = 0; 1818 - int taforkblks = 0; 1792 + xfs_filblks_t aforkblks = 0; 1793 + xfs_filblks_t taforkblks = 0; 1794 + xfs_extnum_t junk; 1819 1795 xfs_extnum_t nextents; 1820 - __uint64_t tmp; 1796 + uint64_t tmp; 1821 1797 int error; 1822 1798 1823 1799 /* ··· 1826 1800 */ 1827 1801 if ( ((XFS_IFORK_Q(ip) != 0) && (ip->i_d.di_anextents > 0)) && 1828 1802 (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { 1829 - error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, 1803 + error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &junk, 1830 1804 &aforkblks); 1831 1805 if (error) 1832 1806 return error; 1833 1807 } 1834 1808 if ( ((XFS_IFORK_Q(tip) != 0) && (tip->i_d.di_anextents > 0)) && 1835 1809 (tip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)) { 1836 - error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, 1810 + error = xfs_bmap_count_blocks(tp, tip, XFS_ATTR_FORK, &junk, 1837 1811 &taforkblks); 1838 1812 if (error) 1839 1813 return error; ··· 1876 1850 /* 1877 1851 * Fix the on-disk inode values 1878 1852 */ 1879 - tmp = (__uint64_t)ip->i_d.di_nblocks; 1853 + tmp = (uint64_t)ip->i_d.di_nblocks; 1880 1854 ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks; 1881 1855 tip->i_d.di_nblocks = tmp + taforkblks - aforkblks; 1882 1856 1883 - tmp = (__uint64_t) ip->i_d.di_nextents; 1857 + tmp = (uint64_t) ip->i_d.di_nextents; 1884 1858 ip->i_d.di_nextents = tip->i_d.di_nextents; 1885 1859 tip->i_d.di_nextents = tmp; 1886 1860 1887 - tmp = (__uint64_t) ip->i_d.di_format; 1861 + tmp = (uint64_t) ip->i_d.di_format; 1888 1862 ip->i_d.di_format = tip->i_d.di_format; 1889 1863 tip->i_d.di_format = tmp; 1890 1864 ··· 1953 1927 int error = 0; 1954 1928 int lock_flags; 1955 1929 struct xfs_ifork *cowfp; 1956 - __uint64_t f; 1930 + uint64_t f; 1957 1931 int resblks; 1958 1932 1959 1933 /*
+4
fs/xfs/xfs_bmap_util.h
··· 70 70 71 71 xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); 72 72 73 + int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, 74 + int whichfork, xfs_extnum_t *nextents, 75 + xfs_filblks_t *count); 76 + 73 77 #endif /* __XFS_BMAP_UTIL_H__ */
+61 -1
fs/xfs/xfs_buf.c
··· 1194 1194 { 1195 1195 xfs_alert(bp->b_target->bt_mount, 1196 1196 "metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d", 1197 - (__uint64_t)XFS_BUF_ADDR(bp), func, -bp->b_error, bp->b_length); 1197 + (uint64_t)XFS_BUF_ADDR(bp), func, -bp->b_error, bp->b_length); 1198 1198 } 1199 1199 1200 1200 int ··· 2046 2046 if (!error) 2047 2047 error = error2; 2048 2048 } 2049 + 2050 + return error; 2051 + } 2052 + 2053 + /* 2054 + * Push a single buffer on a delwri queue. 2055 + * 2056 + * The purpose of this function is to submit a single buffer of a delwri queue 2057 + * and return with the buffer still on the original queue. The waiting delwri 2058 + * buffer submission infrastructure guarantees transfer of the delwri queue 2059 + * buffer reference to a temporary wait list. We reuse this infrastructure to 2060 + * transfer the buffer back to the original queue. 2061 + * 2062 + * Note the buffer transitions from the queued state, to the submitted and wait 2063 + * listed state and back to the queued state during this call. The buffer 2064 + * locking and queue management logic between _delwri_pushbuf() and 2065 + * _delwri_queue() guarantee that the buffer cannot be queued to another list 2066 + * before returning. 2067 + */ 2068 + int 2069 + xfs_buf_delwri_pushbuf( 2070 + struct xfs_buf *bp, 2071 + struct list_head *buffer_list) 2072 + { 2073 + LIST_HEAD (submit_list); 2074 + int error; 2075 + 2076 + ASSERT(bp->b_flags & _XBF_DELWRI_Q); 2077 + 2078 + trace_xfs_buf_delwri_pushbuf(bp, _RET_IP_); 2079 + 2080 + /* 2081 + * Isolate the buffer to a new local list so we can submit it for I/O 2082 + * independently from the rest of the original list. 2083 + */ 2084 + xfs_buf_lock(bp); 2085 + list_move(&bp->b_list, &submit_list); 2086 + xfs_buf_unlock(bp); 2087 + 2088 + /* 2089 + * Delwri submission clears the DELWRI_Q buffer flag and returns with 2090 + * the buffer on the wait list with an associated reference. Rather than 2091 + * bounce the buffer from a local wait list back to the original list 2092 + * after I/O completion, reuse the original list as the wait list. 2093 + */ 2094 + xfs_buf_delwri_submit_buffers(&submit_list, buffer_list); 2095 + 2096 + /* 2097 + * The buffer is now under I/O and wait listed as during typical delwri 2098 + * submission. Lock the buffer to wait for I/O completion. Rather than 2099 + * remove the buffer from the wait list and release the reference, we 2100 + * want to return with the buffer queued to the original list. The 2101 + * buffer already sits on the original list with a wait list reference, 2102 + * however. If we let the queue inherit that wait list reference, all we 2103 + * need to do is reset the DELWRI_Q flag. 2104 + */ 2105 + xfs_buf_lock(bp); 2106 + error = bp->b_error; 2107 + bp->b_flags |= _XBF_DELWRI_Q; 2108 + xfs_buf_unlock(bp); 2049 2109 2050 2110 return error; 2051 2111 }
+1
fs/xfs/xfs_buf.h
··· 332 332 extern bool xfs_buf_delwri_queue(struct xfs_buf *, struct list_head *); 333 333 extern int xfs_buf_delwri_submit(struct list_head *); 334 334 extern int xfs_buf_delwri_submit_nowait(struct list_head *); 335 + extern int xfs_buf_delwri_pushbuf(struct xfs_buf *, struct list_head *); 335 336 336 337 /* Buffer Daemon Setup Routines */ 337 338 extern int xfs_buf_init(void);
+12 -9
fs/xfs/xfs_buf_item.c
··· 636 636 637 637 /* 638 638 * Clean buffers, by definition, cannot be in the AIL. However, aborted 639 - * buffers may be dirty and hence in the AIL. Therefore if we are 640 - * aborting a buffer and we've just taken the last refernce away, we 641 - * have to check if it is in the AIL before freeing it. We need to free 642 - * it in this case, because an aborted transaction has already shut the 643 - * filesystem down and this is the last chance we will have to do so. 639 + * buffers may be in the AIL regardless of dirty state. An aborted 640 + * transaction that invalidates a buffer already in the AIL may have 641 + * marked it stale and cleared the dirty state, for example. 642 + * 643 + * Therefore if we are aborting a buffer and we've just taken the last 644 + * reference away, we have to check if it is in the AIL before freeing 645 + * it. We need to free it in this case, because an aborted transaction 646 + * has already shut the filesystem down and this is the last chance we 647 + * will have to do so. 644 648 */ 645 649 if (atomic_dec_and_test(&bip->bli_refcount)) { 646 - if (clean) 647 - xfs_buf_item_relse(bp); 648 - else if (aborted) { 650 + if (aborted) { 649 651 ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp)); 650 652 xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR); 651 653 xfs_buf_item_relse(bp); 652 - } 654 + } else if (clean) 655 + xfs_buf_item_relse(bp); 653 656 } 654 657 655 658 if (!(flags & XFS_BLI_HOLD))
+99 -242
fs/xfs/xfs_dir2_readdir.c
··· 44 44 static unsigned char 45 45 xfs_dir3_get_dtype( 46 46 struct xfs_mount *mp, 47 - __uint8_t filetype) 47 + uint8_t filetype) 48 48 { 49 49 if (!xfs_sb_version_hasftype(&mp->m_sb)) 50 50 return DT_UNKNOWN; ··· 117 117 */ 118 118 sfep = xfs_dir2_sf_firstentry(sfp); 119 119 for (i = 0; i < sfp->count; i++) { 120 - __uint8_t filetype; 120 + uint8_t filetype; 121 121 122 122 off = xfs_dir2_db_off_to_dataptr(geo, geo->datablk, 123 123 xfs_dir2_sf_get_offset(sfep)); ··· 170 170 return 0; 171 171 172 172 lock_mode = xfs_ilock_data_map_shared(dp); 173 - error = xfs_dir3_block_read(NULL, dp, &bp); 173 + error = xfs_dir3_block_read(args->trans, dp, &bp); 174 174 xfs_iunlock(dp, lock_mode); 175 175 if (error) 176 176 return error; ··· 194 194 * Each object is a real entry (dep) or an unused one (dup). 195 195 */ 196 196 while (ptr < endptr) { 197 - __uint8_t filetype; 197 + uint8_t filetype; 198 198 199 199 dup = (xfs_dir2_data_unused_t *)ptr; 200 200 /* ··· 228 228 if (!dir_emit(ctx, (char *)dep->name, dep->namelen, 229 229 be64_to_cpu(dep->inumber), 230 230 xfs_dir3_get_dtype(dp->i_mount, filetype))) { 231 - xfs_trans_brelse(NULL, bp); 231 + xfs_trans_brelse(args->trans, bp); 232 232 return 0; 233 233 } 234 234 } ··· 239 239 */ 240 240 ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) & 241 241 0x7fffffff; 242 - xfs_trans_brelse(NULL, bp); 242 + xfs_trans_brelse(args->trans, bp); 243 243 return 0; 244 244 } 245 245 246 - struct xfs_dir2_leaf_map_info { 247 - xfs_extlen_t map_blocks; /* number of fsbs in map */ 248 - xfs_dablk_t map_off; /* last mapped file offset */ 249 - int map_size; /* total entries in *map */ 250 - int map_valid; /* valid entries in *map */ 251 - int nmap; /* mappings to ask xfs_bmapi */ 252 - xfs_dir2_db_t curdb; /* db for current block */ 253 - int ra_current; /* number of read-ahead blks */ 254 - int ra_index; /* *map index for read-ahead */ 255 - int ra_offset; /* map entry offset for ra */ 256 - int ra_want; /* readahead count wanted */ 257 - struct xfs_bmbt_irec map[]; /* map vector for blocks */ 258 - }; 259 - 246 + /* 247 + * Read a directory block and initiate readahead for blocks beyond that. 248 + * We maintain a sliding readahead window of the remaining space in the 249 + * buffer rounded up to the nearest block. 250 + */ 260 251 STATIC int 261 252 xfs_dir2_leaf_readbuf( 262 253 struct xfs_da_args *args, 263 254 size_t bufsize, 264 - struct xfs_dir2_leaf_map_info *mip, 265 - xfs_dir2_off_t *curoff, 266 - struct xfs_buf **bpp, 267 - bool trim_map) 255 + xfs_dir2_off_t *cur_off, 256 + xfs_dablk_t *ra_blk, 257 + struct xfs_buf **bpp) 268 258 { 269 259 struct xfs_inode *dp = args->dp; 270 260 struct xfs_buf *bp = NULL; 271 - struct xfs_bmbt_irec *map = mip->map; 272 - struct blk_plug plug; 273 - int error = 0; 274 - int length; 275 - int i; 276 - int j; 277 261 struct xfs_da_geometry *geo = args->geo; 262 + struct xfs_ifork *ifp = XFS_IFORK_PTR(dp, XFS_DATA_FORK); 263 + struct xfs_bmbt_irec map; 264 + struct blk_plug plug; 265 + xfs_dir2_off_t new_off; 266 + xfs_dablk_t next_ra; 267 + xfs_dablk_t map_off; 268 + xfs_dablk_t last_da; 269 + xfs_extnum_t idx; 270 + int ra_want; 271 + int error = 0; 278 272 279 - /* 280 - * If the caller just finished processing a buffer, it will tell us 281 - * we need to trim that block out of the mapping now it is done. 282 - */ 283 - if (trim_map) { 284 - mip->map_blocks -= geo->fsbcount; 285 - /* 286 - * Loop to get rid of the extents for the 287 - * directory block. 288 - */ 289 - for (i = geo->fsbcount; i > 0; ) { 290 - j = min_t(int, map->br_blockcount, i); 291 - map->br_blockcount -= j; 292 - map->br_startblock += j; 293 - map->br_startoff += j; 294 - /* 295 - * If mapping is done, pitch it from 296 - * the table. 297 - */ 298 - if (!map->br_blockcount && --mip->map_valid) 299 - memmove(&map[0], &map[1], 300 - sizeof(map[0]) * mip->map_valid); 301 - i -= j; 302 - } 303 - } 304 - 305 - /* 306 - * Recalculate the readahead blocks wanted. 307 - */ 308 - mip->ra_want = howmany(bufsize + geo->blksize, (1 << geo->fsblog)) - 1; 309 - ASSERT(mip->ra_want >= 0); 310 - 311 - /* 312 - * If we don't have as many as we want, and we haven't 313 - * run out of data blocks, get some more mappings. 314 - */ 315 - if (1 + mip->ra_want > mip->map_blocks && 316 - mip->map_off < xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET)) { 317 - /* 318 - * Get more bmaps, fill in after the ones 319 - * we already have in the table. 320 - */ 321 - mip->nmap = mip->map_size - mip->map_valid; 322 - error = xfs_bmapi_read(dp, mip->map_off, 323 - xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET) - 324 - mip->map_off, 325 - &map[mip->map_valid], &mip->nmap, 0); 326 - 327 - /* 328 - * Don't know if we should ignore this or try to return an 329 - * error. The trouble with returning errors is that readdir 330 - * will just stop without actually passing the error through. 331 - */ 273 + if (!(ifp->if_flags & XFS_IFEXTENTS)) { 274 + error = xfs_iread_extents(args->trans, dp, XFS_DATA_FORK); 332 275 if (error) 333 - goto out; /* XXX */ 334 - 335 - /* 336 - * If we got all the mappings we asked for, set the final map 337 - * offset based on the last bmap value received. Otherwise, 338 - * we've reached the end. 339 - */ 340 - if (mip->nmap == mip->map_size - mip->map_valid) { 341 - i = mip->map_valid + mip->nmap - 1; 342 - mip->map_off = map[i].br_startoff + map[i].br_blockcount; 343 - } else 344 - mip->map_off = xfs_dir2_byte_to_da(geo, 345 - XFS_DIR2_LEAF_OFFSET); 346 - 347 - /* 348 - * Look for holes in the mapping, and eliminate them. Count up 349 - * the valid blocks. 350 - */ 351 - for (i = mip->map_valid; i < mip->map_valid + mip->nmap; ) { 352 - if (map[i].br_startblock == HOLESTARTBLOCK) { 353 - mip->nmap--; 354 - length = mip->map_valid + mip->nmap - i; 355 - if (length) 356 - memmove(&map[i], &map[i + 1], 357 - sizeof(map[i]) * length); 358 - } else { 359 - mip->map_blocks += map[i].br_blockcount; 360 - i++; 361 - } 362 - } 363 - mip->map_valid += mip->nmap; 276 + goto out; 364 277 } 365 278 366 279 /* 367 - * No valid mappings, so no more data blocks. 280 + * Look for mapped directory blocks at or above the current offset. 281 + * Truncate down to the nearest directory block to start the scanning 282 + * operation. 368 283 */ 369 - if (!mip->map_valid) { 370 - *curoff = xfs_dir2_da_to_byte(geo, mip->map_off); 284 + last_da = xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET); 285 + map_off = xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, *cur_off)); 286 + if (!xfs_iext_lookup_extent(dp, ifp, map_off, &idx, &map)) 371 287 goto out; 372 - } 288 + if (map.br_startoff >= last_da) 289 + goto out; 290 + xfs_trim_extent(&map, map_off, last_da - map_off); 373 291 374 - /* 375 - * Read the directory block starting at the first mapping. 376 - */ 377 - mip->curdb = xfs_dir2_da_to_db(geo, map->br_startoff); 378 - error = xfs_dir3_data_read(NULL, dp, map->br_startoff, 379 - map->br_blockcount >= geo->fsbcount ? 380 - XFS_FSB_TO_DADDR(dp->i_mount, map->br_startblock) : 381 - -1, &bp); 382 - /* 383 - * Should just skip over the data block instead of giving up. 384 - */ 292 + /* Read the directory block of that first mapping. */ 293 + new_off = xfs_dir2_da_to_byte(geo, map.br_startoff); 294 + if (new_off > *cur_off) 295 + *cur_off = new_off; 296 + error = xfs_dir3_data_read(args->trans, dp, map.br_startoff, -1, &bp); 385 297 if (error) 386 - goto out; /* XXX */ 298 + goto out; 387 299 388 300 /* 389 - * Adjust the current amount of read-ahead: we just read a block that 390 - * was previously ra. 301 + * Start readahead for the next bufsize's worth of dir data blocks. 302 + * We may have already issued readahead for some of that range; 303 + * ra_blk tracks the last block we tried to read(ahead). 391 304 */ 392 - if (mip->ra_current) 393 - mip->ra_current -= geo->fsbcount; 305 + ra_want = howmany(bufsize + geo->blksize, (1 << geo->fsblog)); 306 + if (*ra_blk >= last_da) 307 + goto out; 308 + else if (*ra_blk == 0) 309 + *ra_blk = map.br_startoff; 310 + next_ra = map.br_startoff + geo->fsbcount; 311 + if (next_ra >= last_da) 312 + goto out_no_ra; 313 + if (map.br_blockcount < geo->fsbcount && 314 + !xfs_iext_get_extent(ifp, ++idx, &map)) 315 + goto out_no_ra; 316 + if (map.br_startoff >= last_da) 317 + goto out_no_ra; 318 + xfs_trim_extent(&map, next_ra, last_da - next_ra); 394 319 395 - /* 396 - * Do we need more readahead? 397 - * Each loop tries to process 1 full dir blk; last may be partial. 398 - */ 320 + /* Start ra for each dir (not fs) block that has a mapping. */ 399 321 blk_start_plug(&plug); 400 - for (mip->ra_index = mip->ra_offset = i = 0; 401 - mip->ra_want > mip->ra_current && i < mip->map_blocks; 402 - i += geo->fsbcount) { 403 - ASSERT(mip->ra_index < mip->map_valid); 404 - /* 405 - * Read-ahead a contiguous directory block. 406 - */ 407 - if (i > mip->ra_current && 408 - (map[mip->ra_index].br_blockcount - mip->ra_offset) >= 409 - geo->fsbcount) { 410 - xfs_dir3_data_readahead(dp, 411 - map[mip->ra_index].br_startoff + mip->ra_offset, 412 - XFS_FSB_TO_DADDR(dp->i_mount, 413 - map[mip->ra_index].br_startblock + 414 - mip->ra_offset)); 415 - mip->ra_current = i; 416 - } 417 - 418 - /* 419 - * Read-ahead a non-contiguous directory block. This doesn't 420 - * use our mapping, but this is a very rare case. 421 - */ 422 - else if (i > mip->ra_current) { 423 - xfs_dir3_data_readahead(dp, 424 - map[mip->ra_index].br_startoff + 425 - mip->ra_offset, -1); 426 - mip->ra_current = i; 427 - } 428 - 429 - /* 430 - * Advance offset through the mapping table, processing a full 431 - * dir block even if it is fragmented into several extents. 432 - * But stop if we have consumed all valid mappings, even if 433 - * it's not yet a full directory block. 434 - */ 435 - for (j = 0; 436 - j < geo->fsbcount && mip->ra_index < mip->map_valid; 437 - j += length ) { 438 - /* 439 - * The rest of this extent but not more than a dir 440 - * block. 441 - */ 442 - length = min_t(int, geo->fsbcount - j, 443 - map[mip->ra_index].br_blockcount - 444 - mip->ra_offset); 445 - mip->ra_offset += length; 446 - 447 - /* 448 - * Advance to the next mapping if this one is used up. 449 - */ 450 - if (mip->ra_offset == map[mip->ra_index].br_blockcount) { 451 - mip->ra_offset = 0; 452 - mip->ra_index++; 322 + while (ra_want > 0) { 323 + next_ra = roundup((xfs_dablk_t)map.br_startoff, geo->fsbcount); 324 + while (ra_want > 0 && 325 + next_ra < map.br_startoff + map.br_blockcount) { 326 + if (next_ra >= last_da) { 327 + *ra_blk = last_da; 328 + break; 453 329 } 330 + if (next_ra > *ra_blk) { 331 + xfs_dir3_data_readahead(dp, next_ra, -2); 332 + *ra_blk = next_ra; 333 + } 334 + ra_want -= geo->fsbcount; 335 + next_ra += geo->fsbcount; 336 + } 337 + if (!xfs_iext_get_extent(ifp, ++idx, &map)) { 338 + *ra_blk = last_da; 339 + break; 454 340 } 455 341 } 456 342 blk_finish_plug(&plug); ··· 344 458 out: 345 459 *bpp = bp; 346 460 return error; 461 + out_no_ra: 462 + *ra_blk = last_da; 463 + goto out; 347 464 } 348 465 349 466 /* ··· 364 475 xfs_dir2_data_hdr_t *hdr; /* data block header */ 365 476 xfs_dir2_data_entry_t *dep; /* data entry */ 366 477 xfs_dir2_data_unused_t *dup; /* unused entry */ 367 - int error = 0; /* error return value */ 478 + char *ptr = NULL; /* pointer to current data */ 479 + struct xfs_da_geometry *geo = args->geo; 480 + xfs_dablk_t rablk = 0; /* current readahead block */ 481 + xfs_dir2_off_t curoff; /* current overall offset */ 368 482 int length; /* temporary length value */ 369 483 int byteoff; /* offset in current block */ 370 - xfs_dir2_off_t curoff; /* current overall offset */ 371 - xfs_dir2_off_t newoff; /* new curoff after new blk */ 372 - char *ptr = NULL; /* pointer to current data */ 373 - struct xfs_dir2_leaf_map_info *map_info; 374 - struct xfs_da_geometry *geo = args->geo; 484 + int lock_mode; 485 + int error = 0; /* error return value */ 375 486 376 487 /* 377 488 * If the offset is at or past the largest allowed value, ··· 381 492 return 0; 382 493 383 494 /* 384 - * Set up to bmap a number of blocks based on the caller's 385 - * buffer size, the directory block size, and the filesystem 386 - * block size. 387 - */ 388 - length = howmany(bufsize + geo->blksize, (1 << geo->fsblog)); 389 - map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) + 390 - (length * sizeof(struct xfs_bmbt_irec)), 391 - KM_SLEEP | KM_NOFS); 392 - map_info->map_size = length; 393 - 394 - /* 395 495 * Inside the loop we keep the main offset value as a byte offset 396 496 * in the directory file. 397 497 */ 398 498 curoff = xfs_dir2_dataptr_to_byte(ctx->pos); 399 499 400 500 /* 401 - * Force this conversion through db so we truncate the offset 402 - * down to get the start of the data block. 403 - */ 404 - map_info->map_off = xfs_dir2_db_to_da(geo, 405 - xfs_dir2_byte_to_db(geo, curoff)); 406 - 407 - /* 408 501 * Loop over directory entries until we reach the end offset. 409 502 * Get more blocks and readahead as necessary. 410 503 */ 411 504 while (curoff < XFS_DIR2_LEAF_OFFSET) { 412 - __uint8_t filetype; 505 + uint8_t filetype; 413 506 414 507 /* 415 508 * If we have no buffer, or we're off the end of the 416 509 * current buffer, need to get another one. 417 510 */ 418 511 if (!bp || ptr >= (char *)bp->b_addr + geo->blksize) { 419 - int lock_mode; 420 - bool trim_map = false; 421 - 422 512 if (bp) { 423 - xfs_trans_brelse(NULL, bp); 513 + xfs_trans_brelse(args->trans, bp); 424 514 bp = NULL; 425 - trim_map = true; 426 515 } 427 516 428 517 lock_mode = xfs_ilock_data_map_shared(dp); 429 - error = xfs_dir2_leaf_readbuf(args, bufsize, map_info, 430 - &curoff, &bp, trim_map); 518 + error = xfs_dir2_leaf_readbuf(args, bufsize, &curoff, 519 + &rablk, &bp); 431 520 xfs_iunlock(dp, lock_mode); 432 - if (error || !map_info->map_valid) 521 + if (error || !bp) 433 522 break; 434 523 435 - /* 436 - * Having done a read, we need to set a new offset. 437 - */ 438 - newoff = xfs_dir2_db_off_to_byte(geo, 439 - map_info->curdb, 0); 440 - /* 441 - * Start of the current block. 442 - */ 443 - if (curoff < newoff) 444 - curoff = newoff; 445 - /* 446 - * Make sure we're in the right block. 447 - */ 448 - else if (curoff > newoff) 449 - ASSERT(xfs_dir2_byte_to_db(geo, curoff) == 450 - map_info->curdb); 451 524 hdr = bp->b_addr; 452 525 xfs_dir3_data_check(dp, bp); 453 526 /* ··· 494 643 ctx->pos = XFS_DIR2_MAX_DATAPTR & 0x7fffffff; 495 644 else 496 645 ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff; 497 - kmem_free(map_info); 498 646 if (bp) 499 - xfs_trans_brelse(NULL, bp); 647 + xfs_trans_brelse(args->trans, bp); 500 648 return error; 501 649 } 502 650 503 651 /* 504 652 * Read a directory. 653 + * 654 + * If supplied, the transaction collects locked dir buffers to avoid 655 + * nested buffer deadlocks. This function does not dirty the 656 + * transaction. The caller should ensure that the inode is locked 657 + * before calling this function. 505 658 */ 506 659 int 507 660 xfs_readdir( 661 + struct xfs_trans *tp, 508 662 struct xfs_inode *dp, 509 663 struct dir_context *ctx, 510 664 size_t bufsize) ··· 528 672 529 673 args.dp = dp; 530 674 args.geo = dp->i_mount->m_dir_geo; 675 + args.trans = tp; 531 676 532 677 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 533 678 rval = xfs_dir2_sf_getdents(&args, ctx);
+2 -2
fs/xfs/xfs_discard.c
··· 39 39 xfs_daddr_t start, 40 40 xfs_daddr_t end, 41 41 xfs_daddr_t minlen, 42 - __uint64_t *blocks_trimmed) 42 + uint64_t *blocks_trimmed) 43 43 { 44 44 struct block_device *bdev = mp->m_ddev_targp->bt_bdev; 45 45 struct xfs_btree_cur *cur; ··· 166 166 struct fstrim_range range; 167 167 xfs_daddr_t start, end, minlen; 168 168 xfs_agnumber_t start_agno, end_agno, agno; 169 - __uint64_t blocks_trimmed = 0; 169 + uint64_t blocks_trimmed = 0; 170 170 int error, last_error = 0; 171 171 172 172 if (!capable(CAP_SYS_ADMIN))
+37 -48
fs/xfs/xfs_dquot.c
··· 276 276 void 277 277 xfs_dquot_set_prealloc_limits(struct xfs_dquot *dqp) 278 278 { 279 - __uint64_t space; 279 + uint64_t space; 280 280 281 281 dqp->q_prealloc_hi_wmark = be64_to_cpu(dqp->q_core.d_blk_hardlimit); 282 282 dqp->q_prealloc_lo_wmark = be64_to_cpu(dqp->q_core.d_blk_softlimit); ··· 472 472 struct xfs_mount *mp = dqp->q_mount; 473 473 xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id); 474 474 struct xfs_trans *tp = (tpp ? *tpp : NULL); 475 - uint lock_mode; 475 + uint lock_mode = 0; 476 476 477 477 quotip = xfs_quota_inode(dqp->q_mount, dqp->dq_flags); 478 478 dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk; 479 479 480 - lock_mode = xfs_ilock_data_map_shared(quotip); 480 + ASSERT(!(flags & XFS_QMOPT_NOLOCK) || 481 + xfs_isilocked(quotip, XFS_ILOCK_SHARED) || 482 + xfs_isilocked(quotip, XFS_ILOCK_EXCL)); 483 + if (!(flags & XFS_QMOPT_NOLOCK)) 484 + lock_mode = xfs_ilock_data_map_shared(quotip); 481 485 if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) { 482 486 /* 483 487 * Return if this type of quotas is turned off while we 484 488 * didn't have the quota inode lock. 485 489 */ 486 - xfs_iunlock(quotip, lock_mode); 490 + if (lock_mode) 491 + xfs_iunlock(quotip, lock_mode); 487 492 return -ESRCH; 488 493 } 489 494 ··· 498 493 error = xfs_bmapi_read(quotip, dqp->q_fileoffset, 499 494 XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0); 500 495 501 - xfs_iunlock(quotip, lock_mode); 496 + if (lock_mode) 497 + xfs_iunlock(quotip, lock_mode); 502 498 if (error) 503 499 return error; 504 500 ··· 701 695 */ 702 696 static int 703 697 xfs_dq_get_next_id( 704 - xfs_mount_t *mp, 698 + struct xfs_mount *mp, 705 699 uint type, 706 - xfs_dqid_t *id, 707 - loff_t eof) 700 + xfs_dqid_t *id) 708 701 { 709 - struct xfs_inode *quotip; 702 + struct xfs_inode *quotip = xfs_quota_inode(mp, type); 703 + xfs_dqid_t next_id = *id + 1; /* simple advance */ 704 + uint lock_flags; 705 + struct xfs_bmbt_irec got; 706 + xfs_extnum_t idx; 710 707 xfs_fsblock_t start; 711 - loff_t offset; 712 - uint lock; 713 - xfs_dqid_t next_id; 714 708 int error = 0; 715 - 716 - /* Simple advance */ 717 - next_id = *id + 1; 718 709 719 710 /* If we'd wrap past the max ID, stop */ 720 711 if (next_id < *id) ··· 726 723 /* Nope, next_id is now past the current chunk, so find the next one */ 727 724 start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk; 728 725 729 - quotip = xfs_quota_inode(mp, type); 730 - lock = xfs_ilock_data_map_shared(quotip); 726 + lock_flags = xfs_ilock_data_map_shared(quotip); 727 + if (!(quotip->i_df.if_flags & XFS_IFEXTENTS)) { 728 + error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK); 729 + if (error) 730 + return error; 731 + } 731 732 732 - offset = __xfs_seek_hole_data(VFS_I(quotip), XFS_FSB_TO_B(mp, start), 733 - eof, SEEK_DATA); 734 - if (offset < 0) 735 - error = offset; 733 + if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &idx, &got)) { 734 + /* contiguous chunk, bump startoff for the id calculation */ 735 + if (got.br_startoff < start) 736 + got.br_startoff = start; 737 + *id = got.br_startoff * mp->m_quotainfo->qi_dqperchunk; 738 + } else { 739 + error = -ENOENT; 740 + } 736 741 737 - xfs_iunlock(quotip, lock); 742 + xfs_iunlock(quotip, lock_flags); 738 743 739 - /* -ENXIO is essentially "no more data" */ 740 - if (error) 741 - return (error == -ENXIO ? -ENOENT: error); 742 - 743 - /* Convert next data offset back to a quota id */ 744 - *id = XFS_B_TO_FSB(mp, offset) * mp->m_quotainfo->qi_dqperchunk; 745 - return 0; 744 + return error; 746 745 } 747 746 748 747 /* ··· 767 762 struct xfs_quotainfo *qi = mp->m_quotainfo; 768 763 struct radix_tree_root *tree = xfs_dquot_tree(qi, type); 769 764 struct xfs_dquot *dqp; 770 - loff_t eof = 0; 771 765 int error; 772 766 773 767 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); ··· 794 790 } 795 791 #endif 796 792 797 - /* Get the end of the quota file if we need it */ 798 - if (flags & XFS_QMOPT_DQNEXT) { 799 - struct xfs_inode *quotip; 800 - xfs_fileoff_t last; 801 - uint lock_mode; 802 - 803 - quotip = xfs_quota_inode(mp, type); 804 - lock_mode = xfs_ilock_data_map_shared(quotip); 805 - error = xfs_bmap_last_offset(quotip, &last, XFS_DATA_FORK); 806 - xfs_iunlock(quotip, lock_mode); 807 - if (error) 808 - return error; 809 - eof = XFS_FSB_TO_B(mp, last); 810 - } 811 - 812 793 restart: 813 794 mutex_lock(&qi->qi_tree_lock); 814 795 dqp = radix_tree_lookup(tree, id); ··· 812 823 if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) { 813 824 xfs_dqunlock(dqp); 814 825 mutex_unlock(&qi->qi_tree_lock); 815 - error = xfs_dq_get_next_id(mp, type, &id, eof); 826 + error = xfs_dq_get_next_id(mp, type, &id); 816 827 if (error) 817 828 return error; 818 829 goto restart; ··· 847 858 848 859 /* If we are asked to find next active id, keep looking */ 849 860 if (error == -ENOENT && (flags & XFS_QMOPT_DQNEXT)) { 850 - error = xfs_dq_get_next_id(mp, type, &id, eof); 861 + error = xfs_dq_get_next_id(mp, type, &id); 851 862 if (!error) 852 863 goto restart; 853 864 } ··· 906 917 if (flags & XFS_QMOPT_DQNEXT) { 907 918 if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) { 908 919 xfs_qm_dqput(dqp); 909 - error = xfs_dq_get_next_id(mp, type, &id, eof); 920 + error = xfs_dq_get_next_id(mp, type, &id); 910 921 if (error) 911 922 return error; 912 923 goto restart;
+252 -75
fs/xfs/xfs_error.c
··· 22 22 #include "xfs_trans_resv.h" 23 23 #include "xfs_mount.h" 24 24 #include "xfs_error.h" 25 + #include "xfs_sysfs.h" 25 26 26 27 #ifdef DEBUG 27 28 28 - int xfs_etest[XFS_NUM_INJECT_ERROR]; 29 - int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; 30 - char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; 31 - int xfs_error_test_active; 29 + static unsigned int xfs_errortag_random_default[] = { 30 + XFS_RANDOM_DEFAULT, 31 + XFS_RANDOM_IFLUSH_1, 32 + XFS_RANDOM_IFLUSH_2, 33 + XFS_RANDOM_IFLUSH_3, 34 + XFS_RANDOM_IFLUSH_4, 35 + XFS_RANDOM_IFLUSH_5, 36 + XFS_RANDOM_IFLUSH_6, 37 + XFS_RANDOM_DA_READ_BUF, 38 + XFS_RANDOM_BTREE_CHECK_LBLOCK, 39 + XFS_RANDOM_BTREE_CHECK_SBLOCK, 40 + XFS_RANDOM_ALLOC_READ_AGF, 41 + XFS_RANDOM_IALLOC_READ_AGI, 42 + XFS_RANDOM_ITOBP_INOTOBP, 43 + XFS_RANDOM_IUNLINK, 44 + XFS_RANDOM_IUNLINK_REMOVE, 45 + XFS_RANDOM_DIR_INO_VALIDATE, 46 + XFS_RANDOM_BULKSTAT_READ_CHUNK, 47 + XFS_RANDOM_IODONE_IOERR, 48 + XFS_RANDOM_STRATREAD_IOERR, 49 + XFS_RANDOM_STRATCMPL_IOERR, 50 + XFS_RANDOM_DIOWRITE_IOERR, 51 + XFS_RANDOM_BMAPIFORMAT, 52 + XFS_RANDOM_FREE_EXTENT, 53 + XFS_RANDOM_RMAP_FINISH_ONE, 54 + XFS_RANDOM_REFCOUNT_CONTINUE_UPDATE, 55 + XFS_RANDOM_REFCOUNT_FINISH_ONE, 56 + XFS_RANDOM_BMAP_FINISH_ONE, 57 + XFS_RANDOM_AG_RESV_CRITICAL, 58 + XFS_RANDOM_DROP_WRITES, 59 + XFS_RANDOM_LOG_BAD_CRC, 60 + }; 32 61 33 - int 34 - xfs_error_test(int error_tag, int *fsidp, char *expression, 35 - int line, char *file, unsigned long randfactor) 62 + struct xfs_errortag_attr { 63 + struct attribute attr; 64 + unsigned int tag; 65 + }; 66 + 67 + static inline struct xfs_errortag_attr * 68 + to_attr(struct attribute *attr) 36 69 { 37 - int i; 38 - int64_t fsid; 70 + return container_of(attr, struct xfs_errortag_attr, attr); 71 + } 39 72 40 - if (prandom_u32() % randfactor) 41 - return 0; 73 + static inline struct xfs_mount * 74 + to_mp(struct kobject *kobject) 75 + { 76 + struct xfs_kobj *kobj = to_kobj(kobject); 42 77 43 - memcpy(&fsid, fsidp, sizeof(xfs_fsid_t)); 78 + return container_of(kobj, struct xfs_mount, m_errortag_kobj); 79 + } 44 80 45 - for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { 46 - if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) { 47 - xfs_warn(NULL, 48 - "Injecting error (%s) at file %s, line %d, on filesystem \"%s\"", 49 - expression, file, line, xfs_etest_fsname[i]); 50 - return 1; 51 - } 81 + STATIC ssize_t 82 + xfs_errortag_attr_store( 83 + struct kobject *kobject, 84 + struct attribute *attr, 85 + const char *buf, 86 + size_t count) 87 + { 88 + struct xfs_mount *mp = to_mp(kobject); 89 + struct xfs_errortag_attr *xfs_attr = to_attr(attr); 90 + int ret; 91 + unsigned int val; 92 + 93 + if (strcmp(buf, "default") == 0) { 94 + val = xfs_errortag_random_default[xfs_attr->tag]; 95 + } else { 96 + ret = kstrtouint(buf, 0, &val); 97 + if (ret) 98 + return ret; 52 99 } 53 100 101 + ret = xfs_errortag_set(mp, xfs_attr->tag, val); 102 + if (ret) 103 + return ret; 104 + return count; 105 + } 106 + 107 + STATIC ssize_t 108 + xfs_errortag_attr_show( 109 + struct kobject *kobject, 110 + struct attribute *attr, 111 + char *buf) 112 + { 113 + struct xfs_mount *mp = to_mp(kobject); 114 + struct xfs_errortag_attr *xfs_attr = to_attr(attr); 115 + 116 + return snprintf(buf, PAGE_SIZE, "%u\n", 117 + xfs_errortag_get(mp, xfs_attr->tag)); 118 + } 119 + 120 + static const struct sysfs_ops xfs_errortag_sysfs_ops = { 121 + .show = xfs_errortag_attr_show, 122 + .store = xfs_errortag_attr_store, 123 + }; 124 + 125 + #define XFS_ERRORTAG_ATTR_RW(_name, _tag) \ 126 + static struct xfs_errortag_attr xfs_errortag_attr_##_name = { \ 127 + .attr = {.name = __stringify(_name), \ 128 + .mode = VERIFY_OCTAL_PERMISSIONS(S_IWUSR | S_IRUGO) }, \ 129 + .tag = (_tag), \ 130 + } 131 + 132 + #define XFS_ERRORTAG_ATTR_LIST(_name) &xfs_errortag_attr_##_name.attr 133 + 134 + XFS_ERRORTAG_ATTR_RW(noerror, XFS_ERRTAG_NOERROR); 135 + XFS_ERRORTAG_ATTR_RW(iflush1, XFS_ERRTAG_IFLUSH_1); 136 + XFS_ERRORTAG_ATTR_RW(iflush2, XFS_ERRTAG_IFLUSH_2); 137 + XFS_ERRORTAG_ATTR_RW(iflush3, XFS_ERRTAG_IFLUSH_3); 138 + XFS_ERRORTAG_ATTR_RW(iflush4, XFS_ERRTAG_IFLUSH_4); 139 + XFS_ERRORTAG_ATTR_RW(iflush5, XFS_ERRTAG_IFLUSH_5); 140 + XFS_ERRORTAG_ATTR_RW(iflush6, XFS_ERRTAG_IFLUSH_6); 141 + XFS_ERRORTAG_ATTR_RW(dareadbuf, XFS_ERRTAG_DA_READ_BUF); 142 + XFS_ERRORTAG_ATTR_RW(btree_chk_lblk, XFS_ERRTAG_BTREE_CHECK_LBLOCK); 143 + XFS_ERRORTAG_ATTR_RW(btree_chk_sblk, XFS_ERRTAG_BTREE_CHECK_SBLOCK); 144 + XFS_ERRORTAG_ATTR_RW(readagf, XFS_ERRTAG_ALLOC_READ_AGF); 145 + XFS_ERRORTAG_ATTR_RW(readagi, XFS_ERRTAG_IALLOC_READ_AGI); 146 + XFS_ERRORTAG_ATTR_RW(itobp, XFS_ERRTAG_ITOBP_INOTOBP); 147 + XFS_ERRORTAG_ATTR_RW(iunlink, XFS_ERRTAG_IUNLINK); 148 + XFS_ERRORTAG_ATTR_RW(iunlinkrm, XFS_ERRTAG_IUNLINK_REMOVE); 149 + XFS_ERRORTAG_ATTR_RW(dirinovalid, XFS_ERRTAG_DIR_INO_VALIDATE); 150 + XFS_ERRORTAG_ATTR_RW(bulkstat, XFS_ERRTAG_BULKSTAT_READ_CHUNK); 151 + XFS_ERRORTAG_ATTR_RW(logiodone, XFS_ERRTAG_IODONE_IOERR); 152 + XFS_ERRORTAG_ATTR_RW(stratread, XFS_ERRTAG_STRATREAD_IOERR); 153 + XFS_ERRORTAG_ATTR_RW(stratcmpl, XFS_ERRTAG_STRATCMPL_IOERR); 154 + XFS_ERRORTAG_ATTR_RW(diowrite, XFS_ERRTAG_DIOWRITE_IOERR); 155 + XFS_ERRORTAG_ATTR_RW(bmapifmt, XFS_ERRTAG_BMAPIFORMAT); 156 + XFS_ERRORTAG_ATTR_RW(free_extent, XFS_ERRTAG_FREE_EXTENT); 157 + XFS_ERRORTAG_ATTR_RW(rmap_finish_one, XFS_ERRTAG_RMAP_FINISH_ONE); 158 + XFS_ERRORTAG_ATTR_RW(refcount_continue_update, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE); 159 + XFS_ERRORTAG_ATTR_RW(refcount_finish_one, XFS_ERRTAG_REFCOUNT_FINISH_ONE); 160 + XFS_ERRORTAG_ATTR_RW(bmap_finish_one, XFS_ERRTAG_BMAP_FINISH_ONE); 161 + XFS_ERRORTAG_ATTR_RW(ag_resv_critical, XFS_ERRTAG_AG_RESV_CRITICAL); 162 + XFS_ERRORTAG_ATTR_RW(drop_writes, XFS_ERRTAG_DROP_WRITES); 163 + XFS_ERRORTAG_ATTR_RW(log_bad_crc, XFS_ERRTAG_LOG_BAD_CRC); 164 + 165 + static struct attribute *xfs_errortag_attrs[] = { 166 + XFS_ERRORTAG_ATTR_LIST(noerror), 167 + XFS_ERRORTAG_ATTR_LIST(iflush1), 168 + XFS_ERRORTAG_ATTR_LIST(iflush2), 169 + XFS_ERRORTAG_ATTR_LIST(iflush3), 170 + XFS_ERRORTAG_ATTR_LIST(iflush4), 171 + XFS_ERRORTAG_ATTR_LIST(iflush5), 172 + XFS_ERRORTAG_ATTR_LIST(iflush6), 173 + XFS_ERRORTAG_ATTR_LIST(dareadbuf), 174 + XFS_ERRORTAG_ATTR_LIST(btree_chk_lblk), 175 + XFS_ERRORTAG_ATTR_LIST(btree_chk_sblk), 176 + XFS_ERRORTAG_ATTR_LIST(readagf), 177 + XFS_ERRORTAG_ATTR_LIST(readagi), 178 + XFS_ERRORTAG_ATTR_LIST(itobp), 179 + XFS_ERRORTAG_ATTR_LIST(iunlink), 180 + XFS_ERRORTAG_ATTR_LIST(iunlinkrm), 181 + XFS_ERRORTAG_ATTR_LIST(dirinovalid), 182 + XFS_ERRORTAG_ATTR_LIST(bulkstat), 183 + XFS_ERRORTAG_ATTR_LIST(logiodone), 184 + XFS_ERRORTAG_ATTR_LIST(stratread), 185 + XFS_ERRORTAG_ATTR_LIST(stratcmpl), 186 + XFS_ERRORTAG_ATTR_LIST(diowrite), 187 + XFS_ERRORTAG_ATTR_LIST(bmapifmt), 188 + XFS_ERRORTAG_ATTR_LIST(free_extent), 189 + XFS_ERRORTAG_ATTR_LIST(rmap_finish_one), 190 + XFS_ERRORTAG_ATTR_LIST(refcount_continue_update), 191 + XFS_ERRORTAG_ATTR_LIST(refcount_finish_one), 192 + XFS_ERRORTAG_ATTR_LIST(bmap_finish_one), 193 + XFS_ERRORTAG_ATTR_LIST(ag_resv_critical), 194 + XFS_ERRORTAG_ATTR_LIST(drop_writes), 195 + XFS_ERRORTAG_ATTR_LIST(log_bad_crc), 196 + NULL, 197 + }; 198 + 199 + struct kobj_type xfs_errortag_ktype = { 200 + .release = xfs_sysfs_release, 201 + .sysfs_ops = &xfs_errortag_sysfs_ops, 202 + .default_attrs = xfs_errortag_attrs, 203 + }; 204 + 205 + int 206 + xfs_errortag_init( 207 + struct xfs_mount *mp) 208 + { 209 + mp->m_errortag = kmem_zalloc(sizeof(unsigned int) * XFS_ERRTAG_MAX, 210 + KM_SLEEP | KM_MAYFAIL); 211 + if (!mp->m_errortag) 212 + return -ENOMEM; 213 + 214 + return xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype, 215 + &mp->m_kobj, "errortag"); 216 + } 217 + 218 + void 219 + xfs_errortag_del( 220 + struct xfs_mount *mp) 221 + { 222 + xfs_sysfs_del(&mp->m_errortag_kobj); 223 + kmem_free(mp->m_errortag); 224 + } 225 + 226 + bool 227 + xfs_errortag_test( 228 + struct xfs_mount *mp, 229 + const char *expression, 230 + const char *file, 231 + int line, 232 + unsigned int error_tag) 233 + { 234 + unsigned int randfactor; 235 + 236 + /* 237 + * To be able to use error injection anywhere, we need to ensure error 238 + * injection mechanism is already initialized. 239 + * 240 + * Code paths like I/O completion can be called before the 241 + * initialization is complete, but be able to inject errors in such 242 + * places is still useful. 243 + */ 244 + if (!mp->m_errortag) 245 + return false; 246 + 247 + ASSERT(error_tag < XFS_ERRTAG_MAX); 248 + randfactor = mp->m_errortag[error_tag]; 249 + if (!randfactor || prandom_u32() % randfactor) 250 + return false; 251 + 252 + xfs_warn_ratelimited(mp, 253 + "Injecting error (%s) at file %s, line %d, on filesystem \"%s\"", 254 + expression, file, line, mp->m_fsname); 255 + return true; 256 + } 257 + 258 + int 259 + xfs_errortag_get( 260 + struct xfs_mount *mp, 261 + unsigned int error_tag) 262 + { 263 + if (error_tag >= XFS_ERRTAG_MAX) 264 + return -EINVAL; 265 + 266 + return mp->m_errortag[error_tag]; 267 + } 268 + 269 + int 270 + xfs_errortag_set( 271 + struct xfs_mount *mp, 272 + unsigned int error_tag, 273 + unsigned int tag_value) 274 + { 275 + if (error_tag >= XFS_ERRTAG_MAX) 276 + return -EINVAL; 277 + 278 + mp->m_errortag[error_tag] = tag_value; 54 279 return 0; 55 280 } 56 281 57 282 int 58 - xfs_errortag_add(unsigned int error_tag, xfs_mount_t *mp) 283 + xfs_errortag_add( 284 + struct xfs_mount *mp, 285 + unsigned int error_tag) 59 286 { 60 - int i; 61 - int len; 62 - int64_t fsid; 63 - 64 287 if (error_tag >= XFS_ERRTAG_MAX) 65 288 return -EINVAL; 66 289 67 - memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t)); 68 - 69 - for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { 70 - if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) { 71 - xfs_warn(mp, "error tag #%d on", error_tag); 72 - return 0; 73 - } 74 - } 75 - 76 - for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { 77 - if (xfs_etest[i] == 0) { 78 - xfs_warn(mp, "Turned on XFS error tag #%d", 79 - error_tag); 80 - xfs_etest[i] = error_tag; 81 - xfs_etest_fsid[i] = fsid; 82 - len = strlen(mp->m_fsname); 83 - xfs_etest_fsname[i] = kmem_alloc(len + 1, KM_SLEEP); 84 - strcpy(xfs_etest_fsname[i], mp->m_fsname); 85 - xfs_error_test_active++; 86 - return 0; 87 - } 88 - } 89 - 90 - xfs_warn(mp, "error tag overflow, too many turned on"); 91 - 92 - return 1; 290 + return xfs_errortag_set(mp, error_tag, 291 + xfs_errortag_random_default[error_tag]); 93 292 } 94 293 95 294 int 96 - xfs_errortag_clearall(xfs_mount_t *mp, int loud) 295 + xfs_errortag_clearall( 296 + struct xfs_mount *mp) 97 297 { 98 - int64_t fsid; 99 - int cleared = 0; 100 - int i; 101 - 102 - memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t)); 103 - 104 - 105 - for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) { 106 - if ((fsid == 0LL || xfs_etest_fsid[i] == fsid) && 107 - xfs_etest[i] != 0) { 108 - cleared = 1; 109 - xfs_warn(mp, "Clearing XFS error tag #%d", 110 - xfs_etest[i]); 111 - xfs_etest[i] = 0; 112 - xfs_etest_fsid[i] = 0LL; 113 - kmem_free(xfs_etest_fsname[i]); 114 - xfs_etest_fsname[i] = NULL; 115 - xfs_error_test_active--; 116 - } 117 - } 118 - 119 - if (loud || cleared) 120 - xfs_warn(mp, "Cleared all XFS error tags for filesystem"); 121 - 298 + memset(mp->m_errortag, 0, sizeof(unsigned int) * XFS_ERRTAG_MAX); 122 299 return 0; 123 300 } 124 301 #endif /* DEBUG */
+30 -14
fs/xfs/xfs_error.h
··· 96 96 #define XFS_ERRTAG_REFCOUNT_FINISH_ONE 25 97 97 #define XFS_ERRTAG_BMAP_FINISH_ONE 26 98 98 #define XFS_ERRTAG_AG_RESV_CRITICAL 27 99 - #define XFS_ERRTAG_MAX 28 99 + /* 100 + * DEBUG mode instrumentation to test and/or trigger delayed allocation 101 + * block killing in the event of failed writes. When enabled, all 102 + * buffered writes are silenty dropped and handled as if they failed. 103 + * All delalloc blocks in the range of the write (including pre-existing 104 + * delalloc blocks!) are tossed as part of the write failure error 105 + * handling sequence. 106 + */ 107 + #define XFS_ERRTAG_DROP_WRITES 28 108 + #define XFS_ERRTAG_LOG_BAD_CRC 29 109 + #define XFS_ERRTAG_MAX 30 100 110 101 111 /* 102 112 * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. ··· 139 129 #define XFS_RANDOM_REFCOUNT_FINISH_ONE 1 140 130 #define XFS_RANDOM_BMAP_FINISH_ONE 1 141 131 #define XFS_RANDOM_AG_RESV_CRITICAL 4 132 + #define XFS_RANDOM_DROP_WRITES 1 133 + #define XFS_RANDOM_LOG_BAD_CRC 1 142 134 143 135 #ifdef DEBUG 144 - extern int xfs_error_test_active; 145 - extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); 136 + extern int xfs_errortag_init(struct xfs_mount *mp); 137 + extern void xfs_errortag_del(struct xfs_mount *mp); 138 + extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression, 139 + const char *file, int line, unsigned int error_tag); 140 + #define XFS_TEST_ERROR(expr, mp, tag) \ 141 + ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) 146 142 147 - #define XFS_NUM_INJECT_ERROR 10 148 - #define XFS_TEST_ERROR(expr, mp, tag, rf) \ 149 - ((expr) || (xfs_error_test_active && \ 150 - xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \ 151 - (rf)))) 152 - 153 - extern int xfs_errortag_add(unsigned int error_tag, struct xfs_mount *mp); 154 - extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud); 143 + extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag); 144 + extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag, 145 + unsigned int tag_value); 146 + extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); 147 + extern int xfs_errortag_clearall(struct xfs_mount *mp); 155 148 #else 156 - #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) 157 - #define xfs_errortag_add(tag, mp) (ENOSYS) 158 - #define xfs_errortag_clearall(mp, loud) (ENOSYS) 149 + #define xfs_errortag_init(mp) (0) 150 + #define xfs_errortag_del(mp) 151 + #define XFS_TEST_ERROR(expr, mp, tag) (expr) 152 + #define xfs_errortag_set(mp, tag, val) (ENOSYS) 153 + #define xfs_errortag_add(mp, tag) (ENOSYS) 154 + #define xfs_errortag_clearall(mp) (ENOSYS) 159 155 #endif /* DEBUG */ 160 156 161 157 /*
+16 -362
fs/xfs/xfs_file.c
··· 679 679 xfs_iunlock(ip, iolock); 680 680 eofb.eof_flags = XFS_EOF_FLAGS_SYNC; 681 681 xfs_icache_free_eofblocks(ip->i_mount, &eofb); 682 + xfs_icache_free_cowblocks(ip->i_mount, &eofb); 682 683 goto write_retry; 683 684 } 684 685 ··· 971 970 */ 972 971 bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); 973 972 974 - return xfs_readdir(ip, ctx, bufsize); 975 - } 976 - 977 - /* 978 - * This type is designed to indicate the type of offset we would like 979 - * to search from page cache for xfs_seek_hole_data(). 980 - */ 981 - enum { 982 - HOLE_OFF = 0, 983 - DATA_OFF, 984 - }; 985 - 986 - /* 987 - * Lookup the desired type of offset from the given page. 988 - * 989 - * On success, return true and the offset argument will point to the 990 - * start of the region that was found. Otherwise this function will 991 - * return false and keep the offset argument unchanged. 992 - */ 993 - STATIC bool 994 - xfs_lookup_buffer_offset( 995 - struct page *page, 996 - loff_t *offset, 997 - unsigned int type) 998 - { 999 - loff_t lastoff = page_offset(page); 1000 - bool found = false; 1001 - struct buffer_head *bh, *head; 1002 - 1003 - bh = head = page_buffers(page); 1004 - do { 1005 - /* 1006 - * Unwritten extents that have data in the page 1007 - * cache covering them can be identified by the 1008 - * BH_Unwritten state flag. Pages with multiple 1009 - * buffers might have a mix of holes, data and 1010 - * unwritten extents - any buffer with valid 1011 - * data in it should have BH_Uptodate flag set 1012 - * on it. 1013 - */ 1014 - if (buffer_unwritten(bh) || 1015 - buffer_uptodate(bh)) { 1016 - if (type == DATA_OFF) 1017 - found = true; 1018 - } else { 1019 - if (type == HOLE_OFF) 1020 - found = true; 1021 - } 1022 - 1023 - if (found) { 1024 - *offset = lastoff; 1025 - break; 1026 - } 1027 - lastoff += bh->b_size; 1028 - } while ((bh = bh->b_this_page) != head); 1029 - 1030 - return found; 1031 - } 1032 - 1033 - /* 1034 - * This routine is called to find out and return a data or hole offset 1035 - * from the page cache for unwritten extents according to the desired 1036 - * type for xfs_seek_hole_data(). 1037 - * 1038 - * The argument offset is used to tell where we start to search from the 1039 - * page cache. Map is used to figure out the end points of the range to 1040 - * lookup pages. 1041 - * 1042 - * Return true if the desired type of offset was found, and the argument 1043 - * offset is filled with that address. Otherwise, return false and keep 1044 - * offset unchanged. 1045 - */ 1046 - STATIC bool 1047 - xfs_find_get_desired_pgoff( 1048 - struct inode *inode, 1049 - struct xfs_bmbt_irec *map, 1050 - unsigned int type, 1051 - loff_t *offset) 1052 - { 1053 - struct xfs_inode *ip = XFS_I(inode); 1054 - struct xfs_mount *mp = ip->i_mount; 1055 - struct pagevec pvec; 1056 - pgoff_t index; 1057 - pgoff_t end; 1058 - loff_t endoff; 1059 - loff_t startoff = *offset; 1060 - loff_t lastoff = startoff; 1061 - bool found = false; 1062 - 1063 - pagevec_init(&pvec, 0); 1064 - 1065 - index = startoff >> PAGE_SHIFT; 1066 - endoff = XFS_FSB_TO_B(mp, map->br_startoff + map->br_blockcount); 1067 - end = (endoff - 1) >> PAGE_SHIFT; 1068 - do { 1069 - int want; 1070 - unsigned nr_pages; 1071 - unsigned int i; 1072 - 1073 - want = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; 1074 - nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, 1075 - want); 1076 - if (nr_pages == 0) 1077 - break; 1078 - 1079 - for (i = 0; i < nr_pages; i++) { 1080 - struct page *page = pvec.pages[i]; 1081 - loff_t b_offset; 1082 - 1083 - /* 1084 - * At this point, the page may be truncated or 1085 - * invalidated (changing page->mapping to NULL), 1086 - * or even swizzled back from swapper_space to tmpfs 1087 - * file mapping. However, page->index will not change 1088 - * because we have a reference on the page. 1089 - * 1090 - * If current page offset is beyond where we've ended, 1091 - * we've found a hole. 1092 - */ 1093 - if (type == HOLE_OFF && lastoff < endoff && 1094 - lastoff < page_offset(pvec.pages[i])) { 1095 - found = true; 1096 - *offset = lastoff; 1097 - goto out; 1098 - } 1099 - /* Searching done if the page index is out of range. */ 1100 - if (page->index > end) 1101 - goto out; 1102 - 1103 - lock_page(page); 1104 - /* 1105 - * Page truncated or invalidated(page->mapping == NULL). 1106 - * We can freely skip it and proceed to check the next 1107 - * page. 1108 - */ 1109 - if (unlikely(page->mapping != inode->i_mapping)) { 1110 - unlock_page(page); 1111 - continue; 1112 - } 1113 - 1114 - if (!page_has_buffers(page)) { 1115 - unlock_page(page); 1116 - continue; 1117 - } 1118 - 1119 - found = xfs_lookup_buffer_offset(page, &b_offset, type); 1120 - if (found) { 1121 - /* 1122 - * The found offset may be less than the start 1123 - * point to search if this is the first time to 1124 - * come here. 1125 - */ 1126 - *offset = max_t(loff_t, startoff, b_offset); 1127 - unlock_page(page); 1128 - goto out; 1129 - } 1130 - 1131 - /* 1132 - * We either searching data but nothing was found, or 1133 - * searching hole but found a data buffer. In either 1134 - * case, probably the next page contains the desired 1135 - * things, update the last offset to it so. 1136 - */ 1137 - lastoff = page_offset(page) + PAGE_SIZE; 1138 - unlock_page(page); 1139 - } 1140 - 1141 - /* 1142 - * The number of returned pages less than our desired, search 1143 - * done. 1144 - */ 1145 - if (nr_pages < want) 1146 - break; 1147 - 1148 - index = pvec.pages[i - 1]->index + 1; 1149 - pagevec_release(&pvec); 1150 - } while (index <= end); 1151 - 1152 - /* No page at lastoff and we are not done - we found a hole. */ 1153 - if (type == HOLE_OFF && lastoff < endoff) { 1154 - *offset = lastoff; 1155 - found = true; 1156 - } 1157 - out: 1158 - pagevec_release(&pvec); 1159 - return found; 1160 - } 1161 - 1162 - /* 1163 - * caller must lock inode with xfs_ilock_data_map_shared, 1164 - * can we craft an appropriate ASSERT? 1165 - * 1166 - * end is because the VFS-level lseek interface is defined such that any 1167 - * offset past i_size shall return -ENXIO, but we use this for quota code 1168 - * which does not maintain i_size, and we want to SEEK_DATA past i_size. 1169 - */ 1170 - loff_t 1171 - __xfs_seek_hole_data( 1172 - struct inode *inode, 1173 - loff_t start, 1174 - loff_t end, 1175 - int whence) 1176 - { 1177 - struct xfs_inode *ip = XFS_I(inode); 1178 - struct xfs_mount *mp = ip->i_mount; 1179 - loff_t uninitialized_var(offset); 1180 - xfs_fileoff_t fsbno; 1181 - xfs_filblks_t lastbno; 1182 - int error; 1183 - 1184 - if (start >= end) { 1185 - error = -ENXIO; 1186 - goto out_error; 1187 - } 1188 - 1189 - /* 1190 - * Try to read extents from the first block indicated 1191 - * by fsbno to the end block of the file. 1192 - */ 1193 - fsbno = XFS_B_TO_FSBT(mp, start); 1194 - lastbno = XFS_B_TO_FSB(mp, end); 1195 - 1196 - for (;;) { 1197 - struct xfs_bmbt_irec map[2]; 1198 - int nmap = 2; 1199 - unsigned int i; 1200 - 1201 - error = xfs_bmapi_read(ip, fsbno, lastbno - fsbno, map, &nmap, 1202 - XFS_BMAPI_ENTIRE); 1203 - if (error) 1204 - goto out_error; 1205 - 1206 - /* No extents at given offset, must be beyond EOF */ 1207 - if (nmap == 0) { 1208 - error = -ENXIO; 1209 - goto out_error; 1210 - } 1211 - 1212 - for (i = 0; i < nmap; i++) { 1213 - offset = max_t(loff_t, start, 1214 - XFS_FSB_TO_B(mp, map[i].br_startoff)); 1215 - 1216 - /* Landed in the hole we wanted? */ 1217 - if (whence == SEEK_HOLE && 1218 - map[i].br_startblock == HOLESTARTBLOCK) 1219 - goto out; 1220 - 1221 - /* Landed in the data extent we wanted? */ 1222 - if (whence == SEEK_DATA && 1223 - (map[i].br_startblock == DELAYSTARTBLOCK || 1224 - (map[i].br_state == XFS_EXT_NORM && 1225 - !isnullstartblock(map[i].br_startblock)))) 1226 - goto out; 1227 - 1228 - /* 1229 - * Landed in an unwritten extent, try to search 1230 - * for hole or data from page cache. 1231 - */ 1232 - if (map[i].br_state == XFS_EXT_UNWRITTEN) { 1233 - if (xfs_find_get_desired_pgoff(inode, &map[i], 1234 - whence == SEEK_HOLE ? HOLE_OFF : DATA_OFF, 1235 - &offset)) 1236 - goto out; 1237 - } 1238 - } 1239 - 1240 - /* 1241 - * We only received one extent out of the two requested. This 1242 - * means we've hit EOF and didn't find what we are looking for. 1243 - */ 1244 - if (nmap == 1) { 1245 - /* 1246 - * If we were looking for a hole, set offset to 1247 - * the end of the file (i.e., there is an implicit 1248 - * hole at the end of any file). 1249 - */ 1250 - if (whence == SEEK_HOLE) { 1251 - offset = end; 1252 - break; 1253 - } 1254 - /* 1255 - * If we were looking for data, it's nowhere to be found 1256 - */ 1257 - ASSERT(whence == SEEK_DATA); 1258 - error = -ENXIO; 1259 - goto out_error; 1260 - } 1261 - 1262 - ASSERT(i > 1); 1263 - 1264 - /* 1265 - * Nothing was found, proceed to the next round of search 1266 - * if the next reading offset is not at or beyond EOF. 1267 - */ 1268 - fsbno = map[i - 1].br_startoff + map[i - 1].br_blockcount; 1269 - start = XFS_FSB_TO_B(mp, fsbno); 1270 - if (start >= end) { 1271 - if (whence == SEEK_HOLE) { 1272 - offset = end; 1273 - break; 1274 - } 1275 - ASSERT(whence == SEEK_DATA); 1276 - error = -ENXIO; 1277 - goto out_error; 1278 - } 1279 - } 1280 - 1281 - out: 1282 - /* 1283 - * If at this point we have found the hole we wanted, the returned 1284 - * offset may be bigger than the file size as it may be aligned to 1285 - * page boundary for unwritten extents. We need to deal with this 1286 - * situation in particular. 1287 - */ 1288 - if (whence == SEEK_HOLE) 1289 - offset = min_t(loff_t, offset, end); 1290 - 1291 - return offset; 1292 - 1293 - out_error: 1294 - return error; 1295 - } 1296 - 1297 - STATIC loff_t 1298 - xfs_seek_hole_data( 1299 - struct file *file, 1300 - loff_t start, 1301 - int whence) 1302 - { 1303 - struct inode *inode = file->f_mapping->host; 1304 - struct xfs_inode *ip = XFS_I(inode); 1305 - struct xfs_mount *mp = ip->i_mount; 1306 - uint lock; 1307 - loff_t offset, end; 1308 - int error = 0; 1309 - 1310 - if (XFS_FORCED_SHUTDOWN(mp)) 1311 - return -EIO; 1312 - 1313 - lock = xfs_ilock_data_map_shared(ip); 1314 - 1315 - end = i_size_read(inode); 1316 - offset = __xfs_seek_hole_data(inode, start, end, whence); 1317 - if (offset < 0) { 1318 - error = offset; 1319 - goto out_unlock; 1320 - } 1321 - 1322 - offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes); 1323 - 1324 - out_unlock: 1325 - xfs_iunlock(ip, lock); 1326 - 1327 - if (error) 1328 - return error; 1329 - return offset; 973 + return xfs_readdir(NULL, ip, ctx, bufsize); 1330 974 } 1331 975 1332 976 STATIC loff_t ··· 980 1334 loff_t offset, 981 1335 int whence) 982 1336 { 1337 + struct inode *inode = file->f_mapping->host; 1338 + 1339 + if (XFS_FORCED_SHUTDOWN(XFS_I(inode)->i_mount)) 1340 + return -EIO; 1341 + 983 1342 switch (whence) { 984 - case SEEK_END: 985 - case SEEK_CUR: 986 - case SEEK_SET: 1343 + default: 987 1344 return generic_file_llseek(file, offset, whence); 988 1345 case SEEK_HOLE: 1346 + offset = iomap_seek_hole(inode, offset, &xfs_iomap_ops); 1347 + break; 989 1348 case SEEK_DATA: 990 - return xfs_seek_hole_data(file, offset, whence); 991 - default: 992 - return -EINVAL; 1349 + offset = iomap_seek_data(inode, offset, &xfs_iomap_ops); 1350 + break; 993 1351 } 1352 + 1353 + if (offset < 0) 1354 + return offset; 1355 + return vfs_setpos(file, offset, inode->i_sb->s_maxbytes); 994 1356 } 995 1357 996 1358 /*
+8 -8
fs/xfs/xfs_fsops.c
··· 602 602 if (nagimax) 603 603 mp->m_maxagi = nagimax; 604 604 if (mp->m_sb.sb_imax_pct) { 605 - __uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct; 605 + uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct; 606 606 do_div(icount, 100); 607 607 mp->m_maxicount = icount << mp->m_sb.sb_inopblog; 608 608 } else ··· 793 793 int 794 794 xfs_reserve_blocks( 795 795 xfs_mount_t *mp, 796 - __uint64_t *inval, 796 + uint64_t *inval, 797 797 xfs_fsop_resblks_t *outval) 798 798 { 799 - __int64_t lcounter, delta; 800 - __int64_t fdblks_delta = 0; 801 - __uint64_t request; 802 - __int64_t free; 799 + int64_t lcounter, delta; 800 + int64_t fdblks_delta = 0; 801 + uint64_t request; 802 + int64_t free; 803 803 int error = 0; 804 804 805 805 /* If inval is null, report current values and return */ 806 - if (inval == (__uint64_t *)NULL) { 806 + if (inval == (uint64_t *)NULL) { 807 807 if (!outval) 808 808 return -EINVAL; 809 809 outval->resblks = mp->m_resblks; ··· 904 904 int 905 905 xfs_fs_goingdown( 906 906 xfs_mount_t *mp, 907 - __uint32_t inflags) 907 + uint32_t inflags) 908 908 { 909 909 switch (inflags) { 910 910 case XFS_FSOP_GOING_FLAGS_DEFAULT: {
+2 -2
fs/xfs/xfs_fsops.h
··· 22 22 extern int xfs_growfs_data(xfs_mount_t *mp, xfs_growfs_data_t *in); 23 23 extern int xfs_growfs_log(xfs_mount_t *mp, xfs_growfs_log_t *in); 24 24 extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt); 25 - extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval, 25 + extern int xfs_reserve_blocks(xfs_mount_t *mp, uint64_t *inval, 26 26 xfs_fsop_resblks_t *outval); 27 - extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags); 27 + extern int xfs_fs_goingdown(xfs_mount_t *mp, uint32_t inflags); 28 28 29 29 extern int xfs_fs_reserve_ag_blocks(struct xfs_mount *mp); 30 30 extern int xfs_fs_unreserve_ag_blocks(struct xfs_mount *mp);
+5
fs/xfs/xfs_globals.c
··· 47 47 48 48 struct xfs_globals xfs_globals = { 49 49 .log_recovery_delay = 0, /* no delay by default */ 50 + #ifdef XFS_ASSERT_FATAL 51 + .bug_on_assert = true, /* assert failures BUG() */ 52 + #else 53 + .bug_on_assert = false, /* assert failures WARN() */ 54 + #endif 50 55 };
+50 -2
fs/xfs/xfs_icache.c
··· 368 368 if (ip->i_flags & XFS_IRECLAIMABLE) { 369 369 trace_xfs_iget_reclaim(ip); 370 370 371 + if (flags & XFS_IGET_INCORE) { 372 + error = -EAGAIN; 373 + goto out_error; 374 + } 375 + 371 376 /* 372 377 * We need to set XFS_IRECLAIM to prevent xfs_reclaim_inode 373 378 * from stomping over us while we recycle the inode. We can't ··· 437 432 if (lock_flags != 0) 438 433 xfs_ilock(ip, lock_flags); 439 434 440 - xfs_iflags_clear(ip, XFS_ISTALE | XFS_IDONTCACHE); 435 + if (!(flags & XFS_IGET_INCORE)) 436 + xfs_iflags_clear(ip, XFS_ISTALE | XFS_IDONTCACHE); 441 437 XFS_STATS_INC(mp, xs_ig_found); 442 438 443 439 return 0; ··· 609 603 goto out_error_or_again; 610 604 } else { 611 605 rcu_read_unlock(); 606 + if (flags & XFS_IGET_INCORE) { 607 + error = -ENOENT; 608 + goto out_error_or_again; 609 + } 612 610 XFS_STATS_INC(mp, xs_ig_missed); 613 611 614 612 error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip, ··· 633 623 return 0; 634 624 635 625 out_error_or_again: 636 - if (error == -EAGAIN) { 626 + if (!(flags & XFS_IGET_INCORE) && error == -EAGAIN) { 637 627 delay(1); 638 628 goto again; 639 629 } 640 630 xfs_perag_put(pag); 641 631 return error; 632 + } 633 + 634 + /* 635 + * "Is this a cached inode that's also allocated?" 636 + * 637 + * Look up an inode by number in the given file system. If the inode is 638 + * in cache and isn't in purgatory, return 1 if the inode is allocated 639 + * and 0 if it is not. For all other cases (not in cache, being torn 640 + * down, etc.), return a negative error code. 641 + * 642 + * The caller has to prevent inode allocation and freeing activity, 643 + * presumably by locking the AGI buffer. This is to ensure that an 644 + * inode cannot transition from allocated to freed until the caller is 645 + * ready to allow that. If the inode is in an intermediate state (new, 646 + * reclaimable, or being reclaimed), -EAGAIN will be returned; if the 647 + * inode is not in the cache, -ENOENT will be returned. The caller must 648 + * deal with these scenarios appropriately. 649 + * 650 + * This is a specialized use case for the online scrubber; if you're 651 + * reading this, you probably want xfs_iget. 652 + */ 653 + int 654 + xfs_icache_inode_is_allocated( 655 + struct xfs_mount *mp, 656 + struct xfs_trans *tp, 657 + xfs_ino_t ino, 658 + bool *inuse) 659 + { 660 + struct xfs_inode *ip; 661 + int error; 662 + 663 + error = xfs_iget(mp, tp, ino, XFS_IGET_INCORE, 0, &ip); 664 + if (error) 665 + return error; 666 + 667 + *inuse = !!(VFS_I(ip)->i_mode); 668 + IRELE(ip); 669 + return 0; 642 670 } 643 671 644 672 /*
+4
fs/xfs/xfs_icache.h
··· 47 47 #define XFS_IGET_CREATE 0x1 48 48 #define XFS_IGET_UNTRUSTED 0x2 49 49 #define XFS_IGET_DONTCACHE 0x4 50 + #define XFS_IGET_INCORE 0x8 /* don't read from disk or reinit */ 50 51 51 52 /* 52 53 * flags for AG inode iterator ··· 126 125 } 127 126 return 0; 128 127 } 128 + 129 + int xfs_icache_inode_is_allocated(struct xfs_mount *mp, struct xfs_trans *tp, 130 + xfs_ino_t ino, bool *inuse); 129 131 130 132 #endif
+8 -9
fs/xfs/xfs_inode.c
··· 632 632 633 633 STATIC uint 634 634 _xfs_dic2xflags( 635 - __uint16_t di_flags, 635 + uint16_t di_flags, 636 636 uint64_t di_flags2, 637 637 bool has_attr) 638 638 { ··· 855 855 inode->i_version = 1; 856 856 ip->i_d.di_flags2 = 0; 857 857 ip->i_d.di_cowextsize = 0; 858 - ip->i_d.di_crtime.t_sec = (__int32_t)tv.tv_sec; 859 - ip->i_d.di_crtime.t_nsec = (__int32_t)tv.tv_nsec; 858 + ip->i_d.di_crtime.t_sec = (int32_t)tv.tv_sec; 859 + ip->i_d.di_crtime.t_nsec = (int32_t)tv.tv_nsec; 860 860 } 861 861 862 862 ··· 3489 3489 dip = xfs_buf_offset(bp, ip->i_imap.im_boffset); 3490 3490 3491 3491 if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC), 3492 - mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { 3492 + mp, XFS_ERRTAG_IFLUSH_1)) { 3493 3493 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 3494 3494 "%s: Bad inode %Lu magic number 0x%x, ptr 0x%p", 3495 3495 __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); ··· 3499 3499 if (XFS_TEST_ERROR( 3500 3500 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && 3501 3501 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE), 3502 - mp, XFS_ERRTAG_IFLUSH_3, XFS_RANDOM_IFLUSH_3)) { 3502 + mp, XFS_ERRTAG_IFLUSH_3)) { 3503 3503 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 3504 3504 "%s: Bad regular inode %Lu, ptr 0x%p", 3505 3505 __func__, ip->i_ino, ip); ··· 3510 3510 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && 3511 3511 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) && 3512 3512 (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL), 3513 - mp, XFS_ERRTAG_IFLUSH_4, XFS_RANDOM_IFLUSH_4)) { 3513 + mp, XFS_ERRTAG_IFLUSH_4)) { 3514 3514 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 3515 3515 "%s: Bad directory inode %Lu, ptr 0x%p", 3516 3516 __func__, ip->i_ino, ip); ··· 3518 3518 } 3519 3519 } 3520 3520 if (XFS_TEST_ERROR(ip->i_d.di_nextents + ip->i_d.di_anextents > 3521 - ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5, 3522 - XFS_RANDOM_IFLUSH_5)) { 3521 + ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) { 3523 3522 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 3524 3523 "%s: detected corrupt incore inode %Lu, " 3525 3524 "total extents = %d, nblocks = %Ld, ptr 0x%p", ··· 3528 3529 goto corrupt_out; 3529 3530 } 3530 3531 if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize, 3531 - mp, XFS_ERRTAG_IFLUSH_6, XFS_RANDOM_IFLUSH_6)) { 3532 + mp, XFS_ERRTAG_IFLUSH_6)) { 3532 3533 xfs_alert_tag(mp, XFS_PTAG_IFLUSH, 3533 3534 "%s: bad inode %Lu, forkoff 0x%x, ptr 0x%p", 3534 3535 __func__, ip->i_ino, ip->i_d.di_forkoff, ip);
+2 -5
fs/xfs/xfs_inode.h
··· 192 192 xfs_set_projid(struct xfs_inode *ip, 193 193 prid_t projid) 194 194 { 195 - ip->i_d.di_projid_hi = (__uint16_t) (projid >> 16); 196 - ip->i_d.di_projid_lo = (__uint16_t) (projid & 0xffff); 195 + ip->i_d.di_projid_hi = (uint16_t) (projid >> 16); 196 + ip->i_d.di_projid_lo = (uint16_t) (projid & 0xffff); 197 197 } 198 198 199 199 static inline prid_t ··· 445 445 xfs_fsize_t isize, bool *did_zeroing); 446 446 int xfs_zero_range(struct xfs_inode *ip, xfs_off_t pos, xfs_off_t count, 447 447 bool *did_zero); 448 - loff_t __xfs_seek_hole_data(struct inode *inode, loff_t start, 449 - loff_t eof, int whence); 450 - 451 448 452 449 /* from xfs_iops.c */ 453 450 extern void xfs_setup_inode(struct xfs_inode *ip);
+13 -14
fs/xfs/xfs_ioctl.c
··· 120 120 handle.ha_fid.fid_pad = 0; 121 121 handle.ha_fid.fid_gen = inode->i_generation; 122 122 handle.ha_fid.fid_ino = ip->i_ino; 123 - 124 - hsize = XFS_HSIZE(handle); 123 + hsize = sizeof(xfs_handle_t); 125 124 } 126 125 127 126 error = -EFAULT; ··· 443 444 struct inode *inode, 444 445 unsigned char *name, 445 446 unsigned char __user *ubuf, 446 - __uint32_t *len, 447 - __uint32_t flags) 447 + uint32_t *len, 448 + uint32_t flags) 448 449 { 449 450 unsigned char *kbuf; 450 451 int error = -EFAULT; ··· 472 473 struct inode *inode, 473 474 unsigned char *name, 474 475 const unsigned char __user *ubuf, 475 - __uint32_t len, 476 - __uint32_t flags) 476 + uint32_t len, 477 + uint32_t flags) 477 478 { 478 479 unsigned char *kbuf; 479 480 int error; ··· 498 499 xfs_attrmulti_attr_remove( 499 500 struct inode *inode, 500 501 unsigned char *name, 501 - __uint32_t flags) 502 + uint32_t flags) 502 503 { 503 504 int error; 504 505 ··· 876 877 877 878 STATIC unsigned int 878 879 xfs_di2lxflags( 879 - __uint16_t di_flags) 880 + uint16_t di_flags) 880 881 { 881 882 unsigned int flags = 0; 882 883 ··· 1287 1288 struct fsxattr *fa) 1288 1289 { 1289 1290 /* Disallow 32bit project ids if projid32bit feature is not enabled. */ 1290 - if (fa->fsx_projid > (__uint16_t)-1 && 1291 + if (fa->fsx_projid > (uint16_t)-1 && 1291 1292 !xfs_sb_version_hasprojid32bit(&ip->i_mount->m_sb)) 1292 1293 return -EINVAL; 1293 1294 ··· 1931 1932 1932 1933 case XFS_IOC_SET_RESBLKS: { 1933 1934 xfs_fsop_resblks_t inout; 1934 - __uint64_t in; 1935 + uint64_t in; 1935 1936 1936 1937 if (!capable(CAP_SYS_ADMIN)) 1937 1938 return -EPERM; ··· 2017 2018 } 2018 2019 2019 2020 case XFS_IOC_GOINGDOWN: { 2020 - __uint32_t in; 2021 + uint32_t in; 2021 2022 2022 2023 if (!capable(CAP_SYS_ADMIN)) 2023 2024 return -EPERM; 2024 2025 2025 - if (get_user(in, (__uint32_t __user *)arg)) 2026 + if (get_user(in, (uint32_t __user *)arg)) 2026 2027 return -EFAULT; 2027 2028 2028 2029 return xfs_fs_goingdown(mp, in); ··· 2037 2038 if (copy_from_user(&in, arg, sizeof(in))) 2038 2039 return -EFAULT; 2039 2040 2040 - return xfs_errortag_add(in.errtag, mp); 2041 + return xfs_errortag_add(mp, in.errtag); 2041 2042 } 2042 2043 2043 2044 case XFS_IOC_ERROR_CLEARALL: 2044 2045 if (!capable(CAP_SYS_ADMIN)) 2045 2046 return -EPERM; 2046 2047 2047 - return xfs_errortag_clearall(mp, 1); 2048 + return xfs_errortag_clearall(mp); 2048 2049 2049 2050 case XFS_IOC_FREE_EOFBLOCKS: { 2050 2051 struct xfs_fs_eofblocks eofb;
+5 -5
fs/xfs/xfs_ioctl.h
··· 48 48 struct inode *inode, 49 49 unsigned char *name, 50 50 unsigned char __user *ubuf, 51 - __uint32_t *len, 52 - __uint32_t flags); 51 + uint32_t *len, 52 + uint32_t flags); 53 53 54 54 extern int 55 55 xfs_attrmulti_attr_set( 56 56 struct inode *inode, 57 57 unsigned char *name, 58 58 const unsigned char __user *ubuf, 59 - __uint32_t len, 60 - __uint32_t flags); 59 + uint32_t len, 60 + uint32_t flags); 61 61 62 62 extern int 63 63 xfs_attrmulti_attr_remove( 64 64 struct inode *inode, 65 65 unsigned char *name, 66 - __uint32_t flags); 66 + uint32_t flags); 67 67 68 68 extern struct dentry * 69 69 xfs_handle_to_dentry(
+3 -3
fs/xfs/xfs_ioctl32.h
··· 112 112 113 113 /* The bstat field in the swapext struct needs translation */ 114 114 typedef struct compat_xfs_swapext { 115 - __int64_t sx_version; /* version */ 116 - __int64_t sx_fdtarget; /* fd of target file */ 117 - __int64_t sx_fdtmp; /* fd of tmp file */ 115 + int64_t sx_version; /* version */ 116 + int64_t sx_fdtarget; /* fd of target file */ 117 + int64_t sx_fdtmp; /* fd of tmp file */ 118 118 xfs_off_t sx_offset; /* offset into file */ 119 119 xfs_off_t sx_length; /* leng from offset */ 120 120 char sx_pad[16]; /* pad space, unused */
+2 -2
fs/xfs/xfs_iomap.c
··· 543 543 if (unlikely(XFS_TEST_ERROR( 544 544 (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS && 545 545 XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), 546 - mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { 546 + mp, XFS_ERRTAG_BMAPIFORMAT))) { 547 547 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); 548 548 error = -EFSCORRUPTED; 549 549 goto out_unlock; ··· 1119 1119 * Behave as if the write failed if drop writes is enabled. Set the NEW 1120 1120 * flag to force delalloc cleanup. 1121 1121 */ 1122 - if (xfs_mp_drop_writes(mp)) { 1122 + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DROP_WRITES)) { 1123 1123 iomap->flags |= IOMAP_F_NEW; 1124 1124 written = 0; 1125 1125 }
+3 -3
fs/xfs/xfs_iops.c
··· 190 190 191 191 #ifdef CONFIG_XFS_POSIX_ACL 192 192 if (default_acl) { 193 - error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 193 + error = __xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 194 194 if (error) 195 195 goto out_cleanup_inode; 196 196 } 197 197 if (acl) { 198 - error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS); 198 + error = __xfs_set_acl(inode, acl, ACL_TYPE_ACCESS); 199 199 if (error) 200 200 goto out_cleanup_inode; 201 201 } ··· 460 460 if (!dentry) 461 461 return ERR_PTR(-ECHILD); 462 462 463 - link = kmalloc(MAXPATHLEN+1, GFP_KERNEL); 463 + link = kmalloc(XFS_SYMLINK_MAXLEN+1, GFP_KERNEL); 464 464 if (!link) 465 465 goto out_err; 466 466
+1 -1
fs/xfs/xfs_itable.c
··· 31 31 #include "xfs_trace.h" 32 32 #include "xfs_icache.h" 33 33 34 - STATIC int 34 + int 35 35 xfs_internal_inum( 36 36 xfs_mount_t *mp, 37 37 xfs_ino_t ino)
+2
fs/xfs/xfs_itable.h
··· 96 96 void __user *buffer, /* buffer with inode info */ 97 97 inumbers_fmt_pf formatter); 98 98 99 + int xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); 100 + 99 101 #endif /* __XFS_ITABLE_H__ */
+6 -15
fs/xfs/xfs_linux.h
··· 24 24 /* 25 25 * Kernel specific type declarations for XFS 26 26 */ 27 - typedef signed char __int8_t; 28 - typedef unsigned char __uint8_t; 29 - typedef signed short int __int16_t; 30 - typedef unsigned short int __uint16_t; 31 - typedef signed int __int32_t; 32 - typedef unsigned int __uint32_t; 33 - typedef signed long long int __int64_t; 34 - typedef unsigned long long int __uint64_t; 35 27 36 28 typedef __s64 xfs_off_t; /* <file offset> type */ 37 29 typedef unsigned long long xfs_ino_t; /* <inode> type */ ··· 143 151 #define __return_address __builtin_return_address(0) 144 152 145 153 #define XFS_PROJID_DEFAULT 0 146 - #define MAXPATHLEN 1024 147 154 148 155 #define MIN(a,b) (min(a,b)) 149 156 #define MAX(a,b) (max(a,b)) ··· 177 186 * are converting to the init_user_ns. The uid is later mapped to a particular 178 187 * user namespace value when crossing the kernel/user boundary. 179 188 */ 180 - static inline __uint32_t xfs_kuid_to_uid(kuid_t uid) 189 + static inline uint32_t xfs_kuid_to_uid(kuid_t uid) 181 190 { 182 191 return from_kuid(&init_user_ns, uid); 183 192 } 184 193 185 - static inline kuid_t xfs_uid_to_kuid(__uint32_t uid) 194 + static inline kuid_t xfs_uid_to_kuid(uint32_t uid) 186 195 { 187 196 return make_kuid(&init_user_ns, uid); 188 197 } 189 198 190 - static inline __uint32_t xfs_kgid_to_gid(kgid_t gid) 199 + static inline uint32_t xfs_kgid_to_gid(kgid_t gid) 191 200 { 192 201 return from_kgid(&init_user_ns, gid); 193 202 } 194 203 195 - static inline kgid_t xfs_gid_to_kgid(__uint32_t gid) 204 + static inline kgid_t xfs_gid_to_kgid(uint32_t gid) 196 205 { 197 206 return make_kgid(&init_user_ns, gid); 198 207 } ··· 222 231 223 232 #define do_mod(a, b) xfs_do_mod(&(a), (b), sizeof(a)) 224 233 225 - static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y) 234 + static inline uint64_t roundup_64(uint64_t x, uint32_t y) 226 235 { 227 236 x += y - 1; 228 237 do_div(x, y); 229 238 return x * y; 230 239 } 231 240 232 - static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) 241 + static inline uint64_t howmany_64(uint64_t x, uint32_t y) 233 242 { 234 243 x += y - 1; 235 244 do_div(x, y);
+66 -21
fs/xfs/xfs_log.c
··· 434 434 int unit_bytes, 435 435 int cnt, 436 436 struct xlog_ticket **ticp, 437 - __uint8_t client, 437 + uint8_t client, 438 438 bool permanent) 439 439 { 440 440 struct xlog *log = mp->m_log; ··· 825 825 if (!error) { 826 826 /* the data section must be 32 bit size aligned */ 827 827 struct { 828 - __uint16_t magic; 829 - __uint16_t pad1; 830 - __uint32_t pad2; /* may as well make it 64 bits */ 828 + uint16_t magic; 829 + uint16_t pad1; 830 + uint32_t pad2; /* may as well make it 64 bits */ 831 831 } magic = { 832 832 .magic = XLOG_UNMOUNT_TYPE, 833 833 }; ··· 1189 1189 * IOABORT state. The IOABORT state is only set in DEBUG mode to inject 1190 1190 * CRC errors into log recovery. 1191 1191 */ 1192 - if (XFS_TEST_ERROR(bp->b_error, l->l_mp, XFS_ERRTAG_IODONE_IOERR, 1193 - XFS_RANDOM_IODONE_IOERR) || 1192 + if (XFS_TEST_ERROR(bp->b_error, l->l_mp, XFS_ERRTAG_IODONE_IOERR) || 1194 1193 iclog->ic_state & XLOG_STATE_IOABORT) { 1195 1194 if (iclog->ic_state & XLOG_STATE_IOABORT) 1196 1195 iclog->ic_state &= ~XLOG_STATE_IOABORT; ··· 1664 1665 char *dp, 1665 1666 int size) 1666 1667 { 1667 - __uint32_t crc; 1668 + uint32_t crc; 1668 1669 1669 1670 /* first generate the crc for the record header ... */ 1670 1671 crc = xfs_start_cksum_update((char *)rhead, ··· 1827 1828 */ 1828 1829 dptr = (char *)&iclog->ic_header + count; 1829 1830 for (i = 0; i < split; i += BBSIZE) { 1830 - __uint32_t cycle = be32_to_cpu(*(__be32 *)dptr); 1831 + uint32_t cycle = be32_to_cpu(*(__be32 *)dptr); 1831 1832 if (++cycle == XLOG_HEADER_MAGIC_NUM) 1832 1833 cycle++; 1833 1834 *(__be32 *)dptr = cpu_to_be32(cycle); ··· 1841 1842 /* calculcate the checksum */ 1842 1843 iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, 1843 1844 iclog->ic_datap, size); 1844 - #ifdef DEBUG 1845 1845 /* 1846 1846 * Intentionally corrupt the log record CRC based on the error injection 1847 1847 * frequency, if defined. This facilitates testing log recovery in the ··· 1848 1850 * write on I/O completion and shutdown the fs. The subsequent mount 1849 1851 * detects the bad CRC and attempts to recover. 1850 1852 */ 1851 - if (log->l_badcrc_factor && 1852 - (prandom_u32() % log->l_badcrc_factor == 0)) { 1853 + if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) { 1853 1854 iclog->ic_header.h_crc &= cpu_to_le32(0xAAAAAAAA); 1854 1855 iclog->ic_state |= XLOG_STATE_IOABORT; 1855 1856 xfs_warn(log->l_mp, 1856 1857 "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.", 1857 1858 be64_to_cpu(iclog->ic_header.h_lsn)); 1858 1859 } 1859 - #endif 1860 1860 1861 1861 bp->b_io_length = BTOBB(count); 1862 1862 bp->b_fspriv = iclog; ··· 2020 2024 }; 2021 2025 #undef REG_TYPE_STR 2022 2026 2023 - xfs_warn(mp, "xlog_write: reservation summary:"); 2027 + xfs_warn(mp, "ticket reservation summary:"); 2024 2028 xfs_warn(mp, " unit res = %d bytes", 2025 2029 ticket->t_unit_res); 2026 2030 xfs_warn(mp, " current res = %d bytes", ··· 2041 2045 "bad-rtype" : res_type_str[r_type]), 2042 2046 ticket->t_res_arr[i].r_len); 2043 2047 } 2048 + } 2044 2049 2045 - xfs_alert_tag(mp, XFS_PTAG_LOGRES, 2046 - "xlog_write: reservation ran out. Need to up reservation"); 2047 - xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); 2050 + /* 2051 + * Print a summary of the transaction. 2052 + */ 2053 + void 2054 + xlog_print_trans( 2055 + struct xfs_trans *tp) 2056 + { 2057 + struct xfs_mount *mp = tp->t_mountp; 2058 + struct xfs_log_item_desc *lidp; 2059 + 2060 + /* dump core transaction and ticket info */ 2061 + xfs_warn(mp, "transaction summary:"); 2062 + xfs_warn(mp, " flags = 0x%x", tp->t_flags); 2063 + 2064 + xlog_print_tic_res(mp, tp->t_ticket); 2065 + 2066 + /* dump each log item */ 2067 + list_for_each_entry(lidp, &tp->t_items, lid_trans) { 2068 + struct xfs_log_item *lip = lidp->lid_item; 2069 + struct xfs_log_vec *lv = lip->li_lv; 2070 + struct xfs_log_iovec *vec; 2071 + int i; 2072 + 2073 + xfs_warn(mp, "log item: "); 2074 + xfs_warn(mp, " type = 0x%x", lip->li_type); 2075 + xfs_warn(mp, " flags = 0x%x", lip->li_flags); 2076 + if (!lv) 2077 + continue; 2078 + xfs_warn(mp, " niovecs = %d", lv->lv_niovecs); 2079 + xfs_warn(mp, " size = %d", lv->lv_size); 2080 + xfs_warn(mp, " bytes = %d", lv->lv_bytes); 2081 + xfs_warn(mp, " buf len = %d", lv->lv_buf_len); 2082 + 2083 + /* dump each iovec for the log item */ 2084 + vec = lv->lv_iovecp; 2085 + for (i = 0; i < lv->lv_niovecs; i++) { 2086 + int dumplen = min(vec->i_len, 32); 2087 + 2088 + xfs_warn(mp, " iovec[%d]", i); 2089 + xfs_warn(mp, " type = 0x%x", vec->i_type); 2090 + xfs_warn(mp, " len = %d", vec->i_len); 2091 + xfs_warn(mp, " first %d bytes of iovec[%d]:", dumplen, i); 2092 + xfs_hex_dump(vec->i_addr, dumplen); 2093 + 2094 + vec++; 2095 + } 2096 + } 2048 2097 } 2049 2098 2050 2099 /* ··· 2362 2321 if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) 2363 2322 ticket->t_curr_res -= sizeof(xlog_op_header_t); 2364 2323 2365 - if (ticket->t_curr_res < 0) 2324 + if (ticket->t_curr_res < 0) { 2325 + xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, 2326 + "ctx ticket reservation ran out. Need to up reservation"); 2366 2327 xlog_print_tic_res(log->l_mp, ticket); 2328 + xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); 2329 + } 2367 2330 2368 2331 index = 0; 2369 2332 lv = log_vector; ··· 2408 2363 } 2409 2364 2410 2365 reg = &vecp[index]; 2411 - ASSERT(reg->i_len % sizeof(__int32_t) == 0); 2412 - ASSERT((unsigned long)ptr % sizeof(__int32_t) == 0); 2366 + ASSERT(reg->i_len % sizeof(int32_t) == 0); 2367 + ASSERT((unsigned long)ptr % sizeof(int32_t) == 0); 2413 2368 2414 2369 start_rec_copy = xlog_write_start_rec(ptr, ticket); 2415 2370 if (start_rec_copy) { ··· 3188 3143 /* Round up to next log-sunit */ 3189 3144 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) && 3190 3145 log->l_mp->m_sb.sb_logsunit > 1) { 3191 - __uint32_t sunit_bb = BTOBB(log->l_mp->m_sb.sb_logsunit); 3146 + uint32_t sunit_bb = BTOBB(log->l_mp->m_sb.sb_logsunit); 3192 3147 log->l_curr_block = roundup(log->l_curr_block, sunit_bb); 3193 3148 } 3194 3149 ··· 3816 3771 xlog_in_core_2_t *xhdr; 3817 3772 void *base_ptr, *ptr, *p; 3818 3773 ptrdiff_t field_offset; 3819 - __uint8_t clientid; 3774 + uint8_t clientid; 3820 3775 int len, i, j, k, op_len; 3821 3776 int idx; 3822 3777
+1 -1
fs/xfs/xfs_log.h
··· 159 159 int length, 160 160 int count, 161 161 struct xlog_ticket **ticket, 162 - __uint8_t clientid, 162 + uint8_t clientid, 163 163 bool permanent); 164 164 int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic); 165 165 void xfs_log_unmount(struct xfs_mount *mp);
+62 -45
fs/xfs/xfs_log_cil.c
··· 410 410 int len = 0; 411 411 int diff_iovecs = 0; 412 412 int iclog_space; 413 + int iovhdr_res = 0, split_res = 0, ctx_res = 0; 413 414 414 415 ASSERT(tp); 415 416 ··· 420 419 */ 421 420 xlog_cil_insert_format_items(log, tp, &len, &diff_iovecs); 422 421 422 + spin_lock(&cil->xc_cil_lock); 423 + 424 + /* account for space used by new iovec headers */ 425 + iovhdr_res = diff_iovecs * sizeof(xlog_op_header_t); 426 + len += iovhdr_res; 427 + ctx->nvecs += diff_iovecs; 428 + 429 + /* attach the transaction to the CIL if it has any busy extents */ 430 + if (!list_empty(&tp->t_busy)) 431 + list_splice_init(&tp->t_busy, &ctx->busy_extents); 432 + 433 + /* 434 + * Now transfer enough transaction reservation to the context ticket 435 + * for the checkpoint. The context ticket is special - the unit 436 + * reservation has to grow as well as the current reservation as we 437 + * steal from tickets so we can correctly determine the space used 438 + * during the transaction commit. 439 + */ 440 + if (ctx->ticket->t_curr_res == 0) { 441 + ctx_res = ctx->ticket->t_unit_res; 442 + ctx->ticket->t_curr_res = ctx_res; 443 + tp->t_ticket->t_curr_res -= ctx_res; 444 + } 445 + 446 + /* do we need space for more log record headers? */ 447 + iclog_space = log->l_iclog_size - log->l_iclog_hsize; 448 + if (len > 0 && (ctx->space_used / iclog_space != 449 + (ctx->space_used + len) / iclog_space)) { 450 + split_res = (len + iclog_space - 1) / iclog_space; 451 + /* need to take into account split region headers, too */ 452 + split_res *= log->l_iclog_hsize + sizeof(struct xlog_op_header); 453 + ctx->ticket->t_unit_res += split_res; 454 + ctx->ticket->t_curr_res += split_res; 455 + tp->t_ticket->t_curr_res -= split_res; 456 + ASSERT(tp->t_ticket->t_curr_res >= len); 457 + } 458 + tp->t_ticket->t_curr_res -= len; 459 + ctx->space_used += len; 460 + 461 + /* 462 + * If we've overrun the reservation, dump the tx details before we move 463 + * the log items. Shutdown is imminent... 464 + */ 465 + if (WARN_ON(tp->t_ticket->t_curr_res < 0)) { 466 + xfs_warn(log->l_mp, "Transaction log reservation overrun:"); 467 + xfs_warn(log->l_mp, 468 + " log items: %d bytes (iov hdrs: %d bytes)", 469 + len, iovhdr_res); 470 + xfs_warn(log->l_mp, " split region headers: %d bytes", 471 + split_res); 472 + xfs_warn(log->l_mp, " ctx ticket: %d bytes", ctx_res); 473 + xlog_print_trans(tp); 474 + } 475 + 423 476 /* 424 477 * Now (re-)position everything modified at the tail of the CIL. 425 478 * We do this here so we only need to take the CIL lock once during 426 479 * the transaction commit. 427 480 */ 428 - spin_lock(&cil->xc_cil_lock); 429 481 list_for_each_entry(lidp, &tp->t_items, lid_trans) { 430 482 struct xfs_log_item *lip = lidp->lid_item; 431 483 ··· 495 441 list_move_tail(&lip->li_cil, &cil->xc_cil); 496 442 } 497 443 498 - /* account for space used by new iovec headers */ 499 - len += diff_iovecs * sizeof(xlog_op_header_t); 500 - ctx->nvecs += diff_iovecs; 501 - 502 - /* attach the transaction to the CIL if it has any busy extents */ 503 - if (!list_empty(&tp->t_busy)) 504 - list_splice_init(&tp->t_busy, &ctx->busy_extents); 505 - 506 - /* 507 - * Now transfer enough transaction reservation to the context ticket 508 - * for the checkpoint. The context ticket is special - the unit 509 - * reservation has to grow as well as the current reservation as we 510 - * steal from tickets so we can correctly determine the space used 511 - * during the transaction commit. 512 - */ 513 - if (ctx->ticket->t_curr_res == 0) { 514 - ctx->ticket->t_curr_res = ctx->ticket->t_unit_res; 515 - tp->t_ticket->t_curr_res -= ctx->ticket->t_unit_res; 516 - } 517 - 518 - /* do we need space for more log record headers? */ 519 - iclog_space = log->l_iclog_size - log->l_iclog_hsize; 520 - if (len > 0 && (ctx->space_used / iclog_space != 521 - (ctx->space_used + len) / iclog_space)) { 522 - int hdrs; 523 - 524 - hdrs = (len + iclog_space - 1) / iclog_space; 525 - /* need to take into account split region headers, too */ 526 - hdrs *= log->l_iclog_hsize + sizeof(struct xlog_op_header); 527 - ctx->ticket->t_unit_res += hdrs; 528 - ctx->ticket->t_curr_res += hdrs; 529 - tp->t_ticket->t_curr_res -= hdrs; 530 - ASSERT(tp->t_ticket->t_curr_res >= len); 531 - } 532 - tp->t_ticket->t_curr_res -= len; 533 - ctx->space_used += len; 534 - 535 444 spin_unlock(&cil->xc_cil_lock); 445 + 446 + if (tp->t_ticket->t_curr_res < 0) 447 + xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); 536 448 } 537 449 538 450 static void ··· 993 973 { 994 974 struct xlog *log = mp->m_log; 995 975 struct xfs_cil *cil = log->l_cilp; 976 + xfs_lsn_t xc_commit_lsn; 996 977 997 978 /* 998 979 * Do all necessary memory allocation before we lock the CIL. ··· 1007 986 1008 987 xlog_cil_insert_items(log, tp); 1009 988 1010 - /* check we didn't blow the reservation */ 1011 - if (tp->t_ticket->t_curr_res < 0) 1012 - xlog_print_tic_res(mp, tp->t_ticket); 1013 - 1014 - tp->t_commit_lsn = cil->xc_ctx->sequence; 989 + xc_commit_lsn = cil->xc_ctx->sequence; 1015 990 if (commit_lsn) 1016 - *commit_lsn = tp->t_commit_lsn; 991 + *commit_lsn = xc_commit_lsn; 1017 992 1018 993 xfs_log_done(mp, tp->t_ticket, NULL, regrant); 1019 994 xfs_trans_unreserve_and_mod_sb(tp); ··· 1025 1008 * the log items. This affects (at least) processing of stale buffers, 1026 1009 * inodes and EFIs. 1027 1010 */ 1028 - xfs_trans_free_items(tp, tp->t_commit_lsn, false); 1011 + xfs_trans_free_items(tp, xc_commit_lsn, false); 1029 1012 1030 1013 xlog_cil_push_background(log); 1031 1014
+2 -1
fs/xfs/xfs_log_priv.h
··· 419 419 }; 420 420 421 421 #define XLOG_BUF_CANCEL_BUCKET(log, blkno) \ 422 - ((log)->l_buf_cancel_table + ((__uint64_t)blkno % XLOG_BC_TABLE_SIZE)) 422 + ((log)->l_buf_cancel_table + ((uint64_t)blkno % XLOG_BC_TABLE_SIZE)) 423 423 424 424 #define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR) 425 425 ··· 456 456 } 457 457 458 458 void xlog_print_tic_res(struct xfs_mount *mp, struct xlog_ticket *ticket); 459 + void xlog_print_trans(struct xfs_trans *); 459 460 int 460 461 xlog_write( 461 462 struct xlog *log,
+34 -15
fs/xfs/xfs_log_recover.c
··· 2230 2230 struct xfs_mount *mp, 2231 2231 struct xfs_buf *bp) 2232 2232 { 2233 - __uint32_t magic32; 2234 - __uint16_t magic16; 2235 - __uint16_t magicda; 2233 + uint32_t magic32; 2234 + uint16_t magic16; 2235 + uint16_t magicda; 2236 2236 void *blk = bp->b_addr; 2237 2237 uuid_t *uuid; 2238 2238 xfs_lsn_t lsn = -1; ··· 2381 2381 xfs_lsn_t current_lsn) 2382 2382 { 2383 2383 struct xfs_da_blkinfo *info = bp->b_addr; 2384 - __uint32_t magic32; 2385 - __uint16_t magic16; 2386 - __uint16_t magicda; 2384 + uint32_t magic32; 2385 + uint16_t magic16; 2386 + uint16_t magicda; 2387 2387 char *warnmsg = NULL; 2388 2388 2389 2389 /* ··· 2852 2852 if (XFS_DINODE_MAGIC == 2853 2853 be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) && 2854 2854 (BBTOB(bp->b_io_length) != MAX(log->l_mp->m_sb.sb_blocksize, 2855 - (__uint32_t)log->l_mp->m_inode_cluster_size))) { 2855 + (uint32_t)log->l_mp->m_inode_cluster_size))) { 2856 2856 xfs_buf_stale(bp); 2857 2857 error = xfs_bwrite(bp); 2858 2858 } else { ··· 3423 3423 xfs_efd_log_format_t *efd_formatp; 3424 3424 xfs_efi_log_item_t *efip = NULL; 3425 3425 xfs_log_item_t *lip; 3426 - __uint64_t efi_id; 3426 + uint64_t efi_id; 3427 3427 struct xfs_ail_cursor cur; 3428 3428 struct xfs_ail *ailp = log->l_ailp; 3429 3429 ··· 3519 3519 struct xfs_rud_log_format *rud_formatp; 3520 3520 struct xfs_rui_log_item *ruip = NULL; 3521 3521 struct xfs_log_item *lip; 3522 - __uint64_t rui_id; 3522 + uint64_t rui_id; 3523 3523 struct xfs_ail_cursor cur; 3524 3524 struct xfs_ail *ailp = log->l_ailp; 3525 3525 ··· 3635 3635 struct xfs_cud_log_format *cud_formatp; 3636 3636 struct xfs_cui_log_item *cuip = NULL; 3637 3637 struct xfs_log_item *lip; 3638 - __uint64_t cui_id; 3638 + uint64_t cui_id; 3639 3639 struct xfs_ail_cursor cur; 3640 3640 struct xfs_ail *ailp = log->l_ailp; 3641 3641 ··· 3754 3754 struct xfs_bud_log_format *bud_formatp; 3755 3755 struct xfs_bui_log_item *buip = NULL; 3756 3756 struct xfs_log_item *lip; 3757 - __uint64_t bui_id; 3757 + uint64_t bui_id; 3758 3758 struct xfs_ail_cursor cur; 3759 3759 struct xfs_ail *ailp = log->l_ailp; 3760 3760 ··· 4152 4152 4153 4153 #define XLOG_RECOVER_COMMIT_QUEUE_MAX 100 4154 4154 4155 - hlist_del(&trans->r_list); 4155 + hlist_del_init(&trans->r_list); 4156 4156 4157 4157 error = xlog_recover_reorder_trans(log, trans, pass); 4158 4158 if (error) ··· 4353 4353 { 4354 4354 xlog_recover_item_t *item, *n; 4355 4355 int i; 4356 + 4357 + hlist_del_init(&trans->r_list); 4356 4358 4357 4359 list_for_each_entry_safe(item, n, &trans->r_itemq, ri_list) { 4358 4360 /* Free the regions in the item. */ ··· 5226 5224 int error2 = 0; 5227 5225 int bblks, split_bblks; 5228 5226 int hblks, split_hblks, wrapped_hblks; 5227 + int i; 5229 5228 struct hlist_head rhash[XLOG_RHASH_SIZE]; 5230 5229 LIST_HEAD (buffer_list); 5231 5230 5232 5231 ASSERT(head_blk != tail_blk); 5233 5232 rhead_blk = 0; 5233 + 5234 + for (i = 0; i < XLOG_RHASH_SIZE; i++) 5235 + INIT_HLIST_HEAD(&rhash[i]); 5234 5236 5235 5237 /* 5236 5238 * Read the header of the tail block and get the iclog buffer size from ··· 5471 5465 5472 5466 if (error && first_bad) 5473 5467 *first_bad = rhead_blk; 5468 + 5469 + /* 5470 + * Transactions are freed at commit time but transactions without commit 5471 + * records on disk are never committed. Free any that may be left in the 5472 + * hash table. 5473 + */ 5474 + for (i = 0; i < XLOG_RHASH_SIZE; i++) { 5475 + struct hlist_node *tmp; 5476 + struct xlog_recover *trans; 5477 + 5478 + hlist_for_each_entry_safe(trans, tmp, &rhash[i], r_list) 5479 + xlog_recover_free_trans(trans); 5480 + } 5474 5481 5475 5482 return error ? error : error2; 5476 5483 } ··· 5791 5772 xfs_buf_t *agfbp; 5792 5773 xfs_buf_t *agibp; 5793 5774 xfs_agnumber_t agno; 5794 - __uint64_t freeblks; 5795 - __uint64_t itotal; 5796 - __uint64_t ifree; 5775 + uint64_t freeblks; 5776 + uint64_t itotal; 5777 + uint64_t ifree; 5797 5778 int error; 5798 5779 5799 5780 mp = log->l_mp;
+4 -1
fs/xfs/xfs_message.c
··· 110 110 { 111 111 xfs_emerg(NULL, "Assertion failed: %s, file: %s, line: %d", 112 112 expr, file, line); 113 - BUG(); 113 + if (xfs_globals.bug_on_assert) 114 + BUG(); 115 + else 116 + WARN_ON(1); 114 117 } 115 118 116 119 void
+16 -10
fs/xfs/xfs_mount.c
··· 173 173 int 174 174 xfs_sb_validate_fsb_count( 175 175 xfs_sb_t *sbp, 176 - __uint64_t nblocks) 176 + uint64_t nblocks) 177 177 { 178 178 ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); 179 179 ASSERT(sbp->sb_blocklog >= BBSHIFT); ··· 435 435 xfs_set_maxicount(xfs_mount_t *mp) 436 436 { 437 437 xfs_sb_t *sbp = &(mp->m_sb); 438 - __uint64_t icount; 438 + uint64_t icount; 439 439 440 440 if (sbp->sb_imax_pct) { 441 441 /* ··· 501 501 int i; 502 502 503 503 for (i = 0; i < XFS_LOWSP_MAX; i++) { 504 - __uint64_t space = mp->m_sb.sb_dblocks; 504 + uint64_t space = mp->m_sb.sb_dblocks; 505 505 506 506 do_div(space, 100); 507 507 mp->m_low_space[i] = space * (i + 1); ··· 597 597 return xfs_sync_sb(mp, false); 598 598 } 599 599 600 - __uint64_t 600 + uint64_t 601 601 xfs_default_resblks(xfs_mount_t *mp) 602 602 { 603 - __uint64_t resblks; 603 + uint64_t resblks; 604 604 605 605 /* 606 606 * We default to 5% or 8192 fsbs of space reserved, whichever is ··· 611 611 */ 612 612 resblks = mp->m_sb.sb_dblocks; 613 613 do_div(resblks, 20); 614 - resblks = min_t(__uint64_t, resblks, 8192); 614 + resblks = min_t(uint64_t, resblks, 8192); 615 615 return resblks; 616 616 } 617 617 ··· 631 631 { 632 632 struct xfs_sb *sbp = &(mp->m_sb); 633 633 struct xfs_inode *rip; 634 - __uint64_t resblks; 634 + uint64_t resblks; 635 635 uint quotamount = 0; 636 636 uint quotaflags = 0; 637 637 int error = 0; ··· 719 719 if (error) 720 720 goto out_del_stats; 721 721 722 + error = xfs_errortag_init(mp); 723 + if (error) 724 + goto out_remove_error_sysfs; 722 725 723 726 error = xfs_uuid_mount(mp); 724 727 if (error) 725 - goto out_remove_error_sysfs; 728 + goto out_remove_errortag; 726 729 727 730 /* 728 731 * Set the minimum read and write sizes ··· 1047 1044 xfs_da_unmount(mp); 1048 1045 out_remove_uuid: 1049 1046 xfs_uuid_unmount(mp); 1047 + out_remove_errortag: 1048 + xfs_errortag_del(mp); 1050 1049 out_remove_error_sysfs: 1051 1050 xfs_error_sysfs_del(mp); 1052 1051 out_del_stats: ··· 1067 1062 xfs_unmountfs( 1068 1063 struct xfs_mount *mp) 1069 1064 { 1070 - __uint64_t resblks; 1065 + uint64_t resblks; 1071 1066 int error; 1072 1067 1073 1068 cancel_delayed_work_sync(&mp->m_eofblocks_work); ··· 1152 1147 xfs_uuid_unmount(mp); 1153 1148 1154 1149 #if defined(DEBUG) 1155 - xfs_errortag_clearall(mp, 0); 1150 + xfs_errortag_clearall(mp); 1156 1151 #endif 1157 1152 xfs_free_perag(mp); 1158 1153 1154 + xfs_errortag_del(mp); 1159 1155 xfs_error_sysfs_del(mp); 1160 1156 xfs_sysfs_del(&mp->m_stats.xs_kobj); 1161 1157 xfs_sysfs_del(&mp->m_kobj);
+22 -38
fs/xfs/xfs_mount.h
··· 108 108 xfs_buftarg_t *m_ddev_targp; /* saves taking the address */ 109 109 xfs_buftarg_t *m_logdev_targp;/* ptr to log device */ 110 110 xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */ 111 - __uint8_t m_blkbit_log; /* blocklog + NBBY */ 112 - __uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ 113 - __uint8_t m_agno_log; /* log #ag's */ 114 - __uint8_t m_agino_log; /* #bits for agino in inum */ 111 + uint8_t m_blkbit_log; /* blocklog + NBBY */ 112 + uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ 113 + uint8_t m_agno_log; /* log #ag's */ 114 + uint8_t m_agino_log; /* #bits for agino in inum */ 115 115 uint m_inode_cluster_size;/* min inode buf size */ 116 116 uint m_blockmask; /* sb_blocksize-1 */ 117 117 uint m_blockwsize; /* sb_blocksize in words */ ··· 139 139 struct mutex m_growlock; /* growfs mutex */ 140 140 int m_fixedfsid[2]; /* unchanged for life of FS */ 141 141 uint m_dmevmask; /* DMI events for this FS */ 142 - __uint64_t m_flags; /* global mount flags */ 142 + uint64_t m_flags; /* global mount flags */ 143 143 bool m_inotbt_nores; /* no per-AG finobt resv. */ 144 144 int m_ialloc_inos; /* inodes in inode allocation */ 145 145 int m_ialloc_blks; /* blocks in inode allocation */ ··· 148 148 int m_inoalign_mask;/* mask sb_inoalignmt if used */ 149 149 uint m_qflags; /* quota status flags */ 150 150 struct xfs_trans_resv m_resv; /* precomputed res values */ 151 - __uint64_t m_maxicount; /* maximum inode count */ 152 - __uint64_t m_resblks; /* total reserved blocks */ 153 - __uint64_t m_resblks_avail;/* available reserved blocks */ 154 - __uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 151 + uint64_t m_maxicount; /* maximum inode count */ 152 + uint64_t m_resblks; /* total reserved blocks */ 153 + uint64_t m_resblks_avail;/* available reserved blocks */ 154 + uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 155 155 int m_dalign; /* stripe unit */ 156 156 int m_swidth; /* stripe width */ 157 157 int m_sinoalign; /* stripe unit inode alignment */ 158 - __uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 158 + uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 159 159 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ 160 160 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ 161 161 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ ··· 194 194 * ever support shrinks it would have to be persisted in addition 195 195 * to various other kinds of pain inflicted on the pNFS server. 196 196 */ 197 - __uint32_t m_generation; 197 + uint32_t m_generation; 198 198 199 199 bool m_fail_unmount; 200 200 #ifdef DEBUG 201 201 /* 202 - * DEBUG mode instrumentation to test and/or trigger delayed allocation 203 - * block killing in the event of failed writes. When enabled, all 204 - * buffered writes are silenty dropped and handled as if they failed. 205 - * All delalloc blocks in the range of the write (including pre-existing 206 - * delalloc blocks!) are tossed as part of the write failure error 207 - * handling sequence. 202 + * Frequency with which errors are injected. Replaces xfs_etest; the 203 + * value stored in here is the inverse of the frequency with which the 204 + * error triggers. 1 = always, 2 = half the time, etc. 208 205 */ 209 - bool m_drop_writes; 206 + unsigned int *m_errortag; 207 + struct xfs_kobj m_errortag_kobj; 210 208 #endif 211 209 } xfs_mount_t; 212 210 ··· 323 325 return (xfs_agblock_t) do_div(ld, mp->m_sb.sb_agblocks); 324 326 } 325 327 326 - #ifdef DEBUG 327 - static inline bool 328 - xfs_mp_drop_writes(struct xfs_mount *mp) 329 - { 330 - return mp->m_drop_writes; 331 - } 332 - #else 333 - static inline bool 334 - xfs_mp_drop_writes(struct xfs_mount *mp) 335 - { 336 - return 0; 337 - } 338 - #endif 339 - 340 328 /* per-AG block reservation data structures*/ 341 329 enum xfs_ag_resv_type { 342 330 XFS_AG_RESV_NONE = 0, ··· 351 367 char pagi_init; /* this agi's entry is initialized */ 352 368 char pagf_metadata; /* the agf is preferred to be metadata */ 353 369 char pagi_inodeok; /* The agi is ok for inodes */ 354 - __uint8_t pagf_levels[XFS_BTNUM_AGF]; 370 + uint8_t pagf_levels[XFS_BTNUM_AGF]; 355 371 /* # of levels in bno & cnt btree */ 356 - __uint32_t pagf_flcount; /* count of blocks in freelist */ 372 + uint32_t pagf_flcount; /* count of blocks in freelist */ 357 373 xfs_extlen_t pagf_freeblks; /* total free blocks */ 358 374 xfs_extlen_t pagf_longest; /* longest free space */ 359 - __uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */ 375 + uint32_t pagf_btreeblks; /* # of blocks held in AGF btrees */ 360 376 xfs_agino_t pagi_freecount; /* number of free inodes */ 361 377 xfs_agino_t pagi_count; /* number of allocated inodes */ 362 378 ··· 395 411 struct xfs_ag_resv pag_agfl_resv; 396 412 397 413 /* reference count */ 398 - __uint8_t pagf_refcount_level; 414 + uint8_t pagf_refcount_level; 399 415 } xfs_perag_t; 400 416 401 417 static inline struct xfs_ag_resv * ··· 418 434 419 435 extern void xfs_uuid_table_free(void); 420 436 extern int xfs_log_sbcount(xfs_mount_t *); 421 - extern __uint64_t xfs_default_resblks(xfs_mount_t *mp); 437 + extern uint64_t xfs_default_resblks(xfs_mount_t *mp); 422 438 extern int xfs_mountfs(xfs_mount_t *mp); 423 439 extern int xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount, 424 440 xfs_agnumber_t *maxagi); ··· 434 450 extern int xfs_readsb(xfs_mount_t *, int); 435 451 extern void xfs_freesb(xfs_mount_t *); 436 452 extern bool xfs_fs_writable(struct xfs_mount *mp, int level); 437 - extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); 453 + extern int xfs_sb_validate_fsb_count(struct xfs_sb *, uint64_t); 438 454 439 455 extern int xfs_dev_is_read_only(struct xfs_mount *, char *); 440 456
+27 -1
fs/xfs/xfs_qm.c
··· 1247 1247 struct xfs_dquot *dqp, 1248 1248 void *data) 1249 1249 { 1250 + struct xfs_mount *mp = dqp->q_mount; 1250 1251 struct list_head *buffer_list = data; 1251 1252 struct xfs_buf *bp = NULL; 1252 1253 int error = 0; ··· 1258 1257 if (!XFS_DQ_IS_DIRTY(dqp)) 1259 1258 goto out_unlock; 1260 1259 1261 - xfs_dqflock(dqp); 1260 + /* 1261 + * The only way the dquot is already flush locked by the time quotacheck 1262 + * gets here is if reclaim flushed it before the dqadjust walk dirtied 1263 + * it for the final time. Quotacheck collects all dquot bufs in the 1264 + * local delwri queue before dquots are dirtied, so reclaim can't have 1265 + * possibly queued it for I/O. The only way out is to push the buffer to 1266 + * cycle the flush lock. 1267 + */ 1268 + if (!xfs_dqflock_nowait(dqp)) { 1269 + /* buf is pinned in-core by delwri list */ 1270 + DEFINE_SINGLE_BUF_MAP(map, dqp->q_blkno, 1271 + mp->m_quotainfo->qi_dqchunklen); 1272 + bp = _xfs_buf_find(mp->m_ddev_targp, &map, 1, 0, NULL); 1273 + if (!bp) { 1274 + error = -EINVAL; 1275 + goto out_unlock; 1276 + } 1277 + xfs_buf_unlock(bp); 1278 + 1279 + xfs_buf_delwri_pushbuf(bp, buffer_list); 1280 + xfs_buf_rele(bp); 1281 + 1282 + error = -EAGAIN; 1283 + goto out_unlock; 1284 + } 1285 + 1262 1286 error = xfs_qm_dqflush(dqp, &bp); 1263 1287 if (error) 1264 1288 goto out_unlock;
+1 -1
fs/xfs/xfs_qm_bhv.c
··· 33 33 struct kstatfs *statp, 34 34 struct xfs_dquot *dqp) 35 35 { 36 - __uint64_t limit; 36 + uint64_t limit; 37 37 38 38 limit = dqp->q_core.d_blk_softlimit ? 39 39 be64_to_cpu(dqp->q_core.d_blk_softlimit) :
-1
fs/xfs/xfs_quotaops.c
··· 269 269 /* ID may be different, so convert back what we got */ 270 270 *qid = make_kqid(current_user_ns(), qid->type, id); 271 271 return 0; 272 - 273 272 } 274 273 275 274 STATIC int
+63 -46
fs/xfs/xfs_reflink.c
··· 155 155 int 156 156 xfs_reflink_find_shared( 157 157 struct xfs_mount *mp, 158 + struct xfs_trans *tp, 158 159 xfs_agnumber_t agno, 159 160 xfs_agblock_t agbno, 160 161 xfs_extlen_t aglen, ··· 167 166 struct xfs_btree_cur *cur; 168 167 int error; 169 168 170 - error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 169 + error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); 171 170 if (error) 172 171 return error; 173 172 174 - cur = xfs_refcountbt_init_cursor(mp, NULL, agbp, agno, NULL); 173 + cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL); 175 174 176 175 error = xfs_refcount_find_shared(cur, agbno, aglen, fbno, flen, 177 176 find_end_of_shared); 178 177 179 178 xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR); 180 179 181 - xfs_buf_relse(agbp); 180 + xfs_trans_brelse(tp, agbp); 182 181 return error; 183 182 } 184 183 ··· 218 217 agbno = XFS_FSB_TO_AGBNO(ip->i_mount, irec->br_startblock); 219 218 aglen = irec->br_blockcount; 220 219 221 - error = xfs_reflink_find_shared(ip->i_mount, agno, agbno, 220 + error = xfs_reflink_find_shared(ip->i_mount, NULL, agno, agbno, 222 221 aglen, &fbno, &flen, true); 223 222 if (error) 224 223 return error; ··· 1374 1373 agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock); 1375 1374 aglen = map[1].br_blockcount; 1376 1375 1377 - error = xfs_reflink_find_shared(mp, agno, agbno, aglen, 1378 - &rbno, &rlen, true); 1376 + error = xfs_reflink_find_shared(mp, NULL, agno, agbno, 1377 + aglen, &rbno, &rlen, true); 1379 1378 if (error) 1380 1379 goto out; 1381 1380 if (rbno == NULLAGBLOCK) ··· 1406 1405 return error; 1407 1406 } 1408 1407 1408 + /* Does this inode need the reflink flag? */ 1409 + int 1410 + xfs_reflink_inode_has_shared_extents( 1411 + struct xfs_trans *tp, 1412 + struct xfs_inode *ip, 1413 + bool *has_shared) 1414 + { 1415 + struct xfs_bmbt_irec got; 1416 + struct xfs_mount *mp = ip->i_mount; 1417 + struct xfs_ifork *ifp; 1418 + xfs_agnumber_t agno; 1419 + xfs_agblock_t agbno; 1420 + xfs_extlen_t aglen; 1421 + xfs_agblock_t rbno; 1422 + xfs_extlen_t rlen; 1423 + xfs_extnum_t idx; 1424 + bool found; 1425 + int error; 1426 + 1427 + ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); 1428 + if (!(ifp->if_flags & XFS_IFEXTENTS)) { 1429 + error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); 1430 + if (error) 1431 + return error; 1432 + } 1433 + 1434 + *has_shared = false; 1435 + found = xfs_iext_lookup_extent(ip, ifp, 0, &idx, &got); 1436 + while (found) { 1437 + if (isnullstartblock(got.br_startblock) || 1438 + got.br_state != XFS_EXT_NORM) 1439 + goto next; 1440 + agno = XFS_FSB_TO_AGNO(mp, got.br_startblock); 1441 + agbno = XFS_FSB_TO_AGBNO(mp, got.br_startblock); 1442 + aglen = got.br_blockcount; 1443 + 1444 + error = xfs_reflink_find_shared(mp, tp, agno, agbno, aglen, 1445 + &rbno, &rlen, false); 1446 + if (error) 1447 + return error; 1448 + /* Is there still a shared block here? */ 1449 + if (rbno != NULLAGBLOCK) { 1450 + *has_shared = true; 1451 + return 0; 1452 + } 1453 + next: 1454 + found = xfs_iext_get_extent(ifp, ++idx, &got); 1455 + } 1456 + 1457 + return 0; 1458 + } 1459 + 1409 1460 /* Clear the inode reflink flag if there are no shared extents. */ 1410 1461 int 1411 1462 xfs_reflink_clear_inode_flag( 1412 1463 struct xfs_inode *ip, 1413 1464 struct xfs_trans **tpp) 1414 1465 { 1415 - struct xfs_mount *mp = ip->i_mount; 1416 - xfs_fileoff_t fbno; 1417 - xfs_filblks_t end; 1418 - xfs_agnumber_t agno; 1419 - xfs_agblock_t agbno; 1420 - xfs_extlen_t aglen; 1421 - xfs_agblock_t rbno; 1422 - xfs_extlen_t rlen; 1423 - struct xfs_bmbt_irec map; 1424 - int nmaps; 1466 + bool needs_flag; 1425 1467 int error = 0; 1426 1468 1427 1469 ASSERT(xfs_is_reflink_inode(ip)); 1428 1470 1429 - fbno = 0; 1430 - end = XFS_B_TO_FSB(mp, i_size_read(VFS_I(ip))); 1431 - while (end - fbno > 0) { 1432 - nmaps = 1; 1433 - /* 1434 - * Look for extents in the file. Skip holes, delalloc, or 1435 - * unwritten extents; they can't be reflinked. 1436 - */ 1437 - error = xfs_bmapi_read(ip, fbno, end - fbno, &map, &nmaps, 0); 1438 - if (error) 1439 - return error; 1440 - if (nmaps == 0) 1441 - break; 1442 - if (!xfs_bmap_is_real_extent(&map)) 1443 - goto next; 1444 - 1445 - agno = XFS_FSB_TO_AGNO(mp, map.br_startblock); 1446 - agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock); 1447 - aglen = map.br_blockcount; 1448 - 1449 - error = xfs_reflink_find_shared(mp, agno, agbno, aglen, 1450 - &rbno, &rlen, false); 1451 - if (error) 1452 - return error; 1453 - /* Is there still a shared block here? */ 1454 - if (rbno != NULLAGBLOCK) 1455 - return 0; 1456 - next: 1457 - fbno = map.br_startoff + map.br_blockcount; 1458 - } 1471 + error = xfs_reflink_inode_has_shared_extents(*tpp, ip, &needs_flag); 1472 + if (error || needs_flag) 1473 + return error; 1459 1474 1460 1475 /* 1461 1476 * We didn't find any shared blocks so turn off the reflink flag.
+5 -3
fs/xfs/xfs_reflink.h
··· 20 20 #ifndef __XFS_REFLINK_H 21 21 #define __XFS_REFLINK_H 1 22 22 23 - extern int xfs_reflink_find_shared(struct xfs_mount *mp, xfs_agnumber_t agno, 24 - xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno, 25 - xfs_extlen_t *flen, bool find_maximal); 23 + extern int xfs_reflink_find_shared(struct xfs_mount *mp, struct xfs_trans *tp, 24 + xfs_agnumber_t agno, xfs_agblock_t agbno, xfs_extlen_t aglen, 25 + xfs_agblock_t *fbno, xfs_extlen_t *flen, bool find_maximal); 26 26 extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip, 27 27 struct xfs_bmbt_irec *irec, bool *shared, bool *trimmed); 28 28 ··· 47 47 extern int xfs_reflink_recover_cow(struct xfs_mount *mp); 48 48 extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, 49 49 struct file *file_out, loff_t pos_out, u64 len, bool is_dedupe); 50 + extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, 51 + struct xfs_inode *ip, bool *has_shared); 50 52 extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, 51 53 struct xfs_trans **tpp); 52 54 extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset,
+4 -4
fs/xfs/xfs_rtalloc.c
··· 1256 1256 { 1257 1257 xfs_rtblock_t b; /* result block */ 1258 1258 int log2; /* log of sequence number */ 1259 - __uint64_t resid; /* residual after log removed */ 1260 - __uint64_t seq; /* sequence number of file creation */ 1261 - __uint64_t *seqp; /* pointer to seqno in inode */ 1259 + uint64_t resid; /* residual after log removed */ 1260 + uint64_t seq; /* sequence number of file creation */ 1261 + uint64_t *seqp; /* pointer to seqno in inode */ 1262 1262 1263 1263 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); 1264 1264 1265 - seqp = (__uint64_t *)&VFS_I(mp->m_rbmip)->i_atime; 1265 + seqp = (uint64_t *)&VFS_I(mp->m_rbmip)->i_atime; 1266 1266 if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) { 1267 1267 mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; 1268 1268 *seqp = 0;
+3
fs/xfs/xfs_rtalloc.h
··· 107 107 /* 108 108 * From xfs_rtbitmap.c 109 109 */ 110 + int xfs_rtbuf_get(struct xfs_mount *mp, struct xfs_trans *tp, 111 + xfs_rtblock_t block, int issum, struct xfs_buf **bpp); 110 112 int xfs_rtcheck_range(struct xfs_mount *mp, struct xfs_trans *tp, 111 113 xfs_rtblock_t start, xfs_extlen_t len, int val, 112 114 xfs_rtblock_t *new, int *stat); ··· 145 143 # define xfs_growfs_rt(mp,in) (ENOSYS) 146 144 # define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS) 147 145 # define xfs_rtalloc_query_all(t,f,p) (ENOSYS) 146 + # define xfs_rtbuf_get(m,t,b,i,p) (ENOSYS) 148 147 static inline int /* error */ 149 148 xfs_rtmount_init( 150 149 xfs_mount_t *mp) /* file system mount structure */
+4 -4
fs/xfs/xfs_stats.c
··· 33 33 { 34 34 int i, j; 35 35 int len = 0; 36 - __uint64_t xs_xstrat_bytes = 0; 37 - __uint64_t xs_write_bytes = 0; 38 - __uint64_t xs_read_bytes = 0; 36 + uint64_t xs_xstrat_bytes = 0; 37 + uint64_t xs_write_bytes = 0; 38 + uint64_t xs_read_bytes = 0; 39 39 40 40 static const struct xstats_entry { 41 41 char *desc; ··· 100 100 void xfs_stats_clearall(struct xfsstats __percpu *stats) 101 101 { 102 102 int c; 103 - __uint32_t vn_active; 103 + uint32_t vn_active; 104 104 105 105 xfs_notice(NULL, "Clearing xfsstats"); 106 106 for_each_possible_cpu(c) {
+95 -95
fs/xfs/xfs_stats.h
··· 54 54 */ 55 55 struct __xfsstats { 56 56 # define XFSSTAT_END_EXTENT_ALLOC 4 57 - __uint32_t xs_allocx; 58 - __uint32_t xs_allocb; 59 - __uint32_t xs_freex; 60 - __uint32_t xs_freeb; 57 + uint32_t xs_allocx; 58 + uint32_t xs_allocb; 59 + uint32_t xs_freex; 60 + uint32_t xs_freeb; 61 61 # define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4) 62 - __uint32_t xs_abt_lookup; 63 - __uint32_t xs_abt_compare; 64 - __uint32_t xs_abt_insrec; 65 - __uint32_t xs_abt_delrec; 62 + uint32_t xs_abt_lookup; 63 + uint32_t xs_abt_compare; 64 + uint32_t xs_abt_insrec; 65 + uint32_t xs_abt_delrec; 66 66 # define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7) 67 - __uint32_t xs_blk_mapr; 68 - __uint32_t xs_blk_mapw; 69 - __uint32_t xs_blk_unmap; 70 - __uint32_t xs_add_exlist; 71 - __uint32_t xs_del_exlist; 72 - __uint32_t xs_look_exlist; 73 - __uint32_t xs_cmp_exlist; 67 + uint32_t xs_blk_mapr; 68 + uint32_t xs_blk_mapw; 69 + uint32_t xs_blk_unmap; 70 + uint32_t xs_add_exlist; 71 + uint32_t xs_del_exlist; 72 + uint32_t xs_look_exlist; 73 + uint32_t xs_cmp_exlist; 74 74 # define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4) 75 - __uint32_t xs_bmbt_lookup; 76 - __uint32_t xs_bmbt_compare; 77 - __uint32_t xs_bmbt_insrec; 78 - __uint32_t xs_bmbt_delrec; 75 + uint32_t xs_bmbt_lookup; 76 + uint32_t xs_bmbt_compare; 77 + uint32_t xs_bmbt_insrec; 78 + uint32_t xs_bmbt_delrec; 79 79 # define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4) 80 - __uint32_t xs_dir_lookup; 81 - __uint32_t xs_dir_create; 82 - __uint32_t xs_dir_remove; 83 - __uint32_t xs_dir_getdents; 80 + uint32_t xs_dir_lookup; 81 + uint32_t xs_dir_create; 82 + uint32_t xs_dir_remove; 83 + uint32_t xs_dir_getdents; 84 84 # define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3) 85 - __uint32_t xs_trans_sync; 86 - __uint32_t xs_trans_async; 87 - __uint32_t xs_trans_empty; 85 + uint32_t xs_trans_sync; 86 + uint32_t xs_trans_async; 87 + uint32_t xs_trans_empty; 88 88 # define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7) 89 - __uint32_t xs_ig_attempts; 90 - __uint32_t xs_ig_found; 91 - __uint32_t xs_ig_frecycle; 92 - __uint32_t xs_ig_missed; 93 - __uint32_t xs_ig_dup; 94 - __uint32_t xs_ig_reclaims; 95 - __uint32_t xs_ig_attrchg; 89 + uint32_t xs_ig_attempts; 90 + uint32_t xs_ig_found; 91 + uint32_t xs_ig_frecycle; 92 + uint32_t xs_ig_missed; 93 + uint32_t xs_ig_dup; 94 + uint32_t xs_ig_reclaims; 95 + uint32_t xs_ig_attrchg; 96 96 # define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5) 97 - __uint32_t xs_log_writes; 98 - __uint32_t xs_log_blocks; 99 - __uint32_t xs_log_noiclogs; 100 - __uint32_t xs_log_force; 101 - __uint32_t xs_log_force_sleep; 97 + uint32_t xs_log_writes; 98 + uint32_t xs_log_blocks; 99 + uint32_t xs_log_noiclogs; 100 + uint32_t xs_log_force; 101 + uint32_t xs_log_force_sleep; 102 102 # define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10) 103 - __uint32_t xs_try_logspace; 104 - __uint32_t xs_sleep_logspace; 105 - __uint32_t xs_push_ail; 106 - __uint32_t xs_push_ail_success; 107 - __uint32_t xs_push_ail_pushbuf; 108 - __uint32_t xs_push_ail_pinned; 109 - __uint32_t xs_push_ail_locked; 110 - __uint32_t xs_push_ail_flushing; 111 - __uint32_t xs_push_ail_restarts; 112 - __uint32_t xs_push_ail_flush; 103 + uint32_t xs_try_logspace; 104 + uint32_t xs_sleep_logspace; 105 + uint32_t xs_push_ail; 106 + uint32_t xs_push_ail_success; 107 + uint32_t xs_push_ail_pushbuf; 108 + uint32_t xs_push_ail_pinned; 109 + uint32_t xs_push_ail_locked; 110 + uint32_t xs_push_ail_flushing; 111 + uint32_t xs_push_ail_restarts; 112 + uint32_t xs_push_ail_flush; 113 113 # define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2) 114 - __uint32_t xs_xstrat_quick; 115 - __uint32_t xs_xstrat_split; 114 + uint32_t xs_xstrat_quick; 115 + uint32_t xs_xstrat_split; 116 116 # define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2) 117 - __uint32_t xs_write_calls; 118 - __uint32_t xs_read_calls; 117 + uint32_t xs_write_calls; 118 + uint32_t xs_read_calls; 119 119 # define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4) 120 - __uint32_t xs_attr_get; 121 - __uint32_t xs_attr_set; 122 - __uint32_t xs_attr_remove; 123 - __uint32_t xs_attr_list; 120 + uint32_t xs_attr_get; 121 + uint32_t xs_attr_set; 122 + uint32_t xs_attr_remove; 123 + uint32_t xs_attr_list; 124 124 # define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3) 125 - __uint32_t xs_iflush_count; 126 - __uint32_t xs_icluster_flushcnt; 127 - __uint32_t xs_icluster_flushinode; 125 + uint32_t xs_iflush_count; 126 + uint32_t xs_icluster_flushcnt; 127 + uint32_t xs_icluster_flushinode; 128 128 # define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8) 129 - __uint32_t vn_active; /* # vnodes not on free lists */ 130 - __uint32_t vn_alloc; /* # times vn_alloc called */ 131 - __uint32_t vn_get; /* # times vn_get called */ 132 - __uint32_t vn_hold; /* # times vn_hold called */ 133 - __uint32_t vn_rele; /* # times vn_rele called */ 134 - __uint32_t vn_reclaim; /* # times vn_reclaim called */ 135 - __uint32_t vn_remove; /* # times vn_remove called */ 136 - __uint32_t vn_free; /* # times vn_free called */ 129 + uint32_t vn_active; /* # vnodes not on free lists */ 130 + uint32_t vn_alloc; /* # times vn_alloc called */ 131 + uint32_t vn_get; /* # times vn_get called */ 132 + uint32_t vn_hold; /* # times vn_hold called */ 133 + uint32_t vn_rele; /* # times vn_rele called */ 134 + uint32_t vn_reclaim; /* # times vn_reclaim called */ 135 + uint32_t vn_remove; /* # times vn_remove called */ 136 + uint32_t vn_free; /* # times vn_free called */ 137 137 #define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9) 138 - __uint32_t xb_get; 139 - __uint32_t xb_create; 140 - __uint32_t xb_get_locked; 141 - __uint32_t xb_get_locked_waited; 142 - __uint32_t xb_busy_locked; 143 - __uint32_t xb_miss_locked; 144 - __uint32_t xb_page_retries; 145 - __uint32_t xb_page_found; 146 - __uint32_t xb_get_read; 138 + uint32_t xb_get; 139 + uint32_t xb_create; 140 + uint32_t xb_get_locked; 141 + uint32_t xb_get_locked_waited; 142 + uint32_t xb_busy_locked; 143 + uint32_t xb_miss_locked; 144 + uint32_t xb_page_retries; 145 + uint32_t xb_page_found; 146 + uint32_t xb_get_read; 147 147 /* Version 2 btree counters */ 148 148 #define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF + __XBTS_MAX) 149 - __uint32_t xs_abtb_2[__XBTS_MAX]; 149 + uint32_t xs_abtb_2[__XBTS_MAX]; 150 150 #define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2 + __XBTS_MAX) 151 - __uint32_t xs_abtc_2[__XBTS_MAX]; 151 + uint32_t xs_abtc_2[__XBTS_MAX]; 152 152 #define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2 + __XBTS_MAX) 153 - __uint32_t xs_bmbt_2[__XBTS_MAX]; 153 + uint32_t xs_bmbt_2[__XBTS_MAX]; 154 154 #define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2 + __XBTS_MAX) 155 - __uint32_t xs_ibt_2[__XBTS_MAX]; 155 + uint32_t xs_ibt_2[__XBTS_MAX]; 156 156 #define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2 + __XBTS_MAX) 157 - __uint32_t xs_fibt_2[__XBTS_MAX]; 157 + uint32_t xs_fibt_2[__XBTS_MAX]; 158 158 #define XFSSTAT_END_RMAP_V2 (XFSSTAT_END_FIBT_V2 + __XBTS_MAX) 159 - __uint32_t xs_rmap_2[__XBTS_MAX]; 159 + uint32_t xs_rmap_2[__XBTS_MAX]; 160 160 #define XFSSTAT_END_REFCOUNT (XFSSTAT_END_RMAP_V2 + __XBTS_MAX) 161 - __uint32_t xs_refcbt_2[__XBTS_MAX]; 161 + uint32_t xs_refcbt_2[__XBTS_MAX]; 162 162 #define XFSSTAT_END_XQMSTAT (XFSSTAT_END_REFCOUNT + 6) 163 - __uint32_t xs_qm_dqreclaims; 164 - __uint32_t xs_qm_dqreclaim_misses; 165 - __uint32_t xs_qm_dquot_dups; 166 - __uint32_t xs_qm_dqcachemisses; 167 - __uint32_t xs_qm_dqcachehits; 168 - __uint32_t xs_qm_dqwants; 163 + uint32_t xs_qm_dqreclaims; 164 + uint32_t xs_qm_dqreclaim_misses; 165 + uint32_t xs_qm_dquot_dups; 166 + uint32_t xs_qm_dqcachemisses; 167 + uint32_t xs_qm_dqcachehits; 168 + uint32_t xs_qm_dqwants; 169 169 #define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2) 170 - __uint32_t xs_qm_dquot; 171 - __uint32_t xs_qm_dquot_unused; 170 + uint32_t xs_qm_dquot; 171 + uint32_t xs_qm_dquot_unused; 172 172 /* Extra precision counters */ 173 - __uint64_t xs_xstrat_bytes; 174 - __uint64_t xs_write_bytes; 175 - __uint64_t xs_read_bytes; 173 + uint64_t xs_xstrat_bytes; 174 + uint64_t xs_write_bytes; 175 + uint64_t xs_read_bytes; 176 176 }; 177 177 178 178 struct xfsstats { ··· 186 186 * simple wrapper for getting the array index of s struct member offset 187 187 */ 188 188 #define XFS_STATS_CALC_INDEX(member) \ 189 - (offsetof(struct __xfsstats, member) / (int)sizeof(__uint32_t)) 189 + (offsetof(struct __xfsstats, member) / (int)sizeof(uint32_t)) 190 190 191 191 192 192 int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
+13 -13
fs/xfs/xfs_super.c
··· 196 196 int dsunit = 0; 197 197 int dswidth = 0; 198 198 int iosize = 0; 199 - __uint8_t iosizelog = 0; 199 + uint8_t iosizelog = 0; 200 200 201 201 /* 202 202 * set up the mount name first so all the errors will refer to the ··· 556 556 557 557 return 0; 558 558 } 559 - static __uint64_t 559 + static uint64_t 560 560 xfs_max_file_offset( 561 561 unsigned int blockshift) 562 562 { ··· 587 587 # endif 588 588 #endif 589 589 590 - return (((__uint64_t)pagefactor) << bitshift) - 1; 590 + return (((uint64_t)pagefactor) << bitshift) - 1; 591 591 } 592 592 593 593 /* ··· 622 622 * the max inode percentage. Used only for inode32. 623 623 */ 624 624 if (mp->m_maxicount) { 625 - __uint64_t icount; 625 + uint64_t icount; 626 626 627 627 icount = sbp->sb_dblocks * sbp->sb_imax_pct; 628 628 do_div(icount, 100); ··· 1088 1088 struct xfs_mount *mp = XFS_M(dentry->d_sb); 1089 1089 xfs_sb_t *sbp = &mp->m_sb; 1090 1090 struct xfs_inode *ip = XFS_I(d_inode(dentry)); 1091 - __uint64_t fakeinos, id; 1092 - __uint64_t icount; 1093 - __uint64_t ifree; 1094 - __uint64_t fdblocks; 1091 + uint64_t fakeinos, id; 1092 + uint64_t icount; 1093 + uint64_t ifree; 1094 + uint64_t fdblocks; 1095 1095 xfs_extlen_t lsize; 1096 - __int64_t ffree; 1096 + int64_t ffree; 1097 1097 1098 1098 statp->f_type = XFS_SB_MAGIC; 1099 1099 statp->f_namelen = MAXNAMELEN - 1; ··· 1116 1116 statp->f_bavail = statp->f_bfree; 1117 1117 1118 1118 fakeinos = statp->f_bfree << sbp->sb_inopblog; 1119 - statp->f_files = MIN(icount + fakeinos, (__uint64_t)XFS_MAXINUMBER); 1119 + statp->f_files = MIN(icount + fakeinos, (uint64_t)XFS_MAXINUMBER); 1120 1120 if (mp->m_maxicount) 1121 1121 statp->f_files = min_t(typeof(statp->f_files), 1122 1122 statp->f_files, ··· 1129 1129 1130 1130 /* make sure statp->f_ffree does not underflow */ 1131 1131 ffree = statp->f_files - (icount - ifree); 1132 - statp->f_ffree = max_t(__int64_t, ffree, 0); 1132 + statp->f_ffree = max_t(int64_t, ffree, 0); 1133 1133 1134 1134 1135 1135 if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && ··· 1142 1142 STATIC void 1143 1143 xfs_save_resvblks(struct xfs_mount *mp) 1144 1144 { 1145 - __uint64_t resblks = 0; 1145 + uint64_t resblks = 0; 1146 1146 1147 1147 mp->m_resblks_save = mp->m_resblks; 1148 1148 xfs_reserve_blocks(mp, &resblks, NULL); ··· 1151 1151 STATIC void 1152 1152 xfs_restore_resvblks(struct xfs_mount *mp) 1153 1153 { 1154 - __uint64_t resblks; 1154 + uint64_t resblks; 1155 1155 1156 1156 if (mp->m_resblks_save) { 1157 1157 resblks = mp->m_resblks_save;
+6 -6
fs/xfs/xfs_symlink.c
··· 43 43 #include "xfs_log.h" 44 44 45 45 /* ----- Kernel only functions below ----- */ 46 - STATIC int 47 - xfs_readlink_bmap( 46 + int 47 + xfs_readlink_bmap_ilocked( 48 48 struct xfs_inode *ip, 49 49 char *link) 50 50 { ··· 143 143 if (!pathlen) 144 144 goto out; 145 145 146 - if (pathlen < 0 || pathlen > MAXPATHLEN) { 146 + if (pathlen < 0 || pathlen > XFS_SYMLINK_MAXLEN) { 147 147 xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)", 148 148 __func__, (unsigned long long) ip->i_ino, 149 149 (long long) pathlen); ··· 153 153 } 154 154 155 155 156 - error = xfs_readlink_bmap(ip, link); 156 + error = xfs_readlink_bmap_ilocked(ip, link); 157 157 158 158 out: 159 159 xfs_iunlock(ip, XFS_ILOCK_SHARED); ··· 202 202 * Check component lengths of the target path name. 203 203 */ 204 204 pathlen = strlen(target_path); 205 - if (pathlen >= MAXPATHLEN) /* total string too long */ 205 + if (pathlen >= XFS_SYMLINK_MAXLEN) /* total string too long */ 206 206 return -ENAMETOOLONG; 207 207 208 208 udqp = gdqp = NULL; ··· 559 559 return 0; 560 560 } 561 561 562 - if (pathlen < 0 || pathlen > MAXPATHLEN) { 562 + if (pathlen < 0 || pathlen > XFS_SYMLINK_MAXLEN) { 563 563 xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)", 564 564 __func__, (unsigned long long)ip->i_ino, pathlen); 565 565 xfs_iunlock(ip, XFS_ILOCK_EXCL);
+1
fs/xfs/xfs_symlink.h
··· 21 21 22 22 int xfs_symlink(struct xfs_inode *dp, struct xfs_name *link_name, 23 23 const char *target_path, umode_t mode, struct xfs_inode **ipp); 24 + int xfs_readlink_bmap_ilocked(struct xfs_inode *ip, char *link); 24 25 int xfs_readlink(struct xfs_inode *ip, char *link); 25 26 int xfs_inactive_symlink(struct xfs_inode *ip); 26 27
+1
fs/xfs/xfs_sysctl.h
··· 95 95 96 96 struct xfs_globals { 97 97 int log_recovery_delay; /* log recovery delay (secs) */ 98 + bool bug_on_assert; /* BUG() the kernel on assert failure */ 98 99 }; 99 100 extern struct xfs_globals xfs_globals; 100 101
+33 -78
fs/xfs/xfs_sysfs.c
··· 90 90 return container_of(kobj, struct xfs_mount, m_kobj); 91 91 } 92 92 93 - #ifdef DEBUG 94 - 95 - STATIC ssize_t 96 - drop_writes_store( 97 - struct kobject *kobject, 98 - const char *buf, 99 - size_t count) 100 - { 101 - struct xfs_mount *mp = to_mp(kobject); 102 - int ret; 103 - int val; 104 - 105 - ret = kstrtoint(buf, 0, &val); 106 - if (ret) 107 - return ret; 108 - 109 - if (val == 1) 110 - mp->m_drop_writes = true; 111 - else if (val == 0) 112 - mp->m_drop_writes = false; 113 - else 114 - return -EINVAL; 115 - 116 - return count; 117 - } 118 - 119 - STATIC ssize_t 120 - drop_writes_show( 121 - struct kobject *kobject, 122 - char *buf) 123 - { 124 - struct xfs_mount *mp = to_mp(kobject); 125 - 126 - return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_drop_writes ? 1 : 0); 127 - } 128 - XFS_SYSFS_ATTR_RW(drop_writes); 129 - 130 - #endif /* DEBUG */ 131 - 132 93 static struct attribute *xfs_mp_attrs[] = { 133 - #ifdef DEBUG 134 - ATTR_LIST(drop_writes), 135 - #endif 136 94 NULL, 137 95 }; 138 96 ··· 102 144 103 145 #ifdef DEBUG 104 146 /* debug */ 147 + 148 + STATIC ssize_t 149 + bug_on_assert_store( 150 + struct kobject *kobject, 151 + const char *buf, 152 + size_t count) 153 + { 154 + int ret; 155 + int val; 156 + 157 + ret = kstrtoint(buf, 0, &val); 158 + if (ret) 159 + return ret; 160 + 161 + if (val == 1) 162 + xfs_globals.bug_on_assert = true; 163 + else if (val == 0) 164 + xfs_globals.bug_on_assert = false; 165 + else 166 + return -EINVAL; 167 + 168 + return count; 169 + } 170 + 171 + STATIC ssize_t 172 + bug_on_assert_show( 173 + struct kobject *kobject, 174 + char *buf) 175 + { 176 + return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bug_on_assert ? 1 : 0); 177 + } 178 + XFS_SYSFS_ATTR_RW(bug_on_assert); 105 179 106 180 STATIC ssize_t 107 181 log_recovery_delay_store( ··· 166 176 XFS_SYSFS_ATTR_RW(log_recovery_delay); 167 177 168 178 static struct attribute *xfs_dbg_attrs[] = { 179 + ATTR_LIST(bug_on_assert), 169 180 ATTR_LIST(log_recovery_delay), 170 181 NULL, 171 182 }; ··· 305 314 } 306 315 XFS_SYSFS_ATTR_RO(write_grant_head); 307 316 308 - #ifdef DEBUG 309 - STATIC ssize_t 310 - log_badcrc_factor_store( 311 - struct kobject *kobject, 312 - const char *buf, 313 - size_t count) 314 - { 315 - struct xlog *log = to_xlog(kobject); 316 - int ret; 317 - uint32_t val; 318 - 319 - ret = kstrtouint(buf, 0, &val); 320 - if (ret) 321 - return ret; 322 - 323 - log->l_badcrc_factor = val; 324 - 325 - return count; 326 - } 327 - 328 - STATIC ssize_t 329 - log_badcrc_factor_show( 330 - struct kobject *kobject, 331 - char *buf) 332 - { 333 - struct xlog *log = to_xlog(kobject); 334 - 335 - return snprintf(buf, PAGE_SIZE, "%d\n", log->l_badcrc_factor); 336 - } 337 - 338 - XFS_SYSFS_ATTR_RW(log_badcrc_factor); 339 - #endif /* DEBUG */ 340 - 341 317 static struct attribute *xfs_log_attrs[] = { 342 318 ATTR_LIST(log_head_lsn), 343 319 ATTR_LIST(log_tail_lsn), 344 320 ATTR_LIST(reserve_grant_head), 345 321 ATTR_LIST(write_grant_head), 346 - #ifdef DEBUG 347 - ATTR_LIST(log_badcrc_factor), 348 - #endif 349 322 NULL, 350 323 }; 351 324
+11 -29
fs/xfs/xfs_trace.h
··· 251 251 __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS), 252 252 (long)__entry->idx, 253 253 __entry->startoff, 254 - (__int64_t)__entry->startblock, 254 + (int64_t)__entry->startblock, 255 255 __entry->blockcount, 256 256 __entry->state, 257 257 (char *)__entry->caller_ip) ··· 295 295 __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS), 296 296 (long)__entry->idx, 297 297 __entry->startoff, 298 - (__int64_t)__entry->startblock, 298 + (int64_t)__entry->startblock, 299 299 __entry->blockcount, 300 300 __entry->state, 301 301 (char *)__entry->caller_ip) ··· 367 367 DEFINE_BUF_EVENT(xfs_buf_delwri_queue); 368 368 DEFINE_BUF_EVENT(xfs_buf_delwri_queued); 369 369 DEFINE_BUF_EVENT(xfs_buf_delwri_split); 370 + DEFINE_BUF_EVENT(xfs_buf_delwri_pushbuf); 370 371 DEFINE_BUF_EVENT(xfs_buf_get_uncached); 371 372 DEFINE_BUF_EVENT(xfs_buf_item_relse); 372 373 DEFINE_BUF_EVENT(xfs_buf_item_iodone_async); ··· 1281 1280 __entry->count, 1282 1281 __print_symbolic(__entry->type, XFS_IO_TYPES), 1283 1282 __entry->startoff, 1284 - (__int64_t)__entry->startblock, 1283 + (int64_t)__entry->startblock, 1285 1284 __entry->blockcount) 1286 1285 ) 1287 1286 ··· 1489 1488 __entry->len, 1490 1489 __entry->tbno, 1491 1490 __entry->tlen) 1492 - ); 1493 - 1494 - TRACE_EVENT(xfs_trans_commit_lsn, 1495 - TP_PROTO(struct xfs_trans *trans), 1496 - TP_ARGS(trans), 1497 - TP_STRUCT__entry( 1498 - __field(dev_t, dev) 1499 - __field(struct xfs_trans *, tp) 1500 - __field(xfs_lsn_t, lsn) 1501 - ), 1502 - TP_fast_assign( 1503 - __entry->dev = trans->t_mountp->m_super->s_dev; 1504 - __entry->tp = trans; 1505 - __entry->lsn = trans->t_commit_lsn; 1506 - ), 1507 - TP_printk("dev %d:%d trans 0x%p commit_lsn 0x%llx", 1508 - MAJOR(__entry->dev), MINOR(__entry->dev), 1509 - __entry->tp, 1510 - __entry->lsn) 1511 1491 ); 1512 1492 1513 1493 TRACE_EVENT(xfs_agf, ··· 2039 2057 TP_ARGS(log, buf_f), 2040 2058 TP_STRUCT__entry( 2041 2059 __field(dev_t, dev) 2042 - __field(__int64_t, blkno) 2060 + __field(int64_t, blkno) 2043 2061 __field(unsigned short, len) 2044 2062 __field(unsigned short, flags) 2045 2063 __field(unsigned short, size) ··· 2088 2106 __field(int, fields) 2089 2107 __field(unsigned short, asize) 2090 2108 __field(unsigned short, dsize) 2091 - __field(__int64_t, blkno) 2109 + __field(int64_t, blkno) 2092 2110 __field(int, len) 2093 2111 __field(int, boffset) 2094 2112 ), ··· 3238 3256 __field(xfs_agnumber_t, agno) 3239 3257 __field(xfs_fsblock_t, bno) 3240 3258 __field(xfs_filblks_t, len) 3241 - __field(__uint64_t, owner) 3242 - __field(__uint64_t, offset) 3259 + __field(uint64_t, owner) 3260 + __field(uint64_t, offset) 3243 3261 __field(unsigned int, flags) 3244 3262 ), 3245 3263 TP_fast_assign( ··· 3279 3297 __field(dev_t, keydev) 3280 3298 __field(xfs_daddr_t, block) 3281 3299 __field(xfs_daddr_t, len) 3282 - __field(__uint64_t, owner) 3283 - __field(__uint64_t, offset) 3284 - __field(__uint64_t, flags) 3300 + __field(uint64_t, owner) 3301 + __field(uint64_t, offset) 3302 + __field(uint64_t, flags) 3285 3303 ), 3286 3304 TP_fast_assign( 3287 3305 __entry->dev = mp->m_super->s_dev;
+2 -6
fs/xfs/xfs_trans.h
··· 105 105 unsigned int t_rtx_res; /* # of rt extents resvd */ 106 106 unsigned int t_rtx_res_used; /* # of resvd rt extents used */ 107 107 struct xlog_ticket *t_ticket; /* log mgr ticket */ 108 - xfs_lsn_t t_lsn; /* log seq num of start of 109 - * transaction. */ 110 - xfs_lsn_t t_commit_lsn; /* log seq num of end of 111 - * transaction. */ 112 108 struct xfs_mount *t_mountp; /* ptr to fs mount struct */ 113 109 struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ 114 110 unsigned int t_flags; /* misc flags */ ··· 245 249 struct xfs_rui_log_item *ruip); 246 250 int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp, 247 251 struct xfs_rud_log_item *rudp, enum xfs_rmap_intent_type type, 248 - __uint64_t owner, int whichfork, xfs_fileoff_t startoff, 252 + uint64_t owner, int whichfork, xfs_fileoff_t startoff, 249 253 xfs_fsblock_t startblock, xfs_filblks_t blockcount, 250 254 xfs_exntst_t state, struct xfs_btree_cur **pcur); 251 255 ··· 271 275 struct xfs_bud_log_item *rudp, struct xfs_defer_ops *dfops, 272 276 enum xfs_bmap_intent_type type, struct xfs_inode *ip, 273 277 int whichfork, xfs_fileoff_t startoff, xfs_fsblock_t startblock, 274 - xfs_filblks_t blockcount, xfs_exntst_t state); 278 + xfs_filblks_t *blockcount, xfs_exntst_t state); 275 279 276 280 #endif /* __XFS_TRANS_H__ */
+9 -2
fs/xfs/xfs_trans_bmap.c
··· 63 63 int whichfork, 64 64 xfs_fileoff_t startoff, 65 65 xfs_fsblock_t startblock, 66 - xfs_filblks_t blockcount, 66 + xfs_filblks_t *blockcount, 67 67 xfs_exntst_t state) 68 68 { 69 69 int error; ··· 196 196 void **state) 197 197 { 198 198 struct xfs_bmap_intent *bmap; 199 + xfs_filblks_t count; 199 200 int error; 200 201 201 202 bmap = container_of(item, struct xfs_bmap_intent, bi_list); 203 + count = bmap->bi_bmap.br_blockcount; 202 204 error = xfs_trans_log_finish_bmap_update(tp, done_item, dop, 203 205 bmap->bi_type, 204 206 bmap->bi_owner, bmap->bi_whichfork, 205 207 bmap->bi_bmap.br_startoff, 206 208 bmap->bi_bmap.br_startblock, 207 - bmap->bi_bmap.br_blockcount, 209 + &count, 208 210 bmap->bi_bmap.br_state); 211 + if (!error && count > 0) { 212 + ASSERT(bmap->bi_type == XFS_BMAP_UNMAP); 213 + bmap->bi_bmap.br_blockcount = count; 214 + return -EAGAIN; 215 + } 209 216 kmem_free(bmap); 210 217 return error; 211 218 }
+14 -7
fs/xfs/xfs_trans_buf.c
··· 356 356 xfs_buf_t *bp) 357 357 { 358 358 xfs_buf_log_item_t *bip; 359 + int freed; 359 360 360 361 /* 361 362 * Default to a normal brelse() call if the tp is NULL. ··· 420 419 /* 421 420 * Drop our reference to the buf log item. 422 421 */ 423 - atomic_dec(&bip->bli_refcount); 422 + freed = atomic_dec_and_test(&bip->bli_refcount); 424 423 425 424 /* 426 - * If the buf item is not tracking data in the log, then 427 - * we must free it before releasing the buffer back to the 428 - * free pool. Before releasing the buffer to the free pool, 429 - * clear the transaction pointer in b_fsprivate2 to dissolve 430 - * its relation to this transaction. 425 + * If the buf item is not tracking data in the log, then we must free it 426 + * before releasing the buffer back to the free pool. 427 + * 428 + * If the fs has shutdown and we dropped the last reference, it may fall 429 + * on us to release a (possibly dirty) bli if it never made it to the 430 + * AIL (e.g., the aborted unpin already happened and didn't release it 431 + * due to our reference). Since we're already shutdown and need xa_lock, 432 + * just force remove from the AIL and release the bli here. 431 433 */ 432 - if (!xfs_buf_item_dirty(bip)) { 434 + if (XFS_FORCED_SHUTDOWN(tp->t_mountp) && freed) { 435 + xfs_trans_ail_remove(&bip->bli_item, SHUTDOWN_LOG_IO_ERROR); 436 + xfs_buf_item_relse(bp); 437 + } else if (!xfs_buf_item_dirty(bip)) { 433 438 /*** 434 439 ASSERT(bp->b_pincount == 0); 435 440 ***/
+1 -1
fs/xfs/xfs_trans_rmap.c
··· 96 96 struct xfs_trans *tp, 97 97 struct xfs_rud_log_item *rudp, 98 98 enum xfs_rmap_intent_type type, 99 - __uint64_t owner, 99 + uint64_t owner, 100 100 int whichfork, 101 101 xfs_fileoff_t startoff, 102 102 xfs_fsblock_t startblock,
+2
include/linux/buffer_head.h
··· 202 202 sector_t bblock, unsigned blocksize); 203 203 int bh_uptodate_or_lock(struct buffer_head *bh); 204 204 int bh_submit_read(struct buffer_head *bh); 205 + loff_t page_cache_seek_hole_data(struct inode *inode, loff_t offset, 206 + loff_t length, int whence); 205 207 206 208 extern int buffer_heads_over_limit; 207 209
+4
include/linux/iomap.h
··· 84 84 int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops); 85 85 int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 86 86 loff_t start, loff_t len, const struct iomap_ops *ops); 87 + loff_t iomap_seek_hole(struct inode *inode, loff_t offset, 88 + const struct iomap_ops *ops); 89 + loff_t iomap_seek_data(struct inode *inode, loff_t offset, 90 + const struct iomap_ops *ops); 87 91 88 92 /* 89 93 * Flags for direct I/O ->end_io: