aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_node.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:20:54 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:20:54 -0400
commitbc85178a7668db835666c6a5bd53436eebfc94b1 (patch)
treea66a6163b3d24a5cb2d31c33593abddf5563f27f /fs/xfs/xfs_dir2_node.c
parent53f82db003900822ff828b792b1690a53a57c028 (diff)
xfs: remove mp->m_dir_geo from directory logging
We don't pass the xfs_da_args or the geometry all the way down to the directory buffer logging code, hence we have to use mp->m_dir_geo here. Fix this to use the geometry passed via the xfs_da_args, and convert all the directory logging functions for consistency. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/xfs_dir2_node.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index eff6b8d67dab..65df8cbedbb7 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -241,8 +241,7 @@ xfs_dir3_free_get_buf(
241 */ 241 */
242STATIC void 242STATIC void
243xfs_dir2_free_log_bests( 243xfs_dir2_free_log_bests(
244 struct xfs_trans *tp, 244 struct xfs_da_args *args,
245 struct xfs_inode *dp,
246 struct xfs_buf *bp, 245 struct xfs_buf *bp,
247 int first, /* first entry to log */ 246 int first, /* first entry to log */
248 int last) /* last entry to log */ 247 int last) /* last entry to log */
@@ -251,10 +250,10 @@ xfs_dir2_free_log_bests(
251 __be16 *bests; 250 __be16 *bests;
252 251
253 free = bp->b_addr; 252 free = bp->b_addr;
254 bests = dp->d_ops->free_bests_p(free); 253 bests = args->dp->d_ops->free_bests_p(free);
255 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 254 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
256 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 255 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
257 xfs_trans_log_buf(tp, bp, 256 xfs_trans_log_buf(args->trans, bp,
258 (uint)((char *)&bests[first] - (char *)free), 257 (uint)((char *)&bests[first] - (char *)free),
259 (uint)((char *)&bests[last] - (char *)free + 258 (uint)((char *)&bests[last] - (char *)free +
260 sizeof(bests[0]) - 1)); 259 sizeof(bests[0]) - 1));
@@ -265,8 +264,7 @@ xfs_dir2_free_log_bests(
265 */ 264 */
266static void 265static void
267xfs_dir2_free_log_header( 266xfs_dir2_free_log_header(
268 struct xfs_trans *tp, 267 struct xfs_da_args *args,
269 struct xfs_inode *dp,
270 struct xfs_buf *bp) 268 struct xfs_buf *bp)
271{ 269{
272#ifdef DEBUG 270#ifdef DEBUG
@@ -276,7 +274,8 @@ xfs_dir2_free_log_header(
276 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 274 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
277 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 275 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
278#endif 276#endif
279 xfs_trans_log_buf(tp, bp, 0, dp->d_ops->free_hdr_size - 1); 277 xfs_trans_log_buf(args->trans, bp, 0,
278 args->dp->d_ops->free_hdr_size - 1);
280} 279}
281 280
282/* 281/*
@@ -350,8 +349,8 @@ xfs_dir2_leaf_to_node(
350 freehdr.nvalid = be32_to_cpu(ltp->bestcount); 349 freehdr.nvalid = be32_to_cpu(ltp->bestcount);
351 350
352 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 351 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
353 xfs_dir2_free_log_bests(tp, dp, fbp, 0, freehdr.nvalid - 1); 352 xfs_dir2_free_log_bests(args, fbp, 0, freehdr.nvalid - 1);
354 xfs_dir2_free_log_header(tp, dp, fbp); 353 xfs_dir2_free_log_header(args, fbp);
355 354
356 /* 355 /*
357 * Converting the leaf to a leafnode is just a matter of changing the 356 * Converting the leaf to a leafnode is just a matter of changing the
@@ -365,7 +364,7 @@ xfs_dir2_leaf_to_node(
365 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); 364 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
366 lbp->b_ops = &xfs_dir3_leafn_buf_ops; 365 lbp->b_ops = &xfs_dir3_leafn_buf_ops;
367 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF); 366 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF);
368 xfs_dir3_leaf_log_header(tp, dp, lbp); 367 xfs_dir3_leaf_log_header(args, lbp);
369 xfs_dir3_leaf_check(dp, lbp); 368 xfs_dir3_leaf_check(dp, lbp);
370 return 0; 369 return 0;
371} 370}
@@ -455,8 +454,8 @@ xfs_dir2_leafn_add(
455 args->blkno, args->index)); 454 args->blkno, args->index));
456 455
457 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 456 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
458 xfs_dir3_leaf_log_header(tp, dp, bp); 457 xfs_dir3_leaf_log_header(args, bp);
459 xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh); 458 xfs_dir3_leaf_log_ents(args, bp, lfloglow, lfloghigh);
460 xfs_dir3_leaf_check(dp, bp); 459 xfs_dir3_leaf_check(dp, bp);
461 return 0; 460 return 0;
462} 461}
@@ -851,7 +850,6 @@ xfs_dir3_leafn_moveents(
851 int start_d,/* destination leaf index */ 850 int start_d,/* destination leaf index */
852 int count) /* count of leaves to copy */ 851 int count) /* count of leaves to copy */
853{ 852{
854 struct xfs_trans *tp = args->trans;
855 int stale; /* count stale leaves copied */ 853 int stale; /* count stale leaves copied */
856 854
857 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count); 855 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count);
@@ -870,7 +868,7 @@ xfs_dir3_leafn_moveents(
870 if (start_d < dhdr->count) { 868 if (start_d < dhdr->count) {
871 memmove(&dents[start_d + count], &dents[start_d], 869 memmove(&dents[start_d + count], &dents[start_d],
872 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t)); 870 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t));
873 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, start_d + count, 871 xfs_dir3_leaf_log_ents(args, bp_d, start_d + count,
874 count + dhdr->count - 1); 872 count + dhdr->count - 1);
875 } 873 }
876 /* 874 /*
@@ -892,8 +890,7 @@ xfs_dir3_leafn_moveents(
892 */ 890 */
893 memcpy(&dents[start_d], &sents[start_s], 891 memcpy(&dents[start_d], &sents[start_s],
894 count * sizeof(xfs_dir2_leaf_entry_t)); 892 count * sizeof(xfs_dir2_leaf_entry_t));
895 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, 893 xfs_dir3_leaf_log_ents(args, bp_d, start_d, start_d + count - 1);
896 start_d, start_d + count - 1);
897 894
898 /* 895 /*
899 * If there are source entries after the ones we copied, 896 * If there are source entries after the ones we copied,
@@ -902,8 +899,7 @@ xfs_dir3_leafn_moveents(
902 if (start_s + count < shdr->count) { 899 if (start_s + count < shdr->count) {
903 memmove(&sents[start_s], &sents[start_s + count], 900 memmove(&sents[start_s], &sents[start_s + count],
904 count * sizeof(xfs_dir2_leaf_entry_t)); 901 count * sizeof(xfs_dir2_leaf_entry_t));
905 xfs_dir3_leaf_log_ents(tp, args->dp, bp_s, 902 xfs_dir3_leaf_log_ents(args, bp_s, start_s, start_s + count - 1);
906 start_s, start_s + count - 1);
907 } 903 }
908 904
909 /* 905 /*
@@ -1039,8 +1035,8 @@ xfs_dir2_leafn_rebalance(
1039 /* log the changes made when moving the entries */ 1035 /* log the changes made when moving the entries */
1040 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1); 1036 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1);
1041 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2); 1037 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2);
1042 xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp); 1038 xfs_dir3_leaf_log_header(args, blk1->bp);
1043 xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp); 1039 xfs_dir3_leaf_log_header(args, blk2->bp);
1044 1040
1045 xfs_dir3_leaf_check(dp, blk1->bp); 1041 xfs_dir3_leaf_check(dp, blk1->bp);
1046 xfs_dir3_leaf_check(dp, blk2->bp); 1042 xfs_dir3_leaf_check(dp, blk2->bp);
@@ -1083,7 +1079,6 @@ xfs_dir3_data_block_free(
1083 struct xfs_buf *fbp, 1079 struct xfs_buf *fbp,
1084 int longest) 1080 int longest)
1085{ 1081{
1086 struct xfs_trans *tp = args->trans;
1087 int logfree = 0; 1082 int logfree = 0;
1088 __be16 *bests; 1083 __be16 *bests;
1089 struct xfs_dir3_icfree_hdr freehdr; 1084 struct xfs_dir3_icfree_hdr freehdr;
@@ -1097,7 +1092,7 @@ xfs_dir3_data_block_free(
1097 * value. 1092 * value.
1098 */ 1093 */
1099 bests[findex] = cpu_to_be16(longest); 1094 bests[findex] = cpu_to_be16(longest);
1100 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1095 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1101 return 0; 1096 return 0;
1102 } 1097 }
1103 1098
@@ -1125,7 +1120,7 @@ xfs_dir3_data_block_free(
1125 } 1120 }
1126 1121
1127 dp->d_ops->free_hdr_to_disk(free, &freehdr); 1122 dp->d_ops->free_hdr_to_disk(free, &freehdr);
1128 xfs_dir2_free_log_header(tp, dp, fbp); 1123 xfs_dir2_free_log_header(args, fbp);
1129 1124
1130 /* 1125 /*
1131 * If there are no useful entries left in the block, get rid of the 1126 * If there are no useful entries left in the block, get rid of the
@@ -1149,7 +1144,7 @@ xfs_dir3_data_block_free(
1149 1144
1150 /* Log the free entry that changed, unless we got rid of it. */ 1145 /* Log the free entry that changed, unless we got rid of it. */
1151 if (logfree) 1146 if (logfree)
1152 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1147 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1153 return 0; 1148 return 0;
1154} 1149}
1155 1150
@@ -1211,10 +1206,10 @@ xfs_dir2_leafn_remove(
1211 */ 1206 */
1212 leafhdr.stale++; 1207 leafhdr.stale++;
1213 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 1208 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1214 xfs_dir3_leaf_log_header(tp, dp, bp); 1209 xfs_dir3_leaf_log_header(args, bp);
1215 1210
1216 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1211 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
1217 xfs_dir3_leaf_log_ents(tp, dp, bp, index, index); 1212 xfs_dir3_leaf_log_ents(args, bp, index, index);
1218 1213
1219 /* 1214 /*
1220 * Make the data entry free. Keep track of the longest freespace 1215 * Make the data entry free. Keep track of the longest freespace
@@ -1226,7 +1221,7 @@ xfs_dir2_leafn_remove(
1226 bf = dp->d_ops->data_bestfree_p(hdr); 1221 bf = dp->d_ops->data_bestfree_p(hdr);
1227 longest = be16_to_cpu(bf[0].length); 1222 longest = be16_to_cpu(bf[0].length);
1228 needlog = needscan = 0; 1223 needlog = needscan = 0;
1229 xfs_dir2_data_make_free(tp, dp, dbp, off, 1224 xfs_dir2_data_make_free(args, dbp, off,
1230 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); 1225 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
1231 /* 1226 /*
1232 * Rescan the data block freespaces for bestfree. 1227 * Rescan the data block freespaces for bestfree.
@@ -1235,7 +1230,7 @@ xfs_dir2_leafn_remove(
1235 if (needscan) 1230 if (needscan)
1236 xfs_dir2_data_freescan(dp, hdr, &needlog); 1231 xfs_dir2_data_freescan(dp, hdr, &needlog);
1237 if (needlog) 1232 if (needlog)
1238 xfs_dir2_data_log_header(tp, dp, dbp); 1233 xfs_dir2_data_log_header(args, dbp);
1239 xfs_dir3_data_check(dp, dbp); 1234 xfs_dir3_data_check(dp, dbp);
1240 /* 1235 /*
1241 * If the longest data block freespace changes, need to update 1236 * If the longest data block freespace changes, need to update
@@ -1569,8 +1564,8 @@ xfs_dir2_leafn_unbalance(
1569 /* log the changes made when moving the entries */ 1564 /* log the changes made when moving the entries */
1570 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr); 1565 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr);
1571 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr); 1566 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr);
1572 xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp); 1567 xfs_dir3_leaf_log_header(args, save_blk->bp);
1573 xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp); 1568 xfs_dir3_leaf_log_header(args, drop_blk->bp);
1574 1569
1575 xfs_dir3_leaf_check(dp, save_blk->bp); 1570 xfs_dir3_leaf_check(dp, save_blk->bp);
1576 xfs_dir3_leaf_check(dp, drop_blk->bp); 1571 xfs_dir3_leaf_check(dp, drop_blk->bp);
@@ -1931,7 +1926,7 @@ xfs_dir2_node_addname_int(
1931 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) { 1926 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) {
1932 freehdr.nused++; 1927 freehdr.nused++;
1933 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 1928 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
1934 xfs_dir2_free_log_header(tp, dp, fbp); 1929 xfs_dir2_free_log_header(args, fbp);
1935 } 1930 }
1936 /* 1931 /*
1937 * Update the real value in the table. 1932 * Update the real value in the table.
@@ -1975,7 +1970,7 @@ xfs_dir2_node_addname_int(
1975 /* 1970 /*
1976 * Mark the first part of the unused space, inuse for us. 1971 * Mark the first part of the unused space, inuse for us.
1977 */ 1972 */
1978 xfs_dir2_data_use_free(tp, dp, dbp, dup, 1973 xfs_dir2_data_use_free(args, dbp, dup,
1979 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, 1974 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
1980 &needlog, &needscan); 1975 &needlog, &needscan);
1981 /* 1976 /*
@@ -1988,7 +1983,7 @@ xfs_dir2_node_addname_int(
1988 dp->d_ops->data_put_ftype(dep, args->filetype); 1983 dp->d_ops->data_put_ftype(dep, args->filetype);
1989 tagp = dp->d_ops->data_entry_tag_p(dep); 1984 tagp = dp->d_ops->data_entry_tag_p(dep);
1990 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1985 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1991 xfs_dir2_data_log_entry(tp, dp, dbp, dep); 1986 xfs_dir2_data_log_entry(args, dbp, dep);
1992 /* 1987 /*
1993 * Rescan the block for bestfree if needed. 1988 * Rescan the block for bestfree if needed.
1994 */ 1989 */
@@ -1998,7 +1993,7 @@ xfs_dir2_node_addname_int(
1998 * Log the data block header if needed. 1993 * Log the data block header if needed.
1999 */ 1994 */
2000 if (needlog) 1995 if (needlog)
2001 xfs_dir2_data_log_header(tp, dp, dbp); 1996 xfs_dir2_data_log_header(args, dbp);
2002 /* 1997 /*
2003 * If the freespace entry is now wrong, update it. 1998 * If the freespace entry is now wrong, update it.
2004 */ 1999 */
@@ -2011,7 +2006,7 @@ xfs_dir2_node_addname_int(
2011 * Log the freespace entry if needed. 2006 * Log the freespace entry if needed.
2012 */ 2007 */
2013 if (logfree) 2008 if (logfree)
2014 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 2009 xfs_dir2_free_log_bests(args, fbp, findex, findex);
2015 /* 2010 /*
2016 * Return the data block and offset in args, then drop the data block. 2011 * Return the data block and offset in args, then drop the data block.
2017 */ 2012 */
@@ -2208,8 +2203,7 @@ xfs_dir2_node_replace(
2208 */ 2203 */
2209 dep->inumber = cpu_to_be64(inum); 2204 dep->inumber = cpu_to_be64(inum);
2210 args->dp->d_ops->data_put_ftype(dep, args->filetype); 2205 args->dp->d_ops->data_put_ftype(dep, args->filetype);
2211 xfs_dir2_data_log_entry(args->trans, args->dp, 2206 xfs_dir2_data_log_entry(args, state->extrablk.bp, dep);
2212 state->extrablk.bp, dep);
2213 rval = 0; 2207 rval = 0;
2214 } 2208 }
2215 /* 2209 /*