Commit 8e123850863366b738d6dfb9a84045018ff038fc

Authored by Dave Chinner
Committed by Alex Elder
1 parent 4aaf15d1aa

xfs: remove stale parameter from ->iop_unpin method

The staleness of a object being unpinned can be directly derived
from the object itself - there is no need to extract it from the
object then pass it as a parameter into IOP_UNPIN().

This means we can kill the XFS_LID_BUF_STALE flag - it is set,
checked and cleared in the same places XFS_BLI_STALE flag in the
xfs_buf_log_item so it is now redundant and hence safe to remove.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>

Showing 7 changed files with 39 additions and 52 deletions Side-by-side Diff

fs/xfs/quota/xfs_dquot_item.c
... ... @@ -107,8 +107,7 @@
107 107 /* ARGSUSED */
108 108 STATIC void
109 109 xfs_qm_dquot_logitem_unpin(
110   - xfs_dq_logitem_t *logitem,
111   - int stale)
  110 + xfs_dq_logitem_t *logitem)
112 111 {
113 112 xfs_dquot_t *dqp = logitem->qli_dquot;
114 113  
... ... @@ -123,7 +122,7 @@
123 122 xfs_dq_logitem_t *logitem,
124 123 xfs_trans_t *tp)
125 124 {
126   - xfs_qm_dquot_logitem_unpin(logitem, 0);
  125 + xfs_qm_dquot_logitem_unpin(logitem);
127 126 }
128 127  
129 128 /*
... ... @@ -329,8 +328,7 @@
329 328 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
330 329 xfs_qm_dquot_logitem_format,
331 330 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin,
332   - .iop_unpin = (void(*)(xfs_log_item_t*, int))
333   - xfs_qm_dquot_logitem_unpin,
  331 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unpin,
334 332 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
335 333 xfs_qm_dquot_logitem_unpin_remove,
336 334 .iop_trylock = (uint(*)(xfs_log_item_t*))
... ... @@ -425,7 +423,7 @@
425 423 */
426 424 /*ARGSUSED*/
427 425 STATIC void
428   -xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf, int stale)
  426 +xfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf)
429 427 {
430 428 return;
431 429 }
... ... @@ -536,8 +534,7 @@
536 534 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
537 535 xfs_qm_qoff_logitem_format,
538 536 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
539   - .iop_unpin = (void(*)(xfs_log_item_t* ,int))
540   - xfs_qm_qoff_logitem_unpin,
  537 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unpin,
541 538 .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
542 539 xfs_qm_qoff_logitem_unpin_remove,
543 540 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
... ... @@ -558,8 +555,7 @@
558 555 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
559 556 xfs_qm_qoff_logitem_format,
560 557 .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin,
561   - .iop_unpin = (void(*)(xfs_log_item_t*, int))
562   - xfs_qm_qoff_logitem_unpin,
  558 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unpin,
563 559 .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*))
564 560 xfs_qm_qoff_logitem_unpin_remove,
565 561 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock,
fs/xfs/xfs_buf_item.c
... ... @@ -372,12 +372,12 @@
372 372 */
373 373 STATIC void
374 374 xfs_buf_item_unpin(
375   - xfs_buf_log_item_t *bip,
376   - int stale)
  375 + xfs_buf_log_item_t *bip)
377 376 {
378 377 struct xfs_ail *ailp;
379 378 xfs_buf_t *bp;
380 379 int freed;
  380 + int stale = bip->bli_flags & XFS_BLI_STALE;
381 381  
382 382 bp = bip->bli_buf;
383 383 ASSERT(bp != NULL);
384 384  
385 385  
386 386  
387 387  
388 388  
389 389  
... ... @@ -428,40 +428,34 @@
428 428 xfs_buf_log_item_t *bip,
429 429 xfs_trans_t *tp)
430 430 {
431   - xfs_buf_t *bp;
432   - xfs_log_item_desc_t *lidp;
433   - int stale = 0;
434   -
435   - bp = bip->bli_buf;
436   - /*
437   - * will xfs_buf_item_unpin() call xfs_buf_item_relse()?
438   - */
  431 + /* will xfs_buf_item_unpin() call xfs_buf_item_relse()? */
439 432 if ((atomic_read(&bip->bli_refcount) == 1) &&
440 433 (bip->bli_flags & XFS_BLI_STALE)) {
  434 + /*
  435 + * yes -- We can safely do some work here and then call
  436 + * buf_item_unpin to do the rest because we are
  437 + * are holding the buffer locked so no one else will be
  438 + * able to bump up the refcount. We have to remove the
  439 + * log item from the transaction as we are about to release
  440 + * our reference to the buffer. If we don't, the unlock that
  441 + * occurs later in the xfs_trans_uncommit() will try to
  442 + * reference the buffer which we no longer have a hold on.
  443 + */
  444 + struct xfs_log_item_desc *lidp;
  445 +
441 446 ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0);
442 447 trace_xfs_buf_item_unpin_stale(bip);
443 448  
444   - /*
445   - * yes -- clear the xaction descriptor in-use flag
446   - * and free the chunk if required. We can safely
447   - * do some work here and then call buf_item_unpin
448   - * to do the rest because if the if is true, then
449   - * we are holding the buffer locked so no one else
450   - * will be able to bump up the refcount.
451   - */
452   - lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) bip);
453   - stale = lidp->lid_flags & XFS_LID_BUF_STALE;
  449 + lidp = xfs_trans_find_item(tp, (xfs_log_item_t *)bip);
454 450 xfs_trans_free_item(tp, lidp);
  451 +
455 452 /*
456   - * Since the transaction no longer refers to the buffer,
457   - * the buffer should no longer refer to the transaction.
  453 + * Since the transaction no longer refers to the buffer, the
  454 + * buffer should no longer refer to the transaction.
458 455 */
459   - XFS_BUF_SET_FSPRIVATE2(bp, NULL);
  456 + XFS_BUF_SET_FSPRIVATE2(bip->bli_buf, NULL);
460 457 }
461   -
462   - xfs_buf_item_unpin(bip, stale);
463   -
464   - return;
  458 + xfs_buf_item_unpin(bip);
465 459 }
466 460  
467 461 /*
... ... @@ -675,7 +669,7 @@
675 669 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
676 670 xfs_buf_item_format,
677 671 .iop_pin = (void(*)(xfs_log_item_t*))xfs_buf_item_pin,
678   - .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_buf_item_unpin,
  672 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_buf_item_unpin,
679 673 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
680 674 xfs_buf_item_unpin_remove,
681 675 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_buf_item_trylock,
fs/xfs/xfs_extfree_item.c
... ... @@ -106,7 +106,7 @@
106 106 */
107 107 /*ARGSUSED*/
108 108 STATIC void
109   -xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
  109 +xfs_efi_item_unpin(xfs_efi_log_item_t *efip)
110 110 {
111 111 struct xfs_ail *ailp = efip->efi_item.li_ailp;
112 112  
... ... @@ -224,7 +224,7 @@
224 224 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
225 225 xfs_efi_item_format,
226 226 .iop_pin = (void(*)(xfs_log_item_t*))xfs_efi_item_pin,
227   - .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efi_item_unpin,
  227 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_efi_item_unpin,
228 228 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t *))
229 229 xfs_efi_item_unpin_remove,
230 230 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efi_item_trylock,
... ... @@ -425,7 +425,7 @@
425 425 */
426 426 /*ARGSUSED*/
427 427 STATIC void
428   -xfs_efd_item_unpin(xfs_efd_log_item_t *efdp, int stale)
  428 +xfs_efd_item_unpin(xfs_efd_log_item_t *efdp)
429 429 {
430 430 return;
431 431 }
... ... @@ -515,7 +515,7 @@
515 515 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
516 516 xfs_efd_item_format,
517 517 .iop_pin = (void(*)(xfs_log_item_t*))xfs_efd_item_pin,
518   - .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_efd_item_unpin,
  518 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_efd_item_unpin,
519 519 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
520 520 xfs_efd_item_unpin_remove,
521 521 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_efd_item_trylock,
fs/xfs/xfs_inode_item.c
... ... @@ -557,8 +557,7 @@
557 557 /* ARGSUSED */
558 558 STATIC void
559 559 xfs_inode_item_unpin(
560   - xfs_inode_log_item_t *iip,
561   - int stale)
  560 + xfs_inode_log_item_t *iip)
562 561 {
563 562 struct xfs_inode *ip = iip->ili_inode;
564 563  
... ... @@ -574,7 +573,7 @@
574 573 xfs_inode_log_item_t *iip,
575 574 xfs_trans_t *tp)
576 575 {
577   - xfs_inode_item_unpin(iip, 0);
  576 + xfs_inode_item_unpin(iip);
578 577 }
579 578  
580 579 /*
... ... @@ -840,7 +839,7 @@
840 839 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
841 840 xfs_inode_item_format,
842 841 .iop_pin = (void(*)(xfs_log_item_t*))xfs_inode_item_pin,
843   - .iop_unpin = (void(*)(xfs_log_item_t*, int))xfs_inode_item_unpin,
  842 + .iop_unpin = (void(*)(xfs_log_item_t*))xfs_inode_item_unpin,
844 843 .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*))
845 844 xfs_inode_item_unpin_remove,
846 845 .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_inode_item_trylock,
... ... @@ -1451,7 +1451,7 @@
1451 1451 * flags, if anyone else stales the buffer we do not
1452 1452 * want to pay any attention to it.
1453 1453 */
1454   - IOP_UNPIN(lip, lidp->lid_flags & XFS_LID_BUF_STALE);
  1454 + IOP_UNPIN(lip);
1455 1455 }
1456 1456 }
... ... @@ -159,7 +159,6 @@
159 159  
160 160 #define XFS_LID_DIRTY 0x1
161 161 #define XFS_LID_PINNED 0x2
162   -#define XFS_LID_BUF_STALE 0x8
163 162  
164 163 /*
165 164 * This structure is used to maintain a chunk list of log_item_desc
... ... @@ -833,7 +832,7 @@
833 832 uint (*iop_size)(xfs_log_item_t *);
834 833 void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *);
835 834 void (*iop_pin)(xfs_log_item_t *);
836   - void (*iop_unpin)(xfs_log_item_t *, int);
  835 + void (*iop_unpin)(xfs_log_item_t *);
837 836 void (*iop_unpin_remove)(xfs_log_item_t *, struct xfs_trans *);
838 837 uint (*iop_trylock)(xfs_log_item_t *);
839 838 void (*iop_unlock)(xfs_log_item_t *);
... ... @@ -846,7 +845,7 @@
846 845 #define IOP_SIZE(ip) (*(ip)->li_ops->iop_size)(ip)
847 846 #define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp)
848 847 #define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip)
849   -#define IOP_UNPIN(ip, flags) (*(ip)->li_ops->iop_unpin)(ip, flags)
  848 +#define IOP_UNPIN(ip) (*(ip)->li_ops->iop_unpin)(ip)
850 849 #define IOP_UNPIN_REMOVE(ip,tp) (*(ip)->li_ops->iop_unpin_remove)(ip, tp)
851 850 #define IOP_TRYLOCK(ip) (*(ip)->li_ops->iop_trylock)(ip)
852 851 #define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip)
fs/xfs/xfs_trans_buf.c
... ... @@ -696,7 +696,6 @@
696 696  
697 697 tp->t_flags |= XFS_TRANS_DIRTY;
698 698 lidp->lid_flags |= XFS_LID_DIRTY;
699   - lidp->lid_flags &= ~XFS_LID_BUF_STALE;
700 699 bip->bli_flags |= XFS_BLI_LOGGED;
701 700 xfs_buf_item_log(bip, first, last);
702 701 }
... ... @@ -782,7 +781,7 @@
782 781 bip->bli_format.blf_flags |= XFS_BLI_CANCEL;
783 782 memset((char *)(bip->bli_format.blf_data_map), 0,
784 783 (bip->bli_format.blf_map_size * sizeof(uint)));
785   - lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE;
  784 + lidp->lid_flags |= XFS_LID_DIRTY;
786 785 tp->t_flags |= XFS_TRANS_DIRTY;
787 786 }
788 787