aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_extfree_item.c
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2005-06-23 06:26:22 -0400
committerAnton Altaparmakov <aia21@cantab.net>2005-06-23 06:26:22 -0400
commit3357d4c75f1fb67e7304998c4ad4e9a9fed66fa4 (patch)
treeceba46966a5a1112a05d257d8ecb25ae5eee95e0 /fs/xfs/xfs_extfree_item.c
parent364f6c717deef4a3ac4982e670fa9846b43cd060 (diff)
parentee98689be1b054897ff17655008c3048fe88be94 (diff)
Automatic merge with /usr/src/ntfs-2.6.git.
Diffstat (limited to 'fs/xfs/xfs_extfree_item.c')
-rw-r--r--fs/xfs/xfs_extfree_item.c126
1 files changed, 32 insertions, 94 deletions
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 5eafd5b63211..db7cbd1bc857 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -59,6 +59,18 @@ STATIC void xfs_efi_item_abort(xfs_efi_log_item_t *);
59STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *); 59STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *);
60 60
61 61
62void
63xfs_efi_item_free(xfs_efi_log_item_t *efip)
64{
65 int nexts = efip->efi_format.efi_nextents;
66
67 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
68 kmem_free(efip, sizeof(xfs_efi_log_item_t) +
69 (nexts - 1) * sizeof(xfs_extent_t));
70 } else {
71 kmem_zone_free(xfs_efi_zone, efip);
72 }
73}
62 74
63/* 75/*
64 * This returns the number of iovecs needed to log the given efi item. 76 * This returns the number of iovecs needed to log the given efi item.
@@ -120,8 +132,6 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip)
120STATIC void 132STATIC void
121xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale) 133xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
122{ 134{
123 int nexts;
124 int size;
125 xfs_mount_t *mp; 135 xfs_mount_t *mp;
126 SPLDECL(s); 136 SPLDECL(s);
127 137
@@ -132,21 +142,11 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
132 * xfs_trans_delete_ail() drops the AIL lock. 142 * xfs_trans_delete_ail() drops the AIL lock.
133 */ 143 */
134 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 144 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
135 145 xfs_efi_item_free(efip);
136 nexts = efip->efi_format.efi_nextents;
137 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
138 size = sizeof(xfs_efi_log_item_t);
139 size += (nexts - 1) * sizeof(xfs_extent_t);
140 kmem_free(efip, size);
141 } else {
142 kmem_zone_free(xfs_efi_zone, efip);
143 }
144 } else { 146 } else {
145 efip->efi_flags |= XFS_EFI_COMMITTED; 147 efip->efi_flags |= XFS_EFI_COMMITTED;
146 AIL_UNLOCK(mp, s); 148 AIL_UNLOCK(mp, s);
147 } 149 }
148
149 return;
150} 150}
151 151
152/* 152/*
@@ -159,8 +159,6 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
159STATIC void 159STATIC void
160xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp) 160xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
161{ 161{
162 int nexts;
163 int size;
164 xfs_mount_t *mp; 162 xfs_mount_t *mp;
165 xfs_log_item_desc_t *lidp; 163 xfs_log_item_desc_t *lidp;
166 SPLDECL(s); 164 SPLDECL(s);
@@ -178,23 +176,11 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
178 * xfs_trans_delete_ail() drops the AIL lock. 176 * xfs_trans_delete_ail() drops the AIL lock.
179 */ 177 */
180 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 178 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
181 /* 179 xfs_efi_item_free(efip);
182 * now free the item itself
183 */
184 nexts = efip->efi_format.efi_nextents;
185 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
186 size = sizeof(xfs_efi_log_item_t);
187 size += (nexts - 1) * sizeof(xfs_extent_t);
188 kmem_free(efip, size);
189 } else {
190 kmem_zone_free(xfs_efi_zone, efip);
191 }
192 } else { 180 } else {
193 efip->efi_flags |= XFS_EFI_COMMITTED; 181 efip->efi_flags |= XFS_EFI_COMMITTED;
194 AIL_UNLOCK(mp, s); 182 AIL_UNLOCK(mp, s);
195 } 183 }
196
197 return;
198} 184}
199 185
200/* 186/*
@@ -245,18 +231,7 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
245STATIC void 231STATIC void
246xfs_efi_item_abort(xfs_efi_log_item_t *efip) 232xfs_efi_item_abort(xfs_efi_log_item_t *efip)
247{ 233{
248 int nexts; 234 xfs_efi_item_free(efip);
249 int size;
250
251 nexts = efip->efi_format.efi_nextents;
252 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
253 size = sizeof(xfs_efi_log_item_t);
254 size += (nexts - 1) * sizeof(xfs_extent_t);
255 kmem_free(efip, size);
256 } else {
257 kmem_zone_free(xfs_efi_zone, efip);
258 }
259 return;
260} 235}
261 236
262/* 237/*
@@ -288,7 +263,7 @@ xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
288/* 263/*
289 * This is the ops vector shared by all efi log items. 264 * This is the ops vector shared by all efi log items.
290 */ 265 */
291struct xfs_item_ops xfs_efi_item_ops = { 266STATIC struct xfs_item_ops xfs_efi_item_ops = {
292 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size, 267 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size,
293 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 268 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
294 xfs_efi_item_format, 269 xfs_efi_item_format,
@@ -355,8 +330,6 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
355{ 330{
356 xfs_mount_t *mp; 331 xfs_mount_t *mp;
357 int extents_left; 332 int extents_left;
358 uint size;
359 int nexts;
360 SPLDECL(s); 333 SPLDECL(s);
361 334
362 mp = efip->efi_item.li_mountp; 335 mp = efip->efi_item.li_mountp;
@@ -372,20 +345,10 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
372 * xfs_trans_delete_ail() drops the AIL lock. 345 * xfs_trans_delete_ail() drops the AIL lock.
373 */ 346 */
374 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 347 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
348 xfs_efi_item_free(efip);
375 } else { 349 } else {
376 AIL_UNLOCK(mp, s); 350 AIL_UNLOCK(mp, s);
377 } 351 }
378
379 if (extents_left == 0) {
380 nexts = efip->efi_format.efi_nextents;
381 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
382 size = sizeof(xfs_efi_log_item_t);
383 size += (nexts - 1) * sizeof(xfs_extent_t);
384 kmem_free(efip, size);
385 } else {
386 kmem_zone_free(xfs_efi_zone, efip);
387 }
388 }
389} 352}
390 353
391/* 354/*
@@ -398,8 +361,6 @@ STATIC void
398xfs_efi_cancel( 361xfs_efi_cancel(
399 xfs_efi_log_item_t *efip) 362 xfs_efi_log_item_t *efip)
400{ 363{
401 int nexts;
402 int size;
403 xfs_mount_t *mp; 364 xfs_mount_t *mp;
404 SPLDECL(s); 365 SPLDECL(s);
405 366
@@ -410,26 +371,25 @@ xfs_efi_cancel(
410 * xfs_trans_delete_ail() drops the AIL lock. 371 * xfs_trans_delete_ail() drops the AIL lock.
411 */ 372 */
412 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 373 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
413 374 xfs_efi_item_free(efip);
414 nexts = efip->efi_format.efi_nextents;
415 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
416 size = sizeof(xfs_efi_log_item_t);
417 size += (nexts - 1) * sizeof(xfs_extent_t);
418 kmem_free(efip, size);
419 } else {
420 kmem_zone_free(xfs_efi_zone, efip);
421 }
422 } else { 375 } else {
423 efip->efi_flags |= XFS_EFI_CANCELED; 376 efip->efi_flags |= XFS_EFI_CANCELED;
424 AIL_UNLOCK(mp, s); 377 AIL_UNLOCK(mp, s);
425 } 378 }
426
427 return;
428} 379}
429 380
381STATIC void
382xfs_efd_item_free(xfs_efd_log_item_t *efdp)
383{
384 int nexts = efdp->efd_format.efd_nextents;
430 385
431 386 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
432 387 kmem_free(efdp, sizeof(xfs_efd_log_item_t) +
388 (nexts - 1) * sizeof(xfs_extent_t));
389 } else {
390 kmem_zone_free(xfs_efd_zone, efdp);
391 }
392}
433 393
434/* 394/*
435 * This returns the number of iovecs needed to log the given efd item. 395 * This returns the number of iovecs needed to log the given efd item.
@@ -533,9 +493,6 @@ xfs_efd_item_unlock(xfs_efd_log_item_t *efdp)
533STATIC xfs_lsn_t 493STATIC xfs_lsn_t
534xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) 494xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
535{ 495{
536 uint size;
537 int nexts;
538
539 /* 496 /*
540 * If we got a log I/O error, it's always the case that the LR with the 497 * If we got a log I/O error, it's always the case that the LR with the
541 * EFI got unpinned and freed before the EFD got aborted. 498 * EFI got unpinned and freed before the EFD got aborted.
@@ -543,15 +500,7 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
543 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) 500 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
544 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); 501 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
545 502
546 nexts = efdp->efd_format.efd_nextents; 503 xfs_efd_item_free(efdp);
547 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
548 size = sizeof(xfs_efd_log_item_t);
549 size += (nexts - 1) * sizeof(xfs_extent_t);
550 kmem_free(efdp, size);
551 } else {
552 kmem_zone_free(xfs_efd_zone, efdp);
553 }
554
555 return (xfs_lsn_t)-1; 504 return (xfs_lsn_t)-1;
556} 505}
557 506
@@ -565,9 +514,6 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
565STATIC void 514STATIC void
566xfs_efd_item_abort(xfs_efd_log_item_t *efdp) 515xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
567{ 516{
568 int nexts;
569 int size;
570
571 /* 517 /*
572 * If we got a log I/O error, it's always the case that the LR with the 518 * If we got a log I/O error, it's always the case that the LR with the
573 * EFI got unpinned and freed before the EFD got aborted. So don't 519 * EFI got unpinned and freed before the EFD got aborted. So don't
@@ -576,15 +522,7 @@ xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
576 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) 522 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
577 xfs_efi_cancel(efdp->efd_efip); 523 xfs_efi_cancel(efdp->efd_efip);
578 524
579 nexts = efdp->efd_format.efd_nextents; 525 xfs_efd_item_free(efdp);
580 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
581 size = sizeof(xfs_efd_log_item_t);
582 size += (nexts - 1) * sizeof(xfs_extent_t);
583 kmem_free(efdp, size);
584 } else {
585 kmem_zone_free(xfs_efd_zone, efdp);
586 }
587 return;
588} 526}
589 527
590/* 528/*
@@ -615,7 +553,7 @@ xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn)
615/* 553/*
616 * This is the ops vector shared by all efd log items. 554 * This is the ops vector shared by all efd log items.
617 */ 555 */
618struct xfs_item_ops xfs_efd_item_ops = { 556STATIC struct xfs_item_ops xfs_efd_item_ops = {
619 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size, 557 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size,
620 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 558 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
621 xfs_efd_item_format, 559 xfs_efd_item_format,