xfs: better log intent item refcount checking
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 20 Apr 2017 22:09:05 +0000 (15:09 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Apr 2017 16:40:42 +0000 (09:40 -0700)
Use ASSERTs on the log intent item refcounts so that we fail noisily if
anyone tries to double-free the item.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c

index 9bf57c76623b404ebf5e1e57dd1582ad52de7c92..2d7017373e202f60b9665d5cb00046ba5f4e77b1 100644 (file)
@@ -215,6 +215,7 @@ void
 xfs_bui_release(
        struct xfs_bui_log_item *buip)
 {
+       ASSERT(atomic_read(&buip->bui_refcount) > 0);
        if (atomic_dec_and_test(&buip->bui_refcount)) {
                xfs_trans_ail_remove(&buip->bui_item, SHUTDOWN_LOG_IO_ERROR);
                xfs_bui_item_free(buip);
index d7bc14906af87f14ef570a968ead42100445c8bd..44f8c54512102577dbe768e5f137298ba1ee79c7 100644 (file)
@@ -290,6 +290,7 @@ void
 xfs_efi_release(
        struct xfs_efi_log_item *efip)
 {
+       ASSERT(atomic_read(&efip->efi_refcount) > 0);
        if (atomic_dec_and_test(&efip->efi_refcount)) {
                xfs_trans_ail_remove(&efip->efi_item, SHUTDOWN_LOG_IO_ERROR);
                xfs_efi_item_free(efip);
index 6e4c7446c3d4561f85d86686d5b4a40bc4cd0ce6..96fe209b5eb61fb5b45fcc46f6733c6b46f29308 100644 (file)
@@ -221,6 +221,7 @@ void
 xfs_cui_release(
        struct xfs_cui_log_item *cuip)
 {
+       ASSERT(atomic_read(&cuip->cui_refcount) > 0);
        if (atomic_dec_and_test(&cuip->cui_refcount)) {
                xfs_trans_ail_remove(&cuip->cui_item, SHUTDOWN_LOG_IO_ERROR);
                xfs_cui_item_free(cuip);
index 73c827831551942550c3e0a3a66c4a7abdf52ef6..f3b139c9aa1674a3f652ec622286e9aba616d5c3 100644 (file)
@@ -243,6 +243,7 @@ void
 xfs_rui_release(
        struct xfs_rui_log_item *ruip)
 {
+       ASSERT(atomic_read(&ruip->rui_refcount) > 0);
        if (atomic_dec_and_test(&ruip->rui_refcount)) {
                xfs_trans_ail_remove(&ruip->rui_item, SHUTDOWN_LOG_IO_ERROR);
                xfs_rui_item_free(ruip);