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