aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2016-01-11 15:04:30 -0500
committerDave Chinner <david@fromorbit.com>2016-01-11 15:04:30 -0500
commitdde7f55bd000696acc38296c21241971e1840142 (patch)
tree79fd17020de1ea6921107ad3dbabf5eb33a88838 /fs/xfs
parent4922be51ef1a95ca6a38694cf0cde5dd0308a24e (diff)
parent7d6a13f023567d573ac362502bb702eda716e654 (diff)
Merge branch 'xfs-misc-fixes-for-4.5-2' into for-next
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_attr.c141
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c31
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c16
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h2
-rw-r--r--fs/xfs/libxfs/xfs_dquot_buf.c36
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c14
-rw-r--r--fs/xfs/libxfs/xfs_quota_defs.h2
-rw-r--r--fs/xfs/libxfs/xfs_shared.h1
-rw-r--r--fs/xfs/xfs_aops.c2
-rw-r--r--fs/xfs/xfs_bmap_util.c43
-rw-r--r--fs/xfs/xfs_buf.c7
-rw-r--r--fs/xfs/xfs_dquot.c13
-rw-r--r--fs/xfs/xfs_inode.c25
-rw-r--r--fs/xfs/xfs_iomap.c10
-rw-r--r--fs/xfs/xfs_log_recover.c9
-rw-r--r--fs/xfs/xfs_rtalloc.c3
-rw-r--r--fs/xfs/xfs_symlink.c12
-rw-r--r--fs/xfs/xfs_trace.h26
18 files changed, 159 insertions, 234 deletions
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index f949818fa1c7..fa3b948ef9c2 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -207,7 +207,7 @@ xfs_attr_set(
207 struct xfs_trans_res tres; 207 struct xfs_trans_res tres;
208 xfs_fsblock_t firstblock; 208 xfs_fsblock_t firstblock;
209 int rsvd = (flags & ATTR_ROOT) != 0; 209 int rsvd = (flags & ATTR_ROOT) != 0;
210 int error, err2, committed, local; 210 int error, err2, local;
211 211
212 XFS_STATS_INC(mp, xs_attr_set); 212 XFS_STATS_INC(mp, xs_attr_set);
213 213
@@ -334,25 +334,15 @@ xfs_attr_set(
334 */ 334 */
335 xfs_bmap_init(args.flist, args.firstblock); 335 xfs_bmap_init(args.flist, args.firstblock);
336 error = xfs_attr_shortform_to_leaf(&args); 336 error = xfs_attr_shortform_to_leaf(&args);
337 if (!error) { 337 if (!error)
338 error = xfs_bmap_finish(&args.trans, args.flist, 338 error = xfs_bmap_finish(&args.trans, args.flist, dp);
339 &committed);
340 }
341 if (error) { 339 if (error) {
342 ASSERT(committed);
343 args.trans = NULL; 340 args.trans = NULL;
344 xfs_bmap_cancel(&flist); 341 xfs_bmap_cancel(&flist);
345 goto out; 342 goto out;
346 } 343 }
347 344
348 /* 345 /*
349 * bmap_finish() may have committed the last trans and started
350 * a new one. We need the inode to be in all transactions.
351 */
352 if (committed)
353 xfs_trans_ijoin(args.trans, dp, 0);
354
355 /*
356 * Commit the leaf transformation. We'll need another (linked) 346 * Commit the leaf transformation. We'll need another (linked)
357 * transaction to add the new attribute to the leaf. 347 * transaction to add the new attribute to the leaf.
358 */ 348 */
@@ -568,7 +558,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
568{ 558{
569 xfs_inode_t *dp; 559 xfs_inode_t *dp;
570 struct xfs_buf *bp; 560 struct xfs_buf *bp;
571 int retval, error, committed, forkoff; 561 int retval, error, forkoff;
572 562
573 trace_xfs_attr_leaf_addname(args); 563 trace_xfs_attr_leaf_addname(args);
574 564
@@ -628,25 +618,15 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
628 */ 618 */
629 xfs_bmap_init(args->flist, args->firstblock); 619 xfs_bmap_init(args->flist, args->firstblock);
630 error = xfs_attr3_leaf_to_node(args); 620 error = xfs_attr3_leaf_to_node(args);
631 if (!error) { 621 if (!error)
632 error = xfs_bmap_finish(&args->trans, args->flist, 622 error = xfs_bmap_finish(&args->trans, args->flist, dp);
633 &committed);
634 }
635 if (error) { 623 if (error) {
636 ASSERT(committed);
637 args->trans = NULL; 624 args->trans = NULL;
638 xfs_bmap_cancel(args->flist); 625 xfs_bmap_cancel(args->flist);
639 return error; 626 return error;
640 } 627 }
641 628
642 /* 629 /*
643 * bmap_finish() may have committed the last trans and started
644 * a new one. We need the inode to be in all transactions.
645 */
646 if (committed)
647 xfs_trans_ijoin(args->trans, dp, 0);
648
649 /*
650 * Commit the current trans (including the inode) and start 630 * Commit the current trans (including the inode) and start
651 * a new one. 631 * a new one.
652 */ 632 */
@@ -729,25 +709,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
729 xfs_bmap_init(args->flist, args->firstblock); 709 xfs_bmap_init(args->flist, args->firstblock);
730 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); 710 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
731 /* bp is gone due to xfs_da_shrink_inode */ 711 /* bp is gone due to xfs_da_shrink_inode */
732 if (!error) { 712 if (!error)
733 error = xfs_bmap_finish(&args->trans, 713 error = xfs_bmap_finish(&args->trans,
734 args->flist, 714 args->flist, dp);
735 &committed);
736 }
737 if (error) { 715 if (error) {
738 ASSERT(committed);
739 args->trans = NULL; 716 args->trans = NULL;
740 xfs_bmap_cancel(args->flist); 717 xfs_bmap_cancel(args->flist);
741 return error; 718 return error;
742 } 719 }
743
744 /*
745 * bmap_finish() may have committed the last trans
746 * and started a new one. We need the inode to be
747 * in all transactions.
748 */
749 if (committed)
750 xfs_trans_ijoin(args->trans, dp, 0);
751 } 720 }
752 721
753 /* 722 /*
@@ -775,7 +744,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
775{ 744{
776 xfs_inode_t *dp; 745 xfs_inode_t *dp;
777 struct xfs_buf *bp; 746 struct xfs_buf *bp;
778 int error, committed, forkoff; 747 int error, forkoff;
779 748
780 trace_xfs_attr_leaf_removename(args); 749 trace_xfs_attr_leaf_removename(args);
781 750
@@ -803,23 +772,13 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
803 xfs_bmap_init(args->flist, args->firstblock); 772 xfs_bmap_init(args->flist, args->firstblock);
804 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); 773 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
805 /* bp is gone due to xfs_da_shrink_inode */ 774 /* bp is gone due to xfs_da_shrink_inode */
806 if (!error) { 775 if (!error)
807 error = xfs_bmap_finish(&args->trans, args->flist, 776 error = xfs_bmap_finish(&args->trans, args->flist, dp);
808 &committed);
809 }
810 if (error) { 777 if (error) {
811 ASSERT(committed);
812 args->trans = NULL; 778 args->trans = NULL;
813 xfs_bmap_cancel(args->flist); 779 xfs_bmap_cancel(args->flist);
814 return error; 780 return error;
815 } 781 }
816
817 /*
818 * bmap_finish() may have committed the last trans and started
819 * a new one. We need the inode to be in all transactions.
820 */
821 if (committed)
822 xfs_trans_ijoin(args->trans, dp, 0);
823 } 782 }
824 return 0; 783 return 0;
825} 784}
@@ -877,7 +836,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)
877 xfs_da_state_blk_t *blk; 836 xfs_da_state_blk_t *blk;
878 xfs_inode_t *dp; 837 xfs_inode_t *dp;
879 xfs_mount_t *mp; 838 xfs_mount_t *mp;
880 int committed, retval, error; 839 int retval, error;
881 840
882 trace_xfs_attr_node_addname(args); 841 trace_xfs_attr_node_addname(args);
883 842
@@ -938,27 +897,16 @@ restart:
938 state = NULL; 897 state = NULL;
939 xfs_bmap_init(args->flist, args->firstblock); 898 xfs_bmap_init(args->flist, args->firstblock);
940 error = xfs_attr3_leaf_to_node(args); 899 error = xfs_attr3_leaf_to_node(args);
941 if (!error) { 900 if (!error)
942 error = xfs_bmap_finish(&args->trans, 901 error = xfs_bmap_finish(&args->trans,
943 args->flist, 902 args->flist, dp);
944 &committed);
945 }
946 if (error) { 903 if (error) {
947 ASSERT(committed);
948 args->trans = NULL; 904 args->trans = NULL;
949 xfs_bmap_cancel(args->flist); 905 xfs_bmap_cancel(args->flist);
950 goto out; 906 goto out;
951 } 907 }
952 908
953 /* 909 /*
954 * bmap_finish() may have committed the last trans
955 * and started a new one. We need the inode to be
956 * in all transactions.
957 */
958 if (committed)
959 xfs_trans_ijoin(args->trans, dp, 0);
960
961 /*
962 * Commit the node conversion and start the next 910 * Commit the node conversion and start the next
963 * trans in the chain. 911 * trans in the chain.
964 */ 912 */
@@ -977,23 +925,13 @@ restart:
977 */ 925 */
978 xfs_bmap_init(args->flist, args->firstblock); 926 xfs_bmap_init(args->flist, args->firstblock);
979 error = xfs_da3_split(state); 927 error = xfs_da3_split(state);
980 if (!error) { 928 if (!error)
981 error = xfs_bmap_finish(&args->trans, args->flist, 929 error = xfs_bmap_finish(&args->trans, args->flist, dp);
982 &committed);
983 }
984 if (error) { 930 if (error) {
985 ASSERT(committed);
986 args->trans = NULL; 931 args->trans = NULL;
987 xfs_bmap_cancel(args->flist); 932 xfs_bmap_cancel(args->flist);
988 goto out; 933 goto out;
989 } 934 }
990
991 /*
992 * bmap_finish() may have committed the last trans and started
993 * a new one. We need the inode to be in all transactions.
994 */
995 if (committed)
996 xfs_trans_ijoin(args->trans, dp, 0);
997 } else { 935 } else {
998 /* 936 /*
999 * Addition succeeded, update Btree hashvals. 937 * Addition succeeded, update Btree hashvals.
@@ -1086,25 +1024,14 @@ restart:
1086 if (retval && (state->path.active > 1)) { 1024 if (retval && (state->path.active > 1)) {
1087 xfs_bmap_init(args->flist, args->firstblock); 1025 xfs_bmap_init(args->flist, args->firstblock);
1088 error = xfs_da3_join(state); 1026 error = xfs_da3_join(state);
1089 if (!error) { 1027 if (!error)
1090 error = xfs_bmap_finish(&args->trans, 1028 error = xfs_bmap_finish(&args->trans,
1091 args->flist, 1029 args->flist, dp);
1092 &committed);
1093 }
1094 if (error) { 1030 if (error) {
1095 ASSERT(committed);
1096 args->trans = NULL; 1031 args->trans = NULL;
1097 xfs_bmap_cancel(args->flist); 1032 xfs_bmap_cancel(args->flist);
1098 goto out; 1033 goto out;
1099 } 1034 }
1100
1101 /*
1102 * bmap_finish() may have committed the last trans
1103 * and started a new one. We need the inode to be
1104 * in all transactions.
1105 */
1106 if (committed)
1107 xfs_trans_ijoin(args->trans, dp, 0);
1108 } 1035 }
1109 1036
1110 /* 1037 /*
@@ -1146,7 +1073,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1146 xfs_da_state_blk_t *blk; 1073 xfs_da_state_blk_t *blk;
1147 xfs_inode_t *dp; 1074 xfs_inode_t *dp;
1148 struct xfs_buf *bp; 1075 struct xfs_buf *bp;
1149 int retval, error, committed, forkoff; 1076 int retval, error, forkoff;
1150 1077
1151 trace_xfs_attr_node_removename(args); 1078 trace_xfs_attr_node_removename(args);
1152 1079
@@ -1220,24 +1147,13 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1220 if (retval && (state->path.active > 1)) { 1147 if (retval && (state->path.active > 1)) {
1221 xfs_bmap_init(args->flist, args->firstblock); 1148 xfs_bmap_init(args->flist, args->firstblock);
1222 error = xfs_da3_join(state); 1149 error = xfs_da3_join(state);
1223 if (!error) { 1150 if (!error)
1224 error = xfs_bmap_finish(&args->trans, args->flist, 1151 error = xfs_bmap_finish(&args->trans, args->flist, dp);
1225 &committed);
1226 }
1227 if (error) { 1152 if (error) {
1228 ASSERT(committed);
1229 args->trans = NULL; 1153 args->trans = NULL;
1230 xfs_bmap_cancel(args->flist); 1154 xfs_bmap_cancel(args->flist);
1231 goto out; 1155 goto out;
1232 } 1156 }
1233
1234 /*
1235 * bmap_finish() may have committed the last trans and started
1236 * a new one. We need the inode to be in all transactions.
1237 */
1238 if (committed)
1239 xfs_trans_ijoin(args->trans, dp, 0);
1240
1241 /* 1157 /*
1242 * Commit the Btree join operation and start a new trans. 1158 * Commit the Btree join operation and start a new trans.
1243 */ 1159 */
@@ -1265,25 +1181,14 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1265 xfs_bmap_init(args->flist, args->firstblock); 1181 xfs_bmap_init(args->flist, args->firstblock);
1266 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); 1182 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
1267 /* bp is gone due to xfs_da_shrink_inode */ 1183 /* bp is gone due to xfs_da_shrink_inode */
1268 if (!error) { 1184 if (!error)
1269 error = xfs_bmap_finish(&args->trans, 1185 error = xfs_bmap_finish(&args->trans,
1270 args->flist, 1186 args->flist, dp);
1271 &committed);
1272 }
1273 if (error) { 1187 if (error) {
1274 ASSERT(committed);
1275 args->trans = NULL; 1188 args->trans = NULL;
1276 xfs_bmap_cancel(args->flist); 1189 xfs_bmap_cancel(args->flist);
1277 goto out; 1190 goto out;
1278 } 1191 }
1279
1280 /*
1281 * bmap_finish() may have committed the last trans
1282 * and started a new one. We need the inode to be
1283 * in all transactions.
1284 */
1285 if (committed)
1286 xfs_trans_ijoin(args->trans, dp, 0);
1287 } else 1192 } else
1288 xfs_trans_brelse(args->trans, bp); 1193 xfs_trans_brelse(args->trans, bp);
1289 } 1194 }
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index f3ed9bf0b065..a572532a55cd 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -448,8 +448,6 @@ xfs_attr_rmtval_set(
448 * Roll through the "value", allocating blocks on disk as required. 448 * Roll through the "value", allocating blocks on disk as required.
449 */ 449 */
450 while (blkcnt > 0) { 450 while (blkcnt > 0) {
451 int committed;
452
453 /* 451 /*
454 * Allocate a single extent, up to the size of the value. 452 * Allocate a single extent, up to the size of the value.
455 * 453 *
@@ -467,24 +465,14 @@ xfs_attr_rmtval_set(
467 error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, 465 error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
468 blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, 466 blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
469 args->total, &map, &nmap, args->flist); 467 args->total, &map, &nmap, args->flist);
470 if (!error) { 468 if (!error)
471 error = xfs_bmap_finish(&args->trans, args->flist, 469 error = xfs_bmap_finish(&args->trans, args->flist, dp);
472 &committed);
473 }
474 if (error) { 470 if (error) {
475 ASSERT(committed);
476 args->trans = NULL; 471 args->trans = NULL;
477 xfs_bmap_cancel(args->flist); 472 xfs_bmap_cancel(args->flist);
478 return error; 473 return error;
479 } 474 }
480 475
481 /*
482 * bmap_finish() may have committed the last trans and started
483 * a new one. We need the inode to be in all transactions.
484 */
485 if (committed)
486 xfs_trans_ijoin(args->trans, dp, 0);
487
488 ASSERT(nmap == 1); 476 ASSERT(nmap == 1);
489 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 477 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
490 (map.br_startblock != HOLESTARTBLOCK)); 478 (map.br_startblock != HOLESTARTBLOCK));
@@ -615,31 +603,20 @@ xfs_attr_rmtval_remove(
615 blkcnt = args->rmtblkcnt; 603 blkcnt = args->rmtblkcnt;
616 done = 0; 604 done = 0;
617 while (!done) { 605 while (!done) {
618 int committed;
619
620 xfs_bmap_init(args->flist, args->firstblock); 606 xfs_bmap_init(args->flist, args->firstblock);
621 error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, 607 error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
622 XFS_BMAPI_ATTRFORK, 1, args->firstblock, 608 XFS_BMAPI_ATTRFORK, 1, args->firstblock,
623 args->flist, &done); 609 args->flist, &done);
624 if (!error) { 610 if (!error)
625 error = xfs_bmap_finish(&args->trans, args->flist, 611 error = xfs_bmap_finish(&args->trans, args->flist,
626 &committed); 612 args->dp);
627 }
628 if (error) { 613 if (error) {
629 ASSERT(committed);
630 args->trans = NULL; 614 args->trans = NULL;
631 xfs_bmap_cancel(args->flist); 615 xfs_bmap_cancel(args->flist);
632 return error; 616 return error;
633 } 617 }
634 618
635 /* 619 /*
636 * bmap_finish() may have committed the last trans and started
637 * a new one. We need the inode to be in all transactions.
638 */
639 if (committed)
640 xfs_trans_ijoin(args->trans, args->dp, 0);
641
642 /*
643 * Close out trans and start the next one in the chain. 620 * Close out trans and start the next one in the chain.
644 */ 621 */
645 error = xfs_trans_roll(&args->trans, args->dp); 622 error = xfs_trans_roll(&args->trans, args->dp);
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 73884953b21c..ef00156f4f96 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -325,9 +325,11 @@ xfs_check_block(
325 325
326/* 326/*
327 * Check that the extents for the inode ip are in the right order in all 327 * Check that the extents for the inode ip are in the right order in all
328 * btree leaves. 328 * btree leaves. THis becomes prohibitively expensive for large extent count
329 * files, so don't bother with inodes that have more than 10,000 extents in
330 * them. The btree record ordering checks will still be done, so for such large
331 * bmapbt constructs that is going to catch most corruptions.
329 */ 332 */
330
331STATIC void 333STATIC void
332xfs_bmap_check_leaf_extents( 334xfs_bmap_check_leaf_extents(
333 xfs_btree_cur_t *cur, /* btree cursor or null */ 335 xfs_btree_cur_t *cur, /* btree cursor or null */
@@ -352,6 +354,10 @@ xfs_bmap_check_leaf_extents(
352 return; 354 return;
353 } 355 }
354 356
357 /* skip large extent count inodes */
358 if (ip->i_d.di_nextents > 10000)
359 return;
360
355 bno = NULLFSBLOCK; 361 bno = NULLFSBLOCK;
356 mp = ip->i_mount; 362 mp = ip->i_mount;
357 ifp = XFS_IFORK_PTR(ip, whichfork); 363 ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -1111,7 +1117,6 @@ xfs_bmap_add_attrfork(
1111 xfs_trans_t *tp; /* transaction pointer */ 1117 xfs_trans_t *tp; /* transaction pointer */
1112 int blks; /* space reservation */ 1118 int blks; /* space reservation */
1113 int version = 1; /* superblock attr version */ 1119 int version = 1; /* superblock attr version */
1114 int committed; /* xaction was committed */
1115 int logflags; /* logging flags */ 1120 int logflags; /* logging flags */
1116 int error; /* error return value */ 1121 int error; /* error return value */
1117 1122
@@ -1214,7 +1219,7 @@ xfs_bmap_add_attrfork(
1214 xfs_log_sb(tp); 1219 xfs_log_sb(tp);
1215 } 1220 }
1216 1221
1217 error = xfs_bmap_finish(&tp, &flist, &committed); 1222 error = xfs_bmap_finish(&tp, &flist, NULL);
1218 if (error) 1223 if (error)
1219 goto bmap_cancel; 1224 goto bmap_cancel;
1220 error = xfs_trans_commit(tp); 1225 error = xfs_trans_commit(tp);
@@ -5951,7 +5956,6 @@ xfs_bmap_split_extent(
5951 struct xfs_trans *tp; 5956 struct xfs_trans *tp;
5952 struct xfs_bmap_free free_list; 5957 struct xfs_bmap_free free_list;
5953 xfs_fsblock_t firstfsb; 5958 xfs_fsblock_t firstfsb;
5954 int committed;
5955 int error; 5959 int error;
5956 5960
5957 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); 5961 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
@@ -5972,7 +5976,7 @@ xfs_bmap_split_extent(
5972 if (error) 5976 if (error)
5973 goto out; 5977 goto out;
5974 5978
5975 error = xfs_bmap_finish(&tp, &free_list, &committed); 5979 error = xfs_bmap_finish(&tp, &free_list, NULL);
5976 if (error) 5980 if (error)
5977 goto out; 5981 goto out;
5978 5982
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index a160f8a5a3fc..423a34e832bd 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -195,7 +195,7 @@ void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len,
195 struct xfs_bmap_free *flist, struct xfs_mount *mp); 195 struct xfs_bmap_free *flist, struct xfs_mount *mp);
196void xfs_bmap_cancel(struct xfs_bmap_free *flist); 196void xfs_bmap_cancel(struct xfs_bmap_free *flist);
197int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, 197int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist,
198 int *committed); 198 struct xfs_inode *ip);
199void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); 199void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork);
200int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, 200int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip,
201 xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); 201 xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork);
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index 11cefb2a372a..3cc3cf767474 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -54,7 +54,7 @@ xfs_dqcheck(
54 xfs_dqid_t id, 54 xfs_dqid_t id,
55 uint type, /* used only when IO_dorepair is true */ 55 uint type, /* used only when IO_dorepair is true */
56 uint flags, 56 uint flags,
57 char *str) 57 const char *str)
58{ 58{
59 xfs_dqblk_t *d = (xfs_dqblk_t *)ddq; 59 xfs_dqblk_t *d = (xfs_dqblk_t *)ddq;
60 int errs = 0; 60 int errs = 0;
@@ -207,7 +207,8 @@ xfs_dquot_buf_verify_crc(
207STATIC bool 207STATIC bool
208xfs_dquot_buf_verify( 208xfs_dquot_buf_verify(
209 struct xfs_mount *mp, 209 struct xfs_mount *mp,
210 struct xfs_buf *bp) 210 struct xfs_buf *bp,
211 int warn)
211{ 212{
212 struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; 213 struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
213 xfs_dqid_t id = 0; 214 xfs_dqid_t id = 0;
@@ -240,8 +241,7 @@ xfs_dquot_buf_verify(
240 if (i == 0) 241 if (i == 0)
241 id = be32_to_cpu(ddq->d_id); 242 id = be32_to_cpu(ddq->d_id);
242 243
243 error = xfs_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN, 244 error = xfs_dqcheck(mp, ddq, id + i, 0, warn, __func__);
244 "xfs_dquot_buf_verify");
245 if (error) 245 if (error)
246 return false; 246 return false;
247 } 247 }
@@ -256,7 +256,7 @@ xfs_dquot_buf_read_verify(
256 256
257 if (!xfs_dquot_buf_verify_crc(mp, bp)) 257 if (!xfs_dquot_buf_verify_crc(mp, bp))
258 xfs_buf_ioerror(bp, -EFSBADCRC); 258 xfs_buf_ioerror(bp, -EFSBADCRC);
259 else if (!xfs_dquot_buf_verify(mp, bp)) 259 else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN))
260 xfs_buf_ioerror(bp, -EFSCORRUPTED); 260 xfs_buf_ioerror(bp, -EFSCORRUPTED);
261 261
262 if (bp->b_error) 262 if (bp->b_error)
@@ -264,6 +264,25 @@ xfs_dquot_buf_read_verify(
264} 264}
265 265
266/* 266/*
267 * readahead errors are silent and simply leave the buffer as !done so a real
268 * read will then be run with the xfs_dquot_buf_ops verifier. See
269 * xfs_inode_buf_verify() for why we use EIO and ~XBF_DONE here rather than
270 * reporting the failure.
271 */
272static void
273xfs_dquot_buf_readahead_verify(
274 struct xfs_buf *bp)
275{
276 struct xfs_mount *mp = bp->b_target->bt_mount;
277
278 if (!xfs_dquot_buf_verify_crc(mp, bp) ||
279 !xfs_dquot_buf_verify(mp, bp, 0)) {
280 xfs_buf_ioerror(bp, -EIO);
281 bp->b_flags &= ~XBF_DONE;
282 }
283}
284
285/*
267 * we don't calculate the CRC here as that is done when the dquot is flushed to 286 * we don't calculate the CRC here as that is done when the dquot is flushed to
268 * the buffer after the update is done. This ensures that the dquot in the 287 * the buffer after the update is done. This ensures that the dquot in the
269 * buffer always has an up-to-date CRC value. 288 * buffer always has an up-to-date CRC value.
@@ -274,7 +293,7 @@ xfs_dquot_buf_write_verify(
274{ 293{
275 struct xfs_mount *mp = bp->b_target->bt_mount; 294 struct xfs_mount *mp = bp->b_target->bt_mount;
276 295
277 if (!xfs_dquot_buf_verify(mp, bp)) { 296 if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) {
278 xfs_buf_ioerror(bp, -EFSCORRUPTED); 297 xfs_buf_ioerror(bp, -EFSCORRUPTED);
279 xfs_verifier_error(bp); 298 xfs_verifier_error(bp);
280 return; 299 return;
@@ -287,3 +306,8 @@ const struct xfs_buf_ops xfs_dquot_buf_ops = {
287 .verify_write = xfs_dquot_buf_write_verify, 306 .verify_write = xfs_dquot_buf_write_verify,
288}; 307};
289 308
309const struct xfs_buf_ops xfs_dquot_buf_ra_ops = {
310 .name = "xfs_dquot_ra",
311 .verify_read = xfs_dquot_buf_readahead_verify,
312 .verify_write = xfs_dquot_buf_write_verify,
313};
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 1b8d98a915c4..1aabfda669b0 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -62,11 +62,14 @@ xfs_inobp_check(
62 * has not had the inode cores stamped into it. Hence for readahead, the buffer 62 * has not had the inode cores stamped into it. Hence for readahead, the buffer
63 * may be potentially invalid. 63 * may be potentially invalid.
64 * 64 *
65 * If the readahead buffer is invalid, we don't want to mark it with an error, 65 * If the readahead buffer is invalid, we need to mark it with an error and
66 * but we do want to clear the DONE status of the buffer so that a followup read 66 * clear the DONE status of the buffer so that a followup read will re-read it
67 * will re-read it from disk. This will ensure that we don't get an unnecessary 67 * from disk. We don't report the error otherwise to avoid warnings during log
68 * warnings during log recovery and we don't get unnecssary panics on debug 68 * recovery and we don't get unnecssary panics on debug kernels. We use EIO here
69 * kernels. 69 * because all we want to do is say readahead failed; there is no-one to report
70 * the error to, so this will distinguish it from a non-ra verifier failure.
71 * Changes to this readahead error behavour also need to be reflected in
72 * xfs_dquot_buf_readahead_verify().
70 */ 73 */
71static void 74static void
72xfs_inode_buf_verify( 75xfs_inode_buf_verify(
@@ -93,6 +96,7 @@ xfs_inode_buf_verify(
93 XFS_RANDOM_ITOBP_INOTOBP))) { 96 XFS_RANDOM_ITOBP_INOTOBP))) {
94 if (readahead) { 97 if (readahead) {
95 bp->b_flags &= ~XBF_DONE; 98 bp->b_flags &= ~XBF_DONE;
99 xfs_buf_ioerror(bp, -EIO);
96 return; 100 return;
97 } 101 }
98 102
diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
index 1b0a08379759..f51078f1e92a 100644
--- a/fs/xfs/libxfs/xfs_quota_defs.h
+++ b/fs/xfs/libxfs/xfs_quota_defs.h
@@ -153,7 +153,7 @@ typedef __uint16_t xfs_qwarncnt_t;
153#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 153#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
154 154
155extern int xfs_dqcheck(struct xfs_mount *mp, xfs_disk_dquot_t *ddq, 155extern int xfs_dqcheck(struct xfs_mount *mp, xfs_disk_dquot_t *ddq,
156 xfs_dqid_t id, uint type, uint flags, char *str); 156 xfs_dqid_t id, uint type, uint flags, const char *str);
157extern int xfs_calc_dquots_per_chunk(unsigned int nbblks); 157extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
158 158
159#endif /* __XFS_QUOTA_H__ */ 159#endif /* __XFS_QUOTA_H__ */
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 5be529707903..15c3ceb845b9 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -49,6 +49,7 @@ extern const struct xfs_buf_ops xfs_inobt_buf_ops;
49extern const struct xfs_buf_ops xfs_inode_buf_ops; 49extern const struct xfs_buf_ops xfs_inode_buf_ops;
50extern const struct xfs_buf_ops xfs_inode_buf_ra_ops; 50extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
51extern const struct xfs_buf_ops xfs_dquot_buf_ops; 51extern const struct xfs_buf_ops xfs_dquot_buf_ops;
52extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
52extern const struct xfs_buf_ops xfs_sb_buf_ops; 53extern const struct xfs_buf_ops xfs_sb_buf_ops;
53extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops; 54extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
54extern const struct xfs_buf_ops xfs_symlink_buf_ops; 55extern const struct xfs_buf_ops xfs_symlink_buf_ops;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 29e7e5dd5178..379c089fb051 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -1917,6 +1917,7 @@ xfs_vm_readpage(
1917 struct file *unused, 1917 struct file *unused,
1918 struct page *page) 1918 struct page *page)
1919{ 1919{
1920 trace_xfs_vm_readpage(page->mapping->host, 1);
1920 return mpage_readpage(page, xfs_get_blocks); 1921 return mpage_readpage(page, xfs_get_blocks);
1921} 1922}
1922 1923
@@ -1927,6 +1928,7 @@ xfs_vm_readpages(
1927 struct list_head *pages, 1928 struct list_head *pages,
1928 unsigned nr_pages) 1929 unsigned nr_pages)
1929{ 1930{
1931 trace_xfs_vm_readpages(mapping->host, nr_pages);
1930 return mpage_readpages(mapping, pages, nr_pages, xfs_get_blocks); 1932 return mpage_readpages(mapping, pages, nr_pages, xfs_get_blocks);
1931} 1933}
1932 1934
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index dbae6490a79a..45ec9e40150c 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -91,32 +91,32 @@ xfs_zero_extent(
91 * last due to locking considerations. We never free any extents in 91 * last due to locking considerations. We never free any extents in
92 * the first transaction. 92 * the first transaction.
93 * 93 *
94 * Return 1 if the given transaction was committed and a new one 94 * If an inode *ip is provided, rejoin it to the transaction if
95 * started, and 0 otherwise in the committed parameter. 95 * the transaction was committed.
96 */ 96 */
97int /* error */ 97int /* error */
98xfs_bmap_finish( 98xfs_bmap_finish(
99 struct xfs_trans **tp, /* transaction pointer addr */ 99 struct xfs_trans **tp, /* transaction pointer addr */
100 struct xfs_bmap_free *flist, /* i/o: list extents to free */ 100 struct xfs_bmap_free *flist, /* i/o: list extents to free */
101 int *committed)/* xact committed or not */ 101 struct xfs_inode *ip)
102{ 102{
103 struct xfs_efd_log_item *efd; /* extent free data */ 103 struct xfs_efd_log_item *efd; /* extent free data */
104 struct xfs_efi_log_item *efi; /* extent free intention */ 104 struct xfs_efi_log_item *efi; /* extent free intention */
105 int error; /* error return value */ 105 int error; /* error return value */
106 int committed;/* xact committed or not */
106 struct xfs_bmap_free_item *free; /* free extent item */ 107 struct xfs_bmap_free_item *free; /* free extent item */
107 struct xfs_bmap_free_item *next; /* next item on free list */ 108 struct xfs_bmap_free_item *next; /* next item on free list */
108 109
109 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); 110 ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES);
110 if (flist->xbf_count == 0) { 111 if (flist->xbf_count == 0)
111 *committed = 0;
112 return 0; 112 return 0;
113 } 113
114 efi = xfs_trans_get_efi(*tp, flist->xbf_count); 114 efi = xfs_trans_get_efi(*tp, flist->xbf_count);
115 for (free = flist->xbf_first; free; free = free->xbfi_next) 115 for (free = flist->xbf_first; free; free = free->xbfi_next)
116 xfs_trans_log_efi_extent(*tp, efi, free->xbfi_startblock, 116 xfs_trans_log_efi_extent(*tp, efi, free->xbfi_startblock,
117 free->xbfi_blockcount); 117 free->xbfi_blockcount);
118 118
119 error = __xfs_trans_roll(tp, NULL, committed); 119 error = __xfs_trans_roll(tp, ip, &committed);
120 if (error) { 120 if (error) {
121 /* 121 /*
122 * If the transaction was committed, drop the EFD reference 122 * If the transaction was committed, drop the EFD reference
@@ -128,16 +128,13 @@ xfs_bmap_finish(
128 * transaction so we should return committed=1 even though we're 128 * transaction so we should return committed=1 even though we're
129 * returning an error. 129 * returning an error.
130 */ 130 */
131 if (*committed) { 131 if (committed) {
132 xfs_efi_release(efi); 132 xfs_efi_release(efi);
133 xfs_force_shutdown((*tp)->t_mountp, 133 xfs_force_shutdown((*tp)->t_mountp,
134 (error == -EFSCORRUPTED) ? 134 (error == -EFSCORRUPTED) ?
135 SHUTDOWN_CORRUPT_INCORE : 135 SHUTDOWN_CORRUPT_INCORE :
136 SHUTDOWN_META_IO_ERROR); 136 SHUTDOWN_META_IO_ERROR);
137 } else {
138 *committed = 1;
139 } 137 }
140
141 return error; 138 return error;
142 } 139 }
143 140
@@ -969,7 +966,6 @@ xfs_alloc_file_space(
969 xfs_bmbt_irec_t imaps[1], *imapp; 966 xfs_bmbt_irec_t imaps[1], *imapp;
970 xfs_bmap_free_t free_list; 967 xfs_bmap_free_t free_list;
971 uint qblocks, resblks, resrtextents; 968 uint qblocks, resblks, resrtextents;
972 int committed;
973 int error; 969 int error;
974 970
975 trace_xfs_alloc_file_space(ip); 971 trace_xfs_alloc_file_space(ip);
@@ -1064,23 +1060,20 @@ xfs_alloc_file_space(
1064 error = xfs_bmapi_write(tp, ip, startoffset_fsb, 1060 error = xfs_bmapi_write(tp, ip, startoffset_fsb,
1065 allocatesize_fsb, alloc_type, &firstfsb, 1061 allocatesize_fsb, alloc_type, &firstfsb,
1066 resblks, imapp, &nimaps, &free_list); 1062 resblks, imapp, &nimaps, &free_list);
1067 if (error) { 1063 if (error)
1068 goto error0; 1064 goto error0;
1069 }
1070 1065
1071 /* 1066 /*
1072 * Complete the transaction 1067 * Complete the transaction
1073 */ 1068 */
1074 error = xfs_bmap_finish(&tp, &free_list, &committed); 1069 error = xfs_bmap_finish(&tp, &free_list, NULL);
1075 if (error) { 1070 if (error)
1076 goto error0; 1071 goto error0;
1077 }
1078 1072
1079 error = xfs_trans_commit(tp); 1073 error = xfs_trans_commit(tp);
1080 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1074 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1081 if (error) { 1075 if (error)
1082 break; 1076 break;
1083 }
1084 1077
1085 allocated_fsb = imapp->br_blockcount; 1078 allocated_fsb = imapp->br_blockcount;
1086 1079
@@ -1206,7 +1199,6 @@ xfs_free_file_space(
1206 xfs_off_t offset, 1199 xfs_off_t offset,
1207 xfs_off_t len) 1200 xfs_off_t len)
1208{ 1201{
1209 int committed;
1210 int done; 1202 int done;
1211 xfs_fileoff_t endoffset_fsb; 1203 xfs_fileoff_t endoffset_fsb;
1212 int error; 1204 int error;
@@ -1346,17 +1338,15 @@ xfs_free_file_space(
1346 error = xfs_bunmapi(tp, ip, startoffset_fsb, 1338 error = xfs_bunmapi(tp, ip, startoffset_fsb,
1347 endoffset_fsb - startoffset_fsb, 1339 endoffset_fsb - startoffset_fsb,
1348 0, 2, &firstfsb, &free_list, &done); 1340 0, 2, &firstfsb, &free_list, &done);
1349 if (error) { 1341 if (error)
1350 goto error0; 1342 goto error0;
1351 }
1352 1343
1353 /* 1344 /*
1354 * complete the transaction 1345 * complete the transaction
1355 */ 1346 */
1356 error = xfs_bmap_finish(&tp, &free_list, &committed); 1347 error = xfs_bmap_finish(&tp, &free_list, NULL);
1357 if (error) { 1348 if (error)
1358 goto error0; 1349 goto error0;
1359 }
1360 1350
1361 error = xfs_trans_commit(tp); 1351 error = xfs_trans_commit(tp);
1362 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1352 xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -1434,7 +1424,6 @@ xfs_shift_file_space(
1434 int error; 1424 int error;
1435 struct xfs_bmap_free free_list; 1425 struct xfs_bmap_free free_list;
1436 xfs_fsblock_t first_block; 1426 xfs_fsblock_t first_block;
1437 int committed;
1438 xfs_fileoff_t stop_fsb; 1427 xfs_fileoff_t stop_fsb;
1439 xfs_fileoff_t next_fsb; 1428 xfs_fileoff_t next_fsb;
1440 xfs_fileoff_t shift_fsb; 1429 xfs_fileoff_t shift_fsb;
@@ -1526,7 +1515,7 @@ xfs_shift_file_space(
1526 if (error) 1515 if (error)
1527 goto out_bmap_cancel; 1516 goto out_bmap_cancel;
1528 1517
1529 error = xfs_bmap_finish(&tp, &free_list, &committed); 1518 error = xfs_bmap_finish(&tp, &free_list, NULL);
1530 if (error) 1519 if (error)
1531 goto out_bmap_cancel; 1520 goto out_bmap_cancel;
1532 1521
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 45a8ea7cfdb2..ae86b16f9025 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -604,6 +604,13 @@ found:
604 } 604 }
605 } 605 }
606 606
607 /*
608 * Clear b_error if this is a lookup from a caller that doesn't expect
609 * valid data to be found in the buffer.
610 */
611 if (!(flags & XBF_READ))
612 xfs_buf_ioerror(bp, 0);
613
607 XFS_STATS_INC(target->bt_mount, xb_get); 614 XFS_STATS_INC(target->bt_mount, xb_get);
608 trace_xfs_buf_get(bp, flags, _RET_IP_); 615 trace_xfs_buf_get(bp, flags, _RET_IP_);
609 return bp; 616 return bp;
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 7ac6c5c586cb..9c44d38dcd1f 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -306,7 +306,7 @@ xfs_qm_dqalloc(
306 xfs_fsblock_t firstblock; 306 xfs_fsblock_t firstblock;
307 xfs_bmap_free_t flist; 307 xfs_bmap_free_t flist;
308 xfs_bmbt_irec_t map; 308 xfs_bmbt_irec_t map;
309 int nmaps, error, committed; 309 int nmaps, error;
310 xfs_buf_t *bp; 310 xfs_buf_t *bp;
311 xfs_trans_t *tp = *tpp; 311 xfs_trans_t *tp = *tpp;
312 312
@@ -379,11 +379,12 @@ xfs_qm_dqalloc(
379 379
380 xfs_trans_bhold(tp, bp); 380 xfs_trans_bhold(tp, bp);
381 381
382 if ((error = xfs_bmap_finish(tpp, &flist, &committed))) { 382 error = xfs_bmap_finish(tpp, &flist, NULL);
383 if (error)
383 goto error1; 384 goto error1;
384 }
385 385
386 if (committed) { 386 /* Transaction was committed? */
387 if (*tpp != tp) {
387 tp = *tpp; 388 tp = *tpp;
388 xfs_trans_bjoin(tp, bp); 389 xfs_trans_bjoin(tp, bp);
389 } else { 390 } else {
@@ -393,9 +394,9 @@ xfs_qm_dqalloc(
393 *O_bpp = bp; 394 *O_bpp = bp;
394 return 0; 395 return 0;
395 396
396 error1: 397error1:
397 xfs_bmap_cancel(&flist); 398 xfs_bmap_cancel(&flist);
398 error0: 399error0:
399 xfs_iunlock(quotip, XFS_ILOCK_EXCL); 400 xfs_iunlock(quotip, XFS_ILOCK_EXCL);
400 401
401 return error; 402 return error;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 8ee393996b7d..ae3758a90ed6 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1143,7 +1143,6 @@ xfs_create(
1143 xfs_bmap_free_t free_list; 1143 xfs_bmap_free_t free_list;
1144 xfs_fsblock_t first_block; 1144 xfs_fsblock_t first_block;
1145 bool unlock_dp_on_error = false; 1145 bool unlock_dp_on_error = false;
1146 int committed;
1147 prid_t prid; 1146 prid_t prid;
1148 struct xfs_dquot *udqp = NULL; 1147 struct xfs_dquot *udqp = NULL;
1149 struct xfs_dquot *gdqp = NULL; 1148 struct xfs_dquot *gdqp = NULL;
@@ -1226,7 +1225,7 @@ xfs_create(
1226 * pointing to itself. 1225 * pointing to itself.
1227 */ 1226 */
1228 error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, 1227 error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev,
1229 prid, resblks > 0, &ip, &committed); 1228 prid, resblks > 0, &ip, NULL);
1230 if (error) 1229 if (error)
1231 goto out_trans_cancel; 1230 goto out_trans_cancel;
1232 1231
@@ -1275,7 +1274,7 @@ xfs_create(
1275 */ 1274 */
1276 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); 1275 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp);
1277 1276
1278 error = xfs_bmap_finish(&tp, &free_list, &committed); 1277 error = xfs_bmap_finish(&tp, &free_list, NULL);
1279 if (error) 1278 if (error)
1280 goto out_bmap_cancel; 1279 goto out_bmap_cancel;
1281 1280
@@ -1427,7 +1426,6 @@ xfs_link(
1427 int error; 1426 int error;
1428 xfs_bmap_free_t free_list; 1427 xfs_bmap_free_t free_list;
1429 xfs_fsblock_t first_block; 1428 xfs_fsblock_t first_block;
1430 int committed;
1431 int resblks; 1429 int resblks;
1432 1430
1433 trace_xfs_link(tdp, target_name); 1431 trace_xfs_link(tdp, target_name);
@@ -1502,11 +1500,10 @@ xfs_link(
1502 * link transaction goes to disk before returning to 1500 * link transaction goes to disk before returning to
1503 * the user. 1501 * the user.
1504 */ 1502 */
1505 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) { 1503 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
1506 xfs_trans_set_sync(tp); 1504 xfs_trans_set_sync(tp);
1507 }
1508 1505
1509 error = xfs_bmap_finish (&tp, &free_list, &committed); 1506 error = xfs_bmap_finish(&tp, &free_list, NULL);
1510 if (error) { 1507 if (error) {
1511 xfs_bmap_cancel(&free_list); 1508 xfs_bmap_cancel(&free_list);
1512 goto error_return; 1509 goto error_return;
@@ -1555,7 +1552,6 @@ xfs_itruncate_extents(
1555 xfs_fileoff_t first_unmap_block; 1552 xfs_fileoff_t first_unmap_block;
1556 xfs_fileoff_t last_block; 1553 xfs_fileoff_t last_block;
1557 xfs_filblks_t unmap_len; 1554 xfs_filblks_t unmap_len;
1558 int committed;
1559 int error = 0; 1555 int error = 0;
1560 int done = 0; 1556 int done = 0;
1561 1557
@@ -1601,9 +1597,7 @@ xfs_itruncate_extents(
1601 * Duplicate the transaction that has the permanent 1597 * Duplicate the transaction that has the permanent
1602 * reservation and commit the old transaction. 1598 * reservation and commit the old transaction.
1603 */ 1599 */
1604 error = xfs_bmap_finish(&tp, &free_list, &committed); 1600 error = xfs_bmap_finish(&tp, &free_list, ip);
1605 if (committed)
1606 xfs_trans_ijoin(tp, ip, 0);
1607 if (error) 1601 if (error)
1608 goto out_bmap_cancel; 1602 goto out_bmap_cancel;
1609 1603
@@ -1774,7 +1768,6 @@ xfs_inactive_ifree(
1774{ 1768{
1775 xfs_bmap_free_t free_list; 1769 xfs_bmap_free_t free_list;
1776 xfs_fsblock_t first_block; 1770 xfs_fsblock_t first_block;
1777 int committed;
1778 struct xfs_mount *mp = ip->i_mount; 1771 struct xfs_mount *mp = ip->i_mount;
1779 struct xfs_trans *tp; 1772 struct xfs_trans *tp;
1780 int error; 1773 int error;
@@ -1841,7 +1834,7 @@ xfs_inactive_ifree(
1841 * Just ignore errors at this point. There is nothing we can do except 1834 * Just ignore errors at this point. There is nothing we can do except
1842 * to try to keep going. Make sure it's not a silent error. 1835 * to try to keep going. Make sure it's not a silent error.
1843 */ 1836 */
1844 error = xfs_bmap_finish(&tp, &free_list, &committed); 1837 error = xfs_bmap_finish(&tp, &free_list, NULL);
1845 if (error) { 1838 if (error) {
1846 xfs_notice(mp, "%s: xfs_bmap_finish returned error %d", 1839 xfs_notice(mp, "%s: xfs_bmap_finish returned error %d",
1847 __func__, error); 1840 __func__, error);
@@ -2523,7 +2516,6 @@ xfs_remove(
2523 int error = 0; 2516 int error = 0;
2524 xfs_bmap_free_t free_list; 2517 xfs_bmap_free_t free_list;
2525 xfs_fsblock_t first_block; 2518 xfs_fsblock_t first_block;
2526 int committed;
2527 uint resblks; 2519 uint resblks;
2528 2520
2529 trace_xfs_remove(dp, name); 2521 trace_xfs_remove(dp, name);
@@ -2624,7 +2616,7 @@ xfs_remove(
2624 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) 2616 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
2625 xfs_trans_set_sync(tp); 2617 xfs_trans_set_sync(tp);
2626 2618
2627 error = xfs_bmap_finish(&tp, &free_list, &committed); 2619 error = xfs_bmap_finish(&tp, &free_list, NULL);
2628 if (error) 2620 if (error)
2629 goto out_bmap_cancel; 2621 goto out_bmap_cancel;
2630 2622
@@ -2701,7 +2693,6 @@ xfs_finish_rename(
2701 struct xfs_trans *tp, 2693 struct xfs_trans *tp,
2702 struct xfs_bmap_free *free_list) 2694 struct xfs_bmap_free *free_list)
2703{ 2695{
2704 int committed = 0;
2705 int error; 2696 int error;
2706 2697
2707 /* 2698 /*
@@ -2711,7 +2702,7 @@ xfs_finish_rename(
2711 if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) 2702 if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
2712 xfs_trans_set_sync(tp); 2703 xfs_trans_set_sync(tp);
2713 2704
2714 error = xfs_bmap_finish(&tp, free_list, &committed); 2705 error = xfs_bmap_finish(&tp, free_list, NULL);
2715 if (error) { 2706 if (error) {
2716 xfs_bmap_cancel(free_list); 2707 xfs_bmap_cancel(free_list);
2717 xfs_trans_cancel(tp); 2708 xfs_trans_cancel(tp);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 9ed146b96856..d81bdc080370 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -129,7 +129,6 @@ xfs_iomap_write_direct(
129 xfs_trans_t *tp; 129 xfs_trans_t *tp;
130 xfs_bmap_free_t free_list; 130 xfs_bmap_free_t free_list;
131 uint qblocks, resblks, resrtextents; 131 uint qblocks, resblks, resrtextents;
132 int committed;
133 int error; 132 int error;
134 int lockmode; 133 int lockmode;
135 int bmapi_flags = XFS_BMAPI_PREALLOC; 134 int bmapi_flags = XFS_BMAPI_PREALLOC;
@@ -252,7 +251,7 @@ xfs_iomap_write_direct(
252 /* 251 /*
253 * Complete the transaction 252 * Complete the transaction
254 */ 253 */
255 error = xfs_bmap_finish(&tp, &free_list, &committed); 254 error = xfs_bmap_finish(&tp, &free_list, NULL);
256 if (error) 255 if (error)
257 goto out_bmap_cancel; 256 goto out_bmap_cancel;
258 257
@@ -698,7 +697,7 @@ xfs_iomap_write_allocate(
698 xfs_bmap_free_t free_list; 697 xfs_bmap_free_t free_list;
699 xfs_filblks_t count_fsb; 698 xfs_filblks_t count_fsb;
700 xfs_trans_t *tp; 699 xfs_trans_t *tp;
701 int nimaps, committed; 700 int nimaps;
702 int error = 0; 701 int error = 0;
703 int nres; 702 int nres;
704 703
@@ -799,7 +798,7 @@ xfs_iomap_write_allocate(
799 if (error) 798 if (error)
800 goto trans_cancel; 799 goto trans_cancel;
801 800
802 error = xfs_bmap_finish(&tp, &free_list, &committed); 801 error = xfs_bmap_finish(&tp, &free_list, NULL);
803 if (error) 802 if (error)
804 goto trans_cancel; 803 goto trans_cancel;
805 804
@@ -857,7 +856,6 @@ xfs_iomap_write_unwritten(
857 xfs_bmap_free_t free_list; 856 xfs_bmap_free_t free_list;
858 xfs_fsize_t i_size; 857 xfs_fsize_t i_size;
859 uint resblks; 858 uint resblks;
860 int committed;
861 int error; 859 int error;
862 860
863 trace_xfs_unwritten_convert(ip, offset, count); 861 trace_xfs_unwritten_convert(ip, offset, count);
@@ -929,7 +927,7 @@ xfs_iomap_write_unwritten(
929 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 927 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
930 } 928 }
931 929
932 error = xfs_bmap_finish(&tp, &free_list, &committed); 930 error = xfs_bmap_finish(&tp, &free_list, NULL);
933 if (error) 931 if (error)
934 goto error_on_bmapi_transaction; 932 goto error_on_bmapi_transaction;
935 933
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 26e67b4450cc..da37beb76f6e 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3521,6 +3521,7 @@ xlog_recover_dquot_ra_pass2(
3521 struct xfs_disk_dquot *recddq; 3521 struct xfs_disk_dquot *recddq;
3522 struct xfs_dq_logformat *dq_f; 3522 struct xfs_dq_logformat *dq_f;
3523 uint type; 3523 uint type;
3524 int len;
3524 3525
3525 3526
3526 if (mp->m_qflags == 0) 3527 if (mp->m_qflags == 0)
@@ -3541,8 +3542,12 @@ xlog_recover_dquot_ra_pass2(
3541 ASSERT(dq_f); 3542 ASSERT(dq_f);
3542 ASSERT(dq_f->qlf_len == 1); 3543 ASSERT(dq_f->qlf_len == 1);
3543 3544
3544 xfs_buf_readahead(mp->m_ddev_targp, dq_f->qlf_blkno, 3545 len = XFS_FSB_TO_BB(mp, dq_f->qlf_len);
3545 XFS_FSB_TO_BB(mp, dq_f->qlf_len), NULL); 3546 if (xlog_peek_buffer_cancelled(log, dq_f->qlf_blkno, len, 0))
3547 return;
3548
3549 xfs_buf_readahead(mp->m_ddev_targp, dq_f->qlf_blkno, len,
3550 &xfs_dquot_buf_ra_ops);
3546} 3551}
3547 3552
3548STATIC void 3553STATIC void
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index ab1bac6a3a1c..be02a68b2fe2 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -766,7 +766,6 @@ xfs_growfs_rt_alloc(
766{ 766{
767 xfs_fileoff_t bno; /* block number in file */ 767 xfs_fileoff_t bno; /* block number in file */
768 struct xfs_buf *bp; /* temporary buffer for zeroing */ 768 struct xfs_buf *bp; /* temporary buffer for zeroing */
769 int committed; /* transaction committed flag */
770 xfs_daddr_t d; /* disk block address */ 769 xfs_daddr_t d; /* disk block address */
771 int error; /* error return value */ 770 int error; /* error return value */
772 xfs_fsblock_t firstblock;/* first block allocated in xaction */ 771 xfs_fsblock_t firstblock;/* first block allocated in xaction */
@@ -811,7 +810,7 @@ xfs_growfs_rt_alloc(
811 /* 810 /*
812 * Free any blocks freed up in the transaction, then commit. 811 * Free any blocks freed up in the transaction, then commit.
813 */ 812 */
814 error = xfs_bmap_finish(&tp, &flist, &committed); 813 error = xfs_bmap_finish(&tp, &flist, NULL);
815 if (error) 814 if (error)
816 goto out_bmap_cancel; 815 goto out_bmap_cancel;
817 error = xfs_trans_commit(tp); 816 error = xfs_trans_commit(tp);
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 996481eeb491..b44284c1adda 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -178,7 +178,6 @@ xfs_symlink(
178 struct xfs_bmap_free free_list; 178 struct xfs_bmap_free free_list;
179 xfs_fsblock_t first_block; 179 xfs_fsblock_t first_block;
180 bool unlock_dp_on_error = false; 180 bool unlock_dp_on_error = false;
181 int committed;
182 xfs_fileoff_t first_fsb; 181 xfs_fileoff_t first_fsb;
183 xfs_filblks_t fs_blocks; 182 xfs_filblks_t fs_blocks;
184 int nmaps; 183 int nmaps;
@@ -387,7 +386,7 @@ xfs_symlink(
387 xfs_trans_set_sync(tp); 386 xfs_trans_set_sync(tp);
388 } 387 }
389 388
390 error = xfs_bmap_finish(&tp, &free_list, &committed); 389 error = xfs_bmap_finish(&tp, &free_list, NULL);
391 if (error) 390 if (error)
392 goto out_bmap_cancel; 391 goto out_bmap_cancel;
393 392
@@ -434,7 +433,6 @@ xfs_inactive_symlink_rmt(
434 struct xfs_inode *ip) 433 struct xfs_inode *ip)
435{ 434{
436 xfs_buf_t *bp; 435 xfs_buf_t *bp;
437 int committed;
438 int done; 436 int done;
439 int error; 437 int error;
440 xfs_fsblock_t first_block; 438 xfs_fsblock_t first_block;
@@ -510,16 +508,10 @@ xfs_inactive_symlink_rmt(
510 /* 508 /*
511 * Commit the first transaction. This logs the EFI and the inode. 509 * Commit the first transaction. This logs the EFI and the inode.
512 */ 510 */
513 error = xfs_bmap_finish(&tp, &free_list, &committed); 511 error = xfs_bmap_finish(&tp, &free_list, ip);
514 if (error) 512 if (error)
515 goto error_bmap_cancel; 513 goto error_bmap_cancel;
516 /* 514 /*
517 * The transaction must have been committed, since there were
518 * actually extents freed by xfs_bunmapi. See xfs_bmap_finish.
519 * The new tp has the extent freeing and EFDs.
520 */
521 ASSERT(committed);
522 /*
523 * The first xact was committed, so add the inode to the new one. 515 * The first xact was committed, so add the inode to the new one.
524 * Mark it dirty so it will be logged and moved forward in the log as 516 * Mark it dirty so it will be logged and moved forward in the log as
525 * part of every commit. 517 * part of every commit.
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 877079eb0f8f..391d797cb53f 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1222,6 +1222,32 @@ DEFINE_PAGE_EVENT(xfs_writepage);
1222DEFINE_PAGE_EVENT(xfs_releasepage); 1222DEFINE_PAGE_EVENT(xfs_releasepage);
1223DEFINE_PAGE_EVENT(xfs_invalidatepage); 1223DEFINE_PAGE_EVENT(xfs_invalidatepage);
1224 1224
1225DECLARE_EVENT_CLASS(xfs_readpage_class,
1226 TP_PROTO(struct inode *inode, int nr_pages),
1227 TP_ARGS(inode, nr_pages),
1228 TP_STRUCT__entry(
1229 __field(dev_t, dev)
1230 __field(xfs_ino_t, ino)
1231 __field(int, nr_pages)
1232 ),
1233 TP_fast_assign(
1234 __entry->dev = inode->i_sb->s_dev;
1235 __entry->ino = inode->i_ino;
1236 __entry->nr_pages = nr_pages;
1237 ),
1238 TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
1239 MAJOR(__entry->dev), MINOR(__entry->dev),
1240 __entry->ino,
1241 __entry->nr_pages)
1242)
1243
1244#define DEFINE_READPAGE_EVENT(name) \
1245DEFINE_EVENT(xfs_readpage_class, name, \
1246 TP_PROTO(struct inode *inode, int nr_pages), \
1247 TP_ARGS(inode, nr_pages))
1248DEFINE_READPAGE_EVENT(xfs_vm_readpage);
1249DEFINE_READPAGE_EVENT(xfs_vm_readpages);
1250
1225DECLARE_EVENT_CLASS(xfs_imap_class, 1251DECLARE_EVENT_CLASS(xfs_imap_class,
1226 TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, 1252 TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count,
1227 int type, struct xfs_bmbt_irec *irec), 1253 int type, struct xfs_bmbt_irec *irec),