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 23a4fbe6abSDave Chinner struct xfs_mount; 24a4fbe6abSDave Chinner struct xfs_trans; 25a4fbe6abSDave Chinner struct xfs_alloc_arg; 26a4fbe6abSDave Chinner 27efc27b52SDave Chinner /* 28efc27b52SDave Chinner * Busy block/extent entry. Indexed by a rbtree in perag to mark blocks that 29efc27b52SDave Chinner * have been freed but whose transactions aren't committed to disk yet. 30efc27b52SDave Chinner * 31efc27b52SDave Chinner * Note that we use the transaction ID to record the transaction, not the 32efc27b52SDave Chinner * transaction structure itself. See xfs_extent_busy_insert() for details. 33efc27b52SDave Chinner */ 344ecbfe63SDave Chinner struct xfs_extent_busy { 35efc27b52SDave Chinner struct rb_node rb_node; /* ag by-bno indexed search tree */ 36efc27b52SDave Chinner struct list_head list; /* transaction busy extent list */ 37efc27b52SDave Chinner xfs_agnumber_t agno; 38efc27b52SDave Chinner xfs_agblock_t bno; 39efc27b52SDave Chinner xfs_extlen_t length; 40efc27b52SDave Chinner unsigned int flags; 414ecbfe63SDave Chinner #define XFS_EXTENT_BUSY_DISCARDED 0x01 /* undergoing a discard op. */ 424ecbfe63SDave Chinner #define XFS_EXTENT_BUSY_SKIP_DISCARD 0x02 /* do not discard */ 43efc27b52SDave Chinner }; 44efc27b52SDave Chinner 45efc27b52SDave Chinner void 464ecbfe63SDave Chinner xfs_extent_busy_insert(struct xfs_trans *tp, xfs_agnumber_t agno, 47efc27b52SDave Chinner xfs_agblock_t bno, xfs_extlen_t len, unsigned int flags); 48efc27b52SDave Chinner 49efc27b52SDave Chinner void 504ecbfe63SDave Chinner xfs_extent_busy_clear(struct xfs_mount *mp, struct list_head *list, 51efc27b52SDave Chinner bool do_discard); 52efc27b52SDave Chinner 53efc27b52SDave Chinner int 544ecbfe63SDave Chinner xfs_extent_busy_search(struct xfs_mount *mp, xfs_agnumber_t agno, 55efc27b52SDave Chinner xfs_agblock_t bno, xfs_extlen_t len); 56efc27b52SDave Chinner 57efc27b52SDave Chinner void 584ecbfe63SDave Chinner xfs_extent_busy_reuse(struct xfs_mount *mp, xfs_agnumber_t agno, 59efc27b52SDave Chinner xfs_agblock_t fbno, xfs_extlen_t flen, bool userdata); 60efc27b52SDave Chinner 61e700a06cSBen Myers void 62e700a06cSBen Myers xfs_extent_busy_trim(struct xfs_alloc_arg *args, xfs_agblock_t bno, 63e700a06cSBen Myers xfs_extlen_t len, xfs_agblock_t *rbno, xfs_extlen_t *rlen); 64e700a06cSBen Myers 65efc27b52SDave Chinner int 664ecbfe63SDave Chinner xfs_extent_busy_ag_cmp(void *priv, struct list_head *a, struct list_head *b); 67efc27b52SDave Chinner 684ecbfe63SDave Chinner static inline void xfs_extent_busy_sort(struct list_head *list) 69efc27b52SDave Chinner { 704ecbfe63SDave Chinner list_sort(NULL, list, xfs_extent_busy_ag_cmp); 71efc27b52SDave Chinner } 72efc27b52SDave Chinner 73efc27b52SDave Chinner #endif /* __XFS_EXTENT_BUSY_H__ */ 74