aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_alloc.c36
-rw-r--r--fs/xfs/xfs_alloc.h12
-rw-r--r--fs/xfs/xfs_attr.c16
-rw-r--r--fs/xfs/xfs_attr_leaf.c40
-rw-r--r--fs/xfs/xfs_bmap.c9
-rw-r--r--fs/xfs/xfs_da_btree.c32
-rw-r--r--fs/xfs/xfs_discard.c61
-rw-r--r--fs/xfs/xfs_dquot.c2
-rw-r--r--fs/xfs/xfs_iget.c8
-rw-r--r--fs/xfs/xfs_inode.h4
-rw-r--r--fs/xfs/xfs_ioctl.c14
-rw-r--r--fs/xfs/xfs_itable.c3
-rw-r--r--fs/xfs/xfs_log.c3
-rw-r--r--fs/xfs/xfs_log_recover.c33
-rw-r--r--fs/xfs/xfs_rtalloc.c9
-rw-r--r--fs/xfs/xfs_super.c33
-rw-r--r--fs/xfs/xfs_trace.h78
17 files changed, 317 insertions, 76 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index ce84ffd0264..0f0df2759b0 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -35,6 +35,7 @@
35#include "xfs_error.h" 35#include "xfs_error.h"
36#include "xfs_trace.h" 36#include "xfs_trace.h"
37 37
38struct workqueue_struct *xfs_alloc_wq;
38 39
39#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) 40#define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))
40 41
@@ -68,7 +69,7 @@ xfs_alloc_lookup_eq(
68 * Lookup the first record greater than or equal to [bno, len] 69 * Lookup the first record greater than or equal to [bno, len]
69 * in the btree given by cur. 70 * in the btree given by cur.
70 */ 71 */
71STATIC int /* error */ 72int /* error */
72xfs_alloc_lookup_ge( 73xfs_alloc_lookup_ge(
73 struct xfs_btree_cur *cur, /* btree cursor */ 74 struct xfs_btree_cur *cur, /* btree cursor */
74 xfs_agblock_t bno, /* starting block of extent */ 75 xfs_agblock_t bno, /* starting block of extent */
@@ -2207,7 +2208,7 @@ xfs_alloc_read_agf(
2207 * group or loop over the allocation groups to find the result. 2208 * group or loop over the allocation groups to find the result.
2208 */ 2209 */
2209int /* error */ 2210int /* error */
2210xfs_alloc_vextent( 2211__xfs_alloc_vextent(
2211 xfs_alloc_arg_t *args) /* allocation argument structure */ 2212 xfs_alloc_arg_t *args) /* allocation argument structure */
2212{ 2213{
2213 xfs_agblock_t agsize; /* allocation group size */ 2214 xfs_agblock_t agsize; /* allocation group size */
@@ -2417,6 +2418,37 @@ error0:
2417 return error; 2418 return error;
2418} 2419}
2419 2420
2421static void
2422xfs_alloc_vextent_worker(
2423 struct work_struct *work)
2424{
2425 struct xfs_alloc_arg *args = container_of(work,
2426 struct xfs_alloc_arg, work);
2427 unsigned long pflags;
2428
2429 /* we are in a transaction context here */
2430 current_set_flags_nested(&pflags, PF_FSTRANS);
2431
2432 args->result = __xfs_alloc_vextent(args);
2433 complete(args->done);
2434
2435 current_restore_flags_nested(&pflags, PF_FSTRANS);
2436}
2437
2438
2439int /* error */
2440xfs_alloc_vextent(
2441 xfs_alloc_arg_t *args) /* allocation argument structure */
2442{
2443 DECLARE_COMPLETION_ONSTACK(done);
2444
2445 args->done = &done;
2446 INIT_WORK(&args->work, xfs_alloc_vextent_worker);
2447 queue_work(xfs_alloc_wq, &args->work);
2448 wait_for_completion(&done);
2449 return args->result;
2450}
2451
2420/* 2452/*
2421 * Free an extent. 2453 * Free an extent.
2422 * Just break up the extent address and hand off to xfs_free_ag_extent 2454 * Just break up the extent address and hand off to xfs_free_ag_extent
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index 2f52b924be7..3a7e7d8f8de 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -25,6 +25,8 @@ struct xfs_perag;
25struct xfs_trans; 25struct xfs_trans;
26struct xfs_busy_extent; 26struct xfs_busy_extent;
27 27
28extern struct workqueue_struct *xfs_alloc_wq;
29
28/* 30/*
29 * Freespace allocation types. Argument to xfs_alloc_[v]extent. 31 * Freespace allocation types. Argument to xfs_alloc_[v]extent.
30 */ 32 */
@@ -119,6 +121,9 @@ typedef struct xfs_alloc_arg {
119 char isfl; /* set if is freelist blocks - !acctg */ 121 char isfl; /* set if is freelist blocks - !acctg */
120 char userdata; /* set if this is user data */ 122 char userdata; /* set if this is user data */
121 xfs_fsblock_t firstblock; /* io first block allocated */ 123 xfs_fsblock_t firstblock; /* io first block allocated */
124 struct completion *done;
125 struct work_struct work;
126 int result;
122} xfs_alloc_arg_t; 127} xfs_alloc_arg_t;
123 128
124/* 129/*
@@ -243,6 +248,13 @@ xfs_alloc_lookup_le(
243 xfs_extlen_t len, /* length of extent */ 248 xfs_extlen_t len, /* length of extent */
244 int *stat); /* success/failure */ 249 int *stat); /* success/failure */
245 250
251int /* error */
252xfs_alloc_lookup_ge(
253 struct xfs_btree_cur *cur, /* btree cursor */
254 xfs_agblock_t bno, /* starting block of extent */
255 xfs_extlen_t len, /* length of extent */
256 int *stat); /* success/failure */
257
246int /* error */ 258int /* error */
247xfs_alloc_get_rec( 259xfs_alloc_get_rec(
248 struct xfs_btree_cur *cur, /* btree cursor */ 260 struct xfs_btree_cur *cur, /* btree cursor */
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 08b9ac644c3..65d61b948ea 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -853,6 +853,8 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
853{ 853{
854 int newsize, forkoff, retval; 854 int newsize, forkoff, retval;
855 855
856 trace_xfs_attr_sf_addname(args);
857
856 retval = xfs_attr_shortform_lookup(args); 858 retval = xfs_attr_shortform_lookup(args);
857 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 859 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
858 return(retval); 860 return(retval);
@@ -896,6 +898,8 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
896 xfs_dabuf_t *bp; 898 xfs_dabuf_t *bp;
897 int retval, error, committed, forkoff; 899 int retval, error, committed, forkoff;
898 900
901 trace_xfs_attr_leaf_addname(args);
902
899 /* 903 /*
900 * Read the (only) block in the attribute list in. 904 * Read the (only) block in the attribute list in.
901 */ 905 */
@@ -920,6 +924,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
920 xfs_da_brelse(args->trans, bp); 924 xfs_da_brelse(args->trans, bp);
921 return(retval); 925 return(retval);
922 } 926 }
927
928 trace_xfs_attr_leaf_replace(args);
929
923 args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */ 930 args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */
924 args->blkno2 = args->blkno; /* set 2nd entry info*/ 931 args->blkno2 = args->blkno; /* set 2nd entry info*/
925 args->index2 = args->index; 932 args->index2 = args->index;
@@ -1090,6 +1097,8 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1090 xfs_dabuf_t *bp; 1097 xfs_dabuf_t *bp;
1091 int error, committed, forkoff; 1098 int error, committed, forkoff;
1092 1099
1100 trace_xfs_attr_leaf_removename(args);
1101
1093 /* 1102 /*
1094 * Remove the attribute. 1103 * Remove the attribute.
1095 */ 1104 */
@@ -1223,6 +1232,8 @@ xfs_attr_node_addname(xfs_da_args_t *args)
1223 xfs_mount_t *mp; 1232 xfs_mount_t *mp;
1224 int committed, retval, error; 1233 int committed, retval, error;
1225 1234
1235 trace_xfs_attr_node_addname(args);
1236
1226 /* 1237 /*
1227 * Fill in bucket of arguments/results/context to carry around. 1238 * Fill in bucket of arguments/results/context to carry around.
1228 */ 1239 */
@@ -1249,6 +1260,9 @@ restart:
1249 } else if (retval == EEXIST) { 1260 } else if (retval == EEXIST) {
1250 if (args->flags & ATTR_CREATE) 1261 if (args->flags & ATTR_CREATE)
1251 goto out; 1262 goto out;
1263
1264 trace_xfs_attr_node_replace(args);
1265
1252 args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */ 1266 args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */
1253 args->blkno2 = args->blkno; /* set 2nd entry info*/ 1267 args->blkno2 = args->blkno; /* set 2nd entry info*/
1254 args->index2 = args->index; 1268 args->index2 = args->index;
@@ -1480,6 +1494,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1480 xfs_dabuf_t *bp; 1494 xfs_dabuf_t *bp;
1481 int retval, error, committed, forkoff; 1495 int retval, error, committed, forkoff;
1482 1496
1497 trace_xfs_attr_node_removename(args);
1498
1483 /* 1499 /*
1484 * Tie a string around our finger to remind us where we are. 1500 * Tie a string around our finger to remind us where we are.
1485 */ 1501 */
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index d25eafd4d28..76d93dc953e 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -235,6 +235,8 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
235 xfs_inode_t *dp; 235 xfs_inode_t *dp;
236 xfs_ifork_t *ifp; 236 xfs_ifork_t *ifp;
237 237
238 trace_xfs_attr_sf_create(args);
239
238 dp = args->dp; 240 dp = args->dp;
239 ASSERT(dp != NULL); 241 ASSERT(dp != NULL);
240 ifp = dp->i_afp; 242 ifp = dp->i_afp;
@@ -268,6 +270,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
268 xfs_inode_t *dp; 270 xfs_inode_t *dp;
269 xfs_ifork_t *ifp; 271 xfs_ifork_t *ifp;
270 272
273 trace_xfs_attr_sf_add(args);
274
271 dp = args->dp; 275 dp = args->dp;
272 mp = dp->i_mount; 276 mp = dp->i_mount;
273 dp->i_d.di_forkoff = forkoff; 277 dp->i_d.di_forkoff = forkoff;
@@ -337,6 +341,8 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
337 xfs_mount_t *mp; 341 xfs_mount_t *mp;
338 xfs_inode_t *dp; 342 xfs_inode_t *dp;
339 343
344 trace_xfs_attr_sf_remove(args);
345
340 dp = args->dp; 346 dp = args->dp;
341 mp = dp->i_mount; 347 mp = dp->i_mount;
342 base = sizeof(xfs_attr_sf_hdr_t); 348 base = sizeof(xfs_attr_sf_hdr_t);
@@ -405,6 +411,8 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
405 int i; 411 int i;
406 xfs_ifork_t *ifp; 412 xfs_ifork_t *ifp;
407 413
414 trace_xfs_attr_sf_lookup(args);
415
408 ifp = args->dp->i_afp; 416 ifp = args->dp->i_afp;
409 ASSERT(ifp->if_flags & XFS_IFINLINE); 417 ASSERT(ifp->if_flags & XFS_IFINLINE);
410 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 418 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
@@ -476,6 +484,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
476 xfs_dabuf_t *bp; 484 xfs_dabuf_t *bp;
477 xfs_ifork_t *ifp; 485 xfs_ifork_t *ifp;
478 486
487 trace_xfs_attr_sf_to_leaf(args);
488
479 dp = args->dp; 489 dp = args->dp;
480 ifp = dp->i_afp; 490 ifp = dp->i_afp;
481 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 491 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
@@ -775,6 +785,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
775 char *tmpbuffer; 785 char *tmpbuffer;
776 int error, i; 786 int error, i;
777 787
788 trace_xfs_attr_leaf_to_sf(args);
789
778 dp = args->dp; 790 dp = args->dp;
779 tmpbuffer = kmem_alloc(XFS_LBSIZE(dp->i_mount), KM_SLEEP); 791 tmpbuffer = kmem_alloc(XFS_LBSIZE(dp->i_mount), KM_SLEEP);
780 ASSERT(tmpbuffer != NULL); 792 ASSERT(tmpbuffer != NULL);
@@ -848,6 +860,8 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
848 xfs_dablk_t blkno; 860 xfs_dablk_t blkno;
849 int error; 861 int error;
850 862
863 trace_xfs_attr_leaf_to_node(args);
864
851 dp = args->dp; 865 dp = args->dp;
852 bp1 = bp2 = NULL; 866 bp1 = bp2 = NULL;
853 error = xfs_da_grow_inode(args, &blkno); 867 error = xfs_da_grow_inode(args, &blkno);
@@ -911,6 +925,8 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
911 xfs_dabuf_t *bp; 925 xfs_dabuf_t *bp;
912 int error; 926 int error;
913 927
928 trace_xfs_attr_leaf_create(args);
929
914 dp = args->dp; 930 dp = args->dp;
915 ASSERT(dp != NULL); 931 ASSERT(dp != NULL);
916 error = xfs_da_get_buf(args->trans, args->dp, blkno, -1, &bp, 932 error = xfs_da_get_buf(args->trans, args->dp, blkno, -1, &bp,
@@ -948,6 +964,8 @@ xfs_attr_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
948 xfs_dablk_t blkno; 964 xfs_dablk_t blkno;
949 int error; 965 int error;
950 966
967 trace_xfs_attr_leaf_split(state->args);
968
951 /* 969 /*
952 * Allocate space for a new leaf node. 970 * Allocate space for a new leaf node.
953 */ 971 */
@@ -977,10 +995,13 @@ xfs_attr_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
977 * 995 *
978 * Insert the "new" entry in the correct block. 996 * Insert the "new" entry in the correct block.
979 */ 997 */
980 if (state->inleaf) 998 if (state->inleaf) {
999 trace_xfs_attr_leaf_add_old(state->args);
981 error = xfs_attr_leaf_add(oldblk->bp, state->args); 1000 error = xfs_attr_leaf_add(oldblk->bp, state->args);
982 else 1001 } else {
1002 trace_xfs_attr_leaf_add_new(state->args);
983 error = xfs_attr_leaf_add(newblk->bp, state->args); 1003 error = xfs_attr_leaf_add(newblk->bp, state->args);
1004 }
984 1005
985 /* 1006 /*
986 * Update last hashval in each block since we added the name. 1007 * Update last hashval in each block since we added the name.
@@ -1001,6 +1022,8 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
1001 xfs_attr_leaf_map_t *map; 1022 xfs_attr_leaf_map_t *map;
1002 int tablesize, entsize, sum, tmp, i; 1023 int tablesize, entsize, sum, tmp, i;
1003 1024
1025 trace_xfs_attr_leaf_add(args);
1026
1004 leaf = bp->data; 1027 leaf = bp->data;
1005 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1028 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1006 ASSERT((args->index >= 0) 1029 ASSERT((args->index >= 0)
@@ -1128,8 +1151,6 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1128 (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval))); 1151 (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval)));
1129 1152
1130 /* 1153 /*
1131 * Copy the attribute name and value into the new space.
1132 *
1133 * For "remote" attribute values, simply note that we need to 1154 * For "remote" attribute values, simply note that we need to
1134 * allocate space for the "remote" value. We can't actually 1155 * allocate space for the "remote" value. We can't actually
1135 * allocate the extents in this transaction, and we can't decide 1156 * allocate the extents in this transaction, and we can't decide
@@ -1265,6 +1286,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1265 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1286 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1266 args = state->args; 1287 args = state->args;
1267 1288
1289 trace_xfs_attr_leaf_rebalance(args);
1290
1268 /* 1291 /*
1269 * Check ordering of blocks, reverse if it makes things simpler. 1292 * Check ordering of blocks, reverse if it makes things simpler.
1270 * 1293 *
@@ -1810,6 +1833,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1810 xfs_mount_t *mp; 1833 xfs_mount_t *mp;
1811 char *tmpbuffer; 1834 char *tmpbuffer;
1812 1835
1836 trace_xfs_attr_leaf_unbalance(state->args);
1837
1813 /* 1838 /*
1814 * Set up environment. 1839 * Set up environment.
1815 */ 1840 */
@@ -1919,6 +1944,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1919 int probe, span; 1944 int probe, span;
1920 xfs_dahash_t hashval; 1945 xfs_dahash_t hashval;
1921 1946
1947 trace_xfs_attr_leaf_lookup(args);
1948
1922 leaf = bp->data; 1949 leaf = bp->data;
1923 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1950 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1924 ASSERT(be16_to_cpu(leaf->hdr.count) 1951 ASSERT(be16_to_cpu(leaf->hdr.count)
@@ -2445,6 +2472,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2445 char *name; 2472 char *name;
2446#endif /* DEBUG */ 2473#endif /* DEBUG */
2447 2474
2475 trace_xfs_attr_leaf_clearflag(args);
2448 /* 2476 /*
2449 * Set up the operation. 2477 * Set up the operation.
2450 */ 2478 */
@@ -2509,6 +2537,8 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2509 xfs_dabuf_t *bp; 2537 xfs_dabuf_t *bp;
2510 int error; 2538 int error;
2511 2539
2540 trace_xfs_attr_leaf_setflag(args);
2541
2512 /* 2542 /*
2513 * Set up the operation. 2543 * Set up the operation.
2514 */ 2544 */
@@ -2565,6 +2595,8 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2565 char *name1, *name2; 2595 char *name1, *name2;
2566#endif /* DEBUG */ 2596#endif /* DEBUG */
2567 2597
2598 trace_xfs_attr_leaf_flipflags(args);
2599
2568 /* 2600 /*
2569 * Read the block containing the "old" attr 2601 * Read the block containing the "old" attr
2570 */ 2602 */
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 3548c6f7559..85e7e327bcd 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -5124,6 +5124,15 @@ xfs_bunmapi(
5124 cur->bc_private.b.flags = 0; 5124 cur->bc_private.b.flags = 0;
5125 } else 5125 } else
5126 cur = NULL; 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 extno = 0; 5136 extno = 0;
5128 while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >= 0 && 5137 while (bno != (xfs_fileoff_t)-1 && bno >= start && lastx >= 0 &&
5129 (nexts == 0 || extno < nexts)) { 5138 (nexts == 0 || extno < nexts)) {
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 77c74257c2a..7f1a6f5b05a 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -108,6 +108,8 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
108 int error; 108 int error;
109 xfs_trans_t *tp; 109 xfs_trans_t *tp;
110 110
111 trace_xfs_da_node_create(args);
112
111 tp = args->trans; 113 tp = args->trans;
112 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork); 114 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork);
113 if (error) 115 if (error)
@@ -140,6 +142,8 @@ xfs_da_split(xfs_da_state_t *state)
140 xfs_dabuf_t *bp; 142 xfs_dabuf_t *bp;
141 int max, action, error, i; 143 int max, action, error, i;
142 144
145 trace_xfs_da_split(state->args);
146
143 /* 147 /*
144 * Walk back up the tree splitting/inserting/adjusting as necessary. 148 * Walk back up the tree splitting/inserting/adjusting as necessary.
145 * If we need to insert and there isn't room, split the node, then 149 * If we need to insert and there isn't room, split the node, then
@@ -178,10 +182,12 @@ xfs_da_split(xfs_da_state_t *state)
178 state->extravalid = 1; 182 state->extravalid = 1;
179 if (state->inleaf) { 183 if (state->inleaf) {
180 state->extraafter = 0; /* before newblk */ 184 state->extraafter = 0; /* before newblk */
185 trace_xfs_attr_leaf_split_before(state->args);
181 error = xfs_attr_leaf_split(state, oldblk, 186 error = xfs_attr_leaf_split(state, oldblk,
182 &state->extrablk); 187 &state->extrablk);
183 } else { 188 } else {
184 state->extraafter = 1; /* after newblk */ 189 state->extraafter = 1; /* after newblk */
190 trace_xfs_attr_leaf_split_after(state->args);
185 error = xfs_attr_leaf_split(state, newblk, 191 error = xfs_attr_leaf_split(state, newblk,
186 &state->extrablk); 192 &state->extrablk);
187 } 193 }
@@ -300,6 +306,8 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
300 xfs_mount_t *mp; 306 xfs_mount_t *mp;
301 xfs_dir2_leaf_t *leaf; 307 xfs_dir2_leaf_t *leaf;
302 308
309 trace_xfs_da_root_split(state->args);
310
303 /* 311 /*
304 * Copy the existing (incorrect) block from the root node position 312 * Copy the existing (incorrect) block from the root node position
305 * to a free space somewhere. 313 * to a free space somewhere.
@@ -380,6 +388,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
380 int newcount, error; 388 int newcount, error;
381 int useextra; 389 int useextra;
382 390
391 trace_xfs_da_node_split(state->args);
392
383 node = oldblk->bp->data; 393 node = oldblk->bp->data;
384 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 394 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
385 395
@@ -466,6 +476,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
466 int count, tmp; 476 int count, tmp;
467 xfs_trans_t *tp; 477 xfs_trans_t *tp;
468 478
479 trace_xfs_da_node_rebalance(state->args);
480
469 node1 = blk1->bp->data; 481 node1 = blk1->bp->data;
470 node2 = blk2->bp->data; 482 node2 = blk2->bp->data;
471 /* 483 /*
@@ -574,6 +586,8 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
574 xfs_da_node_entry_t *btree; 586 xfs_da_node_entry_t *btree;
575 int tmp; 587 int tmp;
576 588
589 trace_xfs_da_node_add(state->args);
590
577 node = oldblk->bp->data; 591 node = oldblk->bp->data;
578 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 592 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
579 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); 593 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
@@ -619,6 +633,8 @@ xfs_da_join(xfs_da_state_t *state)
619 xfs_da_state_blk_t *drop_blk, *save_blk; 633 xfs_da_state_blk_t *drop_blk, *save_blk;
620 int action, error; 634 int action, error;
621 635
636 trace_xfs_da_join(state->args);
637
622 action = 0; 638 action = 0;
623 drop_blk = &state->path.blk[ state->path.active-1 ]; 639 drop_blk = &state->path.blk[ state->path.active-1 ];
624 save_blk = &state->altpath.blk[ state->path.active-1 ]; 640 save_blk = &state->altpath.blk[ state->path.active-1 ];
@@ -723,6 +739,8 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
723 xfs_dabuf_t *bp; 739 xfs_dabuf_t *bp;
724 int error; 740 int error;
725 741
742 trace_xfs_da_root_join(state->args);
743
726 args = state->args; 744 args = state->args;
727 ASSERT(args != NULL); 745 ASSERT(args != NULL);
728 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); 746 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
@@ -941,6 +959,8 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
941 xfs_da_node_entry_t *btree; 959 xfs_da_node_entry_t *btree;
942 int tmp; 960 int tmp;
943 961
962 trace_xfs_da_node_remove(state->args);
963
944 node = drop_blk->bp->data; 964 node = drop_blk->bp->data;
945 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count)); 965 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
946 ASSERT(drop_blk->index >= 0); 966 ASSERT(drop_blk->index >= 0);
@@ -984,6 +1004,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
984 int tmp; 1004 int tmp;
985 xfs_trans_t *tp; 1005 xfs_trans_t *tp;
986 1006
1007 trace_xfs_da_node_unbalance(state->args);
1008
987 drop_node = drop_blk->bp->data; 1009 drop_node = drop_blk->bp->data;
988 save_node = save_blk->bp->data; 1010 save_node = save_blk->bp->data;
989 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1011 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
@@ -1230,6 +1252,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1230 /* 1252 /*
1231 * Link new block in before existing block. 1253 * Link new block in before existing block.
1232 */ 1254 */
1255 trace_xfs_da_link_before(args);
1233 new_info->forw = cpu_to_be32(old_blk->blkno); 1256 new_info->forw = cpu_to_be32(old_blk->blkno);
1234 new_info->back = old_info->back; 1257 new_info->back = old_info->back;
1235 if (old_info->back) { 1258 if (old_info->back) {
@@ -1251,6 +1274,7 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1251 /* 1274 /*
1252 * Link new block in after existing block. 1275 * Link new block in after existing block.
1253 */ 1276 */
1277 trace_xfs_da_link_after(args);
1254 new_info->forw = old_info->forw; 1278 new_info->forw = old_info->forw;
1255 new_info->back = cpu_to_be32(old_blk->blkno); 1279 new_info->back = cpu_to_be32(old_blk->blkno);
1256 if (old_info->forw) { 1280 if (old_info->forw) {
@@ -1348,6 +1372,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1348 * Unlink the leaf block from the doubly linked chain of leaves. 1372 * Unlink the leaf block from the doubly linked chain of leaves.
1349 */ 1373 */
1350 if (be32_to_cpu(save_info->back) == drop_blk->blkno) { 1374 if (be32_to_cpu(save_info->back) == drop_blk->blkno) {
1375 trace_xfs_da_unlink_back(args);
1351 save_info->back = drop_info->back; 1376 save_info->back = drop_info->back;
1352 if (drop_info->back) { 1377 if (drop_info->back) {
1353 error = xfs_da_read_buf(args->trans, args->dp, 1378 error = xfs_da_read_buf(args->trans, args->dp,
@@ -1365,6 +1390,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1365 xfs_da_buf_done(bp); 1390 xfs_da_buf_done(bp);
1366 } 1391 }
1367 } else { 1392 } else {
1393 trace_xfs_da_unlink_forward(args);
1368 save_info->forw = drop_info->forw; 1394 save_info->forw = drop_info->forw;
1369 if (drop_info->forw) { 1395 if (drop_info->forw) {
1370 error = xfs_da_read_buf(args->trans, args->dp, 1396 error = xfs_da_read_buf(args->trans, args->dp,
@@ -1652,6 +1678,8 @@ xfs_da_grow_inode(
1652 int count; 1678 int count;
1653 int error; 1679 int error;
1654 1680
1681 trace_xfs_da_grow_inode(args);
1682
1655 if (args->whichfork == XFS_DATA_FORK) { 1683 if (args->whichfork == XFS_DATA_FORK) {
1656 bno = args->dp->i_mount->m_dirleafblk; 1684 bno = args->dp->i_mount->m_dirleafblk;
1657 count = args->dp->i_mount->m_dirblkfsbs; 1685 count = args->dp->i_mount->m_dirblkfsbs;
@@ -1690,6 +1718,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1690 xfs_dir2_leaf_t *dead_leaf2; 1718 xfs_dir2_leaf_t *dead_leaf2;
1691 xfs_dahash_t dead_hash; 1719 xfs_dahash_t dead_hash;
1692 1720
1721 trace_xfs_da_swap_lastblock(args);
1722
1693 dead_buf = *dead_bufp; 1723 dead_buf = *dead_bufp;
1694 dead_blkno = *dead_blknop; 1724 dead_blkno = *dead_blknop;
1695 tp = args->trans; 1725 tp = args->trans;
@@ -1878,6 +1908,8 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
1878 xfs_trans_t *tp; 1908 xfs_trans_t *tp;
1879 xfs_mount_t *mp; 1909 xfs_mount_t *mp;
1880 1910
1911 trace_xfs_da_shrink_inode(args);
1912
1881 dp = args->dp; 1913 dp = args->dp;
1882 w = args->whichfork; 1914 w = args->whichfork;
1883 tp = args->trans; 1915 tp = args->trans;
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 286a051f12c..1ad3a4b8ca4 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -37,9 +37,9 @@ STATIC int
37xfs_trim_extents( 37xfs_trim_extents(
38 struct xfs_mount *mp, 38 struct xfs_mount *mp,
39 xfs_agnumber_t agno, 39 xfs_agnumber_t agno,
40 xfs_fsblock_t start, 40 xfs_daddr_t start,
41 xfs_fsblock_t end, 41 xfs_daddr_t end,
42 xfs_fsblock_t minlen, 42 xfs_daddr_t minlen,
43 __uint64_t *blocks_trimmed) 43 __uint64_t *blocks_trimmed)
44{ 44{
45 struct block_device *bdev = mp->m_ddev_targp->bt_bdev; 45 struct block_device *bdev = mp->m_ddev_targp->bt_bdev;
@@ -67,7 +67,7 @@ xfs_trim_extents(
67 /* 67 /*
68 * Look up the longest btree in the AGF and start with it. 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 be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest), &i); 71 be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest), &i);
72 if (error) 72 if (error)
73 goto out_del_cursor; 73 goto out_del_cursor;
@@ -77,8 +77,10 @@ xfs_trim_extents(
77 * enough to be worth discarding. 77 * enough to be worth discarding.
78 */ 78 */
79 while (i) { 79 while (i) {
80 xfs_agblock_t fbno; 80 xfs_agblock_t fbno;
81 xfs_extlen_t flen; 81 xfs_extlen_t flen;
82 xfs_daddr_t dbno;
83 xfs_extlen_t dlen;
82 84
83 error = xfs_alloc_get_rec(cur, &fbno, &flen, &i); 85 error = xfs_alloc_get_rec(cur, &fbno, &flen, &i);
84 if (error) 86 if (error)
@@ -87,9 +89,17 @@ xfs_trim_extents(
87 ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest)); 89 ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest));
88 90
89 /* 91 /*
92 * use daddr format for all range/len calculations as that is
93 * the format the range/len variables are supplied in by
94 * userspace.
95 */
96 dbno = XFS_AGB_TO_DADDR(mp, agno, fbno);
97 dlen = XFS_FSB_TO_BB(mp, flen);
98
99 /*
90 * Too small? Give up. 100 * Too small? Give up.
91 */ 101 */
92 if (flen < minlen) { 102 if (dlen < minlen) {
93 trace_xfs_discard_toosmall(mp, agno, fbno, flen); 103 trace_xfs_discard_toosmall(mp, agno, fbno, flen);
94 goto out_del_cursor; 104 goto out_del_cursor;
95 } 105 }
@@ -99,8 +109,7 @@ xfs_trim_extents(
99 * supposed to discard skip it. Do not bother to trim 109 * supposed to discard skip it. Do not bother to trim
100 * down partially overlapping ranges for now. 110 * down partially overlapping ranges for now.
101 */ 111 */
102 if (XFS_AGB_TO_FSB(mp, agno, fbno) + flen < start || 112 if (dbno + dlen < start || dbno > end) {
103 XFS_AGB_TO_FSB(mp, agno, fbno) > end) {
104 trace_xfs_discard_exclude(mp, agno, fbno, flen); 113 trace_xfs_discard_exclude(mp, agno, fbno, flen);
105 goto next_extent; 114 goto next_extent;
106 } 115 }
@@ -115,10 +124,7 @@ xfs_trim_extents(
115 } 124 }
116 125
117 trace_xfs_discard_extent(mp, agno, fbno, flen); 126 trace_xfs_discard_extent(mp, agno, fbno, flen);
118 error = -blkdev_issue_discard(bdev, 127 error = -blkdev_issue_discard(bdev, dbno, dlen, GFP_NOFS, 0);
119 XFS_AGB_TO_DADDR(mp, agno, fbno),
120 XFS_FSB_TO_BB(mp, flen),
121 GFP_NOFS, 0);
122 if (error) 128 if (error)
123 goto out_del_cursor; 129 goto out_del_cursor;
124 *blocks_trimmed += flen; 130 *blocks_trimmed += flen;
@@ -137,6 +143,15 @@ out_put_perag:
137 return error; 143 return error;
138} 144}
139 145
146/*
147 * trim a range of the filesystem.
148 *
149 * Note: the parameters passed from userspace are byte ranges into the
150 * filesystem which does not match to the format we use for filesystem block
151 * addressing. FSB addressing is sparse (AGNO|AGBNO), while the incoming format
152 * is a linear address range. Hence we need to use DADDR based conversions and
153 * comparisons for determining the correct offset and regions to trim.
154 */
140int 155int
141xfs_ioc_trim( 156xfs_ioc_trim(
142 struct xfs_mount *mp, 157 struct xfs_mount *mp,
@@ -145,7 +160,7 @@ xfs_ioc_trim(
145 struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue; 160 struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue;
146 unsigned int granularity = q->limits.discard_granularity; 161 unsigned int granularity = q->limits.discard_granularity;
147 struct fstrim_range range; 162 struct fstrim_range range;
148 xfs_fsblock_t start, end, minlen; 163 xfs_daddr_t start, end, minlen;
149 xfs_agnumber_t start_agno, end_agno, agno; 164 xfs_agnumber_t start_agno, end_agno, agno;
150 __uint64_t blocks_trimmed = 0; 165 __uint64_t blocks_trimmed = 0;
151 int error, last_error = 0; 166 int error, last_error = 0;
@@ -159,22 +174,22 @@ xfs_ioc_trim(
159 174
160 /* 175 /*
161 * Truncating down the len isn't actually quite correct, but using 176 * Truncating down the len isn't actually quite correct, but using
162 * XFS_B_TO_FSB would mean we trivially get overflows for values 177 * BBTOB would mean we trivially get overflows for values
163 * of ULLONG_MAX or slightly lower. And ULLONG_MAX is the default 178 * of ULLONG_MAX or slightly lower. And ULLONG_MAX is the default
164 * used by the fstrim application. In the end it really doesn't 179 * used by the fstrim application. In the end it really doesn't
165 * matter as trimming blocks is an advisory interface. 180 * matter as trimming blocks is an advisory interface.
166 */ 181 */
167 start = XFS_B_TO_FSBT(mp, range.start); 182 start = BTOBB(range.start);
168 end = start + XFS_B_TO_FSBT(mp, range.len) - 1; 183 end = start + BTOBBT(range.len) - 1;
169 minlen = XFS_B_TO_FSB(mp, max_t(u64, granularity, range.minlen)); 184 minlen = BTOBB(max_t(u64, granularity, range.minlen));
170 185
171 if (start >= mp->m_sb.sb_dblocks) 186 if (XFS_BB_TO_FSB(mp, start) >= mp->m_sb.sb_dblocks)
172 return -XFS_ERROR(EINVAL); 187 return -XFS_ERROR(EINVAL);
173 if (end > mp->m_sb.sb_dblocks - 1) 188 if (end > XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks) - 1)
174 end = mp->m_sb.sb_dblocks - 1; 189 end = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)- 1;
175 190
176 start_agno = XFS_FSB_TO_AGNO(mp, start); 191 start_agno = xfs_daddr_to_agno(mp, start);
177 end_agno = XFS_FSB_TO_AGNO(mp, end); 192 end_agno = xfs_daddr_to_agno(mp, end);
178 193
179 for (agno = start_agno; agno <= end_agno; agno++) { 194 for (agno = start_agno; agno <= end_agno; agno++) {
180 error = -xfs_trim_extents(mp, agno, start, end, minlen, 195 error = -xfs_trim_extents(mp, agno, start, end, minlen,
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 4be16a0cbe5..1155208fa83 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1065,7 +1065,7 @@ out:
1065 return -ENOMEM; 1065 return -ENOMEM;
1066} 1066}
1067 1067
1068void __exit 1068void
1069xfs_qm_exit(void) 1069xfs_qm_exit(void)
1070{ 1070{
1071 kmem_zone_destroy(xfs_qm_dqtrxzone); 1071 kmem_zone_destroy(xfs_qm_dqtrxzone);
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index a98cb4524e6..bcc6c249b2c 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -289,7 +289,7 @@ xfs_iget_cache_hit(
289 if (lock_flags != 0) 289 if (lock_flags != 0)
290 xfs_ilock(ip, lock_flags); 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 XFS_STATS_INC(xs_ig_found); 293 XFS_STATS_INC(xs_ig_found);
294 294
295 return 0; 295 return 0;
@@ -314,6 +314,7 @@ xfs_iget_cache_miss(
314 struct xfs_inode *ip; 314 struct xfs_inode *ip;
315 int error; 315 int error;
316 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino); 316 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino);
317 int iflags;
317 318
318 ip = xfs_inode_alloc(mp, ino); 319 ip = xfs_inode_alloc(mp, ino);
319 if (!ip) 320 if (!ip)
@@ -358,8 +359,11 @@ xfs_iget_cache_miss(
358 * memory barrier that ensures this detection works correctly at lookup 359 * memory barrier that ensures this detection works correctly at lookup
359 * time. 360 * time.
360 */ 361 */
362 iflags = XFS_INEW;
363 if (flags & XFS_IGET_DONTCACHE)
364 iflags |= XFS_IDONTCACHE;
361 ip->i_udquot = ip->i_gdquot = NULL; 365 ip->i_udquot = ip->i_gdquot = NULL;
362 xfs_iflags_set(ip, XFS_INEW); 366 xfs_iflags_set(ip, iflags);
363 367
364 /* insert the new inode */ 368 /* insert the new inode */
365 spin_lock(&pag->pag_ici_lock); 369 spin_lock(&pag->pag_ici_lock);
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index f123dbe6d42..7fee3387e1c 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -387,10 +387,11 @@ xfs_set_projid(struct xfs_inode *ip,
387#define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT) 387#define XFS_IFLOCK (1 << __XFS_IFLOCK_BIT)
388#define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */ 388#define __XFS_IPINNED_BIT 8 /* wakeup key for zero pin count */
389#define XFS_IPINNED (1 << __XFS_IPINNED_BIT) 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 * Per-lifetime flags need to be reset when re-using a reclaimable inode during 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 * ocurring. 395 * ocurring.
395 */ 396 */
396#define XFS_IRECLAIM_RESET_FLAGS \ 397#define XFS_IRECLAIM_RESET_FLAGS \
@@ -553,6 +554,7 @@ do { \
553 */ 554 */
554#define XFS_IGET_CREATE 0x1 555#define XFS_IGET_CREATE 0x1
555#define XFS_IGET_UNTRUSTED 0x2 556#define XFS_IGET_UNTRUSTED 0x2
557#define XFS_IGET_DONTCACHE 0x4
556 558
557int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, 559int xfs_inotobp(struct xfs_mount *, struct xfs_trans *,
558 xfs_ino_t, struct xfs_dinode **, 560 xfs_ino_t, struct xfs_dinode **,
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index f588320dc4b..91f8ff547ab 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -209,6 +209,7 @@ xfs_open_by_handle(
209 struct file *filp; 209 struct file *filp;
210 struct inode *inode; 210 struct inode *inode;
211 struct dentry *dentry; 211 struct dentry *dentry;
212 fmode_t fmode;
212 213
213 if (!capable(CAP_SYS_ADMIN)) 214 if (!capable(CAP_SYS_ADMIN))
214 return -XFS_ERROR(EPERM); 215 return -XFS_ERROR(EPERM);
@@ -228,26 +229,21 @@ xfs_open_by_handle(
228 hreq->oflags |= O_LARGEFILE; 229 hreq->oflags |= O_LARGEFILE;
229#endif 230#endif
230 231
231 /* Put open permission in namei format. */
232 permflag = hreq->oflags; 232 permflag = hreq->oflags;
233 if ((permflag+1) & O_ACCMODE) 233 fmode = OPEN_FMODE(permflag);
234 permflag++;
235 if (permflag & O_TRUNC)
236 permflag |= 2;
237
238 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) && 234 if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
239 (permflag & FMODE_WRITE) && IS_APPEND(inode)) { 235 (fmode & FMODE_WRITE) && IS_APPEND(inode)) {
240 error = -XFS_ERROR(EPERM); 236 error = -XFS_ERROR(EPERM);
241 goto out_dput; 237 goto out_dput;
242 } 238 }
243 239
244 if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) { 240 if ((fmode & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
245 error = -XFS_ERROR(EACCES); 241 error = -XFS_ERROR(EACCES);
246 goto out_dput; 242 goto out_dput;
247 } 243 }
248 244
249 /* Can't write directories. */ 245 /* Can't write directories. */
250 if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) { 246 if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) {
251 error = -XFS_ERROR(EISDIR); 247 error = -XFS_ERROR(EISDIR);
252 goto out_dput; 248 goto out_dput;
253 } 249 }
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 9720c54bbed..acc2bf264da 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -75,7 +75,8 @@ xfs_bulkstat_one_int(
75 return XFS_ERROR(ENOMEM); 75 return XFS_ERROR(ENOMEM);
76 76
77 error = xfs_iget(mp, NULL, ino, 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 if (error) { 80 if (error) {
80 *stat = BULKSTAT_RV_NOTHING; 81 *stat = BULKSTAT_RV_NOTHING;
81 goto out_free; 82 goto out_free;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 98a9cb5ffd1..6db1fef38bf 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -726,8 +726,9 @@ xfs_log_unmount_write(xfs_mount_t *mp)
726 .lv_iovecp = &reg, 726 .lv_iovecp = &reg,
727 }; 727 };
728 728
729 /* remove inited flag */ 729 /* remove inited flag, and account for space used */
730 tic->t_flags = 0; 730 tic->t_flags = 0;
731 tic->t_curr_res -= sizeof(magic);
731 error = xlog_write(log, &vec, tic, &lsn, 732 error = xlog_write(log, &vec, tic, &lsn,
732 NULL, XLOG_UNMOUNT_TRANS); 733 NULL, XLOG_UNMOUNT_TRANS);
733 /* 734 /*
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 7c75c7374d5..8ecad5bad66 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3161,37 +3161,26 @@ xlog_recover_process_iunlinks(
3161 */ 3161 */
3162 continue; 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 agi = XFS_BUF_TO_AGI(agibp); 3173 agi = XFS_BUF_TO_AGI(agibp);
3174 xfs_buf_unlock(agibp);
3165 3175
3166 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) { 3176 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
3167 agino = be32_to_cpu(agi->agi_unlinked[bucket]); 3177 agino = be32_to_cpu(agi->agi_unlinked[bucket]);
3168 while (agino != NULLAGINO) { 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 agino = xlog_recover_process_one_iunlink(mp, 3179 agino = xlog_recover_process_one_iunlink(mp,
3177 agno, agino, bucket); 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 3183 xfs_buf_rele(agibp);
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);
3195 } 3184 }
3196 3185
3197 mp->m_dmevmask = mp_dmevmask; 3186 mp->m_dmevmask = mp_dmevmask;
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 87323f1ded6..ca4f31534a0 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -183,6 +183,7 @@ error_cancel:
183 oblocks = map.br_startoff + map.br_blockcount; 183 oblocks = map.br_startoff + map.br_blockcount;
184 } 184 }
185 return 0; 185 return 0;
186
186error: 187error:
187 return error; 188 return error;
188} 189}
@@ -2139,11 +2140,9 @@ xfs_rtfree_extent(
2139 xfs_buf_t *sumbp; /* summary file block buffer */ 2140 xfs_buf_t *sumbp; /* summary file block buffer */
2140 2141
2141 mp = tp->t_mountp; 2142 mp = tp->t_mountp;
2142 /* 2143
2143 * Synchronize by locking the bitmap inode. 2144 ASSERT(mp->m_rbmip->i_itemp != NULL);
2144 */ 2145 ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
2145 xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
2146 xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
2147 2146
2148#if defined(__KERNEL__) && defined(DEBUG) 2147#if defined(__KERNEL__) && defined(DEBUG)
2149 /* 2148 /*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 912442cf0f8..dab9a5f6dfd 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -950,6 +950,22 @@ xfs_fs_evict_inode(
950 xfs_inactive(ip); 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 */
960STATIC int
961xfs_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
953STATIC void 969STATIC void
954xfs_free_fsname( 970xfs_free_fsname(
955 struct xfs_mount *mp) 971 struct xfs_mount *mp)
@@ -1433,6 +1449,7 @@ static const struct super_operations xfs_super_operations = {
1433 .destroy_inode = xfs_fs_destroy_inode, 1449 .destroy_inode = xfs_fs_destroy_inode,
1434 .dirty_inode = xfs_fs_dirty_inode, 1450 .dirty_inode = xfs_fs_dirty_inode,
1435 .evict_inode = xfs_fs_evict_inode, 1451 .evict_inode = xfs_fs_evict_inode,
1452 .drop_inode = xfs_fs_drop_inode,
1436 .put_super = xfs_fs_put_super, 1453 .put_super = xfs_fs_put_super,
1437 .sync_fs = xfs_fs_sync_fs, 1454 .sync_fs = xfs_fs_sync_fs,
1438 .freeze_fs = xfs_fs_freeze, 1455 .freeze_fs = xfs_fs_freeze,
@@ -1606,12 +1623,28 @@ xfs_init_workqueues(void)
1606 xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0); 1623 xfs_syncd_wq = alloc_workqueue("xfssyncd", WQ_NON_REENTRANT, 0);
1607 if (!xfs_syncd_wq) 1624 if (!xfs_syncd_wq)
1608 return -ENOMEM; 1625 return -ENOMEM;
1626
1627 /*
1628 * The allocation workqueue can be used in memory reclaim situations
1629 * (writepage path), and parallelism is only limited by the number of
1630 * AGs in all the filesystems mounted. Hence use the default large
1631 * max_active value for this workqueue.
1632 */
1633 xfs_alloc_wq = alloc_workqueue("xfsalloc", WQ_MEM_RECLAIM, 0);
1634 if (!xfs_alloc_wq)
1635 goto out_destroy_syncd;
1636
1609 return 0; 1637 return 0;
1638
1639out_destroy_syncd:
1640 destroy_workqueue(xfs_syncd_wq);
1641 return -ENOMEM;
1610} 1642}
1611 1643
1612STATIC void 1644STATIC void
1613xfs_destroy_workqueues(void) 1645xfs_destroy_workqueues(void)
1614{ 1646{
1647 destroy_workqueue(xfs_alloc_wq);
1615 destroy_workqueue(xfs_syncd_wq); 1648 destroy_workqueue(xfs_syncd_wq);
1616} 1649}
1617 1650
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 75eb54af4d5..06838c42b2a 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -627,16 +627,19 @@ DECLARE_EVENT_CLASS(xfs_namespace_class,
627 TP_STRUCT__entry( 627 TP_STRUCT__entry(
628 __field(dev_t, dev) 628 __field(dev_t, dev)
629 __field(xfs_ino_t, dp_ino) 629 __field(xfs_ino_t, dp_ino)
630 __field(int, namelen)
630 __dynamic_array(char, name, name->len) 631 __dynamic_array(char, name, name->len)
631 ), 632 ),
632 TP_fast_assign( 633 TP_fast_assign(
633 __entry->dev = VFS_I(dp)->i_sb->s_dev; 634 __entry->dev = VFS_I(dp)->i_sb->s_dev;
634 __entry->dp_ino = dp->i_ino; 635 __entry->dp_ino = dp->i_ino;
636 __entry->namelen = name->len;
635 memcpy(__get_str(name), name->name, name->len); 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 MAJOR(__entry->dev), MINOR(__entry->dev), 640 MAJOR(__entry->dev), MINOR(__entry->dev),
639 __entry->dp_ino, 641 __entry->dp_ino,
642 __entry->namelen,
640 __get_str(name)) 643 __get_str(name))
641) 644)
642 645
@@ -658,6 +661,8 @@ TRACE_EVENT(xfs_rename,
658 __field(dev_t, dev) 661 __field(dev_t, dev)
659 __field(xfs_ino_t, src_dp_ino) 662 __field(xfs_ino_t, src_dp_ino)
660 __field(xfs_ino_t, target_dp_ino) 663 __field(xfs_ino_t, target_dp_ino)
664 __field(int, src_namelen)
665 __field(int, target_namelen)
661 __dynamic_array(char, src_name, src_name->len) 666 __dynamic_array(char, src_name, src_name->len)
662 __dynamic_array(char, target_name, target_name->len) 667 __dynamic_array(char, target_name, target_name->len)
663 ), 668 ),
@@ -665,15 +670,20 @@ TRACE_EVENT(xfs_rename,
665 __entry->dev = VFS_I(src_dp)->i_sb->s_dev; 670 __entry->dev = VFS_I(src_dp)->i_sb->s_dev;
666 __entry->src_dp_ino = src_dp->i_ino; 671 __entry->src_dp_ino = src_dp->i_ino;
667 __entry->target_dp_ino = target_dp->i_ino; 672 __entry->target_dp_ino = target_dp->i_ino;
673 __entry->src_namelen = src_name->len;
674 __entry->target_namelen = target_name->len;
668 memcpy(__get_str(src_name), src_name->name, src_name->len); 675 memcpy(__get_str(src_name), src_name->name, src_name->len);
669 memcpy(__get_str(target_name), target_name->name, target_name->len); 676 memcpy(__get_str(target_name), target_name->name,
677 target_name->len);
670 ), 678 ),
671 TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx" 679 TP_printk("dev %d:%d src dp ino 0x%llx target dp ino 0x%llx"
672 " src name %s target name %s", 680 " src name %.*s target name %.*s",
673 MAJOR(__entry->dev), MINOR(__entry->dev), 681 MAJOR(__entry->dev), MINOR(__entry->dev),
674 __entry->src_dp_ino, 682 __entry->src_dp_ino,
675 __entry->target_dp_ino, 683 __entry->target_dp_ino,
684 __entry->src_namelen,
676 __get_str(src_name), 685 __get_str(src_name),
686 __entry->target_namelen,
677 __get_str(target_name)) 687 __get_str(target_name))
678) 688)
679 689
@@ -1408,7 +1418,7 @@ DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
1408DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed); 1418DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
1409DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed); 1419DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
1410 1420
1411DECLARE_EVENT_CLASS(xfs_dir2_class, 1421DECLARE_EVENT_CLASS(xfs_da_class,
1412 TP_PROTO(struct xfs_da_args *args), 1422 TP_PROTO(struct xfs_da_args *args),
1413 TP_ARGS(args), 1423 TP_ARGS(args),
1414 TP_STRUCT__entry( 1424 TP_STRUCT__entry(
@@ -1443,7 +1453,7 @@ DECLARE_EVENT_CLASS(xfs_dir2_class,
1443) 1453)
1444 1454
1445#define DEFINE_DIR2_EVENT(name) \ 1455#define DEFINE_DIR2_EVENT(name) \
1446DEFINE_EVENT(xfs_dir2_class, name, \ 1456DEFINE_EVENT(xfs_da_class, name, \
1447 TP_PROTO(struct xfs_da_args *args), \ 1457 TP_PROTO(struct xfs_da_args *args), \
1448 TP_ARGS(args)) 1458 TP_ARGS(args))
1449DEFINE_DIR2_EVENT(xfs_dir2_sf_addname); 1459DEFINE_DIR2_EVENT(xfs_dir2_sf_addname);
@@ -1472,6 +1482,64 @@ DEFINE_DIR2_EVENT(xfs_dir2_node_replace);
1472DEFINE_DIR2_EVENT(xfs_dir2_node_removename); 1482DEFINE_DIR2_EVENT(xfs_dir2_node_removename);
1473DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf); 1483DEFINE_DIR2_EVENT(xfs_dir2_node_to_leaf);
1474 1484
1485#define DEFINE_ATTR_EVENT(name) \
1486DEFINE_EVENT(xfs_da_class, name, \
1487 TP_PROTO(struct xfs_da_args *args), \
1488 TP_ARGS(args))
1489DEFINE_ATTR_EVENT(xfs_attr_sf_add);
1490DEFINE_ATTR_EVENT(xfs_attr_sf_addname);
1491DEFINE_ATTR_EVENT(xfs_attr_sf_create);
1492DEFINE_ATTR_EVENT(xfs_attr_sf_lookup);
1493DEFINE_ATTR_EVENT(xfs_attr_sf_remove);
1494DEFINE_ATTR_EVENT(xfs_attr_sf_removename);
1495DEFINE_ATTR_EVENT(xfs_attr_sf_to_leaf);
1496
1497DEFINE_ATTR_EVENT(xfs_attr_leaf_add);
1498DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old);
1499DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new);
1500DEFINE_ATTR_EVENT(xfs_attr_leaf_addname);
1501DEFINE_ATTR_EVENT(xfs_attr_leaf_create);
1502DEFINE_ATTR_EVENT(xfs_attr_leaf_lookup);
1503DEFINE_ATTR_EVENT(xfs_attr_leaf_replace);
1504DEFINE_ATTR_EVENT(xfs_attr_leaf_removename);
1505DEFINE_ATTR_EVENT(xfs_attr_leaf_split);
1506DEFINE_ATTR_EVENT(xfs_attr_leaf_split_before);
1507DEFINE_ATTR_EVENT(xfs_attr_leaf_split_after);
1508DEFINE_ATTR_EVENT(xfs_attr_leaf_clearflag);
1509DEFINE_ATTR_EVENT(xfs_attr_leaf_setflag);
1510DEFINE_ATTR_EVENT(xfs_attr_leaf_flipflags);
1511DEFINE_ATTR_EVENT(xfs_attr_leaf_to_sf);
1512DEFINE_ATTR_EVENT(xfs_attr_leaf_to_node);
1513DEFINE_ATTR_EVENT(xfs_attr_leaf_rebalance);
1514DEFINE_ATTR_EVENT(xfs_attr_leaf_unbalance);
1515
1516DEFINE_ATTR_EVENT(xfs_attr_node_addname);
1517DEFINE_ATTR_EVENT(xfs_attr_node_lookup);
1518DEFINE_ATTR_EVENT(xfs_attr_node_replace);
1519DEFINE_ATTR_EVENT(xfs_attr_node_removename);
1520
1521#define DEFINE_DA_EVENT(name) \
1522DEFINE_EVENT(xfs_da_class, name, \
1523 TP_PROTO(struct xfs_da_args *args), \
1524 TP_ARGS(args))
1525DEFINE_DA_EVENT(xfs_da_split);
1526DEFINE_DA_EVENT(xfs_da_join);
1527DEFINE_DA_EVENT(xfs_da_link_before);
1528DEFINE_DA_EVENT(xfs_da_link_after);
1529DEFINE_DA_EVENT(xfs_da_unlink_back);
1530DEFINE_DA_EVENT(xfs_da_unlink_forward);
1531DEFINE_DA_EVENT(xfs_da_root_split);
1532DEFINE_DA_EVENT(xfs_da_root_join);
1533DEFINE_DA_EVENT(xfs_da_node_add);
1534DEFINE_DA_EVENT(xfs_da_node_create);
1535DEFINE_DA_EVENT(xfs_da_node_split);
1536DEFINE_DA_EVENT(xfs_da_node_remove);
1537DEFINE_DA_EVENT(xfs_da_node_rebalance);
1538DEFINE_DA_EVENT(xfs_da_node_unbalance);
1539DEFINE_DA_EVENT(xfs_da_swap_lastblock);
1540DEFINE_DA_EVENT(xfs_da_grow_inode);
1541DEFINE_DA_EVENT(xfs_da_shrink_inode);
1542
1475DECLARE_EVENT_CLASS(xfs_dir2_space_class, 1543DECLARE_EVENT_CLASS(xfs_dir2_space_class,
1476 TP_PROTO(struct xfs_da_args *args, int idx), 1544 TP_PROTO(struct xfs_da_args *args, int idx),
1477 TP_ARGS(args, idx), 1545 TP_ARGS(args, idx),