@@ -698,6 +698,14 @@ union xfs_rtword_raw {
__u32 old;
};
+/*
+ * Realtime summary counts are accessed by the word, which is currently
+ * stored in host-endian format.
+ */
+union xfs_suminfo_raw {
+ __u32 old;
+};
+
/*
* XFS Timestamps
* ==============
@@ -449,7 +449,6 @@ xfs_rtmodify_summary_int(
int error; /* error value */
xfs_fileoff_t sb; /* summary fsblock */
xfs_rtsumoff_t so; /* index into the summary file */
- xfs_suminfo_t *sp; /* pointer to returned data */
unsigned int infoword;
/*
@@ -488,19 +487,21 @@ xfs_rtmodify_summary_int(
* Point to the summary information, modify/log it, and/or copy it out.
*/
infoword = xfs_rtsumoffs_to_infoword(mp, so);
- sp = xfs_rsumblock_infoptr(bp, infoword);
if (delta) {
- *sp += delta;
+ xfs_suminfo_t val = xfs_suminfo_add(bp, infoword, delta);
+
if (mp->m_rsum_cache) {
- if (*sp == 0 && log == mp->m_rsum_cache[bbno])
+ if (val == 0 && log == mp->m_rsum_cache[bbno])
mp->m_rsum_cache[bbno]++;
- if (*sp != 0 && log < mp->m_rsum_cache[bbno])
+ if (val != 0 && log < mp->m_rsum_cache[bbno])
mp->m_rsum_cache[bbno] = log;
}
xfs_trans_log_rtsummary(tp, bp, infoword);
+ if (sum)
+ *sum = val;
+ } else if (sum) {
+ *sum = xfs_suminfo_get(bp, infoword);
}
- if (sum)
- *sum = *sp;
return 0;
}
@@ -235,16 +235,40 @@ xfs_rtsumoffs_to_infoword(
}
/* Return a pointer to a summary info word within a rt summary block. */
-static inline xfs_suminfo_t *
+static inline union xfs_suminfo_raw *
xfs_rsumblock_infoptr(
struct xfs_buf *bp,
unsigned int index)
{
- xfs_suminfo_t *info = bp->b_addr;
+ union xfs_suminfo_raw *info = bp->b_addr;
return info + index;
}
+/* Get the current value of a summary counter. */
+static inline xfs_suminfo_t
+xfs_suminfo_get(
+ struct xfs_buf *bp,
+ unsigned int index)
+{
+ union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index);
+
+ return info->old;
+}
+
+/* Add to the current value of a summary counter and return the new value. */
+static inline xfs_suminfo_t
+xfs_suminfo_add(
+ struct xfs_buf *bp,
+ unsigned int index,
+ int delta)
+{
+ union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index);
+
+ info->old += delta;
+ return info->old;
+}
+
/*
* Functions for walking free space rtextents in the realtime bitmap.
*/