xfs: return the buffer locked from xfs_buf_get_uncached
authorChristoph Hellwig <hch@lst.de>
Fri, 8 Jul 2011 12:36:25 +0000 (14:36 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 8 Jul 2011 12:36:25 +0000 (14:36 +0200)
All other xfs_buf_get/read-like helpers return the buffer locked, make sure
xfs_buf_get_uncached isn't different for no reason.  Half of the callers
already lock it directly after, and the others probably should also keep
it locked if only for consistency and beeing able to use xfs_buf_rele,
but I'll leave that for later.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/xfs_log.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_vnodeops.c

index c77227615403b18c36cc40cf49ccda98f1249838..6ad5ae249bfb630694bf2806388ec5267bd7632e 100644 (file)
@@ -679,7 +679,6 @@ xfs_buf_read_uncached(
                return NULL;
 
        /* set up the buffer for a read IO */
-       xfs_buf_lock(bp);
        XFS_BUF_SET_ADDR(bp, daddr);
        XFS_BUF_READ(bp);
        XFS_BUF_BUSY(bp);
@@ -814,8 +813,6 @@ xfs_buf_get_uncached(
                goto fail_free_mem;
        }
 
-       xfs_buf_unlock(bp);
-
        trace_xfs_buf_get_uncached(bp, _RET_IP_);
        return bp;
 
index 68e053ea6e7803337e4a13f512a054fc1ef12c45..44c269b387c74f224fb8af1a8ce1f2a271dce276 100644 (file)
@@ -1090,8 +1090,7 @@ xlog_alloc_log(xfs_mount_t        *mp,
                                                log->l_iclog_size, 0);
                if (!bp)
                        goto out_free_iclog;
-               if (!xfs_buf_trylock(bp))
-                       ASSERT(0);
+
                XFS_BUF_SET_IODONE_FUNC(bp, xlog_iodone);
                XFS_BUF_SET_FSPRIVATE2(bp, (unsigned long)1);
                iclog->ic_bp = bp;
index a74e26408343f93829de785c00265239af60da9a..40c9742aa478dc42561626330f4da1a4fd47e3d7 100644 (file)
@@ -91,6 +91,8 @@ xlog_get_bp(
        xlog_t          *log,
        int             nbblks)
 {
+       struct xfs_buf  *bp;
+
        if (!xlog_buf_bbcount_valid(log, nbblks)) {
                xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
                        nbblks);
@@ -118,8 +120,10 @@ xlog_get_bp(
                nbblks += log->l_sectBBsize;
        nbblks = round_up(nbblks, log->l_sectBBsize);
 
-       return xfs_buf_get_uncached(log->l_mp->m_logdev_targp,
-                                       BBTOB(nbblks), 0);
+       bp = xfs_buf_get_uncached(log->l_mp->m_logdev_targp, BBTOB(nbblks), 0);
+       if (bp)
+               xfs_buf_unlock(bp);
+       return bp;
 }
 
 STATIC void
index 11242c4827717c11535c49e39b8ed13898a2de48..88d121486c52935409d99912b347d90cdb6dd818 100644 (file)
@@ -1969,6 +1969,8 @@ xfs_zero_remaining_bytes(
        if (!bp)
                return XFS_ERROR(ENOMEM);
 
+       xfs_buf_unlock(bp);
+
        for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
                offset_fsb = XFS_B_TO_FSBT(mp, offset);
                nimap = 1;