eCryptfs: Fix lockdep warning in miscdev operations
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / xfs / xfs_attr.c
index 65d61b948eadbc287cdc7e61b2275436c9addb54..a17ff01b5adf900da88aacb0e430b8853443bb62 100644 (file)
@@ -21,7 +21,6 @@
 #include "xfs_types.h"
 #include "xfs_bit.h"
 #include "xfs_log.h"
-#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
@@ -39,7 +38,6 @@
 #include "xfs_error.h"
 #include "xfs_quota.h"
 #include "xfs_trans_space.h"
-#include "xfs_rw.h"
 #include "xfs_vnodeops.h"
 #include "xfs_trace.h"
 
@@ -1987,14 +1985,12 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
                               (map[i].br_startblock != HOLESTARTBLOCK));
                        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);
+                       error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
+                                                  dblkno, blkcnt, 0, &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;
@@ -2097,6 +2093,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.
                 */
@@ -2114,15 +2112,16 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
                blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
 
-               bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
-                                XBF_LOCK | XBF_DONT_BLOCK);
+               bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, 0);
                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)