]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: make the record pointer passed to query_range functions const
authorDarrick J. Wong <djwong@kernel.org>
Mon, 31 Jan 2022 20:25:47 +0000 (15:25 -0500)
committerEric Sandeen <sandeen@redhat.com>
Mon, 31 Jan 2022 20:25:47 +0000 (15:25 -0500)
Source kernel commit: 159eb69dba8baf6d5b58b69936920fb311324c82

The query_range functions are supposed to call a caller-supplied
function on each record found in the dataset.  These functions don't
own the memory storing the record, so don't let them change the record.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/fsmap.c
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_btree.c
libxfs/xfs_btree.h
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc.h
libxfs/xfs_refcount.c
libxfs/xfs_refcount.h
libxfs/xfs_rmap.c
libxfs/xfs_rmap.h

index 65e9f1ba1195bfa2c79712b44c12eb9b12291c92..d30b832c4e0cfc063dda1ce2ea4d6f9322dcfebe 100644 (file)
@@ -16,11 +16,11 @@ struct fsmap_info {
 
 static int
 fsmap_fn(
-       struct xfs_btree_cur    *cur,
-       struct xfs_rmap_irec    *rec,
-       void                    *priv)
+       struct xfs_btree_cur            *cur,
+       const struct xfs_rmap_irec      *rec,
+       void                            *priv)
 {
-       struct fsmap_info       *info = priv;
+       struct fsmap_info               *info = priv;
 
        dbprintf(_("%llu: %u/%u len %u owner %lld offset %llu bmbt %d attrfork %d extflag %d\n"),
                info->nr, info->agno, rec->rm_startblock,
index 105c90b0352c2ace7acc850ab7c4631e77f84784..a7c3b07974ad4f0960639df785db637dea1b02bb 100644 (file)
@@ -3388,7 +3388,7 @@ struct xfs_alloc_query_range_info {
 STATIC int
 xfs_alloc_query_range_helper(
        struct xfs_btree_cur            *cur,
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        void                            *priv)
 {
        struct xfs_alloc_query_range_info       *query = priv;
index 3554b7d420f0b16adda39d10706877214db25cbd..e14c56938bacc278e2800c108b112b7cca728c23 100644 (file)
@@ -220,9 +220,9 @@ int xfs_free_extent_fix_freelist(struct xfs_trans *tp, struct xfs_perag *pag,
 xfs_extlen_t xfs_prealloc_blocks(struct xfs_mount *mp);
 
 typedef int (*xfs_alloc_query_range_fn)(
-       struct xfs_btree_cur            *cur,
-       struct xfs_alloc_rec_incore     *rec,
-       void                            *priv);
+       struct xfs_btree_cur                    *cur,
+       const struct xfs_alloc_rec_incore       *rec,
+       void                                    *priv);
 
 int xfs_alloc_query_range(struct xfs_btree_cur *cur,
                const struct xfs_alloc_rec_incore *low_rec,
index aedc62a5a7b0b12d43a4234453073e98638334d2..448f6c0df03d1c02dd2bcc70ddf6d45c6cc47a3b 100644 (file)
@@ -4878,7 +4878,7 @@ xfs_btree_diff_two_ptrs(
 STATIC int
 xfs_btree_has_record_helper(
        struct xfs_btree_cur            *cur,
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        void                            *priv)
 {
        return -ECANCELED;
index 462c25857a2647bd5bdf3eefb76290c4e5814d07..e83836a984e40fc15a8b3be5d0a86e5620356747 100644 (file)
@@ -471,7 +471,7 @@ unsigned long long xfs_btree_calc_size(uint *limits, unsigned long long len);
  * code on its own.
  */
 typedef int (*xfs_btree_query_range_fn)(struct xfs_btree_cur *cur,
-               union xfs_btree_rec *rec, void *priv);
+               const union xfs_btree_rec *rec, void *priv);
 
 int xfs_btree_query_range(struct xfs_btree_cur *cur,
                const union xfs_btree_irec *low_rec,
index 570349b82a757200e276ad1b5b8a8b047b7cc14f..c1f3d28a1966c0c17a4e58604f3482e3ef7d8d90 100644 (file)
@@ -69,7 +69,7 @@ xfs_inobt_update(
 void
 xfs_inobt_btrec_to_irec(
        struct xfs_mount                *mp,
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        struct xfs_inobt_rec_incore     *irec)
 {
        irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino);
@@ -2711,7 +2711,7 @@ struct xfs_ialloc_count_inodes {
 STATIC int
 xfs_ialloc_count_inodes_rec(
        struct xfs_btree_cur            *cur,
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        void                            *priv)
 {
        struct xfs_inobt_rec_incore     irec;
index 9a2112b4ad5eee80656d4682de5056e1c4a5f99d..8b5c2b7090228f2b027b3e9d194fbdafbbba09c0 100644 (file)
@@ -106,7 +106,8 @@ int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
                xfs_agnumber_t agno, struct xfs_buf **bpp);
 
 union xfs_btree_rec;
-void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
+void xfs_inobt_btrec_to_irec(struct xfs_mount *mp,
+               const union xfs_btree_rec *rec,
                struct xfs_inobt_rec_incore *irec);
 int xfs_ialloc_has_inodes_at_extent(struct xfs_btree_cur *cur,
                xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
index 2ef00c64965efe6e8873ef4340f08646dbddbe2f..1c9e7722fe65cba4a06f0d59713399a4e99910fe 100644 (file)
@@ -90,7 +90,7 @@ xfs_refcount_lookup_eq(
 /* Convert on-disk record to in-core format. */
 void
 xfs_refcount_btrec_to_irec(
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        struct xfs_refcount_irec        *irec)
 {
        irec->rc_startblock = be32_to_cpu(rec->refc.rc_startblock);
@@ -1653,7 +1653,7 @@ struct xfs_refcount_recovery {
 STATIC int
 xfs_refcount_recover_extent(
        struct xfs_btree_cur            *cur,
-       union xfs_btree_rec             *rec,
+       const union xfs_btree_rec       *rec,
        void                            *priv)
 {
        struct list_head                *debris = priv;
index 9f6e9aae4da026d5d5ec528dba176a15005be255..02cb3aa405be5119a5c6b687aae14922fc9b4925 100644 (file)
@@ -78,7 +78,7 @@ static inline xfs_fileoff_t xfs_refcount_max_unmap(int log_res)
 extern int xfs_refcount_has_record(struct xfs_btree_cur *cur,
                xfs_agblock_t bno, xfs_extlen_t len, bool *exists);
 union xfs_btree_rec;
-extern void xfs_refcount_btrec_to_irec(union xfs_btree_rec *rec,
+extern void xfs_refcount_btrec_to_irec(const union xfs_btree_rec *rec,
                struct xfs_refcount_irec *irec);
 extern int xfs_refcount_insert(struct xfs_btree_cur *cur,
                struct xfs_refcount_irec *irec, int *stat);
index 100e904d9cd5f9a072c6fccecddbd811fd0f2e79..ed7db353cb21591422d20aaa7b96029d9871ee32 100644 (file)
@@ -178,8 +178,8 @@ done:
 /* Convert an internal btree record to an rmap record. */
 int
 xfs_rmap_btrec_to_irec(
-       union xfs_btree_rec     *rec,
-       struct xfs_rmap_irec    *irec)
+       const union xfs_btree_rec       *rec,
+       struct xfs_rmap_irec            *irec)
 {
        irec->rm_startblock = be32_to_cpu(rec->rmap.rm_startblock);
        irec->rm_blockcount = be32_to_cpu(rec->rmap.rm_blockcount);
@@ -254,9 +254,9 @@ struct xfs_find_left_neighbor_info {
 /* For each rmap given, figure out if it matches the key we want. */
 STATIC int
 xfs_rmap_find_left_neighbor_helper(
-       struct xfs_btree_cur    *cur,
-       struct xfs_rmap_irec    *rec,
-       void                    *priv)
+       struct xfs_btree_cur            *cur,
+       const struct xfs_rmap_irec      *rec,
+       void                            *priv)
 {
        struct xfs_find_left_neighbor_info      *info = priv;
 
@@ -330,9 +330,9 @@ xfs_rmap_find_left_neighbor(
 /* For each rmap given, figure out if it matches the key we want. */
 STATIC int
 xfs_rmap_lookup_le_range_helper(
-       struct xfs_btree_cur    *cur,
-       struct xfs_rmap_irec    *rec,
-       void                    *priv)
+       struct xfs_btree_cur            *cur,
+       const struct xfs_rmap_irec      *rec,
+       void                            *priv)
 {
        struct xfs_find_left_neighbor_info      *info = priv;
 
@@ -2277,9 +2277,9 @@ struct xfs_rmap_query_range_info {
 /* Format btree record and pass to our callback. */
 STATIC int
 xfs_rmap_query_range_helper(
-       struct xfs_btree_cur    *cur,
-       union xfs_btree_rec     *rec,
-       void                    *priv)
+       struct xfs_btree_cur            *cur,
+       const union xfs_btree_rec       *rec,
+       void                            *priv)
 {
        struct xfs_rmap_query_range_info        *query = priv;
        struct xfs_rmap_irec                    irec;
@@ -2706,7 +2706,7 @@ struct xfs_rmap_key_state {
 STATIC int
 xfs_rmap_has_other_keys_helper(
        struct xfs_btree_cur            *cur,
-       struct xfs_rmap_irec            *rec,
+       const struct xfs_rmap_irec      *rec,
        void                            *priv)
 {
        struct xfs_rmap_key_state       *rks = priv;
index 1354efc4ddabea422d567509f41b36c38c3f915c..fd67904ed446fea5d21e1b58932d587568c114dd 100644 (file)
@@ -134,9 +134,9 @@ int xfs_rmap_get_rec(struct xfs_btree_cur *cur, struct xfs_rmap_irec *irec,
                int *stat);
 
 typedef int (*xfs_rmap_query_range_fn)(
-       struct xfs_btree_cur    *cur,
-       struct xfs_rmap_irec    *rec,
-       void                    *priv);
+       struct xfs_btree_cur            *cur,
+       const struct xfs_rmap_irec      *rec,
+       void                            *priv);
 
 int xfs_rmap_query_range(struct xfs_btree_cur *cur,
                const struct xfs_rmap_irec *low_rec,
@@ -193,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(union xfs_btree_rec *rec,
+int 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);