@@ -66,4 +66,18 @@ div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder)
return dividend / divisor;
}
+static inline uint64_t rounddown_64(uint64_t x, uint32_t y)
+{
+ do_div(x, y);
+ return x * y;
+}
+
+static inline uint64_t
+roundup_64(uint64_t x, uint32_t y)
+{
+ x += y - 1;
+ do_div(x, y);
+ return x * y;
+}
+
#endif /* LIBFROG_DIV64_H_ */
@@ -363,14 +363,6 @@ roundup_pow_of_two(uint v)
return 0;
}
-static inline uint64_t
-roundup_64(uint64_t x, uint32_t y)
-{
- x += y - 1;
- do_div(x, y);
- return x * y;
-}
-
static inline uint64_t
howmany_64(uint64_t x, uint32_t y)
{
@@ -56,6 +56,24 @@ xfs_rtb_to_rtxt(
return div_u64(rtbno, mp->m_sb.sb_rextsize);
}
+/* Round this rtblock up to the nearest rt extent size. */
+static inline xfs_rtblock_t
+xfs_rtb_roundup_rtx(
+ struct xfs_mount *mp,
+ xfs_rtblock_t rtbno)
+{
+ return roundup_64(rtbno, mp->m_sb.sb_rextsize);
+}
+
+/* Round this rtblock down to the nearest rt extent size. */
+static inline xfs_rtblock_t
+xfs_rtb_rounddown_rtx(
+ struct xfs_mount *mp,
+ xfs_rtblock_t rtbno)
+{
+ return rounddown_64(rtbno, mp->m_sb.sb_rextsize);
+}
+
/*
* Functions for walking free space rtextents in the realtime bitmap.
*/