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