]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: return a failure address from xfs_rmap_irec_offset_unpack
authorDarrick J. Wong <djwong@kernel.org>
Wed, 31 May 2023 08:58:13 +0000 (10:58 +0200)
committerCarlos Maiolino <cem@kernel.org>
Fri, 9 Jun 2023 08:27:50 +0000 (10:27 +0200)
Source kernel commit: 39ab26d59f039c6190bbaa8118a8f0ffed84492a

Currently, xfs_rmap_irec_offset_unpack returns only 0 or -EFSCORRUPTED.
Change this function to return the code address of a failed conversion
in preparation for the next patch, which standardizes localized record
checking and reporting code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
include/platform_defs.h.in
libxfs/libxfs_priv.h
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h

index 315ad77cfb78e0b36cd48a088f4b5f5f9756bb12..29b9f0c5ba7693dc5094073c2ccfcf30cef010f4 100644 (file)
@@ -137,4 +137,24 @@ static inline size_t __ab_c_size(size_t a, size_t b, size_t c)
 /* Only needed for the kernel. */
 #define __init
 
+#ifdef __GNUC__
+#define __return_address       __builtin_return_address(0)
+
+/*
+ * Return the address of a label.  Use barrier() so that the optimizer
+ * won't reorder code to refactor the error jumpouts into a single
+ * return, which throws off the reported address.
+ */
+#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
+/* Optimization barrier */
+
+/* The "volatile" is due to gcc bugs */
+#define barrier() __asm__ __volatile__("": : :"memory")
+#endif
+
+/* Optimization barrier */
+#ifndef barrier
+# define barrier() __memory_barrier()
+#endif
+
 #endif /* __XFS_PLATFORM_DEFS_H__ */
index e5f37df28c0c6e27b59d8322477d85aa7350037b..386f5706f5b68143abd9c238d9c99d8d99ebcfe5 100644 (file)
@@ -188,26 +188,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 #define xfs_info_once(dev, fmt, ...)                           \
        xfs_printk_once(xfs_info, dev, fmt, ##__VA_ARGS__)
 
-#ifdef __GNUC__
-#define __return_address       __builtin_return_address(0)
-
-/*
- * Return the address of a label.  Use barrier() so that the optimizer
- * won't reorder code to refactor the error jumpouts into a single
- * return, which throws off the reported address.
- */
-#define __this_address  ({ __label__ __here; __here: barrier(); &&__here; })
-/* Optimization barrier */
-
-/* The "volatile" is due to gcc bugs */
-#define barrier() __asm__ __volatile__("": : :"memory")
-#endif
-
-/* Optimization barrier */
-#ifndef barrier
-# define barrier() __memory_barrier()
-#endif
-
 /* miscellaneous kernel routines not in user space */
 #define likely(x)              (x)
 #define unlikely(x)            (x)
index a235fc75394cc9f2538771144e22837229c859fb..2afe027d578a336f676ee1e6cf0d9959c81692eb 100644 (file)
@@ -192,7 +192,7 @@ done:
 }
 
 /* Convert an internal btree record to an rmap record. */
-int
+xfs_failaddr_t
 xfs_rmap_btrec_to_irec(
        const union xfs_btree_rec       *rec,
        struct xfs_rmap_irec            *irec)
@@ -2319,11 +2319,10 @@ xfs_rmap_query_range_helper(
 {
        struct xfs_rmap_query_range_info        *query = priv;
        struct xfs_rmap_irec                    irec;
-       int                                     error;
 
-       error = xfs_rmap_btrec_to_irec(rec, &irec);
-       if (error)
-               return error;
+       if (xfs_rmap_btrec_to_irec(rec, &irec) != NULL)
+               return -EFSCORRUPTED;
+
        return query->fn(cur, &irec, query->priv);
 }
 
index 1472ae570a8a631def322303aab58b2fff973da7..6a08c403e8b77179504a6a62275766cbe4493c4a 100644 (file)
@@ -62,13 +62,14 @@ xfs_rmap_irec_offset_pack(
        return x;
 }
 
-static inline int
+static inline xfs_failaddr_t
 xfs_rmap_irec_offset_unpack(
        __u64                   offset,
        struct xfs_rmap_irec    *irec)
 {
        if (offset & ~(XFS_RMAP_OFF_MASK | XFS_RMAP_OFF_FLAGS))
-               return -EFSCORRUPTED;
+               return __this_address;
+
        irec->rm_offset = XFS_RMAP_OFF(offset);
        irec->rm_flags = 0;
        if (offset & XFS_RMAP_OFF_ATTR_FORK)
@@ -77,7 +78,7 @@ xfs_rmap_irec_offset_unpack(
                irec->rm_flags |= XFS_RMAP_BMBT_BLOCK;
        if (offset & XFS_RMAP_OFF_UNWRITTEN)
                irec->rm_flags |= XFS_RMAP_UNWRITTEN;
-       return 0;
+       return NULL;
 }
 
 static inline void
@@ -192,7 +193,7 @@ int xfs_rmap_lookup_le_range(struct xfs_btree_cur *cur, xfs_agblock_t bno,
 int xfs_rmap_compare(const struct xfs_rmap_irec *a,
                const struct xfs_rmap_irec *b);
 union xfs_btree_rec;
-int xfs_rmap_btrec_to_irec(const union xfs_btree_rec *rec,
+xfs_failaddr_t xfs_rmap_btrec_to_irec(const union xfs_btree_rec *rec,
                struct xfs_rmap_irec *irec);
 int xfs_rmap_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno,
                xfs_extlen_t len, bool *exists);