Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 3 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_EXTFREE_ITEM_H__ |
| 7 | #define __XFS_EXTFREE_ITEM_H__ |
| 8 | |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 9 | /* kernel only EFI/EFD definitions */ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | struct xfs_mount; |
Darrick J. Wong | e7720afa | 2021-09-27 14:26:19 -0700 | [diff] [blame] | 12 | struct kmem_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* |
| 15 | * Max number of extents in fast allocation path. |
| 16 | */ |
| 17 | #define XFS_EFI_MAX_FAST_EXTENTS 16 |
| 18 | |
| 19 | /* |
Dave Chinner | 666d644 | 2013-04-03 14:09:21 +1100 | [diff] [blame] | 20 | * This is the "extent free intention" log item. It is used to log the fact |
| 21 | * that some extents need to be free. It is used in conjunction with the |
| 22 | * "extent free done" log item described below. |
| 23 | * |
| 24 | * The EFI is reference counted so that it is not freed prior to both the EFI |
Brian Foster | 8d99fe9 | 2015-08-19 09:51:16 +1000 | [diff] [blame] | 25 | * and EFD being committed and unpinned. This ensures the EFI is inserted into |
| 26 | * the AIL even in the event of out of order EFI/EFD processing. In other words, |
| 27 | * an EFI is born with two references: |
| 28 | * |
| 29 | * 1.) an EFI held reference to track EFI AIL insertion |
| 30 | * 2.) an EFD held reference to track EFD commit |
| 31 | * |
| 32 | * On allocation, both references are the responsibility of the caller. Once the |
| 33 | * EFI is added to and dirtied in a transaction, ownership of reference one |
| 34 | * transfers to the transaction. The reference is dropped once the EFI is |
| 35 | * inserted to the AIL or in the event of failure along the way (e.g., commit |
| 36 | * failure, log I/O error, etc.). Note that the caller remains responsible for |
| 37 | * the EFD reference under all circumstances to this point. The caller has no |
| 38 | * means to detect failure once the transaction is committed, however. |
| 39 | * Therefore, an EFD is required after this point, even in the event of |
| 40 | * unrelated failure. |
| 41 | * |
| 42 | * Once an EFD is allocated and dirtied in a transaction, reference two |
| 43 | * transfers to the transaction. The EFD reference is dropped once it reaches |
| 44 | * the unpin handler. Similar to the EFI, the reference also drops in the event |
| 45 | * of commit failure or log I/O errors. Note that the EFD is not inserted in the |
| 46 | * AIL, so at this point both the EFI and EFD are freed. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | */ |
Christoph Hellwig | 82ff450 | 2020-04-30 12:52:18 -0700 | [diff] [blame] | 48 | struct xfs_efi_log_item { |
Christoph Hellwig | efe2330 | 2019-06-28 19:27:33 -0700 | [diff] [blame] | 49 | struct xfs_log_item efi_item; |
Dave Chinner | 666d644 | 2013-04-03 14:09:21 +1100 | [diff] [blame] | 50 | atomic_t efi_refcount; |
Dave Chinner | b199c8a | 2010-12-20 11:59:49 +1100 | [diff] [blame] | 51 | atomic_t efi_next_extent; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | xfs_efi_log_format_t efi_format; |
Christoph Hellwig | 82ff450 | 2020-04-30 12:52:18 -0700 | [diff] [blame] | 53 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * This is the "extent free done" log item. It is used to log |
| 57 | * the fact that some extents earlier mentioned in an efi item |
| 58 | * have been freed. |
| 59 | */ |
Christoph Hellwig | c84e819 | 2020-04-30 12:52:19 -0700 | [diff] [blame] | 60 | struct xfs_efd_log_item { |
Christoph Hellwig | efe2330 | 2019-06-28 19:27:33 -0700 | [diff] [blame] | 61 | struct xfs_log_item efd_item; |
Christoph Hellwig | 82ff450 | 2020-04-30 12:52:18 -0700 | [diff] [blame] | 62 | struct xfs_efi_log_item *efd_efip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | uint efd_next_extent; |
| 64 | xfs_efd_log_format_t efd_format; |
Christoph Hellwig | c84e819 | 2020-04-30 12:52:19 -0700 | [diff] [blame] | 65 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * Max number of extents in fast allocation path. |
| 69 | */ |
| 70 | #define XFS_EFD_MAX_FAST_EXTENTS 16 |
| 71 | |
Darrick J. Wong | 182696f | 2021-10-12 11:09:23 -0700 | [diff] [blame] | 72 | extern struct kmem_cache *xfs_efi_cache; |
| 73 | extern struct kmem_cache *xfs_efd_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | #endif /* __XFS_EXTFREE_ITEM_H__ */ |