Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_EXTFREE_ITEM_H__
0007 #define __XFS_EXTFREE_ITEM_H__
0008 
0009 /* kernel only EFI/EFD definitions */
0010 
0011 struct xfs_mount;
0012 struct kmem_cache;
0013 
0014 /*
0015  * Max number of extents in fast allocation path.
0016  */
0017 #define XFS_EFI_MAX_FAST_EXTENTS    16
0018 
0019 /*
0020  * This is the "extent free intention" log item.  It is used to log the fact
0021  * that some extents need to be free.  It is used in conjunction with the
0022  * "extent free done" log item described below.
0023  *
0024  * The EFI is reference counted so that it is not freed prior to both the EFI
0025  * and EFD being committed and unpinned. This ensures the EFI is inserted into
0026  * the AIL even in the event of out of order EFI/EFD processing. In other words,
0027  * an EFI is born with two references:
0028  *
0029  *  1.) an EFI held reference to track EFI AIL insertion
0030  *  2.) an EFD held reference to track EFD commit
0031  *
0032  * On allocation, both references are the responsibility of the caller. Once the
0033  * EFI is added to and dirtied in a transaction, ownership of reference one
0034  * transfers to the transaction. The reference is dropped once the EFI is
0035  * inserted to the AIL or in the event of failure along the way (e.g., commit
0036  * failure, log I/O error, etc.). Note that the caller remains responsible for
0037  * the EFD reference under all circumstances to this point. The caller has no
0038  * means to detect failure once the transaction is committed, however.
0039  * Therefore, an EFD is required after this point, even in the event of
0040  * unrelated failure.
0041  *
0042  * Once an EFD is allocated and dirtied in a transaction, reference two
0043  * transfers to the transaction. The EFD reference is dropped once it reaches
0044  * the unpin handler. Similar to the EFI, the reference also drops in the event
0045  * of commit failure or log I/O errors. Note that the EFD is not inserted in the
0046  * AIL, so at this point both the EFI and EFD are freed.
0047  */
0048 struct xfs_efi_log_item {
0049     struct xfs_log_item efi_item;
0050     atomic_t        efi_refcount;
0051     atomic_t        efi_next_extent;
0052     xfs_efi_log_format_t    efi_format;
0053 };
0054 
0055 /*
0056  * This is the "extent free done" log item.  It is used to log
0057  * the fact that some extents earlier mentioned in an efi item
0058  * have been freed.
0059  */
0060 struct xfs_efd_log_item {
0061     struct xfs_log_item efd_item;
0062     struct xfs_efi_log_item *efd_efip;
0063     uint            efd_next_extent;
0064     xfs_efd_log_format_t    efd_format;
0065 };
0066 
0067 /*
0068  * Max number of extents in fast allocation path.
0069  */
0070 #define XFS_EFD_MAX_FAST_EXTENTS    16
0071 
0072 extern struct kmem_cache    *xfs_efi_cache;
0073 extern struct kmem_cache    *xfs_efd_cache;
0074 
0075 #endif  /* __XFS_EXTFREE_ITEM_H__ */