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

Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs

Pull XFS update (part 2) from Ben Myers:
"Fixes for tracing of xfs_name strings, flag handling in
open_by_handle, a log space hang with freeze/unfreeze, fstrim offset
calculations, a section mismatch with xfs_qm_exit, an oops in
xlog_recover_process_iunlinks, and a deadlock in xfs_rtfree_extent.

There are also additional trace points for attributes, and the
addition of a workqueue for allocation to work around kernel stack
size limitations."

* 'for-linus' of git://oss.sgi.com/xfs/xfs:
xfs: add lots of attribute trace points
xfs: Fix oops on IO error during xlog_recover_process_iunlinks()
xfs: fix fstrim offset calculations
xfs: Account log unmount transaction correctly
xfs: don't cache inodes read through bulkstat
xfs: trace xfs_name strings correctly
xfs: introduce an allocation workqueue
xfs: Fix open flag handling in open_by_handle code
xfs: fix deadlock in xfs_rtfree_extent
fs: xfs: fix section mismatch in linux-next

+317 -76
+34 -2
fs/xfs/xfs_alloc.c
··· 35 35 #include "xfs_error.h" 36 36 #include "xfs_trace.h" 37 37 38 + struct workqueue_struct *xfs_alloc_wq; 38 39 39 40 #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) 40 41 ··· 69 68 * Lookup the first record greater than or equal to [bno, len] 70 69 * in the btree given by cur. 71 70 */ 72 - STATIC int /* error */ 71 + int /* error */ 73 72 xfs_alloc_lookup_ge( 74 73 struct xfs_btree_cur *cur, /* btree cursor */ 75 74 xfs_agblock_t bno, /* starting block of extent */ ··· 2208 2207 * group or loop over the allocation groups to find the result. 2209 2208 */ 2210 2209 int /* error */ 2211 - xfs_alloc_vextent( 2210 + __xfs_alloc_vextent( 2212 2211 xfs_alloc_arg_t *args) /* allocation argument structure */ 2213 2212 { 2214 2213 xfs_agblock_t agsize; /* allocation group size */ ··· 2416 2415 error0: 2417 2416 xfs_perag_put(args->pag); 2418 2417 return error; 2418 + } 2419 + 2420 + static void 2421 + xfs_alloc_vextent_worker( 2422 + struct work_struct *work) 2423 + { 2424 + struct xfs_alloc_arg *args = container_of(work, 2425 + struct xfs_alloc_arg, work); 2426 + unsigned long pflags; 2427 + 2428 + /* we are in a transaction context here */ 2429 + current_set_flags_nested(&pflags, PF_FSTRANS); 2430 + 2431 + args->result = __xfs_alloc_vextent(args); 2432 + complete(args->done); 2433 + 2434 + current_restore_flags_nested(&pflags, PF_FSTRANS); 2435 + } 2436 + 2437 + 2438 + int /* error */ 2439 + xfs_alloc_vextent( 2440 + xfs_alloc_arg_t *args) /* allocation argument structure */ 2441 + { 2442 + DECLARE_COMPLETION_ONSTACK(done); 2443 + 2444 + args->done = &done; 2445 + INIT_WORK(&args->work, xfs_alloc_vextent_worker); 2446 + queue_work(xfs_alloc_wq, &args->work); 2447 + wait_for_completion(&done); 2448 + return args->result; 2419 2449 } 2420 2450 2421 2451 /*
+12
fs/xfs/xfs_alloc.h
··· 25 25 struct xfs_trans; 26 26 struct xfs_busy_extent; 27 27 28 + extern struct workqueue_struct *xfs_alloc_wq; 29 + 28 30 /* 29 31 * Freespace allocation types. Argument to xfs_alloc_[v]extent. 30 32 */ ··· 121 119 char isfl; /* set if is freelist blocks - !acctg */ 122 120 char userdata; /* set if this is user data */ 123 121 xfs_fsblock_t firstblock; /* io first block allocated */ 122 + struct completion *done; 123 + struct work_struct work; 124 + int result; 124 125 } xfs_alloc_arg_t; 125 126 126 127 /* ··· 243 238 244 239 int /* error */ 245 240 xfs_alloc_lookup_le( 241 + struct xfs_btree_cur *cur, /* btree cursor */ 242 + xfs_agblock_t bno, /* starting block of extent */ 243 + xfs_extlen_t len, /* length of extent */ 244 + int *stat); /* success/failure */ 245 + 246 + int /* error */ 247 + xfs_alloc_lookup_ge( 246 248 struct xfs_btree_cur *cur, /* btree cursor */ 247 249 xfs_agblock_t bno, /* starting block of extent */ 248 250 xfs_extlen_t len, /* length of extent */
+16
fs/xfs/xfs_attr.c
··· 853 853 { 854 854 int newsize, forkoff, retval; 855 855 856 + trace_xfs_attr_sf_addname(args); 857 + 856 858 retval = xfs_attr_shortform_lookup(args); 857 859 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 858 860 return(retval); ··· 898 896 xfs_dabuf_t *bp; 899 897 int retval, error, committed, forkoff; 900 898 899 + trace_xfs_attr_leaf_addname(args); 900 + 901 901 /* 902 902 * Read the (only) block in the attribute list in. 903 903 */ ··· 924 920 xfs_da_brelse(args->trans, bp); 925 921 return(retval); 926 922 } 923 + 924 + trace_xfs_attr_leaf_replace(args); 925 + 927 926 args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */ 928 927 args->blkno2 = args->blkno; /* set 2nd entry info*/ 929 928 args->index2 = args->index; ··· 1097 1090 xfs_dabuf_t *bp; 1098 1091 int error, committed, forkoff; 1099 1092 1093 + trace_xfs_attr_leaf_removename(args); 1094 + 1100 1095 /* 1101 1096 * Remove the attribute. 1102 1097 */ ··· 1232 1223 xfs_mount_t *mp; 1233 1224 int committed, retval, error; 1234 1225 1226 + trace_xfs_attr_node_addname(args); 1227 + 1235 1228 /* 1236 1229 * Fill in bucket of arguments/results/context to carry around. 1237 1230 */ ··· 1260 1249 } else if (retval == EEXIST) { 1261 1250 if (args->flags & ATTR_CREATE) 1262 1251 goto out; 1252 + 1253 + trace_xfs_attr_node_replace(args); 1254 + 1263 1255 args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */ 1264 1256 args->blkno2 = args->blkno; /* set 2nd entry info*/ 1265 1257 args->index2 = args->index; ··· 1493 1479 xfs_inode_t *dp; 1494 1480 xfs_dabuf_t *bp; 1495 1481 int retval, error, committed, forkoff; 1482 + 1483 + trace_xfs_attr_node_removename(args); 1496 1484 1497 1485 /* 1498 1486 * Tie a string around our finger to remind us where we are.
+36 -4
fs/xfs/xfs_attr_leaf.c
··· 235 235 xfs_inode_t *dp; 236 236 xfs_ifork_t *ifp; 237 237 238 + trace_xfs_attr_sf_create(args); 239 + 238 240 dp = args->dp; 239 241 ASSERT(dp != NULL); 240 242 ifp = dp->i_afp; ··· 269 267 xfs_mount_t *mp; 270 268 xfs_inode_t *dp; 271 269 xfs_ifork_t *ifp; 270 + 271 + trace_xfs_attr_sf_add(args); 272 272 273 273 dp = args->dp; 274 274 mp = dp->i_mount; ··· 341 337 xfs_mount_t *mp; 342 338 xfs_inode_t *dp; 343 339 340 + trace_xfs_attr_sf_remove(args); 341 + 344 342 dp = args->dp; 345 343 mp = dp->i_mount; 346 344 base = sizeof(xfs_attr_sf_hdr_t); ··· 410 404 xfs_attr_sf_entry_t *sfe; 411 405 int i; 412 406 xfs_ifork_t *ifp; 407 + 408 + trace_xfs_attr_sf_lookup(args); 413 409 414 410 ifp = args->dp->i_afp; 415 411 ASSERT(ifp->if_flags & XFS_IFINLINE); ··· 483 475 xfs_dablk_t blkno; 484 476 xfs_dabuf_t *bp; 485 477 xfs_ifork_t *ifp; 478 + 479 + trace_xfs_attr_sf_to_leaf(args); 486 480 487 481 dp = args->dp; 488 482 ifp = dp->i_afp; ··· 785 775 char *tmpbuffer; 786 776 int error, i; 787 777 778 + trace_xfs_attr_leaf_to_sf(args); 779 + 788 780 dp = args->dp; 789 781 tmpbuffer = kmem_alloc(XFS_LBSIZE(dp->i_mount), KM_SLEEP); 790 782 ASSERT(tmpbuffer != NULL); ··· 860 848 xfs_dablk_t blkno; 861 849 int error; 862 850 851 + trace_xfs_attr_leaf_to_node(args); 852 + 863 853 dp = args->dp; 864 854 bp1 = bp2 = NULL; 865 855 error = xfs_da_grow_inode(args, &blkno); ··· 925 911 xfs_dabuf_t *bp; 926 912 int error; 927 913 914 + trace_xfs_attr_leaf_create(args); 915 + 928 916 dp = args->dp; 929 917 ASSERT(dp != NULL); 930 918 error = xfs_da_get_buf(args->trans, args->dp, blkno, -1, &bp, ··· 964 948 xfs_dablk_t blkno; 965 949 int error; 966 950 951 + trace_xfs_attr_leaf_split(state->args); 952 + 967 953 /* 968 954 * Allocate space for a new leaf node. 969 955 */ ··· 995 977 * 996 978 * Insert the "new" entry in the correct block. 997 979 */ 998 - if (state->inleaf) 980 + if (state->inleaf) { 981 + trace_xfs_attr_leaf_add_old(state->args); 999 982 error = xfs_attr_leaf_add(oldblk->bp, state->args); 1000 - else 983 + } else { 984 + trace_xfs_attr_leaf_add_new(state->args); 1001 985 error = xfs_attr_leaf_add(newblk->bp, state->args); 986 + } 1002 987 1003 988 /* 1004 989 * Update last hashval in each block since we added the name. ··· 1021 1000 xfs_attr_leaf_hdr_t *hdr; 1022 1001 xfs_attr_leaf_map_t *map; 1023 1002 int tablesize, entsize, sum, tmp, i; 1003 + 1004 + trace_xfs_attr_leaf_add(args); 1024 1005 1025 1006 leaf = bp->data; 1026 1007 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); ··· 1151 1128 (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval))); 1152 1129 1153 1130 /* 1154 - * Copy the attribute name and value into the new space. 1155 - * 1156 1131 * For "remote" attribute values, simply note that we need to 1157 1132 * allocate space for the "remote" value. We can't actually 1158 1133 * allocate the extents in this transaction, and we can't decide ··· 1285 1264 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1286 1265 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1287 1266 args = state->args; 1267 + 1268 + trace_xfs_attr_leaf_rebalance(args); 1288 1269 1289 1270 /* 1290 1271 * Check ordering of blocks, reverse if it makes things simpler. ··· 1833 1810 xfs_mount_t *mp; 1834 1811 char *tmpbuffer; 1835 1812 1813 + trace_xfs_attr_leaf_unbalance(state->args); 1814 + 1836 1815 /* 1837 1816 * Set up environment. 1838 1817 */ ··· 1943 1918 xfs_attr_leaf_name_remote_t *name_rmt; 1944 1919 int probe, span; 1945 1920 xfs_dahash_t hashval; 1921 + 1922 + trace_xfs_attr_leaf_lookup(args); 1946 1923 1947 1924 leaf = bp->data; 1948 1925 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); ··· 2472 2445 char *name; 2473 2446 #endif /* DEBUG */ 2474 2447 2448 + trace_xfs_attr_leaf_clearflag(args); 2475 2449 /* 2476 2450 * Set up the operation. 2477 2451 */ ··· 2537 2509 xfs_dabuf_t *bp; 2538 2510 int error; 2539 2511 2512 + trace_xfs_attr_leaf_setflag(args); 2513 + 2540 2514 /* 2541 2515 * Set up the operation. 2542 2516 */ ··· 2594 2564 int namelen1, namelen2; 2595 2565 char *name1, *name2; 2596 2566 #endif /* DEBUG */ 2567 + 2568 + trace_xfs_attr_leaf_flipflags(args); 2597 2569 2598 2570 /* 2599 2571 * Read the block containing the "old" attr
+9
fs/xfs/xfs_bmap.c
··· 5124 5124 cur->bc_private.b.flags = 0; 5125 5125 } else 5126 5126 cur = NULL; 5127 + 5128 + if (isrt) { 5129 + /* 5130 + * Synchronize by locking the bitmap inode. 5131 + */ 5132 + xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); 5133 + xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); 5134 + } 5135 + 5127 5136 extno = 0; 5128 5137 while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >= 0 && 5129 5138 (nexts == 0 || extno < nexts)) {
+32
fs/xfs/xfs_da_btree.c
··· 108 108 int error; 109 109 xfs_trans_t *tp; 110 110 111 + trace_xfs_da_node_create(args); 112 + 111 113 tp = args->trans; 112 114 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork); 113 115 if (error) ··· 141 139 xfs_da_intnode_t *node; 142 140 xfs_dabuf_t *bp; 143 141 int max, action, error, i; 142 + 143 + trace_xfs_da_split(state->args); 144 144 145 145 /* 146 146 * Walk back up the tree splitting/inserting/adjusting as necessary. ··· 182 178 state->extravalid = 1; 183 179 if (state->inleaf) { 184 180 state->extraafter = 0; /* before newblk */ 181 + trace_xfs_attr_leaf_split_before(state->args); 185 182 error = xfs_attr_leaf_split(state, oldblk, 186 183 &state->extrablk); 187 184 } else { 188 185 state->extraafter = 1; /* after newblk */ 186 + trace_xfs_attr_leaf_split_after(state->args); 189 187 error = xfs_attr_leaf_split(state, newblk, 190 188 &state->extrablk); 191 189 } ··· 306 300 xfs_mount_t *mp; 307 301 xfs_dir2_leaf_t *leaf; 308 302 303 + trace_xfs_da_root_split(state->args); 304 + 309 305 /* 310 306 * Copy the existing (incorrect) block from the root node position 311 307 * to a free space somewhere. ··· 387 379 xfs_dablk_t blkno; 388 380 int newcount, error; 389 381 int useextra; 382 + 383 + trace_xfs_da_node_split(state->args); 390 384 391 385 node = oldblk->bp->data; 392 386 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); ··· 475 465 xfs_da_node_entry_t *btree_s, *btree_d; 476 466 int count, tmp; 477 467 xfs_trans_t *tp; 468 + 469 + trace_xfs_da_node_rebalance(state->args); 478 470 479 471 node1 = blk1->bp->data; 480 472 node2 = blk2->bp->data; ··· 586 574 xfs_da_node_entry_t *btree; 587 575 int tmp; 588 576 577 + trace_xfs_da_node_add(state->args); 578 + 589 579 node = oldblk->bp->data; 590 580 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 591 581 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); ··· 632 618 { 633 619 xfs_da_state_blk_t *drop_blk, *save_blk; 634 620 int action, error; 621 + 622 + trace_xfs_da_join(state->args); 635 623 636 624 action = 0; 637 625 drop_blk = &state->path.blk[ state->path.active-1 ]; ··· 738 722 xfs_dablk_t child; 739 723 xfs_dabuf_t *bp; 740 724 int error; 725 + 726 + trace_xfs_da_root_join(state->args); 741 727 742 728 args = state->args; 743 729 ASSERT(args != NULL); ··· 959 941 xfs_da_node_entry_t *btree; 960 942 int tmp; 961 943 944 + trace_xfs_da_node_remove(state->args); 945 + 962 946 node = drop_blk->bp->data; 963 947 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count)); 964 948 ASSERT(drop_blk->index >= 0); ··· 1003 983 xfs_da_node_entry_t *btree; 1004 984 int tmp; 1005 985 xfs_trans_t *tp; 986 + 987 + trace_xfs_da_node_unbalance(state->args); 1006 988 1007 989 drop_node = drop_blk->bp->data; 1008 990 save_node = save_blk->bp->data; ··· 1252 1230 /* 1253 1231 * Link new block in before existing block. 1254 1232 */ 1233 + trace_xfs_da_link_before(args); 1255 1234 new_info->forw = cpu_to_be32(old_blk->blkno); 1256 1235 new_info->back = old_info->back; 1257 1236 if (old_info->back) { ··· 1274 1251 /* 1275 1252 * Link new block in after existing block. 1276 1253 */ 1254 + trace_xfs_da_link_after(args); 1277 1255 new_info->forw = old_info->forw; 1278 1256 new_info->back = cpu_to_be32(old_blk->blkno); 1279 1257 if (old_info->forw) { ··· 1372 1348 * Unlink the leaf block from the doubly linked chain of leaves. 1373 1349 */ 1374 1350 if (be32_to_cpu(save_info->back) == drop_blk->blkno) { 1351 + trace_xfs_da_unlink_back(args); 1375 1352 save_info->back = drop_info->back; 1376 1353 if (drop_info->back) { 1377 1354 error = xfs_da_read_buf(args->trans, args->dp, ··· 1390 1365 xfs_da_buf_done(bp); 1391 1366 } 1392 1367 } else { 1368 + trace_xfs_da_unlink_forward(args); 1393 1369 save_info->forw = drop_info->forw; 1394 1370 if (drop_info->forw) { 1395 1371 error = xfs_da_read_buf(args->trans, args->dp, ··· 1678 1652 int count; 1679 1653 int error; 1680 1654 1655 + trace_xfs_da_grow_inode(args); 1656 + 1681 1657 if (args->whichfork == XFS_DATA_FORK) { 1682 1658 bno = args->dp->i_mount->m_dirleafblk; 1683 1659 count = args->dp->i_mount->m_dirblkfsbs; ··· 1717 1689 xfs_da_intnode_t *par_node, *dead_node; 1718 1690 xfs_dir2_leaf_t *dead_leaf2; 1719 1691 xfs_dahash_t dead_hash; 1692 + 1693 + trace_xfs_da_swap_lastblock(args); 1720 1694 1721 1695 dead_buf = *dead_bufp; 1722 1696 dead_blkno = *dead_blknop; ··· 1907 1877 int done, error, w, count; 1908 1878 xfs_trans_t *tp; 1909 1879 xfs_mount_t *mp; 1880 + 1881 + trace_xfs_da_shrink_inode(args); 1910 1882 1911 1883 dp = args->dp; 1912 1884 w = args->whichfork;
+38 -23
fs/xfs/xfs_discard.c
··· 37 37 xfs_trim_extents( 38 38 struct xfs_mount *mp, 39 39 xfs_agnumber_t agno, 40 - xfs_fsblock_t start, 41 - xfs_fsblock_t end, 42 - xfs_fsblock_t minlen, 40 + xfs_daddr_t start, 41 + xfs_daddr_t end, 42 + xfs_daddr_t minlen, 43 43 __uint64_t *blocks_trimmed) 44 44 { 45 45 struct block_device *bdev = mp->m_ddev_targp->bt_bdev; ··· 67 67 /* 68 68 * Look up the longest btree in the AGF and start with it. 69 69 */ 70 - error = xfs_alloc_lookup_le(cur, 0, 70 + error = xfs_alloc_lookup_ge(cur, 0, 71 71 be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest), &i); 72 72 if (error) 73 73 goto out_del_cursor; ··· 77 77 * enough to be worth discarding. 78 78 */ 79 79 while (i) { 80 - xfs_agblock_t fbno; 81 - xfs_extlen_t flen; 80 + xfs_agblock_t fbno; 81 + xfs_extlen_t flen; 82 + xfs_daddr_t dbno; 83 + xfs_extlen_t dlen; 82 84 83 85 error = xfs_alloc_get_rec(cur, &fbno, &flen, &i); 84 86 if (error) ··· 89 87 ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest)); 90 88 91 89 /* 90 + * use daddr format for all range/len calculations as that is 91 + * the format the range/len variables are supplied in by 92 + * userspace. 93 + */ 94 + dbno = XFS_AGB_TO_DADDR(mp, agno, fbno); 95 + dlen = XFS_FSB_TO_BB(mp, flen); 96 + 97 + /* 92 98 * Too small? Give up. 93 99 */ 94 - if (flen < minlen) { 100 + if (dlen < minlen) { 95 101 trace_xfs_discard_toosmall(mp, agno, fbno, flen); 96 102 goto out_del_cursor; 97 103 } ··· 109 99 * supposed to discard skip it. Do not bother to trim 110 100 * down partially overlapping ranges for now. 111 101 */ 112 - if (XFS_AGB_TO_FSB(mp, agno, fbno) + flen < start || 113 - XFS_AGB_TO_FSB(mp, agno, fbno) > end) { 102 + if (dbno + dlen < start || dbno > end) { 114 103 trace_xfs_discard_exclude(mp, agno, fbno, flen); 115 104 goto next_extent; 116 105 } ··· 124 115 } 125 116 126 117 trace_xfs_discard_extent(mp, agno, fbno, flen); 127 - error = -blkdev_issue_discard(bdev, 128 - XFS_AGB_TO_DADDR(mp, agno, fbno), 129 - XFS_FSB_TO_BB(mp, flen), 130 - GFP_NOFS, 0); 118 + error = -blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0); 131 119 if (error) 132 120 goto out_del_cursor; 133 121 *blocks_trimmed += flen; ··· 143 137 return error; 144 138 } 145 139 140 + /* 141 + * trim a range of the filesystem. 142 + * 143 + * Note: the parameters passed from userspace are byte ranges into the 144 + * filesystem which does not match to the format we use for filesystem block 145 + * addressing. FSB addressing is sparse (AGNO|AGBNO), while the incoming format 146 + * is a linear address range. Hence we need to use DADDR based conversions and 147 + * comparisons for determining the correct offset and regions to trim. 148 + */ 146 149 int 147 150 xfs_ioc_trim( 148 151 struct xfs_mount *mp, ··· 160 145 struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue; 161 146 unsigned int granularity = q->limits.discard_granularity; 162 147 struct fstrim_range range; 163 - xfs_fsblock_t start, end, minlen; 148 + xfs_daddr_t start, end, minlen; 164 149 xfs_agnumber_t start_agno, end_agno, agno; 165 150 __uint64_t blocks_trimmed = 0; 166 151 int error, last_error = 0; ··· 174 159 175 160 /* 176 161 * Truncating down the len isn't actually quite correct, but using 177 - * XFS_B_TO_FSB would mean we trivially get overflows for values 162 + * BBTOB would mean we trivially get overflows for values 178 163 * of ULLONG_MAX or slightly lower. And ULLONG_MAX is the default 179 164 * used by the fstrim application. In the end it really doesn't 180 165 * matter as trimming blocks is an advisory interface. 181 166 */ 182 - start = XFS_B_TO_FSBT(mp, range.start); 183 - end = start + XFS_B_TO_FSBT(mp, range.len) - 1; 184 - minlen = XFS_B_TO_FSB(mp, max_t(u64, granularity, range.minlen)); 167 + start = BTOBB(range.start); 168 + end = start + BTOBBT(range.len) - 1; 169 + minlen = BTOBB(max_t(u64, granularity, range.minlen)); 185 170 186 - if (start >= mp->m_sb.sb_dblocks) 171 + if (XFS_BB_TO_FSB(mp, start) >= mp->m_sb.sb_dblocks) 187 172 return -XFS_ERROR(EINVAL); 188 - if (end > mp->m_sb.sb_dblocks - 1) 189 - end = mp->m_sb.sb_dblocks - 1; 173 + if (end > XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks) - 1) 174 + end = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)- 1; 190 175 191 - start_agno = XFS_FSB_TO_AGNO(mp, start); 192 - end_agno = XFS_FSB_TO_AGNO(mp, end); 176 + start_agno = xfs_daddr_to_agno(mp, start); 177 + end_agno = xfs_daddr_to_agno(mp, end); 193 178 194 179 for (agno = start_agno; agno <= end_agno; agno++) { 195 180 error = -xfs_trim_extents(mp, agno, start, end, minlen,
+1 -1
fs/xfs/xfs_dquot.c
··· 1065 1065 return -ENOMEM; 1066 1066 } 1067 1067 1068 - void __exit 1068 + void 1069 1069 xfs_qm_exit(void) 1070 1070 { 1071 1071 kmem_zone_destroy(xfs_qm_dqtrxzone);
+6 -2
fs/xfs/xfs_iget.c
··· 289 289 if (lock_flags != 0) 290 290 xfs_ilock(ip, lock_flags); 291 291 292 - xfs_iflags_clear(ip, XFS_ISTALE); 292 + xfs_iflags_clear(ip, XFS_ISTALE | XFS_IDONTCACHE); 293 293 XFS_STATS_INC(xs_ig_found); 294 294 295 295 return 0; ··· 314 314 struct xfs_inode *ip; 315 315 int error; 316 316 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino); 317 + int iflags; 317 318 318 319 ip = xfs_inode_alloc(mp, ino); 319 320 if (!ip) ··· 359 358 * memory barrier that ensures this detection works correctly at lookup 360 359 * time. 361 360 */ 361 + iflags = XFS_INEW; 362 + if (flags & XFS_IGET_DONTCACHE) 363 + iflags |= XFS_IDONTCACHE; 362 364 ip->i_udquot = ip->i_gdquot = NULL; 363 - xfs_iflags_set(ip, XFS_INEW); 365 + xfs_iflags_set(ip, iflags); 364 366 365 367 /* insert the new inode */ 366 368 spin_lock(&pag->pag_ici_lock);
+3 -1
fs/xfs/xfs_inode.h
··· 387 387 #define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT) 388 388 #define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ 389 389 #define XFS_IPINNED (1 << __XFS_IPINNED_BIT) 390 + #define XFS_IDONTCACHE (1 << 9) /* don't cache the inode long term */ 390 391 391 392 /* 392 393 * Per-lifetime flags need to be reset when re-using a reclaimable inode during 393 - * inode lookup. Thi prevents unintended behaviour on the new inode from 394 + * inode lookup. This prevents unintended behaviour on the new inode from 394 395 * ocurring. 395 396 */ 396 397 #define XFS_IRECLAIM_RESET_FLAGS \ ··· 554 553 */ 555 554 #define XFS_IGET_CREATE 0x1 556 555 #define XFS_IGET_UNTRUSTED 0x2 556 + #define XFS_IGET_DONTCACHE 0x4 557 557 558 558 int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, 559 559 xfs_ino_t, struct xfs_dinode **,
+5 -9
fs/xfs/xfs_ioctl.c
··· 209 209 struct file *filp; 210 210 struct inode *inode; 211 211 struct dentry *dentry; 212 + fmode_t fmode; 212 213 213 214 if (!capable(CAP_SYS_ADMIN)) 214 215 return -XFS_ERROR(EPERM); ··· 229 228 hreq->oflags |= O_LARGEFILE; 230 229 #endif 231 230 232 - /* Put open permission in namei format. */ 233 231 permflag = hreq->oflags; 234 - if ((permflag+1) & O_ACCMODE) 235 - permflag++; 236 - if (permflag & O_TRUNC) 237 - permflag |= 2; 238 - 232 + fmode = OPEN_FMODE(permflag); 239 233 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && 240 - (permflag & FMODE_WRITE) && IS_APPEND(inode)) { 234 + (fmode & FMODE_WRITE) && IS_APPEND(inode)) { 241 235 error = -XFS_ERROR(EPERM); 242 236 goto out_dput; 243 237 } 244 238 245 - if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 239 + if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 246 240 error = -XFS_ERROR(EACCES); 247 241 goto out_dput; 248 242 } 249 243 250 244 /* Can't write directories. */ 251 - if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) { 245 + if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) { 252 246 error = -XFS_ERROR(EISDIR); 253 247 goto out_dput; 254 248 }
+2 -1
fs/xfs/xfs_itable.c
··· 75 75 return XFS_ERROR(ENOMEM); 76 76 77 77 error = xfs_iget(mp, NULL, ino, 78 - XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip); 78 + (XFS_IGET_DONTCACHE | XFS_IGET_UNTRUSTED), 79 + XFS_ILOCK_SHARED, &ip); 79 80 if (error) { 80 81 *stat = BULKSTAT_RV_NOTHING; 81 82 goto out_free;
+2 -1
fs/xfs/xfs_log.c
··· 726 726 .lv_iovecp = &reg, 727 727 }; 728 728 729 - /* remove inited flag */ 729 + /* remove inited flag, and account for space used */ 730 730 tic->t_flags = 0; 731 + tic->t_curr_res -= sizeof(magic); 731 732 error = xlog_write(log, &vec, tic, &lsn, 732 733 NULL, XLOG_UNMOUNT_TRANS); 733 734 /*
+11 -22
fs/xfs/xfs_log_recover.c
··· 3161 3161 */ 3162 3162 continue; 3163 3163 } 3164 + /* 3165 + * Unlock the buffer so that it can be acquired in the normal 3166 + * course of the transaction to truncate and free each inode. 3167 + * Because we are not racing with anyone else here for the AGI 3168 + * buffer, we don't even need to hold it locked to read the 3169 + * initial unlinked bucket entries out of the buffer. We keep 3170 + * buffer reference though, so that it stays pinned in memory 3171 + * while we need the buffer. 3172 + */ 3164 3173 agi = XFS_BUF_TO_AGI(agibp); 3174 + xfs_buf_unlock(agibp); 3165 3175 3166 3176 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { 3167 3177 agino = be32_to_cpu(agi->agi_unlinked[bucket]); 3168 3178 while (agino != NULLAGINO) { 3169 - /* 3170 - * Release the agi buffer so that it can 3171 - * be acquired in the normal course of the 3172 - * transaction to truncate and free the inode. 3173 - */ 3174 - xfs_buf_relse(agibp); 3175 - 3176 3179 agino = xlog_recover_process_one_iunlink(mp, 3177 3180 agno, agino, bucket); 3178 - 3179 - /* 3180 - * Reacquire the agibuffer and continue around 3181 - * the loop. This should never fail as we know 3182 - * the buffer was good earlier on. 3183 - */ 3184 - error = xfs_read_agi(mp, NULL, agno, &agibp); 3185 - ASSERT(error == 0); 3186 - agi = XFS_BUF_TO_AGI(agibp); 3187 3181 } 3188 3182 } 3189 - 3190 - /* 3191 - * Release the buffer for the current agi so we can 3192 - * go on to the next one. 3193 - */ 3194 - xfs_buf_relse(agibp); 3183 + xfs_buf_rele(agibp); 3195 3184 } 3196 3185 3197 3186 mp->m_dmevmask = mp_dmevmask;
+4 -5
fs/xfs/xfs_rtalloc.c
··· 183 183 oblocks = map.br_startoff + map.br_blockcount; 184 184 } 185 185 return 0; 186 + 186 187 error: 187 188 return error; 188 189 } ··· 2140 2139 xfs_buf_t *sumbp; /* summary file block buffer */ 2141 2140 2142 2141 mp = tp->t_mountp; 2143 - /* 2144 - * Synchronize by locking the bitmap inode. 2145 - */ 2146 - xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); 2147 - xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); 2142 + 2143 + ASSERT(mp->m_rbmip->i_itemp != NULL); 2144 + ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL)); 2148 2145 2149 2146 #if defined(__KERNEL__) && defined(DEBUG) 2150 2147 /*
+33
fs/xfs/xfs_super.c
··· 950 950 xfs_inactive(ip); 951 951 } 952 952 953 + /* 954 + * We do an unlocked check for XFS_IDONTCACHE here because we are already 955 + * serialised against cache hits here via the inode->i_lock and igrab() in 956 + * xfs_iget_cache_hit(). Hence a lookup that might clear this flag will not be 957 + * racing with us, and it avoids needing to grab a spinlock here for every inode 958 + * we drop the final reference on. 959 + */ 960 + STATIC int 961 + xfs_fs_drop_inode( 962 + struct inode *inode) 963 + { 964 + struct xfs_inode *ip = XFS_I(inode); 965 + 966 + return generic_drop_inode(inode) || (ip->i_flags & XFS_IDONTCACHE); 967 + } 968 + 953 969 STATIC void 954 970 xfs_free_fsname( 955 971 struct xfs_mount *mp) ··· 1449 1433 .destroy_inode = xfs_fs_destroy_inode, 1450 1434 .dirty_inode = xfs_fs_dirty_inode, 1451 1435 .evict_inode = xfs_fs_evict_inode, 1436 + .drop_inode = xfs_fs_drop_inode, 1452 1437 .put_super = xfs_fs_put_super, 1453 1438 .sync_fs = xfs_fs_sync_fs, 1454 1439 .freeze_fs = xfs_fs_freeze, ··· 1623 1606 xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0); 1624 1607 if (!xfs_syncd_wq) 1625 1608 return -ENOMEM; 1609 + 1610 + /* 1611 + * The allocation workqueue can be used in memory reclaim situations 1612 + * (writepage path), and parallelism is only limited by the number of 1613 + * AGs in all the filesystems mounted. Hence use the default large 1614 + * max_active value for this workqueue. 1615 + */ 1616 + xfs_alloc_wq = alloc_workqueue("xfsalloc", WQ_MEM_RECLAIM, 0); 1617 + if (!xfs_alloc_wq) 1618 + goto out_destroy_syncd; 1619 + 1626 1620 return 0; 1621 + 1622 + out_destroy_syncd: 1623 + destroy_workqueue(xfs_syncd_wq); 1624 + return -ENOMEM; 1627 1625 } 1628 1626 1629 1627 STATIC void 1630 1628 xfs_destroy_workqueues(void) 1631 1629 { 1630 + destroy_workqueue(xfs_alloc_wq); 1632 1631 destroy_workqueue(xfs_syncd_wq); 1633 1632 } 1634 1633
+73 -5
fs/xfs/xfs_trace.h
··· 627 627 TP_STRUCT__entry( 628 628 __field(dev_t, dev) 629 629 __field(xfs_ino_t, dp_ino) 630 + __field(int, namelen) 630 631 __dynamic_array(char, name, name->len) 631 632 ), 632 633 TP_fast_assign( 633 634 __entry->dev = VFS_I(dp)->i_sb->s_dev; 634 635 __entry->dp_ino = dp->i_ino; 636 + __entry->namelen = name->len; 635 637 memcpy(__get_str(name), name->name, name->len); 636 638 ), 637 - TP_printk("dev %d:%d dp ino 0x%llx name %s", 639 + TP_printk("dev %d:%d dp ino 0x%llx name %.*s", 638 640 MAJOR(__entry->dev), MINOR(__entry->dev), 639 641 __entry->dp_ino, 642 + __entry->namelen, 640 643 __get_str(name)) 641 644 ) 642 645 ··· 661 658 __field(dev_t, dev) 662 659 __field(xfs_ino_t, src_dp_ino) 663 660 __field(xfs_ino_t, target_dp_ino) 661 + __field(int, src_namelen) 662 + __field(int, target_namelen) 664 663 __dynamic_array(char, src_name, src_name->len) 665 664 __dynamic_array(char, target_name, target_name->len) 666 665 ), ··· 670 665 __entry->dev = VFS_I(src_dp)->i_sb->s_dev; 671 666 __entry->src_dp_ino = src_dp->i_ino; 672 667 __entry->target_dp_ino = target_dp->i_ino; 668 + __entry->src_namelen = src_name->len; 669 + __entry->target_namelen = target_name->len; 673 670 memcpy(__get_str(src_name), src_name->name, src_name->len); 674 - memcpy(__get_str(target_name), target_name->name, target_name->len); 671 + memcpy(__get_str(target_name), target_name->name, 672 + target_name->len); 675 673 ), 676 674 TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx" 677 - " src name %s target name %s", 675 + " src name %.*s target name %.*s", 678 676 MAJOR(__entry->dev), MINOR(__entry->dev), 679 677 __entry->src_dp_ino, 680 678 __entry->target_dp_ino, 679 + __entry->src_namelen, 681 680 __get_str(src_name), 681 + __entry->target_namelen, 682 682 __get_str(target_name)) 683 683 ) 684 684 ··· 1418 1408 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed); 1419 1409 DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed); 1420 1410 1421 - DECLARE_EVENT_CLASS(xfs_dir2_class, 1411 + DECLARE_EVENT_CLASS(xfs_da_class, 1422 1412 TP_PROTO(struct xfs_da_args *args), 1423 1413 TP_ARGS(args), 1424 1414 TP_STRUCT__entry( ··· 1453 1443 ) 1454 1444 1455 1445 #define DEFINE_DIR2_EVENT(name) \ 1456 - DEFINE_EVENT(xfs_dir2_class, name, \ 1446 + DEFINE_EVENT(xfs_da_class, name, \ 1457 1447 TP_PROTO(struct xfs_da_args *args), \ 1458 1448 TP_ARGS(args)) 1459 1449 DEFINE_DIR2_EVENT(xfs_dir2_sf_addname); ··· 1481 1471 DEFINE_DIR2_EVENT(xfs_dir2_node_replace); 1482 1472 DEFINE_DIR2_EVENT(xfs_dir2_node_removename); 1483 1473 DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf); 1474 + 1475 + #define DEFINE_ATTR_EVENT(name) \ 1476 + DEFINE_EVENT(xfs_da_class, name, \ 1477 + TP_PROTO(struct xfs_da_args *args), \ 1478 + TP_ARGS(args)) 1479 + DEFINE_ATTR_EVENT(xfs_attr_sf_add); 1480 + DEFINE_ATTR_EVENT(xfs_attr_sf_addname); 1481 + DEFINE_ATTR_EVENT(xfs_attr_sf_create); 1482 + DEFINE_ATTR_EVENT(xfs_attr_sf_lookup); 1483 + DEFINE_ATTR_EVENT(xfs_attr_sf_remove); 1484 + DEFINE_ATTR_EVENT(xfs_attr_sf_removename); 1485 + DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf); 1486 + 1487 + DEFINE_ATTR_EVENT(xfs_attr_leaf_add); 1488 + DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old); 1489 + DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new); 1490 + DEFINE_ATTR_EVENT(xfs_attr_leaf_addname); 1491 + DEFINE_ATTR_EVENT(xfs_attr_leaf_create); 1492 + DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup); 1493 + DEFINE_ATTR_EVENT(xfs_attr_leaf_replace); 1494 + DEFINE_ATTR_EVENT(xfs_attr_leaf_removename); 1495 + DEFINE_ATTR_EVENT(xfs_attr_leaf_split); 1496 + DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before); 1497 + DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after); 1498 + DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag); 1499 + DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag); 1500 + DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags); 1501 + DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf); 1502 + DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node); 1503 + DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance); 1504 + DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance); 1505 + 1506 + DEFINE_ATTR_EVENT(xfs_attr_node_addname); 1507 + DEFINE_ATTR_EVENT(xfs_attr_node_lookup); 1508 + DEFINE_ATTR_EVENT(xfs_attr_node_replace); 1509 + DEFINE_ATTR_EVENT(xfs_attr_node_removename); 1510 + 1511 + #define DEFINE_DA_EVENT(name) \ 1512 + DEFINE_EVENT(xfs_da_class, name, \ 1513 + TP_PROTO(struct xfs_da_args *args), \ 1514 + TP_ARGS(args)) 1515 + DEFINE_DA_EVENT(xfs_da_split); 1516 + DEFINE_DA_EVENT(xfs_da_join); 1517 + DEFINE_DA_EVENT(xfs_da_link_before); 1518 + DEFINE_DA_EVENT(xfs_da_link_after); 1519 + DEFINE_DA_EVENT(xfs_da_unlink_back); 1520 + DEFINE_DA_EVENT(xfs_da_unlink_forward); 1521 + DEFINE_DA_EVENT(xfs_da_root_split); 1522 + DEFINE_DA_EVENT(xfs_da_root_join); 1523 + DEFINE_DA_EVENT(xfs_da_node_add); 1524 + DEFINE_DA_EVENT(xfs_da_node_create); 1525 + DEFINE_DA_EVENT(xfs_da_node_split); 1526 + DEFINE_DA_EVENT(xfs_da_node_remove); 1527 + DEFINE_DA_EVENT(xfs_da_node_rebalance); 1528 + DEFINE_DA_EVENT(xfs_da_node_unbalance); 1529 + DEFINE_DA_EVENT(xfs_da_swap_lastblock); 1530 + DEFINE_DA_EVENT(xfs_da_grow_inode); 1531 + DEFINE_DA_EVENT(xfs_da_shrink_inode); 1484 1532 1485 1533 DECLARE_EVENT_CLASS(xfs_dir2_space_class, 1486 1534 TP_PROTO(struct xfs_da_args *args, int idx),