Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
0004  * Copyright (c) 2010 David Chinner.
0005  * Copyright (c) 2011 Christoph Hellwig.
0006  * All Rights Reserved.
0007  */
0008 #ifndef __XFS_EXTENT_BUSY_H__
0009 #define __XFS_EXTENT_BUSY_H__
0010 
0011 struct xfs_mount;
0012 struct xfs_perag;
0013 struct xfs_trans;
0014 struct xfs_alloc_arg;
0015 
0016 /*
0017  * Busy block/extent entry.  Indexed by a rbtree in perag to mark blocks that
0018  * have been freed but whose transactions aren't committed to disk yet.
0019  *
0020  * Note that we use the transaction ID to record the transaction, not the
0021  * transaction structure itself. See xfs_extent_busy_insert() for details.
0022  */
0023 struct xfs_extent_busy {
0024     struct rb_node  rb_node;    /* ag by-bno indexed search tree */
0025     struct list_head list;      /* transaction busy extent list */
0026     xfs_agnumber_t  agno;
0027     xfs_agblock_t   bno;
0028     xfs_extlen_t    length;
0029     unsigned int    flags;
0030 #define XFS_EXTENT_BUSY_DISCARDED   0x01    /* undergoing a discard op. */
0031 #define XFS_EXTENT_BUSY_SKIP_DISCARD    0x02    /* do not discard */
0032 };
0033 
0034 void
0035 xfs_extent_busy_insert(struct xfs_trans *tp, struct xfs_perag *pag,
0036     xfs_agblock_t bno, xfs_extlen_t len, unsigned int flags);
0037 
0038 void
0039 xfs_extent_busy_clear(struct xfs_mount *mp, struct list_head *list,
0040     bool do_discard);
0041 
0042 int
0043 xfs_extent_busy_search(struct xfs_mount *mp, struct xfs_perag *pag,
0044     xfs_agblock_t bno, xfs_extlen_t len);
0045 
0046 void
0047 xfs_extent_busy_reuse(struct xfs_mount *mp, struct xfs_perag *pag,
0048     xfs_agblock_t fbno, xfs_extlen_t flen, bool userdata);
0049 
0050 bool
0051 xfs_extent_busy_trim(struct xfs_alloc_arg *args, xfs_agblock_t *bno,
0052         xfs_extlen_t *len, unsigned *busy_gen);
0053 
0054 void
0055 xfs_extent_busy_flush(struct xfs_mount *mp, struct xfs_perag *pag,
0056     unsigned busy_gen);
0057 
0058 void
0059 xfs_extent_busy_wait_all(struct xfs_mount *mp);
0060 
0061 int
0062 xfs_extent_busy_ag_cmp(void *priv, const struct list_head *a,
0063     const struct list_head *b);
0064 
0065 static inline void xfs_extent_busy_sort(struct list_head *list)
0066 {
0067     list_sort(NULL, list, xfs_extent_busy_ag_cmp);
0068 }
0069 
0070 #endif /* __XFS_EXTENT_BUSY_H__ */