Merge branches 'release', 'dmi' and 'misc' into release
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_rtalloc.c
index 6fff19dc3cf96e8cb6d00fabe3dd88d176847f46..ca83ddf72af4569ab8cfa1b3cdfcbbf16c80ffb6 100644 (file)
@@ -72,18 +72,6 @@ STATIC int xfs_rtmodify_summary(xfs_mount_t *, xfs_trans_t *, int,
  * Internal functions.
  */
 
-/*
- * xfs_lowbit32: get low bit set out of 32-bit argument, -1 if none set.
- */
-STATIC int
-xfs_lowbit32(
-       __uint32_t      v)
-{
-       if (v)
-               return ffs(v) - 1;
-       return -1;
-}
-
 /*
  * Allocate space to the bitmap or summary file, and zero it, for growfs.
  */
@@ -150,7 +138,7 @@ xfs_growfs_rt_alloc(
                error = xfs_bmap_finish(&tp, &flist, &committed);
                if (error)
                        goto error_exit;
-               xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
+               xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
                /*
                 * Now we need to clear the allocated blocks.
                 * Do this one block per transaction, to keep it simple.
@@ -187,7 +175,7 @@ xfs_growfs_rt_alloc(
                        /*
                         * Commit the transaction.
                         */
-                       xfs_trans_commit(tp, 0, NULL);
+                       xfs_trans_commit(tp, 0);
                }
                /*
                 * Go on to the next extent, if any.
@@ -444,6 +432,7 @@ xfs_rtallocate_extent_near(
        }
        bbno = XFS_BITTOBLOCK(mp, bno);
        i = 0;
+       ASSERT(minlen != 0);
        log2len = xfs_highbit32(minlen);
        /*
         * Loop over all bitmap blocks (bbno + i is current block).
@@ -612,6 +601,8 @@ xfs_rtallocate_extent_size(
        xfs_suminfo_t   sum;            /* summary information for extents */
 
        ASSERT(minlen % prod == 0 && maxlen % prod == 0);
+       ASSERT(maxlen != 0);
+
        /*
         * Loop over all the levels starting with maxlen.
         * At each level, look at all the bitmap blocks, to see if there
@@ -669,6 +660,9 @@ xfs_rtallocate_extent_size(
                *rtblock = NULLRTBLOCK;
                return 0;
        }
+       ASSERT(minlen != 0);
+       ASSERT(maxlen != 0);
+
        /*
         * Loop over sizes, from maxlen down to minlen.
         * This time, when we do the allocations, allow smaller ones
@@ -1882,11 +1876,13 @@ xfs_growfs_rt(
            (nrblocks = in->newblocks) <= sbp->sb_rblocks ||
            (sbp->sb_rblocks && (in->extsize != sbp->sb_rextsize)))
                return XFS_ERROR(EINVAL);
+       if ((error = xfs_sb_validate_fsb_count(sbp, nrblocks)))
+               return error;
        /*
         * Read in the last block of the device, make sure it exists.
         */
        error = xfs_read_buf(mp, mp->m_rtdev_targp,
-                       XFS_FSB_TO_BB(mp, in->newblocks - 1),
+                       XFS_FSB_TO_BB(mp, nrblocks - 1),
                        XFS_FSB_TO_BB(mp, 1), 0, &bp);
        if (error)
                return error;
@@ -1952,6 +1948,7 @@ xfs_growfs_rt(
                                  nsbp->sb_blocksize * nsbp->sb_rextsize);
                nsbp->sb_rextents = nsbp->sb_rblocks;
                do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
+               ASSERT(nsbp->sb_rextents != 0);
                nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
                nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;
                nrsumsize =
@@ -2042,7 +2039,7 @@ xfs_growfs_rt(
                /*
                 * Commit the transaction.
                 */
-               xfs_trans_commit(tp, 0, NULL);
+               xfs_trans_commit(tp, 0);
        }
 
        if (error)