xfs: kill XBF_LOCK
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_attr.c
index 08b9ac644c3140f6f6cc007f6f3eab05331ff35b..c8ef9a9c312bc5d42fe484369d11b9272073c76d 100644 (file)
@@ -853,6 +853,8 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
 {
        int newsize, forkoff, retval;
 
+       trace_xfs_attr_sf_addname(args);
+
        retval = xfs_attr_shortform_lookup(args);
        if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
                return(retval);
@@ -896,6 +898,8 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
        xfs_dabuf_t *bp;
        int retval, error, committed, forkoff;
 
+       trace_xfs_attr_leaf_addname(args);
+
        /*
         * Read the (only) block in the attribute list in.
         */
@@ -920,6 +924,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                        xfs_da_brelse(args->trans, bp);
                        return(retval);
                }
+
+               trace_xfs_attr_leaf_replace(args);
+
                args->op_flags |= XFS_DA_OP_RENAME;     /* an atomic rename */
                args->blkno2 = args->blkno;             /* set 2nd entry info*/
                args->index2 = args->index;
@@ -1090,6 +1097,8 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
        xfs_dabuf_t *bp;
        int error, committed, forkoff;
 
+       trace_xfs_attr_leaf_removename(args);
+
        /*
         * Remove the attribute.
         */
@@ -1223,6 +1232,8 @@ xfs_attr_node_addname(xfs_da_args_t *args)
        xfs_mount_t *mp;
        int committed, retval, error;
 
+       trace_xfs_attr_node_addname(args);
+
        /*
         * Fill in bucket of arguments/results/context to carry around.
         */
@@ -1249,6 +1260,9 @@ restart:
        } else if (retval == EEXIST) {
                if (args->flags & ATTR_CREATE)
                        goto out;
+
+               trace_xfs_attr_node_replace(args);
+
                args->op_flags |= XFS_DA_OP_RENAME;     /* atomic rename op */
                args->blkno2 = args->blkno;             /* set 2nd entry info*/
                args->index2 = args->index;
@@ -1480,6 +1494,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
        xfs_dabuf_t *bp;
        int retval, error, committed, forkoff;
 
+       trace_xfs_attr_node_removename(args);
+
        /*
         * Tie a string around our finger to remind us where we are.
         */
@@ -1972,13 +1988,11 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
                        dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
                        blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
                        error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
-                                            blkcnt, XBF_LOCK | XBF_DONT_BLOCK,
-                                            &bp);
+                                            blkcnt, XBF_DONT_BLOCK, &bp);
                        if (error)
                                return(error);
 
-                       tmp = (valuelen < XFS_BUF_SIZE(bp))
-                               ? valuelen : XFS_BUF_SIZE(bp);
+                       tmp = min_t(int, valuelen, BBTOB(bp->b_length));
                        xfs_buf_iomove(bp, 0, tmp, dst, XBRW_READ);
                        xfs_buf_relse(bp);
                        dst += tmp;
@@ -2081,6 +2095,8 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
        lblkno = args->rmtblkno;
        valuelen = args->valuelen;
        while (valuelen > 0) {
+               int buflen;
+
                /*
                 * Try to remember where we decided to put the value.
                 */
@@ -2099,14 +2115,16 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
 
                bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
-                                XBF_LOCK | XBF_DONT_BLOCK);
+                                XBF_DONT_BLOCK);
                if (!bp)
                        return ENOMEM;
-               tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen :
-                                                       XFS_BUF_SIZE(bp);
+
+               buflen = BBTOB(bp->b_length);
+               tmp = min_t(int, valuelen, buflen);
                xfs_buf_iomove(bp, 0, tmp, src, XBRW_WRITE);
-               if (tmp < XFS_BUF_SIZE(bp))
-                       xfs_buf_zero(bp, tmp, XFS_BUF_SIZE(bp) - tmp);
+               if (tmp < buflen)
+                       xfs_buf_zero(bp, tmp, buflen - tmp);
+
                error = xfs_bwrite(bp); /* GROT: NOTE: synchronous write */
                xfs_buf_relse(bp);
                if (error)