1 // SPDX-License-Identifier: GPL-2.0+ << 2 /* 1 /* 3 * Copyright (C) 2016 Oracle. All Rights Rese 2 * Copyright (C) 2016 Oracle. All Rights Reserved. >> 3 * 4 * Author: Darrick J. Wong <darrick.wong@oracl 4 * Author: Darrick J. Wong <darrick.wong@oracle.com> >> 5 * >> 6 * This program is free software; you can redistribute it and/or >> 7 * modify it under the terms of the GNU General Public License >> 8 * as published by the Free Software Foundation; either version 2 >> 9 * of the License, or (at your option) any later version. >> 10 * >> 11 * This program is distributed in the hope that it would be useful, >> 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 14 * GNU General Public License for more details. >> 15 * >> 16 * You should have received a copy of the GNU General Public License >> 17 * along with this program; if not, write the Free Software Foundation, >> 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 5 */ 19 */ 6 #ifndef __XFS_REFCOUNT_ITEM_H__ 20 #ifndef __XFS_REFCOUNT_ITEM_H__ 7 #define __XFS_REFCOUNT_ITEM_H__ 21 #define __XFS_REFCOUNT_ITEM_H__ 8 22 9 /* 23 /* 10 * There are (currently) two pairs of refcount 24 * There are (currently) two pairs of refcount btree redo item types: 11 * increase and decrease. The log items for t 25 * increase and decrease. The log items for these are CUI (refcount 12 * update intent) and CUD (refcount update don 26 * update intent) and CUD (refcount update done). The redo item type 13 * is encoded in the flags field of each xfs_m 27 * is encoded in the flags field of each xfs_map_extent. 14 * 28 * 15 * *I items should be recorded in the *first* 29 * *I items should be recorded in the *first* of a series of rolled 16 * transactions, and the *D items should be re 30 * transactions, and the *D items should be recorded in the same 17 * transaction that records the associated ref 31 * transaction that records the associated refcountbt updates. 18 * 32 * 19 * Should the system crash after the commit of 33 * Should the system crash after the commit of the first transaction 20 * but before the commit of the final transact 34 * but before the commit of the final transaction in a series, log 21 * recovery will use the redo information reco 35 * recovery will use the redo information recorded by the intent items 22 * to replay the refcountbt metadata updates. 36 * to replay the refcountbt metadata updates. 23 */ 37 */ 24 38 25 /* kernel only CUI/CUD definitions */ 39 /* kernel only CUI/CUD definitions */ 26 40 27 struct xfs_mount; 41 struct xfs_mount; 28 struct kmem_cache; !! 42 struct kmem_zone; 29 43 30 /* 44 /* 31 * Max number of extents in fast allocation pa 45 * Max number of extents in fast allocation path. 32 */ 46 */ 33 #define XFS_CUI_MAX_FAST_EXTENTS 16 47 #define XFS_CUI_MAX_FAST_EXTENTS 16 34 48 35 /* 49 /* >> 50 * Define CUI flag bits. Manipulated by set/clear/test_bit operators. >> 51 */ >> 52 #define XFS_CUI_RECOVERED 1 >> 53 >> 54 /* 36 * This is the "refcount update intent" log it 55 * This is the "refcount update intent" log item. It is used to log 37 * the fact that some reverse mappings need to 56 * the fact that some reverse mappings need to change. It is used in 38 * conjunction with the "refcount update done" 57 * conjunction with the "refcount update done" log item described 39 * below. 58 * below. 40 * 59 * 41 * These log items follow the same rules as st 60 * These log items follow the same rules as struct xfs_efi_log_item; 42 * see the comments about that structure (in x 61 * see the comments about that structure (in xfs_extfree_item.h) for 43 * more details. 62 * more details. 44 */ 63 */ 45 struct xfs_cui_log_item { 64 struct xfs_cui_log_item { 46 struct xfs_log_item cui_it 65 struct xfs_log_item cui_item; 47 atomic_t cui_re 66 atomic_t cui_refcount; 48 atomic_t cui_ne 67 atomic_t cui_next_extent; >> 68 unsigned long cui_flags; /* misc flags */ 49 struct xfs_cui_log_format cui_fo 69 struct xfs_cui_log_format cui_format; 50 }; 70 }; 51 71 52 static inline size_t 72 static inline size_t 53 xfs_cui_log_item_sizeof( 73 xfs_cui_log_item_sizeof( 54 unsigned int nr) 74 unsigned int nr) 55 { 75 { 56 return offsetof(struct xfs_cui_log_ite 76 return offsetof(struct xfs_cui_log_item, cui_format) + 57 xfs_cui_log_format_siz 77 xfs_cui_log_format_sizeof(nr); 58 } 78 } 59 79 60 /* 80 /* 61 * This is the "refcount update done" log item 81 * This is the "refcount update done" log item. It is used to log the 62 * fact that some refcountbt updates mentioned 82 * fact that some refcountbt updates mentioned in an earlier cui item 63 * have been performed. 83 * have been performed. 64 */ 84 */ 65 struct xfs_cud_log_item { 85 struct xfs_cud_log_item { 66 struct xfs_log_item cud_it 86 struct xfs_log_item cud_item; 67 struct xfs_cui_log_item *cud_c 87 struct xfs_cui_log_item *cud_cuip; 68 struct xfs_cud_log_format cud_fo 88 struct xfs_cud_log_format cud_format; 69 }; 89 }; 70 90 71 extern struct kmem_cache *xfs_cui_cache !! 91 extern struct kmem_zone *xfs_cui_zone; 72 extern struct kmem_cache *xfs_cud_cache !! 92 extern struct kmem_zone *xfs_cud_zone; 73 << 74 struct xfs_refcount_intent; << 75 93 76 void xfs_refcount_defer_add(struct xfs_trans * !! 94 struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint); 77 struct xfs_refcount_intent *ri !! 95 struct xfs_cud_log_item *xfs_cud_init(struct xfs_mount *, >> 96 struct xfs_cui_log_item *); >> 97 void xfs_cui_item_free(struct xfs_cui_log_item *); >> 98 void xfs_cui_release(struct xfs_cui_log_item *); >> 99 int xfs_cui_recover(struct xfs_mount *mp, struct xfs_cui_log_item *cuip); 78 100 79 #endif /* __XFS_REFCOUNT_ITEM_H__ */ 101 #endif /* __XFS_REFCOUNT_ITEM_H__ */ 80 102
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.