]> git.ipfire.org Git - people/ms/linux.git/blobdiff - fs/xfs/libxfs/xfs_ag.h
Merge branch 'for-6.0/dax' into libnvdimm-fixes
[people/ms/linux.git] / fs / xfs / libxfs / xfs_ag.h
index e411d51c258940355d04f6845e74aa34db75d4f5..517a138faa669b8494dda3810edbab78dc1930ac 100644 (file)
@@ -67,6 +67,12 @@ struct xfs_perag {
        /* for rcu-safe freeing */
        struct rcu_head rcu_head;
 
+       /* Precalculated geometry info */
+       xfs_agblock_t           block_count;
+       xfs_agblock_t           min_block;
+       xfs_agino_t             agino_min;
+       xfs_agino_t             agino_max;
+
 #ifdef __KERNEL__
        /* -- kernel only structures below this line -- */
 
@@ -97,17 +103,11 @@ struct xfs_perag {
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;
 
-       /*
-        * Unlinked inode information.  This incore information reflects
-        * data stored in the AGI, so callers must hold the AGI buffer lock
-        * or have some other means to control concurrency.
-        */
-       struct rhashtable       pagi_unlinked_hash;
 #endif /* __KERNEL__ */
 };
 
 int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount,
-                       xfs_agnumber_t *maxagi);
+                       xfs_rfsblock_t dcount, xfs_agnumber_t *maxagi);
 int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno);
 void xfs_free_perag(struct xfs_mount *mp);
 
@@ -116,6 +116,56 @@ struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno,
                unsigned int tag);
 void xfs_perag_put(struct xfs_perag *pag);
 
+/*
+ * Per-ag geometry infomation and validation
+ */
+xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno);
+void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
+               xfs_agino_t *first, xfs_agino_t *last);
+
+static inline bool
+xfs_verify_agbno(struct xfs_perag *pag, xfs_agblock_t agbno)
+{
+       if (agbno >= pag->block_count)
+               return false;
+       if (agbno <= pag->min_block)
+               return false;
+       return true;
+}
+
+/*
+ * Verify that an AG inode number pointer neither points outside the AG
+ * nor points at static metadata.
+ */
+static inline bool
+xfs_verify_agino(struct xfs_perag *pag, xfs_agino_t agino)
+{
+       if (agino < pag->agino_min)
+               return false;
+       if (agino > pag->agino_max)
+               return false;
+       return true;
+}
+
+/*
+ * Verify that an AG inode number pointer neither points outside the AG
+ * nor points at static metadata, or is NULLAGINO.
+ */
+static inline bool
+xfs_verify_agino_or_null(struct xfs_perag *pag, xfs_agino_t agino)
+{
+       if (agino == NULLAGINO)
+               return true;
+       return xfs_verify_agino(pag, agino);
+}
+
+static inline bool
+xfs_ag_contains_log(struct xfs_mount *mp, xfs_agnumber_t agno)
+{
+       return mp->m_sb.sb_logstart > 0 &&
+              agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart);
+}
+
 /*
  * Perag iteration APIs
  */
@@ -168,11 +218,10 @@ struct aghdr_init_data {
 };
 
 int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id);
-int xfs_ag_shrink_space(struct xfs_mount *mp, struct xfs_trans **tpp,
-                       xfs_agnumber_t agno, xfs_extlen_t delta);
-int xfs_ag_extend_space(struct xfs_mount *mp, struct xfs_trans *tp,
-                       struct aghdr_init_data *id, xfs_extlen_t len);
-int xfs_ag_get_geometry(struct xfs_mount *mp, xfs_agnumber_t agno,
-                       struct xfs_ag_geometry *ageo);
+int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp,
+                       xfs_extlen_t delta);
+int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp,
+                       xfs_extlen_t len);
+int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
 
 #endif /* __LIBXFS_AG_H */