Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
| 4 | * Copyright (c) 2010 David Chinner. |
| 5 | * Copyright (c) 2011 Christoph Hellwig. |
| 6 | * All Rights Reserved. |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | #ifndef __XFS_EXTENT_BUSY_H__ |
| 9 | #define __XFS_EXTENT_BUSY_H__ |
| 10 | |
Dave Chinner | a4fbe6a | 2013-10-23 10:51:50 +1100 | [diff] [blame] | 11 | struct xfs_mount; |
| 12 | struct xfs_trans; |
| 13 | struct xfs_alloc_arg; |
| 14 | |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 15 | /* |
| 16 | * Busy block/extent entry. Indexed by a rbtree in perag to mark blocks that |
| 17 | * have been freed but whose transactions aren't committed to disk yet. |
| 18 | * |
| 19 | * Note that we use the transaction ID to record the transaction, not the |
| 20 | * transaction structure itself. See xfs_extent_busy_insert() for details. |
| 21 | */ |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 22 | struct xfs_extent_busy { |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 23 | struct rb_node rb_node; /* ag by-bno indexed search tree */ |
| 24 | struct list_head list; /* transaction busy extent list */ |
| 25 | xfs_agnumber_t agno; |
| 26 | xfs_agblock_t bno; |
| 27 | xfs_extlen_t length; |
| 28 | unsigned int flags; |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 29 | #define XFS_EXTENT_BUSY_DISCARDED 0x01 /* undergoing a discard op. */ |
| 30 | #define XFS_EXTENT_BUSY_SKIP_DISCARD 0x02 /* do not discard */ |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | void |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 34 | xfs_extent_busy_insert(struct xfs_trans *tp, xfs_agnumber_t agno, |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 35 | xfs_agblock_t bno, xfs_extlen_t len, unsigned int flags); |
| 36 | |
| 37 | void |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 38 | xfs_extent_busy_clear(struct xfs_mount *mp, struct list_head *list, |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 39 | bool do_discard); |
| 40 | |
| 41 | int |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 42 | xfs_extent_busy_search(struct xfs_mount *mp, xfs_agnumber_t agno, |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 43 | xfs_agblock_t bno, xfs_extlen_t len); |
| 44 | |
| 45 | void |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 46 | xfs_extent_busy_reuse(struct xfs_mount *mp, xfs_agnumber_t agno, |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 47 | xfs_agblock_t fbno, xfs_extlen_t flen, bool userdata); |
| 48 | |
Christoph Hellwig | ebf5587 | 2017-02-07 14:06:57 -0800 | [diff] [blame] | 49 | bool |
| 50 | xfs_extent_busy_trim(struct xfs_alloc_arg *args, xfs_agblock_t *bno, |
| 51 | xfs_extlen_t *len, unsigned *busy_gen); |
| 52 | |
Ben Myers | e700a06 | 2012-05-10 13:55:33 -0500 | [diff] [blame] | 53 | void |
Christoph Hellwig | ebf5587 | 2017-02-07 14:06:57 -0800 | [diff] [blame] | 54 | xfs_extent_busy_flush(struct xfs_mount *mp, struct xfs_perag *pag, |
| 55 | unsigned busy_gen); |
| 56 | |
| 57 | void |
| 58 | xfs_extent_busy_wait_all(struct xfs_mount *mp); |
Ben Myers | e700a06 | 2012-05-10 13:55:33 -0500 | [diff] [blame] | 59 | |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 60 | int |
Sami Tolvanen | 4f0f586 | 2021-04-08 11:28:34 -0700 | [diff] [blame] | 61 | xfs_extent_busy_ag_cmp(void *priv, const struct list_head *a, |
| 62 | const struct list_head *b); |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 63 | |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 64 | static inline void xfs_extent_busy_sort(struct list_head *list) |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 65 | { |
Dave Chinner | 4ecbfe6 | 2012-04-29 10:41:10 +0000 | [diff] [blame] | 66 | list_sort(NULL, list, xfs_extent_busy_ag_cmp); |
Dave Chinner | efc27b5 | 2012-04-29 10:39:43 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | #endif /* __XFS_EXTENT_BUSY_H__ */ |