]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: remove the mappedbno argument to xfs_da_read_buf
authorChristoph Hellwig <hch@lst.de>
Wed, 22 Jan 2020 16:29:46 +0000 (11:29 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 22 Jan 2020 16:29:46 +0000 (11:29 -0500)
Source kernel commit: cd2c9f1b544b8f5e1ca1874032fd669d74946a6d

Move the code for reading an already mapped block into
xfs_da3_node_read_mapped, which is the only caller ever passing a block
number in the mappedbno argument and replace the mappedbno argument with
the simple xfs_dabuf_get flags.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c
libxfs/xfs_da_btree.h
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_data.c
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c
libxfs/xfs_dir2_priv.h

index 61b8b7c808ad5e87838d397524ff92e5b8437aee..2d01bd43c7f2b0c08b6fbef84cacc9410a20f720 100644 (file)
@@ -430,7 +430,7 @@ xfs_attr3_leaf_read(
 {
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, bno, -1, bpp, XFS_ATTR_FORK,
+       err = xfs_da_read_buf(tp, dp, bno, 0, bpp, XFS_ATTR_FORK,
                        &xfs_attr3_leaf_buf_ops);
        if (!err && tp && *bpp)
                xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_ATTR_LEAF_BUF);
index 63c896641d7750f2275588f4b6a4243bb267fa48..ec49dffb6911e5bda984f4c9b895f492479a7957 100644 (file)
@@ -366,7 +366,7 @@ xfs_da3_node_read(
 {
        int                     error;
 
-       error = xfs_da_read_buf(tp, dp, bno, -1, bpp, whichfork,
+       error = xfs_da_read_buf(tp, dp, bno, 0, bpp, whichfork,
                        &xfs_da3_node_buf_ops);
        if (error || !*bpp || !tp)
                return error;
@@ -381,12 +381,22 @@ xfs_da3_node_read_mapped(
        struct xfs_buf          **bpp,
        int                     whichfork)
 {
+       struct xfs_mount        *mp = dp->i_mount;
        int                     error;
 
-       error = xfs_da_read_buf(tp, dp, 0, mappedbno, bpp, whichfork,
-                       &xfs_da3_node_buf_ops);
-       if (error || !*bpp || !tp)
+       error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, mappedbno,
+                       XFS_FSB_TO_BB(mp, xfs_dabuf_nfsb(mp, whichfork)), 0,
+                       bpp, &xfs_da3_node_buf_ops);
+       if (error || !*bpp)
                return error;
+
+       if (whichfork == XFS_ATTR_FORK)
+               xfs_buf_set_ref(*bpp, XFS_ATTR_BTREE_REF);
+       else
+               xfs_buf_set_ref(*bpp, XFS_DIR_BTREE_REF);
+
+       if (!tp)
+               return 0;
        return xfs_da3_node_set_type(tp, *bpp);
 }
 
@@ -2615,7 +2625,7 @@ xfs_da_read_buf(
        struct xfs_trans        *tp,
        struct xfs_inode        *dp,
        xfs_dablk_t             bno,
-       xfs_daddr_t             mappedbno,
+       unsigned int            flags,
        struct xfs_buf          **bpp,
        int                     whichfork,
        const struct xfs_buf_ops *ops)
@@ -2627,24 +2637,12 @@ xfs_da_read_buf(
        int                     error;
 
        *bpp = NULL;
-
-       if (mappedbno >= 0) {
-               error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
-                               mappedbno, XFS_FSB_TO_BB(mp,
-                                       xfs_dabuf_nfsb(mp, whichfork)),
-                               0, &bp, ops);
-               goto done;
-       }
-
-       error = xfs_dabuf_map(dp, bno,
-                       mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
-                       whichfork, &mapp, &nmap);
+       error = xfs_dabuf_map(dp, bno, flags, whichfork, &mapp, &nmap);
        if (error || !nmap)
                goto out_free;
 
        error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0,
                        &bp, ops);
-done:
        if (error)
                goto out_free;
 
index 25bcbfa9016fd2802a8ecc323d8fbb06f61ecbe6..f83d18a5d5f1f435c71d081bcdf9b5bcdc259cb1 100644 (file)
@@ -206,9 +206,8 @@ int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
                              xfs_dablk_t bno, xfs_daddr_t mappedbno,
                              struct xfs_buf **bp, int whichfork);
 int    xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
-                              xfs_dablk_t bno, xfs_daddr_t mappedbno,
-                              struct xfs_buf **bpp, int whichfork,
-                              const struct xfs_buf_ops *ops);
+               xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp,
+               int whichfork, const struct xfs_buf_ops *ops);
 int    xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
                unsigned int flags, int whichfork,
                const struct xfs_buf_ops *ops);
index 4f9c21a209138fe0c4b26af978500a3f83dde7a1..a135e24cf6b515c6dc56d3fa58db8deee19ac796 100644 (file)
@@ -120,7 +120,7 @@ xfs_dir3_block_read(
        struct xfs_mount        *mp = dp->i_mount;
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp,
+       err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, 0, bpp,
                                XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
        if (!err && tp && *bpp)
                xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
@@ -947,7 +947,7 @@ xfs_dir2_leaf_to_block(
         * Read the data block if we don't already have it, give up if it fails.
         */
        if (!dbp) {
-               error = xfs_dir3_data_read(tp, dp, args->geo->datablk, -1, &dbp);
+               error = xfs_dir3_data_read(tp, dp, args->geo->datablk, 0, &dbp);
                if (error)
                        return error;
        }
index 6dc495396ca2616b7e86039caf1c0bcfaf894de8..5f65664a4bdd94f38a3f002f741b79d9ff301dde 100644 (file)
@@ -397,13 +397,13 @@ xfs_dir3_data_read(
        struct xfs_trans        *tp,
        struct xfs_inode        *dp,
        xfs_dablk_t             bno,
-       xfs_daddr_t             mapped_bno,
+       unsigned int            flags,
        struct xfs_buf          **bpp)
 {
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
-                               XFS_DATA_FORK, &xfs_dir3_data_buf_ops);
+       err = xfs_da_read_buf(tp, dp, bno, flags, bpp, XFS_DATA_FORK,
+                       &xfs_dir3_data_buf_ops);
        if (!err && tp && *bpp)
                xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
        return err;
index 5560e15524fbbb51fef612d7c2b35b62f4664f12..8b73726df5ad4ad102b99b4e508268b410421999 100644 (file)
@@ -264,7 +264,7 @@ xfs_dir3_leaf_read(
 {
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK,
+       err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK,
                        &xfs_dir3_leaf1_buf_ops);
        if (!err && tp && *bpp)
                xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAF1_BUF);
@@ -280,7 +280,7 @@ xfs_dir3_leafn_read(
 {
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, fbno, -1, bpp, XFS_DATA_FORK,
+       err = xfs_da_read_buf(tp, dp, fbno, 0, bpp, XFS_DATA_FORK,
                        &xfs_dir3_leafn_buf_ops);
        if (!err && tp && *bpp)
                xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_LEAFN_BUF);
@@ -824,7 +824,7 @@ xfs_dir2_leaf_addname(
                 */
                error = xfs_dir3_data_read(tp, dp,
                                   xfs_dir2_db_to_da(args->geo, use_block),
-                                  -1, &dbp);
+                                  0, &dbp);
                if (error) {
                        xfs_trans_brelse(tp, lbp);
                        return error;
@@ -1266,7 +1266,7 @@ xfs_dir2_leaf_lookup_int(
                                xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
                                           xfs_dir2_db_to_da(args->geo, newdb),
-                                          -1, &dbp);
+                                          0, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1308,7 +1308,7 @@ xfs_dir2_leaf_lookup_int(
                        xfs_trans_brelse(tp, dbp);
                        error = xfs_dir3_data_read(tp, dp,
                                           xfs_dir2_db_to_da(args->geo, cidb),
-                                          -1, &dbp);
+                                          0, &dbp);
                        if (error) {
                                xfs_trans_brelse(tp, lbp);
                                return error;
@@ -1600,8 +1600,7 @@ xfs_dir2_leaf_trim_data(
        /*
         * Read the offending data block.  We need its buffer.
         */
-       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), -1,
-                                  &dbp);
+       error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(geo, db), 0, &dbp);
        if (error)
                return error;
 
index 58870f9c13ac87443f12d88688f2beeb13079cbc..c1229e8102df3ca325e05ed519f3ad6b120a2d4d 100644 (file)
@@ -209,14 +209,14 @@ __xfs_dir3_free_read(
        struct xfs_trans        *tp,
        struct xfs_inode        *dp,
        xfs_dablk_t             fbno,
-       xfs_daddr_t             mappedbno,
+       unsigned int            flags,
        struct xfs_buf          **bpp)
 {
        xfs_failaddr_t          fa;
        int                     err;
 
-       err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
-                               XFS_DATA_FORK, &xfs_dir3_free_buf_ops);
+       err = xfs_da_read_buf(tp, dp, fbno, flags, bpp, XFS_DATA_FORK,
+                       &xfs_dir3_free_buf_ops);
        if (err || !*bpp)
                return err;
 
@@ -294,7 +294,7 @@ xfs_dir2_free_read(
        xfs_dablk_t             fbno,
        struct xfs_buf          **bpp)
 {
-       return __xfs_dir3_free_read(tp, dp, fbno, -1, bpp);
+       return __xfs_dir3_free_read(tp, dp, fbno, 0, bpp);
 }
 
 static int
@@ -304,7 +304,7 @@ xfs_dir2_free_try_read(
        xfs_dablk_t             fbno,
        struct xfs_buf          **bpp)
 {
-       return __xfs_dir3_free_read(tp, dp, fbno, -2, bpp);
+       return __xfs_dir3_free_read(tp, dp, fbno, XFS_DABUF_MAP_HOLE_OK, bpp);
 }
 
 static int
@@ -854,7 +854,7 @@ xfs_dir2_leafn_lookup_for_entry(
                                error = xfs_dir3_data_read(tp, dp,
                                                xfs_dir2_db_to_da(args->geo,
                                                                  newdb),
-                                               -1, &curbp);
+                                               0, &curbp);
                                if (error)
                                        return error;
                        }
@@ -1937,7 +1937,7 @@ xfs_dir2_node_addname_int(
                /* Read the data block in. */
                error = xfs_dir3_data_read(tp, dp,
                                           xfs_dir2_db_to_da(args->geo, dbno),
-                                          -1, &dbp);
+                                          0, &dbp);
        }
        if (error)
                return error;
index 278e55a0970f4ceb354327b4d36a05da08121a96..0b0d7908baa603e0f2fa47f266165624b70b3c83 100644 (file)
@@ -77,8 +77,8 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
 
 extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
                struct xfs_buf *bp);
-extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
-               xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
+int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
+               xfs_dablk_t bno, unsigned int flags, struct xfs_buf **bpp);
 int xfs_dir3_data_readahead(struct xfs_inode *dp, xfs_dablk_t bno,
                unsigned int flags);