xfs: clean up MIN/MAX
authorDave Chinner <dchinner@redhat.com>
Thu, 7 Jun 2018 14:54:02 +0000 (07:54 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 8 Jun 2018 17:07:52 +0000 (10:07 -0700)
Get rid of the MIN/MAX macros and just use the native min/max macros
directly in the XFS code.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-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>
15 files changed:
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_leaf.c
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_trans_resv.c
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_iomap.c
fs/xfs/xfs_itable.c
fs/xfs/xfs_linux.h
fs/xfs/xfs_log.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index cf1504208811d2f82360be3043db3ba328d35d10..99e0f5749dba9f5f086ee2fbfba756c50c9badf5 100644 (file)
@@ -465,7 +465,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
         * A data fork btree root must have space for at least
         * MINDBTPTRS key/ptr pairs if the data fork is small or empty.
         */
-       minforkoff = MAX(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
+       minforkoff = max(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
        minforkoff = roundup(minforkoff, 8) >> 3;
 
        /* attr fork btree root can have at least this many key/ptr pairs */
index 3de047eb820928e7495079154a24f8ee5d0ea2f4..6a79a07528cf32335762d3c6d09b59baacfde743 100644 (file)
@@ -3467,7 +3467,7 @@ xfs_bmap_btalloc(
        xfs_rmap_skip_owner_update(&args.oinfo);
 
        /* Trim the allocation back to the maximum an AG can fit. */
-       args.maxlen = MIN(ap->length, mp->m_ag_max_usable);
+       args.maxlen = min(ap->length, mp->m_ag_max_usable);
        args.firstblock = *ap->firstblock;
        blen = 0;
        if (nullfb) {
index 5d5955d1f775e7f814a3cc3e2f958914496c8c97..8a301402bbc4e3bb6f54abfa0320a33cba1eddaa 100644 (file)
@@ -2081,7 +2081,7 @@ xfs_da_grow_inode_int(
                 */
                mapp = kmem_alloc(sizeof(*mapp) * count, KM_SLEEP);
                for (b = *bno, mapi = 0; b < *bno + count; ) {
-                       nmap = MIN(XFS_BMAP_MAX_NMAP, count);
+                       nmap = min(XFS_BMAP_MAX_NMAP, count);
                        c = (int)(*bno + count - b);
                        error = xfs_bmapi_write(tp, dp, b, c,
                                        xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
index bac4c93e6381a4f06d238c8f8cd65753be3638d9..30ed5919da7235e8885afbe15adacffad9949a79 100644 (file)
@@ -502,8 +502,8 @@ xfs_dir2_block_addname(
                        if (mid - lowstale)
                                memmove(&blp[lowstale], &blp[lowstale + 1],
                                        (mid - lowstale) * sizeof(*blp));
-                       lfloglow = MIN(lowstale, lfloglow);
-                       lfloghigh = MAX(mid, lfloghigh);
+                       lfloglow = min(lowstale, lfloglow);
+                       lfloghigh = max(mid, lfloghigh);
                }
                /*
                 * Move entries toward the high-numbered stale entry.
@@ -514,8 +514,8 @@ xfs_dir2_block_addname(
                        if (highstale - mid)
                                memmove(&blp[mid + 1], &blp[mid],
                                        (highstale - mid) * sizeof(*blp));
-                       lfloglow = MIN(mid, lfloglow);
-                       lfloghigh = MAX(highstale, lfloghigh);
+                       lfloglow = min(mid, lfloglow);
+                       lfloghigh = max(highstale, lfloghigh);
                }
                be32_add_cpu(&btp->stale, -1);
        }
index 728c3428abe34526e258b02fbd65dfc470bec41e..1728a3e6f5cf7381460ffce134f166661e164dc3 100644 (file)
@@ -590,8 +590,8 @@ xfs_dir3_leaf_find_entry(
                                (index - lowstale - 1) *
                                        sizeof(xfs_dir2_leaf_entry_t));
                }
-               *lfloglow = MIN(lowstale, *lfloglow);
-               *lfloghigh = MAX(index - 1, *lfloghigh);
+               *lfloglow = min(lowstale, *lfloglow);
+               *lfloghigh = max(index - 1, *lfloghigh);
                leafhdr->stale--;
                return &ents[index - 1];
        }
@@ -610,8 +610,8 @@ xfs_dir3_leaf_find_entry(
                memmove(&ents[index + 1], &ents[index],
                        (highstale - index) * sizeof(xfs_dir2_leaf_entry_t));
        }
-       *lfloglow = MIN(index, *lfloglow);
-       *lfloghigh = MAX(highstale, *lfloghigh);
+       *lfloglow = min(index, *lfloglow);
+       *lfloghigh = max(highstale, *lfloghigh);
        leafhdr->stale--;
        return &ents[index];
 }
index a63788661a4ca4af2e176e286e7e9b34a0c3ff0c..350119eeaecb29b23b6fde020ee75c2542777013 100644 (file)
@@ -771,7 +771,7 @@ xfs_sb_mount_common(
        mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2;
 
        mp->m_bsize = XFS_FSB_TO_BB(mp, 1);
-       mp->m_ialloc_inos = (int)MAX((uint16_t)XFS_INODES_PER_CHUNK,
+       mp->m_ialloc_inos = max_t(uint16_t, XFS_INODES_PER_CHUNK,
                                        sbp->sb_inopblock);
        mp->m_ialloc_blks = mp->m_ialloc_inos >> sbp->sb_inopblog;
 
index 50c44e3c0bc52f45f353e869462c5eb2512b1485..f99a7aefe4184dc86aa9bb8ee7e631526b57d711 100644 (file)
@@ -236,7 +236,7 @@ xfs_calc_write_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
                                      XFS_FSB_TO_B(mp, 1)) +
                     xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
@@ -263,7 +263,7 @@ xfs_calc_itruncate_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1,
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
@@ -288,7 +288,7 @@ xfs_calc_rename_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 4) +
+               max((xfs_calc_inode_res(mp, 4) +
                     xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) +
@@ -328,7 +328,7 @@ xfs_calc_link_reservation(
 {
        return XFS_DQUOT_LOGRES(mp) +
                xfs_calc_iunlink_remove_reservation(mp) +
-               MAX((xfs_calc_inode_res(mp, 2) +
+               max((xfs_calc_inode_res(mp, 2) +
                     xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
@@ -366,7 +366,7 @@ xfs_calc_remove_reservation(
 {
        return XFS_DQUOT_LOGRES(mp) +
                xfs_calc_iunlink_add_reservation(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
@@ -424,7 +424,7 @@ STATIC uint
 xfs_calc_icreate_reservation(xfs_mount_t *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX(xfs_calc_icreate_resv_alloc(mp),
+               max(xfs_calc_icreate_resv_alloc(mp),
                    xfs_calc_create_resv_modify(mp));
 }
 
@@ -632,7 +632,7 @@ STATIC uint
 xfs_calc_attrinval_reservation(
        struct xfs_mount        *mp)
 {
-       return MAX((xfs_calc_inode_res(mp, 1) +
+       return max((xfs_calc_inode_res(mp, 1) +
                    xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
                                     XFS_FSB_TO_B(mp, 1))),
                   (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
@@ -696,7 +696,7 @@ xfs_calc_attrrm_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
                                      XFS_FSB_TO_B(mp, 1)) +
                     (uint)XFS_FSB_TO_B(mp,
index 5d18c8089499f4c00efe1f3f663b885b9dbecad0..1c9d1398980b6562969ab03a38e5158aeafc6c07 100644 (file)
@@ -830,7 +830,7 @@ xfs_buf_item_log_segment(
         * of the last bit to be set in this word plus one.
         */
        if (bit) {
-               end_bit = MIN(bit + bits_to_set, (uint)NBWORD);
+               end_bit = min(bit + bits_to_set, (uint)NBWORD);
                mask = ((1U << (end_bit - bit)) - 1) << bit;
                *wordp |= mask;
                wordp++;
index 99a1a10528859e447bff7c3d1b52c5e032d27c7e..49f5492eed3bdb9d85c53843df03546c83f2c799 100644 (file)
@@ -188,7 +188,7 @@ xfs_iomap_write_direct(
                        goto out_unlock;
        } else {
                if (nmaps && (imap->br_startblock == HOLESTARTBLOCK))
-                       last_fsb = MIN(last_fsb, (xfs_fileoff_t)
+                       last_fsb = min(last_fsb, (xfs_fileoff_t)
                                        imap->br_blockcount +
                                        imap->br_startoff);
        }
@@ -476,8 +476,8 @@ xfs_iomap_prealloc_size(
         * The shift throttle value is set to the maximum value as determined by
         * the global low free space values and per-quota low free space values.
         */
-       alloc_blocks = MIN(alloc_blocks, qblocks);
-       shift = MAX(shift, qshift);
+       alloc_blocks = min(alloc_blocks, qblocks);
+       shift = max(shift, qshift);
 
        if (shift)
                alloc_blocks >>= shift;
index fa405f3a00dcce91f7bb097bdc7e1c4da47e1f94..24f4f1c555b5b979ba1e5a640f6a666ce34a12d5 100644 (file)
@@ -559,7 +559,7 @@ xfs_inumbers(
            *lastino != XFS_AGINO_TO_INO(mp, agno, agino))
                return error;
 
-       bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer)));
+       bcount = min(left, (int)(PAGE_SIZE / sizeof(*buffer)));
        buffer = kmem_zalloc(bcount * sizeof(*buffer), KM_SLEEP);
        do {
                struct xfs_inobt_rec_incore     r;
index 1631cf4546f268ce27233da6fc2fd2a65aefe59b..0fcb6295aa5d24ab899ce6779922931c071d143d 100644 (file)
@@ -140,8 +140,6 @@ typedef __u32                       xfs_nlink_t;
 
 #define XFS_PROJID_DEFAULT     0
 
-#define MIN(a,b)       (min(a,b))
-#define MAX(a,b)       (max(a,b))
 #define howmany(x, y)  (((x)+((y)-1))/(y))
 
 static inline void delay(long ticks)
index e630778c08b6d4e3e5f3602edd340be57324863f..5e56f3b93d4b7757865b1e31c402c156c28580df 100644 (file)
@@ -1629,8 +1629,8 @@ xlog_grant_push_ail(
         * log, and 256 blocks.
         */
        free_threshold = BTOBB(need_bytes);
-       free_threshold = MAX(free_threshold, (log->l_logBBsize >> 2));
-       free_threshold = MAX(free_threshold, 256);
+       free_threshold = max(free_threshold, (log->l_logBBsize >> 2));
+       free_threshold = max(free_threshold, 256);
        if (free_blocks >= free_threshold)
                return;
 
index 7d897c58b0c83fac4a2faf410da5892f4a7363be..b1aedf73d09d1f225070c9a8a10392b07a0e7ef5 100644 (file)
@@ -1804,7 +1804,7 @@ xlog_clear_stale_blocks(
         * we don't waste all day writing from the head to the tail
         * for no reason.
         */
-       max_distance = MIN(max_distance, tail_distance);
+       max_distance = min(max_distance, tail_distance);
 
        if ((head_block + max_distance) <= log->l_logBBsize) {
                /*
@@ -2872,14 +2872,14 @@ xlog_recover_buffer_pass2(
         * buffers in the log can be a different size if the log was generated
         * by an older kernel using unclustered inode buffers or a newer kernel
         * running with a different inode cluster size.  Regardless, if the
-        * the inode buffer size isn't MAX(blocksize, mp->m_inode_cluster_size)
+        * the inode buffer size isn't max(blocksize, mp->m_inode_cluster_size)
         * for *our* value of mp->m_inode_cluster_size, then we need to keep
         * the buffer out of the buffer cache so that the buffer won't
         * overlap with future reads of those inodes.
         */
        if (XFS_DINODE_MAGIC ==
            be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
-           (BBTOB(bp->b_io_length) != MAX(log->l_mp->m_sb.sb_blocksize,
+           (BBTOB(bp->b_io_length) != max(log->l_mp->m_sb.sb_blocksize,
                        (uint32_t)log->l_mp->m_inode_cluster_size))) {
                xfs_buf_stale(bp);
                error = xfs_bwrite(bp);
index 7f3d5e012ba3b6caffe4182e491b2281ebdd4139..245349d1e23f351d66d08fe137fe77904d8f046d 100644 (file)
@@ -271,7 +271,7 @@ xfs_preferred_iosize(xfs_mount_t *mp)
        return (mp->m_swidth ?
                (mp->m_swidth << mp->m_sb.sb_blocklog) :
                ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
-                       (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
+                       (1 << (int)max(mp->m_readio_log, mp->m_writeio_log)) :
                        PAGE_SIZE));
 }
 
index d55435e94ea34575b3cf81b48d0d9ba5acbe157c..7c4813a4a9af8457383dcd1a03c17e667a34a05b 100644 (file)
@@ -1136,7 +1136,7 @@ xfs_fs_statfs(
        statp->f_bavail = statp->f_bfree;
 
        fakeinos = statp->f_bfree << sbp->sb_inopblog;
-       statp->f_files = MIN(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
+       statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
        if (mp->m_maxicount)
                statp->f_files = min_t(typeof(statp->f_files),
                                        statp->f_files,