xref: /openbmc/linux/fs/xfs/xfs_extent_busy.h (revision 4ecbfe63)
1efc27b52SDave Chinner /*
2efc27b52SDave Chinner  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3efc27b52SDave Chinner  * Copyright (c) 2010 David Chinner.
4efc27b52SDave Chinner  * Copyright (c) 2011 Christoph Hellwig.
5efc27b52SDave Chinner  * All Rights Reserved.
6efc27b52SDave Chinner  *
7efc27b52SDave Chinner  * This program is free software; you can redistribute it and/or
8efc27b52SDave Chinner  * modify it under the terms of the GNU General Public License as
9efc27b52SDave Chinner  * published by the Free Software Foundation.
10efc27b52SDave Chinner  *
11efc27b52SDave Chinner  * This program is distributed in the hope that it would be useful,
12efc27b52SDave Chinner  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13efc27b52SDave Chinner  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14efc27b52SDave Chinner  * GNU General Public License for more details.
15efc27b52SDave Chinner  *
16efc27b52SDave Chinner  * You should have received a copy of the GNU General Public License
17efc27b52SDave Chinner  * along with this program; if not, write the Free Software Foundation,
18efc27b52SDave Chinner  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19efc27b52SDave Chinner  */
20efc27b52SDave Chinner #ifndef __XFS_EXTENT_BUSY_H__
21efc27b52SDave Chinner #define	__XFS_EXTENT_BUSY_H__
22efc27b52SDave Chinner 
23efc27b52SDave Chinner /*
24efc27b52SDave Chinner  * Busy block/extent entry.  Indexed by a rbtree in perag to mark blocks that
25efc27b52SDave Chinner  * have been freed but whose transactions aren't committed to disk yet.
26efc27b52SDave Chinner  *
27efc27b52SDave Chinner  * Note that we use the transaction ID to record the transaction, not the
28efc27b52SDave Chinner  * transaction structure itself. See xfs_extent_busy_insert() for details.
29efc27b52SDave Chinner  */
304ecbfe63SDave Chinner struct xfs_extent_busy {
31efc27b52SDave Chinner 	struct rb_node	rb_node;	/* ag by-bno indexed search tree */
32efc27b52SDave Chinner 	struct list_head list;		/* transaction busy extent list */
33efc27b52SDave Chinner 	xfs_agnumber_t	agno;
34efc27b52SDave Chinner 	xfs_agblock_t	bno;
35efc27b52SDave Chinner 	xfs_extlen_t	length;
36efc27b52SDave Chinner 	unsigned int	flags;
374ecbfe63SDave Chinner #define XFS_EXTENT_BUSY_DISCARDED	0x01	/* undergoing a discard op. */
384ecbfe63SDave Chinner #define XFS_EXTENT_BUSY_SKIP_DISCARD	0x02	/* do not discard */
39efc27b52SDave Chinner };
40efc27b52SDave Chinner 
41efc27b52SDave Chinner void
424ecbfe63SDave Chinner xfs_extent_busy_insert(struct xfs_trans *tp, xfs_agnumber_t agno,
43efc27b52SDave Chinner 	xfs_agblock_t bno, xfs_extlen_t len, unsigned int flags);
44efc27b52SDave Chinner 
45efc27b52SDave Chinner void
464ecbfe63SDave Chinner xfs_extent_busy_clear(struct xfs_mount *mp, struct list_head *list,
47efc27b52SDave Chinner 	bool do_discard);
48efc27b52SDave Chinner 
49efc27b52SDave Chinner int
504ecbfe63SDave Chinner xfs_extent_busy_search(struct xfs_mount *mp, xfs_agnumber_t agno,
51efc27b52SDave Chinner 	xfs_agblock_t bno, xfs_extlen_t len);
52efc27b52SDave Chinner 
53efc27b52SDave Chinner void
544ecbfe63SDave Chinner xfs_extent_busy_reuse(struct xfs_mount *mp, xfs_agnumber_t agno,
55efc27b52SDave Chinner 	xfs_agblock_t fbno, xfs_extlen_t flen, bool userdata);
56efc27b52SDave Chinner 
57efc27b52SDave Chinner int
584ecbfe63SDave Chinner xfs_extent_busy_ag_cmp(void *priv, struct list_head *a, struct list_head *b);
59efc27b52SDave Chinner 
604ecbfe63SDave Chinner static inline void xfs_extent_busy_sort(struct list_head *list)
61efc27b52SDave Chinner {
624ecbfe63SDave Chinner 	list_sort(NULL, list, xfs_extent_busy_ag_cmp);
63efc27b52SDave Chinner }
64efc27b52SDave Chinner 
65efc27b52SDave Chinner #endif /* __XFS_EXTENT_BUSY_H__ */
66