xfs: minor cleanups
cover xfs: minor cleanups
Hi folks,
These patches are minor cleanups that do not change the behaviour of the code. The first two replace abstractions
that have outlived their usefulness with linux kernel native primitives. It's been tested on both 32 and 64 bit platforms.
The last patch moves all the new(-ish) type verifiers to a common file in libxfs - this means they are easy to find and we have a central place for adding future type verifiers.
Cheers,
Dave.
PATCH 1/3 xfs: move various type verifiers to common file
From: Dave Chinner <[email protected]>
New verification functions like xfs_verify_fsbno() and xfs_verify_agino() are spread across multiple files and different header files. They really don't fit cleanly into the places they've been put, and have wider scope than the current header includes.
Move the type verifiers to a new file in libxfs (xfs-types.c) and the prototypes to xfs_types.h where they will be visible to all the code that uses the types.
--- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_alloc.c | 49 ---------- fs/xfs/libxfs/xfs_alloc.h | 4 - fs/xfs/libxfs/xfs_ialloc.c | 90 ------------------ fs/xfs/libxfs/xfs_ialloc.h | 7 -- fs/xfs/libxfs/xfs_rtbitmap.c | 12 --- fs/xfs/libxfs/xfs_types.c | 173 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_types.h | 19 ++++ fs/xfs/scrub/agheader.c | 2 +- 9 files changed, 194 insertions(+), 163 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_types.c
fs/xfs/Makefile +1 -0
@@ -50,6 +50,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_sb.o \ xfs_symlink_remote.o \ xfs_trans_resv.o \ + xfs_types.o \ ) # xfs_rtbitmap is shared with libxfs xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \
fs/xfs/libxfs/xfs_alloc.c +0 -49
55 lines not on this page · raw message
fs/xfs/libxfs/xfs_alloc.h +0 -4
@@ -242,10 +242,6 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn, void *priv);int xfs_alloc_query_all (struct xfs_btree_cur *cur,xfs_alloc_query_range_fn fn,void *priv); -xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); -bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agblock_t agbno); -bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno);int xfs_alloc_has_record (struct xfs_btree_cur *cur,xfs_agblock_t bno,xfs_extlen_t len,bool *exist);
fs/xfs/libxfs/xfs_ialloc.c +0 -90
96 lines not on this page · raw message
fs/xfs/libxfs/xfs_ialloc.h +0 -7
@@ -169,12 +169,5 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask, int *stat);int xfs_ialloc_cluster_alignment (struct xfs_mount *mp); -void xfs_ialloc_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t *first,xfs_agino_t *last); -bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t agino); -bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino);#endif /* __XFS_IALLOC_H__ */
fs/xfs/libxfs/xfs_rtbitmap.c +0 -12
@@ -1080,18 +1080,6 @@ xfs_rtalloc_query_all(return xfs_rtalloc_query_range (tp, &keys[0 ], &keys[1 ], fn, priv); } -/* -* Verify that an realtime block number pointer doesn't point off the -* end of the realtime device. -*/ -bool -xfs_verify_rtbno ( -struct xfs_mount *mp, -xfs_rtblock_t rtbno) -{ -return rtbno < mp->m_sb.sb_rblocks; -} -/* Is the given extent all free? */ int xfs_rtalloc_extent_is_free(
fs/xfs/libxfs/xfs_types.c new file +173 -0
173 lines not on this page · raw message
fs/xfs/libxfs/xfs_types.h +19 -0
@@ -147,4 +147,23 @@ typedef struct xfs_bmbt_irecxfs_exntst_t br_state;/* extent state */ } xfs_bmbt_irec_t; +/* +* Type verifier functions +*/ +struct xfs_mount ; + +xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); +bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agblock_t agbno); +bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno); + +void xfs_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t *first,xfs_agino_t *last); +bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t agino); +bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_rtbno (struct xfs_mount *mp,xfs_rtblock_t rtbno); +#endif /* __XFS_TYPES_H__ */
fs/xfs/scrub/agheader.c +1 -1
@@ -867,7 +867,7 @@ xfs_scrub_agi( }/* Check inode counters */ -xfs_ialloc_agino_range (mp, agno, &first_agino, &last_agino); +xfs_agino_range (mp, agno, &first_agino, &last_agino); icount =be32_to_cpu (agi->agi_count);if (icount > last_agino - first_agino +1 || icount <be32_to_cpu (agi->agi_freecount))
Signature · 1 line
2.17.0
Re: [PATCH 1/3] xfs: move various type verifiers to common file
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
New verification functions like
xfs_verify_fsbno()andxfs_verify_agino()are spread across multiple files and different header files. They really don't fit cleanly into the places they've been put, and have wider scope than the current header includes.
Quoted 6 lines
Move the type verifiers to a new file in libxfs (
xfs-types.c) and the prototypes toxfs_types.hwhere they will be visible to all the code that uses the types.Signed-off-by Dave Chinner <[email protected]>---
Quoted 467 lines
fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_alloc.c | 49 ---------- fs/xfs/libxfs/xfs_alloc.h | 4 - fs/xfs/libxfs/xfs_ialloc.c | 90 ------------------ fs/xfs/libxfs/xfs_ialloc.h | 7 -- fs/xfs/libxfs/xfs_rtbitmap.c | 12 --- fs/xfs/libxfs/xfs_types.c | 173 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_types.h | 19 ++++ fs/xfs/scrub/agheader.c | 2 +- 9 files changed, 194 insertions(+), 163 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_types.cfs/xfs/Makefile +1
-0@@ -50,6 +50,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_sb.o \ xfs_symlink_remote.o \ xfs_trans_resv.o \ + xfs_types.o \ ) # xfs_rtbitmap is shared with libxfs xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \fs/xfs/libxfs/xfs_alloc.c +0
-49@@ -3123,55 +3123,6 @@ xfs_alloc_query_all(return xfs_btree_query_all (cur, xfs_alloc_query_range_helper, &query); } -/* Find the size of the AG, in blocks. */ -xfs_agblock_t -xfs_ag_block_count ( -struct xfs_mount *mp, -xfs_agnumber_t agno) -{ -ASSERT (agno < mp->m_sb.sb_agcount); - -if (agno < mp->m_sb.sb_agcount -1 ) -return mp->m_sb.sb_agblocks; -return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); -} - -/* -* Verify that an AG block number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agbno ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agblock_t agbno) -{ -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); -if (agbno >= eoag) -return false; -if (agbno <=XFS_AGFL_BLOCK (mp)) -return false; -return true; -} - -/* -* Verify that an FS block number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_fsbno ( -struct xfs_mount *mp, -xfs_fsblock_t fsbno) -{ -xfs_agnumber_t agno =XFS_FSB_TO_AGNO (mp, fsbno); - -if (agno >= mp->m_sb.sb_agcount) -return false; -return xfs_verify_agbno (mp, agno,XFS_FSB_TO_AGBNO (mp, fsbno)); -} -/* Is there a record covering a given extent? */ int xfs_alloc_has_record(fs/xfs/libxfs/xfs_alloc.h +0
-4@@ -242,10 +242,6 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn, void *priv);int xfs_alloc_query_all (struct xfs_btree_cur *cur,xfs_alloc_query_range_fn fn,void *priv); -xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); -bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agblock_t agbno); -bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno);int xfs_alloc_has_record (struct xfs_btree_cur *cur,xfs_agblock_t bno,xfs_extlen_t len,bool *exist);fs/xfs/libxfs/xfs_ialloc.c +0
-90@@ -2674,96 +2674,6 @@ xfs_ialloc_pagi_init(return 0 ; } -/* Calculate the first and last possible inode number in an AG. */ -void -xfs_ialloc_agino_range ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t *first, -xfs_agino_t *last) -{ -xfs_agblock_t bno; -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); - -/* -* Calculate the first inode, which will be in the first -* cluster-aligned block after the AGFL. -*/ - bno =round_up (XFS_AGFL_BLOCK (mp) +1 , -xfs_ialloc_cluster_alignment (mp)); - *first =XFS_OFFBNO_TO_AGINO (mp, bno,0 ); - -/* -* Calculate the last inode, which will be at the end of the -* last (aligned) cluster that can be allocated in the AG. -*/ - bno =round_down (eoag,xfs_ialloc_cluster_alignment (mp)); - *last =XFS_OFFBNO_TO_AGINO (mp, bno,0 ) -1 ; -} - -/* -* Verify that an AG inode number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agino ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t agino) -{ -xfs_agino_t first; -xfs_agino_t last; - -xfs_ialloc_agino_range (mp, agno, &first, &last); -return agino >= first && agino <= last; -} - -/* -* Verify that an FS inode number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ino); -xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ino); - -if (agno >= mp->m_sb.sb_agcount) -return false; -if (XFS_AGINO_TO_INO (mp, agno, agino) != ino) -return false; -return xfs_verify_agino (mp, agno, agino); -} - -/* Is this an internal inode number? */ -bool -xfs_internal_inum ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || - (xfs_sb_version_hasquota (&mp->m_sb) && -xfs_is_quota_inode (&mp->m_sb, ino)); -} - -/* -* Verify that a directory entry's inode number doesn't point at an internal -* inode, empty space, or static AG metadata. -*/ -bool -xfs_verify_dir_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -if (xfs_internal_inum (mp, ino)) -return false; -return xfs_verify_ino (mp, ino); -} -/* Is there an inode record covering a given range of inode numbers? */ int xfs_ialloc_has_inode_record(fs/xfs/libxfs/xfs_ialloc.h +0
-7@@ -169,12 +169,5 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask, int *stat);int xfs_ialloc_cluster_alignment (struct xfs_mount *mp); -void xfs_ialloc_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t *first,xfs_agino_t *last); -bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t agino); -bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino);#endif /* __XFS_IALLOC_H__ */ fs/xfs/libxfs/xfs_rtbitmap.c +0
-12@@ -1080,18 +1080,6 @@ xfs_rtalloc_query_all(return xfs_rtalloc_query_range (tp, &keys[0 ], &keys[1 ], fn, priv); } -/* -* Verify that an realtime block number pointer doesn't point off the -* end of the realtime device. -*/ -bool -xfs_verify_rtbno ( -struct xfs_mount *mp, -xfs_rtblock_t rtbno) -{ -return rtbno < mp->m_sb.sb_rblocks; -} -/* Is the given extent all free? */ int xfs_rtalloc_extent_is_free(fs/xfs/libxfs/xfs_types.c new file +173
-0@@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* Copyright (C) 2017 Oracle. +* All Rights Reserved. +*/ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_sb.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_inode.h" +#include "xfs_btree.h" +#include "xfs_rmap.h" +#include "xfs_alloc_btree.h" +#include "xfs_alloc.h" +#include "xfs_ialloc.h" + +/* Find the size of the AG, in blocks. */ +xfs_agblock_t +xfs_ag_block_count ( +struct xfs_mount *mp, +xfs_agnumber_t agno) +{ +ASSERT (agno < mp->m_sb.sb_agcount); + +if (agno < mp->m_sb.sb_agcount -1 ) +return mp->m_sb.sb_agblocks; +return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); +} + +/* +* Verify that an AG block number pointer neither points outside the AG +* nor points at static metadata. +*/ +bool +xfs_verify_agbno ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agblock_t agbno) +{ +xfs_agblock_t eoag; + + eoag =xfs_ag_block_count (mp, agno); +if (agbno >= eoag) +return false; +if (agbno <=XFS_AGFL_BLOCK (mp)) +return false; +return true; +} + +/* +* Verify that an FS block number pointer neither points outside the +* filesystem nor points at static AG metadata. +*/ +bool +xfs_verify_fsbno ( +struct xfs_mount *mp, +xfs_fsblock_t fsbno) +{ +xfs_agnumber_t agno =XFS_FSB_TO_AGNO (mp, fsbno); + +if (agno >= mp->m_sb.sb_agcount) +return false; +return xfs_verify_agbno (mp, agno,XFS_FSB_TO_AGBNO (mp, fsbno)); +} + +/* Calculate the first and last possible inode number in an AG. */ +void +xfs_agino_range ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agino_t *first, +xfs_agino_t *last) +{ +xfs_agblock_t bno; +xfs_agblock_t eoag; + + eoag =xfs_ag_block_count (mp, agno); + +/* +* Calculate the first inode, which will be in the first +* cluster-aligned block after the AGFL. +*/ + bno =round_up (XFS_AGFL_BLOCK (mp) +1 , +xfs_ialloc_cluster_alignment (mp)); + *first =XFS_OFFBNO_TO_AGINO (mp, bno,0 ); + +/* +* Calculate the last inode, which will be at the end of the +* last (aligned) cluster that can be allocated in the AG. +*/ + bno =round_down (eoag,xfs_ialloc_cluster_alignment (mp)); + *last =XFS_OFFBNO_TO_AGINO (mp, bno,0 ) -1 ; +} + +/* +* Verify that an AG inode number pointer neither points outside the AG +* nor points at static metadata. +*/ +bool +xfs_verify_agino ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agino_t agino) +{ +xfs_agino_t first; +xfs_agino_t last; + +xfs_agino_range (mp, agno, &first, &last); +return agino >= first && agino <= last; +} + +/* +* Verify that an FS inode number pointer neither points outside the +* filesystem nor points at static AG metadata. +*/ +bool +xfs_verify_ino ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ino); +xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ino); + +if (agno >= mp->m_sb.sb_agcount) +return false; +if (XFS_AGINO_TO_INO (mp, agno, agino) != ino) +return false; +return xfs_verify_agino (mp, agno, agino); +} + +/* Is this an internal inode number? */ +bool +xfs_internal_inum ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || + (xfs_sb_version_hasquota (&mp->m_sb) && +xfs_is_quota_inode (&mp->m_sb, ino)); +} + +/* +* Verify that a directory entry's inode number doesn't point at an internal +* inode, empty space, or static AG metadata. +*/ +bool +xfs_verify_dir_ino ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +if (xfs_internal_inum (mp, ino)) +return false; +return xfs_verify_ino (mp, ino); +} + +/* +* Verify that an realtime block number pointer doesn't point off the +* end of the realtime device. +*/ +bool +xfs_verify_rtbno ( +struct xfs_mount *mp, +xfs_rtblock_t rtbno) +{ +return rtbno < mp->m_sb.sb_rblocks; +}fs/xfs/libxfs/xfs_types.h +19
-0@@ -147,4 +147,23 @@ typedef struct xfs_bmbt_irecxfs_exntst_t br_state;/* extent state */ } xfs_bmbt_irec_t; +/* +* Type verifier functions +*/ +struct xfs_mount ; + +xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); +bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agblock_t agbno); +bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno); + +void xfs_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t *first,xfs_agino_t *last); +bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t agino); +bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_rtbno (struct xfs_mount *mp,xfs_rtblock_t rtbno); +#endif /* __XFS_TYPES_H__ */ fs/xfs/scrub/agheader.c +1
-1@@ -867,7 +867,7 @@ xfs_scrub_agi( }/* Check inode counters */ -xfs_ialloc_agino_range (mp, agno, &first_agino, &last_agino); +xfs_agino_range (mp, agno, &first_agino, &last_agino); icount =be32_to_cpu (agi->agi_count);if (icount > last_agino - first_agino +1 || icount <be32_to_cpu (agi->agi_freecount))Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] xfs: move various type verifiers to common file
In reply to Dave ChinnerQuoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
New verification functions like
xfs_verify_fsbno()andxfs_verify_agino()are spread across multiple files and different header files. They really don't fit cleanly into the places they've been put, and have wider scope than the current header includes.
Quoted 5 lines
Move the type verifiers to a new file in libxfs (
xfs-types.c) and the prototypes toxfs_types.hwhere they will be visible to all the code that uses the types.Signed-off-by Dave Chinner <[email protected]>
Looks ok,
--D
Quoted 468 lines
--- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_alloc.c | 49 ---------- fs/xfs/libxfs/xfs_alloc.h | 4 - fs/xfs/libxfs/xfs_ialloc.c | 90 ------------------ fs/xfs/libxfs/xfs_ialloc.h | 7 -- fs/xfs/libxfs/xfs_rtbitmap.c | 12 --- fs/xfs/libxfs/xfs_types.c | 173 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_types.h | 19 ++++ fs/xfs/scrub/agheader.c | 2 +- 9 files changed, 194 insertions(+), 163 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_types.cfs/xfs/Makefile +1
-0@@ -50,6 +50,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_sb.o \ xfs_symlink_remote.o \ xfs_trans_resv.o \ + xfs_types.o \ ) # xfs_rtbitmap is shared with libxfs xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \fs/xfs/libxfs/xfs_alloc.c +0
-49@@ -3123,55 +3123,6 @@ xfs_alloc_query_all(return xfs_btree_query_all (cur, xfs_alloc_query_range_helper, &query); } -/* Find the size of the AG, in blocks. */ -xfs_agblock_t -xfs_ag_block_count ( -struct xfs_mount *mp, -xfs_agnumber_t agno) -{ -ASSERT (agno < mp->m_sb.sb_agcount); - -if (agno < mp->m_sb.sb_agcount -1 ) -return mp->m_sb.sb_agblocks; -return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); -} - -/* -* Verify that an AG block number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agbno ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agblock_t agbno) -{ -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); -if (agbno >= eoag) -return false; -if (agbno <=XFS_AGFL_BLOCK (mp)) -return false; -return true; -} - -/* -* Verify that an FS block number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_fsbno ( -struct xfs_mount *mp, -xfs_fsblock_t fsbno) -{ -xfs_agnumber_t agno =XFS_FSB_TO_AGNO (mp, fsbno); - -if (agno >= mp->m_sb.sb_agcount) -return false; -return xfs_verify_agbno (mp, agno,XFS_FSB_TO_AGBNO (mp, fsbno)); -} -/* Is there a record covering a given extent? */ int xfs_alloc_has_record(fs/xfs/libxfs/xfs_alloc.h +0
-4@@ -242,10 +242,6 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn, void *priv);int xfs_alloc_query_all (struct xfs_btree_cur *cur,xfs_alloc_query_range_fn fn,void *priv); -xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); -bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agblock_t agbno); -bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno);int xfs_alloc_has_record (struct xfs_btree_cur *cur,xfs_agblock_t bno,xfs_extlen_t len,bool *exist);fs/xfs/libxfs/xfs_ialloc.c +0
-90@@ -2674,96 +2674,6 @@ xfs_ialloc_pagi_init(return 0 ; } -/* Calculate the first and last possible inode number in an AG. */ -void -xfs_ialloc_agino_range ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t *first, -xfs_agino_t *last) -{ -xfs_agblock_t bno; -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); - -/* -* Calculate the first inode, which will be in the first -* cluster-aligned block after the AGFL. -*/ - bno =round_up (XFS_AGFL_BLOCK (mp) +1 , -xfs_ialloc_cluster_alignment (mp)); - *first =XFS_OFFBNO_TO_AGINO (mp, bno,0 ); - -/* -* Calculate the last inode, which will be at the end of the -* last (aligned) cluster that can be allocated in the AG. -*/ - bno =round_down (eoag,xfs_ialloc_cluster_alignment (mp)); - *last =XFS_OFFBNO_TO_AGINO (mp, bno,0 ) -1 ; -} - -/* -* Verify that an AG inode number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agino ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t agino) -{ -xfs_agino_t first; -xfs_agino_t last; - -xfs_ialloc_agino_range (mp, agno, &first, &last); -return agino >= first && agino <= last; -} - -/* -* Verify that an FS inode number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ino); -xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ino); - -if (agno >= mp->m_sb.sb_agcount) -return false; -if (XFS_AGINO_TO_INO (mp, agno, agino) != ino) -return false; -return xfs_verify_agino (mp, agno, agino); -} - -/* Is this an internal inode number? */ -bool -xfs_internal_inum ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || - (xfs_sb_version_hasquota (&mp->m_sb) && -xfs_is_quota_inode (&mp->m_sb, ino)); -} - -/* -* Verify that a directory entry's inode number doesn't point at an internal -* inode, empty space, or static AG metadata. -*/ -bool -xfs_verify_dir_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -if (xfs_internal_inum (mp, ino)) -return false; -return xfs_verify_ino (mp, ino); -} -/* Is there an inode record covering a given range of inode numbers? */ int xfs_ialloc_has_inode_record(fs/xfs/libxfs/xfs_ialloc.h +0
-7@@ -169,12 +169,5 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask, int *stat);int xfs_ialloc_cluster_alignment (struct xfs_mount *mp); -void xfs_ialloc_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t *first,xfs_agino_t *last); -bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t agino); -bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino);#endif /* __XFS_IALLOC_H__ */ fs/xfs/libxfs/xfs_rtbitmap.c +0
-12@@ -1080,18 +1080,6 @@ xfs_rtalloc_query_all(return xfs_rtalloc_query_range (tp, &keys[0 ], &keys[1 ], fn, priv); } -/* -* Verify that an realtime block number pointer doesn't point off the -* end of the realtime device. -*/ -bool -xfs_verify_rtbno ( -struct xfs_mount *mp, -xfs_rtblock_t rtbno) -{ -return rtbno < mp->m_sb.sb_rblocks; -} -/* Is the given extent all free? */ int xfs_rtalloc_extent_is_free(fs/xfs/libxfs/xfs_types.c new file +173
-0@@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* Copyright (C) 2017 Oracle. +* All Rights Reserved. +*/ +#include "xfs.h" +#include "xfs_fs.h" +#include "xfs_format.h" +#include "xfs_log_format.h" +#include "xfs_shared.h" +#include "xfs_trans_resv.h" +#include "xfs_bit.h" +#include "xfs_sb.h" +#include "xfs_mount.h" +#include "xfs_defer.h" +#include "xfs_inode.h" +#include "xfs_btree.h" +#include "xfs_rmap.h" +#include "xfs_alloc_btree.h" +#include "xfs_alloc.h" +#include "xfs_ialloc.h" + +/* Find the size of the AG, in blocks. */ +xfs_agblock_t +xfs_ag_block_count ( +struct xfs_mount *mp, +xfs_agnumber_t agno) +{ +ASSERT (agno < mp->m_sb.sb_agcount); + +if (agno < mp->m_sb.sb_agcount -1 ) +return mp->m_sb.sb_agblocks; +return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); +} + +/* +* Verify that an AG block number pointer neither points outside the AG +* nor points at static metadata. +*/ +bool +xfs_verify_agbno ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agblock_t agbno) +{ +xfs_agblock_t eoag; + + eoag =xfs_ag_block_count (mp, agno); +if (agbno >= eoag) +return false; +if (agbno <=XFS_AGFL_BLOCK (mp)) +return false; +return true; +} + +/* +* Verify that an FS block number pointer neither points outside the +* filesystem nor points at static AG metadata. +*/ +bool +xfs_verify_fsbno ( +struct xfs_mount *mp, +xfs_fsblock_t fsbno) +{ +xfs_agnumber_t agno =XFS_FSB_TO_AGNO (mp, fsbno); + +if (agno >= mp->m_sb.sb_agcount) +return false; +return xfs_verify_agbno (mp, agno,XFS_FSB_TO_AGBNO (mp, fsbno)); +} + +/* Calculate the first and last possible inode number in an AG. */ +void +xfs_agino_range ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agino_t *first, +xfs_agino_t *last) +{ +xfs_agblock_t bno; +xfs_agblock_t eoag; + + eoag =xfs_ag_block_count (mp, agno); + +/* +* Calculate the first inode, which will be in the first +* cluster-aligned block after the AGFL. +*/ + bno =round_up (XFS_AGFL_BLOCK (mp) +1 , +xfs_ialloc_cluster_alignment (mp)); + *first =XFS_OFFBNO_TO_AGINO (mp, bno,0 ); + +/* +* Calculate the last inode, which will be at the end of the +* last (aligned) cluster that can be allocated in the AG. +*/ + bno =round_down (eoag,xfs_ialloc_cluster_alignment (mp)); + *last =XFS_OFFBNO_TO_AGINO (mp, bno,0 ) -1 ; +} + +/* +* Verify that an AG inode number pointer neither points outside the AG +* nor points at static metadata. +*/ +bool +xfs_verify_agino ( +struct xfs_mount *mp, +xfs_agnumber_t agno, +xfs_agino_t agino) +{ +xfs_agino_t first; +xfs_agino_t last; + +xfs_agino_range (mp, agno, &first, &last); +return agino >= first && agino <= last; +} + +/* +* Verify that an FS inode number pointer neither points outside the +* filesystem nor points at static AG metadata. +*/ +bool +xfs_verify_ino ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ino); +xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ino); + +if (agno >= mp->m_sb.sb_agcount) +return false; +if (XFS_AGINO_TO_INO (mp, agno, agino) != ino) +return false; +return xfs_verify_agino (mp, agno, agino); +} + +/* Is this an internal inode number? */ +bool +xfs_internal_inum ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || + (xfs_sb_version_hasquota (&mp->m_sb) && +xfs_is_quota_inode (&mp->m_sb, ino)); +} + +/* +* Verify that a directory entry's inode number doesn't point at an internal +* inode, empty space, or static AG metadata. +*/ +bool +xfs_verify_dir_ino ( +struct xfs_mount *mp, +xfs_ino_t ino) +{ +if (xfs_internal_inum (mp, ino)) +return false; +return xfs_verify_ino (mp, ino); +} + +/* +* Verify that an realtime block number pointer doesn't point off the +* end of the realtime device. +*/ +bool +xfs_verify_rtbno ( +struct xfs_mount *mp, +xfs_rtblock_t rtbno) +{ +return rtbno < mp->m_sb.sb_rblocks; +}fs/xfs/libxfs/xfs_types.h +19
-0@@ -147,4 +147,23 @@ typedef struct xfs_bmbt_irecxfs_exntst_t br_state;/* extent state */ } xfs_bmbt_irec_t; +/* +* Type verifier functions +*/ +struct xfs_mount ; + +xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); +bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agblock_t agbno); +bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno); + +void xfs_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t *first,xfs_agino_t *last); +bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, +xfs_agino_t agino); +bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino); +bool xfs_verify_rtbno (struct xfs_mount *mp,xfs_rtblock_t rtbno); +#endif /* __XFS_TYPES_H__ */ fs/xfs/scrub/agheader.c +1
-1@@ -867,7 +867,7 @@ xfs_scrub_agi( }/* Check inode counters */ -xfs_ialloc_agino_range (mp, agno, &first_agino, &last_agino); +xfs_agino_range (mp, agno, &first_agino, &last_agino); icount =be32_to_cpu (agi->agi_count);if (icount > last_agino - first_agino +1 || icount <be32_to_cpu (agi->agi_freecount))Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] xfs: move various type verifiers to common file
In reply to Dave ChinnerQuoted 259 lines · Dave Chinner
From: Dave Chinner <[email protected]>
New verification functions like
xfs_verify_fsbno()andxfs_verify_agino()are spread across multiple files and different header files. They really don't fit cleanly into the places they've been put, and have wider scope than the current header includes.Move the type verifiers to a new file in libxfs (
xfs-types.c) and the prototypes toxfs_types.hwhere they will be visible to all the code that uses the types.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/Makefile | 1 + fs/xfs/libxfs/xfs_alloc.c | 49 ---------- fs/xfs/libxfs/xfs_alloc.h | 4 - fs/xfs/libxfs/xfs_ialloc.c | 90 ------------------ fs/xfs/libxfs/xfs_ialloc.h | 7 -- fs/xfs/libxfs/xfs_rtbitmap.c | 12 --- fs/xfs/libxfs/xfs_types.c | 173 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_types.h | 19 ++++ fs/xfs/scrub/agheader.c | 2 +- 9 files changed, 194 insertions(+), 163 deletions(-) create mode 100644 fs/xfs/libxfs/xfs_types.cfs/xfs/Makefile +1
-0@@ -50,6 +50,7 @@ xfs-y += $(addprefix libxfs/, \ xfs_sb.o \ xfs_symlink_remote.o \ xfs_trans_resv.o \ + xfs_types.o \ ) # xfs_rtbitmap is shared with libxfs xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \fs/xfs/libxfs/xfs_alloc.c +0
-49@@ -3123,55 +3123,6 @@ xfs_alloc_query_all(return xfs_btree_query_all (cur, xfs_alloc_query_range_helper, &query); } -/* Find the size of the AG, in blocks. */ -xfs_agblock_t -xfs_ag_block_count ( -struct xfs_mount *mp, -xfs_agnumber_t agno) -{ -ASSERT (agno < mp->m_sb.sb_agcount); - -if (agno < mp->m_sb.sb_agcount -1 ) -return mp->m_sb.sb_agblocks; -return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); -} - -/* -* Verify that an AG block number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agbno ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agblock_t agbno) -{ -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); -if (agbno >= eoag) -return false; -if (agbno <=XFS_AGFL_BLOCK (mp)) -return false; -return true; -} - -/* -* Verify that an FS block number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_fsbno ( -struct xfs_mount *mp, -xfs_fsblock_t fsbno) -{ -xfs_agnumber_t agno =XFS_FSB_TO_AGNO (mp, fsbno); - -if (agno >= mp->m_sb.sb_agcount) -return false; -return xfs_verify_agbno (mp, agno,XFS_FSB_TO_AGBNO (mp, fsbno)); -} -/* Is there a record covering a given extent? */ int xfs_alloc_has_record(fs/xfs/libxfs/xfs_alloc.h +0
-4@@ -242,10 +242,6 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn, void *priv);int xfs_alloc_query_all (struct xfs_btree_cur *cur,xfs_alloc_query_range_fn fn,void *priv); -xfs_agblock_t xfs_ag_block_count (struct xfs_mount *mp,xfs_agnumber_t agno); -bool xfs_verify_agbno (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agblock_t agbno); -bool xfs_verify_fsbno (struct xfs_mount *mp,xfs_fsblock_t fsbno);int xfs_alloc_has_record (struct xfs_btree_cur *cur,xfs_agblock_t bno,xfs_extlen_t len,bool *exist);fs/xfs/libxfs/xfs_ialloc.c +0
-90@@ -2674,96 +2674,6 @@ xfs_ialloc_pagi_init(return 0 ; } -/* Calculate the first and last possible inode number in an AG. */ -void -xfs_ialloc_agino_range ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t *first, -xfs_agino_t *last) -{ -xfs_agblock_t bno; -xfs_agblock_t eoag; - - eoag =xfs_ag_block_count (mp, agno); - -/* -* Calculate the first inode, which will be in the first -* cluster-aligned block after the AGFL. -*/ - bno =round_up (XFS_AGFL_BLOCK (mp) +1 , -xfs_ialloc_cluster_alignment (mp)); - *first =XFS_OFFBNO_TO_AGINO (mp, bno,0 ); - -/* -* Calculate the last inode, which will be at the end of the -* last (aligned) cluster that can be allocated in the AG. -*/ - bno =round_down (eoag,xfs_ialloc_cluster_alignment (mp)); - *last =XFS_OFFBNO_TO_AGINO (mp, bno,0 ) -1 ; -} - -/* -* Verify that an AG inode number pointer neither points outside the AG -* nor points at static metadata. -*/ -bool -xfs_verify_agino ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -xfs_agino_t agino) -{ -xfs_agino_t first; -xfs_agino_t last; - -xfs_ialloc_agino_range (mp, agno, &first, &last); -return agino >= first && agino <= last; -} - -/* -* Verify that an FS inode number pointer neither points outside the -* filesystem nor points at static AG metadata. -*/ -bool -xfs_verify_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -xfs_agnumber_t agno =XFS_INO_TO_AGNO (mp, ino); -xfs_agino_t agino =XFS_INO_TO_AGINO (mp, ino); - -if (agno >= mp->m_sb.sb_agcount) -return false; -if (XFS_AGINO_TO_INO (mp, agno, agino) != ino) -return false; -return xfs_verify_agino (mp, agno, agino); -} - -/* Is this an internal inode number? */ -bool -xfs_internal_inum ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || - (xfs_sb_version_hasquota (&mp->m_sb) && -xfs_is_quota_inode (&mp->m_sb, ino)); -} - -/* -* Verify that a directory entry's inode number doesn't point at an internal -* inode, empty space, or static AG metadata. -*/ -bool -xfs_verify_dir_ino ( -struct xfs_mount *mp, -xfs_ino_t ino) -{ -if (xfs_internal_inum (mp, ino)) -return false; -return xfs_verify_ino (mp, ino); -} -/* Is there an inode record covering a given range of inode numbers? */ int xfs_ialloc_has_inode_record(fs/xfs/libxfs/xfs_ialloc.h +0
-7@@ -169,12 +169,5 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask, int *stat);int xfs_ialloc_cluster_alignment (struct xfs_mount *mp); -void xfs_ialloc_agino_range (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t *first,xfs_agino_t *last); -bool xfs_verify_agino (struct xfs_mount *mp,xfs_agnumber_t agno, -xfs_agino_t agino); -bool xfs_verify_ino (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_internal_inum (struct xfs_mount *mp,xfs_ino_t ino); -bool xfs_verify_dir_ino (struct xfs_mount *mp,xfs_ino_t ino);#endif /* __XFS_IALLOC_H__ */ fs/xfs/libxfs/xfs_rtbitmap.c +0
-12@@ -1080,18 +1080,6 @@ xfs_rtalloc_query_all(return xfs_rtalloc_query_range (tp, &keys[0 ], &keys[1 ], fn, priv); } -/* -* Verify that an realtime block number pointer doesn't point off the -* end of the realtime device. -*/ -bool -xfs_verify_rtbno ( -struct xfs_mount *mp, -xfs_rtblock_t rtbno) -{ -return rtbno < mp->m_sb.sb_rblocks; -} -/* Is the given extent all free? */ int xfs_rtalloc_extent_is_free(fs/xfs/libxfs/xfs_types.c new file +0
-0
fs/xfs/libxfs/xfs_types.c line 5
Quoted 5 lines
fs/xfs/libxfs/xfs_types.c new file +5
-0@@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* Copyright (C) 2017 Oracle. +* All Rights Reserved.
The all rights reserved statement doesn't relaly make sense with the SPDX header. I guess this is copies from the exiasting code, but we'll need to eventually sort it out.
Otherwise looks fine:
PATCH 2/3 xfs: replace do_mod with native operations
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
do_mod() is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed to do_mod() could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.
As such, we can convert all the do_mod() callers to platform optimised modulus operations as defined by linux/math64.h. Individual conversions depend on the types of variables being used.
--- fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++-------------- fs/xfs/xfs_bmap_util.c | 14 +++++++++----- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iomap.h | 4 ++-- fs/xfs/xfs_linux.h | 19 ------------------- fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++------- fs/xfs/xfs_rtalloc.c | 15 +++++++++++---- 7 files changed, 71 insertions(+), 52 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +23 -14
@@ -2923,7 +2923,7 @@ xfs_bmap_extsize_align(* perform this alignment, or if a truncate shot us in the * foot. */ - temp =do_mod (orig_off, extsz); +div_u64_rem (orig_off, extsz, &temp);if (temp) { align_alen += temp; align_off -= temp;
@@ -3497,15 +3497,17 @@ xfs_bmap_btalloc(/* apply extent size hints if obtained earlier */ if (align) { args.prod = align; -if ((args.mod = (xfs_extlen_t )do_mod (ap->offset, args.prod))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }else if (mp->m_sb.sb_blocksize >=PAGE_SIZE ) { args.prod =1 ; args.mod =0 ; }else { args.prod =PAGE_SIZE >> mp->m_sb.sb_blocklog; -if ((args.mod = (xfs_extlen_t)(do_mod (ap->offset, args.prod)))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }/* * If we are not low on available data blocks, and the
@@ -4953,13 +4955,15 @@ xfs_bmap_del_extent_real(if (whichfork ==XFS_DATA_FORK &&XFS_IS_REALTIME_INODE (ip)) {xfs_fsblock_t bno;xfs_filblks_t len; +xfs_extlen_t mod; + + bno =div_u64_rem (del->br_startblock, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); + len =div_u64_rem (del->br_blockcount, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); -ASSERT (do_mod (del->br_blockcount, mp->m_sb.sb_rextsize) ==0 ); -ASSERT (do_mod (del->br_startblock, mp->m_sb.sb_rextsize) ==0 ); - bno = del->br_startblock; - len = del->br_blockcount; -do_div (bno, mp->m_sb.sb_rextsize); -do_div (len, mp->m_sb.sb_rextsize); error =xfs_rtfree_extent (tp, bno, (xfs_extlen_t )len);if (error) goto done;
@@ -5296,9 +5300,12 @@ __xfs_bunmapi( del.br_blockcount = max_len; } +if (!isrt) + goto delete; + sum = del.br_startblock + del.br_blockcount; -if (isrt && - (mod =do_mod (sum, mp->m_sb.sb_rextsize))) { +div_u64_rem (sum, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent not lined up at the end. * The extent could have been split into written
@@ -5345,7 +5352,8 @@ __xfs_bunmapi( goto error0; goto nodelete; } -if (isrt && (mod =do_mod (del.br_startblock, mp->m_sb.sb_rextsize))) { +div_u64_rem (del.br_startblock, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent is lined up at the end but not * at the front. We'll get rid of full extents if
@@ -5414,6 +5422,7 @@ __xfs_bunmapi( } } +delete:if (wasdel) { error =xfs_bmap_del_extent_delay (ip, whichfork, &icur, &got, &del);
fs/xfs/xfs_bmap_util.c +9 -5
@@ -80,6 +80,7 @@ xfs_bmap_rtalloc(int error;/* error return value */ xfs_mount_t *mp;/* mount point structure */ xfs_extlen_t prod =0 ;/* product factor for allocators */ +xfs_extlen_t mod =0 ;/* product factor for allocators */ xfs_extlen_t ralen =0 ;/* realtime allocation length */ xfs_extlen_t align;/* minimum allocation alignment */ xfs_rtblock_t rtb;
@@ -99,7 +100,8 @@ xfs_bmap_rtalloc(* If the offset & length are not perfectly aligned * then kill prod, it will just get us in trouble. */ -if (do_mod (ap->offset, align) || ap->length % align) +div_u64_rem (ap->offset, align, &mod); +if (mod || ap->length % align) prod =1 ;/* * Set ralen to be the actual requested length in rtextents.
@@ -936,9 +938,11 @@ xfs_alloc_file_space(do_div (s, extsz); s *= extsz; e = startoffset_fsb + allocatesize_fsb; -if ((temp =do_mod (startoffset_fsb, extsz))) +div_u64_rem (startoffset_fsb, extsz, &temp); +if (temp) e += temp; -if ((temp =do_mod (e, extsz))) +div_u64_rem (e, extsz, &temp); +if (temp) e += extsz - temp; }else { s =0 ;
@@ -1090,7 +1094,7 @@ xfs_adjust_extent_unmap_boundaries(struct xfs_mount *mp = ip->i_mount;struct xfs_bmbt_irec imap;int nimap, error; -xfs_extlen_t mod =0 ; +xfs_rtblock_t mod =0 ; nimap =1 ; error =xfs_bmapi_read (ip, *startoffset_fsb,1 , &imap, &nimap,0 );
@@ -1099,7 +1103,7 @@ xfs_adjust_extent_unmap_boundaries(if (nimap && imap.br_startblock !=HOLESTARTBLOCK ) {ASSERT (imap.br_startblock !=DELAYSTARTBLOCK ); - mod =do_mod (imap.br_startblock, mp->m_sb.sb_rextsize); +div64_u64_rem (imap.br_startblock, mp->m_sb.sb_rextsize, &mod);if (mod) *startoffset_fsb += mp->m_sb.sb_rextsize - mod; }
fs/xfs/xfs_inode.c +1 -1
@@ -2258,7 +2258,7 @@ xfs_ifree_cluster(*/ ioffset = inum - xic->first_ino;if ((xic->alloc &XFS_INOBT_MASK (ioffset)) ==0 ) { -ASSERT (do_mod (ioffset, inodes_per_cluster) ==0 ); +ASSERT (ioffset % inodes_per_cluster ==0 );continue ; }
fs/xfs/xfs_iomap.h +2 -2
@@ -30,10 +30,10 @@ xfs_aligned_fsb_count(if (extsz) {xfs_extlen_t align; - align =do_mod (offset_fsb, extsz); +div_u64_rem (offset_fsb, extsz, &align);if (align) count_fsb += align; - align =do_mod (count_fsb, extsz); +div_u64_rem (count_fsb, extsz, &align);if (align) count_fsb += extsz - align; }
fs/xfs/xfs_linux.h +0 -19
@@ -209,25 +209,6 @@ static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)#define xfs_sort (a,n,s,fn) sort(a,n,s,fn,NULL)#define xfs_stack_trace () dump_stack() -/* Side effect free 64 bit mod operation */ -static inline __u32 xfs_do_mod (void *a,__u32 b,int n) -{ -switch (n) { -case 4 : -return *(__u32 *)a % b; -case 8 : - { -__u64 c = *(__u64 *)a; -return do_div (c, b); - } - } - -/* NOTREACHED */ -return 0 ; -} - -#define do_mod (a, b) xfs_do_mod(&(a), (b), sizeof(a)) -static inline uint64_t roundup_64 (uint64_t x,uint32_t y) { x += y -1 ;
fs/xfs/xfs_log_recover.c +25 -7
@@ -1235,6 +1235,25 @@ xlog_verify_head( be32_to_cpu((*rhead)->h_size)); } +/* +* We need to make sure we handle log wrapping properly, so we can't use teh +* calculated logbno directly. Make sure it wraps to teh correct bno inside teh +* log. +* +* The log is limited to 32 bit sizes, so we use the appropriate modulus +* operation here and cast it back to a 64 bit daddr on return. +*/ +static inline xfs_daddr_t +xlog_wrap_logbno ( +struct xlog *log, +xfs_daddr_t bno) +{ +int mod; + +div_s64_rem (bno, log->l_logBBsize, &mod); +return mod; +} +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state
@@ -1283,12 +1302,13 @@ xlog_check_unmount_rec( }else { hblks =1 ; } - after_umount_blk = rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len)); - after_umount_blk =do_mod (after_umount_blk, log->l_logBBsize); + + after_umount_blk =xlog_wrap_logbno (log, + rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len))); +if (*head_blk == after_umount_blk &&be32_to_cpu (rhead->h_num_logops) ==1 ) { - umount_data_blk = rhead_blk + hblks; - umount_data_blk =do_mod (umount_data_blk, log->l_logBBsize); + umount_data_blk =xlog_wrap_logbno (log, rhead_blk + hblks); error =xlog_bread (log, umount_data_blk,1 , bp, &offset);if (error)return error;
@@ -5459,9 +5479,7 @@ xlog_do_recovery_pass(*/ if (blk_no + bblks <= log->l_logBBsize || blk_no >= log->l_logBBsize) { -/* mod blk_no in case the header wrapped and -* pushed it beyond the end of the log */ - rblk_no =do_mod (blk_no, log->l_logBBsize); + rblk_no =xlog_wrap_logbno (log, blk_no); error =xlog_bread (log, rblk_no, bblks, dbp, &offset);if (error)
fs/xfs/xfs_rtalloc.c +11 -4
@@ -301,8 +301,12 @@ xfs_rtallocate_extent_block(/* * If size should be a multiple of prod, make that so. */ -if (prod >1 && (p =do_mod (bestlen, prod))) - bestlen -= p; +if (prod >1 ) { +div_u64_rem (bestlen, prod, &p); +if (p) + bestlen -= p; + } +/* * Allocate besti for bestlen & return that. */
@@ -1262,8 +1266,11 @@ xfs_rtpick_extent( resid = seq - (1ULL << log2); b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 ); -if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +if (b >= mp->m_sb.sb_rextents) { +xfs_rtblock_t mod; +div64_u64_rem (b, mp->m_sb.sb_rextents, &mod); + b = mod; + }if (b + len > mp->m_sb.sb_rextents) b = mp->m_sb.sb_rextents - len; }
Signature · 1 line
2.17.0
Re: [PATCH 2/3] xfs: replace do_mod with native operations
Quoted 24 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++-------------- fs/xfs/xfs_bmap_util.c | 14 +++++++++----- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iomap.h | 4 ++-- fs/xfs/xfs_linux.h | 19 ------------------- fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++------- fs/xfs/xfs_rtalloc.c | 15 +++++++++++---- 7 files changed, 71 insertions(+), 52 deletions(-)
...
fs/xfs/xfs_log_recover.c xlog_verify_head( · line 1242
Quoted 13 lines
fs/xfs/xfs_log_recover.c +5
-0@@ -1235,6 +1235,25 @@ xlog_verify_head( be32_to_cpu((*rhead)->h_size)); } +/* +* We need to make sure we handle log wrapping properly, so we can't use teh +* calculated logbno directly. Make sure it wraps to teh correct bno inside teh +* log. +*
s/teh/the/
Quoted 17 lines
fs/xfs/xfs_log_recover.c +14
-0+* The log is limited to 32 bit sizes, so we use the appropriate modulus +* operation here and cast it back to a 64 bit daddr on return. +*/ +static inline xfs_daddr_t +xlog_wrap_logbno ( +struct xlog *log, +xfs_daddr_t bno) +{ +int mod; + +div_s64_rem (bno, log->l_logBBsize, &mod); +return mod; +} +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state
...
Quoted 4 lines
fs/xfs/xfs_rtalloc.c +0
-0
...
fs/xfs/xfs_rtalloc.c xfs_rtpick_extent( · line 1273
Quoted 11 lines
fs/xfs/xfs_rtalloc.c +5
-2@@ -1262,8 +1266,11 @@ xfs_rtpick_extent( resid = seq - (1ULL << log2); b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 ); -if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +if (b >= mp->m_sb.sb_rextents) { +xfs_rtblock_t mod; +div64_u64_rem (b, mp->m_sb.sb_rextents, &mod); + b = mod; + }
Shouldn't we be able to do 'div64_u64_rem(b, mp->m_sb.sb_rextents, &b)' here? Otherwise looks fine:
Quoted 10 lines
fs/xfs/xfs_rtalloc.c +0
-0if (b + len > mp->m_sb.sb_rextents) b = mp->m_sb.sb_rextents - len; }Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] xfs: replace do_mod with native operations
Quoted 65 lines · Brian Foster
Quoted 24 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++-------------- fs/xfs/xfs_bmap_util.c | 14 +++++++++----- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iomap.h | 4 ++-- fs/xfs/xfs_linux.h | 19 ------------------- fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++------- fs/xfs/xfs_rtalloc.c | 15 +++++++++++---- 7 files changed, 71 insertions(+), 52 deletions(-)...
fs/xfs/xfs_log_recover.c xlog_verify_head( · line 1242
Quoted 13 lines
fs/xfs/xfs_log_recover.c +5
-0@@ -1235,6 +1235,25 @@ xlog_verify_head( be32_to_cpu((*rhead)->h_size)); } +/* +* We need to make sure we handle log wrapping properly, so we can't use teh +* calculated logbno directly. Make sure it wraps to teh correct bno inside teh +* log. +* s/teh/the/
Quoted 17 lines
fs/xfs/xfs_log_recover.c +14
-0+* The log is limited to 32 bit sizes, so we use the appropriate modulus +* operation here and cast it back to a 64 bit daddr on return. +*/ +static inline xfs_daddr_t +xlog_wrap_logbno ( +struct xlog *log, +xfs_daddr_t bno) +{ +int mod; + +div_s64_rem (bno, log->l_logBBsize, &mod); +return mod; +} +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state ...
Quoted 4 lines
fs/xfs/xfs_rtalloc.c +0
-0...
Quoted 14 lines
fs/xfs/xfs_rtalloc.c xfs_rtpick_extent( · line 1273
Quoted 11 lines
fs/xfs/xfs_rtalloc.c +5
-2@@ -1262,8 +1266,11 @@ xfs_rtpick_extent( resid = seq - (1ULL << log2); b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 ); -if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +if (b >= mp->m_sb.sb_rextents) { +xfs_rtblock_t mod; +div64_u64_rem (b, mp->m_sb.sb_rextents, &mod); + b = mod; + }Shouldn't we be able to do '
div64_u64_rem(b, mp->m_sb.sb_rextents, &b)' here? Otherwise looks fine:
I think Dave is trying to avoid aliasing the arguments in case div64_u64_rem ever gets turned into a horrible macro (or over-optimized by gcc)
--D
Quoted 17 lines
Reviewed-by Brian Foster <[email protected]>Quoted 10 lines
fs/xfs/xfs_rtalloc.c +0
-0if (b + len > mp->m_sb.sb_rextents) b = mp->m_sb.sb_rextents - len; }Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] xfs: replace do_mod with native operations
In reply to Brian FosterQuoted 15 lines · Brian Foster
Quoted 14 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.Signed-off-by Dave Chinner <[email protected]>
....
Quoted 5 lines
Quoted 4 lines
fs/xfs/xfs_rtalloc.c +0
-0...
Quoted 14 lines
fs/xfs/xfs_rtalloc.c xfs_rtpick_extent( · line 1273
Quoted 11 lines
fs/xfs/xfs_rtalloc.c +5
-2@@ -1262,8 +1266,11 @@ xfs_rtpick_extent( resid = seq - (1ULL << log2); b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 ); -if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +if (b >= mp->m_sb.sb_rextents) { +xfs_rtblock_t mod; +div64_u64_rem (b, mp->m_sb.sb_rextents, &mod); + b = mod; + }Shouldn't we be able to do '
div64_u64_rem(b, mp->m_sb.sb_rextents, &b)' here? Otherwise looks fine:
Yeah, I think we can. IIRC I was looking at various implementations and took the template from something like dm_sector_div64() because "obviously correct" :)
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 2/3] xfs: replace do_mod with native operations
In reply to Dave ChinnerQuoted 119 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++-------------- fs/xfs/xfs_bmap_util.c | 14 +++++++++----- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iomap.h | 4 ++-- fs/xfs/xfs_linux.h | 19 ------------------- fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++------- fs/xfs/xfs_rtalloc.c | 15 +++++++++++---- 7 files changed, 71 insertions(+), 52 deletions(-)fs/xfs/libxfs/xfs_bmap.c +23
-14@@ -2923,7 +2923,7 @@ xfs_bmap_extsize_align(* perform this alignment, or if a truncate shot us in the * foot. */ - temp =do_mod (orig_off, extsz); +div_u64_rem (orig_off, extsz, &temp);if (temp) { align_alen += temp; align_off -= temp;@@ -3497,15 +3497,17 @@ xfs_bmap_btalloc(/* apply extent size hints if obtained earlier */ if (align) { args.prod = align; -if ((args.mod = (xfs_extlen_t )do_mod (ap->offset, args.prod))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }else if (mp->m_sb.sb_blocksize >=PAGE_SIZE ) { args.prod =1 ; args.mod =0 ; }else { args.prod =PAGE_SIZE >> mp->m_sb.sb_blocklog; -if ((args.mod = (xfs_extlen_t)(do_mod (ap->offset, args.prod)))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }/* * If we are not low on available data blocks, and the @@ -4953,13 +4955,15 @@ xfs_bmap_del_extent_real(if (whichfork ==XFS_DATA_FORK &&XFS_IS_REALTIME_INODE (ip)) {xfs_fsblock_t bno;xfs_filblks_t len; +xfs_extlen_t mod; + + bno =div_u64_rem (del->br_startblock, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); + len =div_u64_rem (del->br_blockcount, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); -ASSERT (do_mod (del->br_blockcount, mp->m_sb.sb_rextsize) ==0 ); -ASSERT (do_mod (del->br_startblock, mp->m_sb.sb_rextsize) ==0 ); - bno = del->br_startblock; - len = del->br_blockcount; -do_div (bno, mp->m_sb.sb_rextsize); -do_div (len, mp->m_sb.sb_rextsize); error =xfs_rtfree_extent (tp, bno, (xfs_extlen_t )len);if (error) goto done;@@ -5296,9 +5300,12 @@ __xfs_bunmapi( del.br_blockcount = max_len; } +if (!isrt) + goto delete; + sum = del.br_startblock + del.br_blockcount; -if (isrt && - (mod =do_mod (sum, mp->m_sb.sb_rextsize))) { +div_u64_rem (sum, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent not lined up at the end. * The extent could have been split into written @@ -5345,7 +5352,8 @@ __xfs_bunmapi( goto error0; goto nodelete; } -if (isrt && (mod =do_mod (del.br_startblock, mp->m_sb.sb_rextsize))) { +div_u64_rem (del.br_startblock, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent is lined up at the end but not * at the front. We'll get rid of full extents if @@ -5414,6 +5422,7 @@ __xfs_bunmapi( } } +delete:if (wasdel) { error =xfs_bmap_del_extent_delay (ip, whichfork, &icur, &got, &del);fs/xfs/xfs_bmap_util.c +0
-0
fs/xfs/xfs_bmap_util.c xfs_bmap_rtalloc( · line 83
Quoted 4 lines
fs/xfs/xfs_bmap_util.c +1
-0@@ -80,6 +80,7 @@ xfs_bmap_rtalloc(int error;/* error return value */ xfs_mount_t *mp;/* mount point structure */ xfs_extlen_t prod =0 ;/* product factor for allocators */ +xfs_extlen_t mod =0 ;/* product factor for allocators */
I don't think we need the initial value or the comment.
Quoted 37 lines
fs/xfs/xfs_bmap_util.c +7
-4xfs_extlen_t ralen =0 ;/* realtime allocation length */ xfs_extlen_t align;/* minimum allocation alignment */ xfs_rtblock_t rtb;@@ -99,7 +100,8 @@ xfs_bmap_rtalloc(* If the offset & length are not perfectly aligned * then kill prod, it will just get us in trouble. */ -if (do_mod (ap->offset, align) || ap->length % align) +div_u64_rem (ap->offset, align, &mod); +if (mod || ap->length % align) prod =1 ;/* * Set ralen to be the actual requested length in rtextents. @@ -936,9 +938,11 @@ xfs_alloc_file_space(do_div (s, extsz); s *= extsz; e = startoffset_fsb + allocatesize_fsb; -if ((temp =do_mod (startoffset_fsb, extsz))) +div_u64_rem (startoffset_fsb, extsz, &temp); +if (temp) e += temp; -if ((temp =do_mod (e, extsz))) +div_u64_rem (e, extsz, &temp); +if (temp) e += extsz - temp; }else { s =0 ;@@ -1090,7 +1094,7 @@ xfs_adjust_extent_unmap_boundaries(struct xfs_mount *mp = ip->i_mount;struct xfs_bmbt_irec imap;int nimap, error; -xfs_extlen_t mod =0 ; +xfs_rtblock_t mod =0 ; nimap =1 ; error =xfs_bmapi_read (ip, *startoffset_fsb,1 , &imap, &nimap,0 );
fs/xfs/xfs_bmap_util.c xfs_adjust_extent_unmap_boundaries( · line 1106
Quoted 5 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1099,7 +1103,7 @@ xfs_adjust_extent_unmap_boundaries(if (nimap && imap.br_startblock !=HOLESTARTBLOCK ) {ASSERT (imap.br_startblock !=DELAYSTARTBLOCK ); - mod =do_mod (imap.br_startblock, mp->m_sb.sb_rextsize); +div64_u64_rem (imap.br_startblock, mp->m_sb.sb_rextsize, &mod);
Why does this need to be a div64_u64_rem? sb_rextsize is 32-bit, so the remainder won't exceed 2^32-1, right?
fs/xfs/xfs_bmap_util.c xfs_adjust_extent_unmap_boundaries( · line 1108
Quoted 2 lines
fs/xfs/xfs_bmap_util.c +0
-0if (mod) *startoffset_fsb += mp->m_sb.sb_rextsize - mod;
Indeed if it ever did that would screw up this logic, wouldn't it?
--D
Quoted 160 lines
fs/xfs/xfs_bmap_util.c +0
-0}fs/xfs/xfs_inode.c +1
-1@@ -2258,7 +2258,7 @@ xfs_ifree_cluster(*/ ioffset = inum - xic->first_ino;if ((xic->alloc &XFS_INOBT_MASK (ioffset)) ==0 ) { -ASSERT (do_mod (ioffset, inodes_per_cluster) ==0 ); +ASSERT (ioffset % inodes_per_cluster ==0 );continue ; }fs/xfs/xfs_iomap.h +2
-2@@ -30,10 +30,10 @@ xfs_aligned_fsb_count(if (extsz) {xfs_extlen_t align; - align =do_mod (offset_fsb, extsz); +div_u64_rem (offset_fsb, extsz, &align);if (align) count_fsb += align; - align =do_mod (count_fsb, extsz); +div_u64_rem (count_fsb, extsz, &align);if (align) count_fsb += extsz - align; }fs/xfs/xfs_linux.h +0
-19@@ -209,25 +209,6 @@ static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)#define xfs_sort (a,n,s,fn) sort(a,n,s,fn,NULL)#define xfs_stack_trace () dump_stack() -/* Side effect free 64 bit mod operation */ -static inline __u32 xfs_do_mod (void *a,__u32 b,int n) -{ -switch (n) { -case 4 : -return *(__u32 *)a % b; -case 8 : - { -__u64 c = *(__u64 *)a; -return do_div (c, b); - } - } - -/* NOTREACHED */ -return 0 ; -} - -#define do_mod (a, b) xfs_do_mod(&(a), (b), sizeof(a)) -static inline uint64_t roundup_64 (uint64_t x,uint32_t y) { x += y -1 ;fs/xfs/xfs_log_recover.c +25
-7@@ -1235,6 +1235,25 @@ xlog_verify_head( be32_to_cpu((*rhead)->h_size)); } +/* +* We need to make sure we handle log wrapping properly, so we can't use teh +* calculated logbno directly. Make sure it wraps to teh correct bno inside teh +* log. +* +* The log is limited to 32 bit sizes, so we use the appropriate modulus +* operation here and cast it back to a 64 bit daddr on return. +*/ +static inline xfs_daddr_t +xlog_wrap_logbno ( +struct xlog *log, +xfs_daddr_t bno) +{ +int mod; + +div_s64_rem (bno, log->l_logBBsize, &mod); +return mod; +} +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state @@ -1283,12 +1302,13 @@ xlog_check_unmount_rec( }else { hblks =1 ; } - after_umount_blk = rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len)); - after_umount_blk =do_mod (after_umount_blk, log->l_logBBsize); + + after_umount_blk =xlog_wrap_logbno (log, + rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len))); +if (*head_blk == after_umount_blk &&be32_to_cpu (rhead->h_num_logops) ==1 ) { - umount_data_blk = rhead_blk + hblks; - umount_data_blk =do_mod (umount_data_blk, log->l_logBBsize); + umount_data_blk =xlog_wrap_logbno (log, rhead_blk + hblks); error =xlog_bread (log, umount_data_blk,1 , bp, &offset);if (error)return error;@@ -5459,9 +5479,7 @@ xlog_do_recovery_pass(*/ if (blk_no + bblks <= log->l_logBBsize || blk_no >= log->l_logBBsize) { -/* mod blk_no in case the header wrapped and -* pushed it beyond the end of the log */ - rblk_no =do_mod (blk_no, log->l_logBBsize); + rblk_no =xlog_wrap_logbno (log, blk_no); error =xlog_bread (log, rblk_no, bblks, dbp, &offset);if (error)fs/xfs/xfs_rtalloc.c +11
-4@@ -301,8 +301,12 @@ xfs_rtallocate_extent_block(/* * If size should be a multiple of prod, make that so. */ -if (prod >1 && (p =do_mod (bestlen, prod))) - bestlen -= p; +if (prod >1 ) { +div_u64_rem (bestlen, prod, &p); +if (p) + bestlen -= p; + } +/* * Allocate besti for bestlen & return that. */ @@ -1262,8 +1266,11 @@ xfs_rtpick_extent( resid = seq - (1ULL << log2); b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 ); -if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +if (b >= mp->m_sb.sb_rextents) { +xfs_rtblock_t mod; +div64_u64_rem (b, mp->m_sb.sb_rextents, &mod); + b = mod; + }if (b + len > mp->m_sb.sb_rextents) b = mp->m_sb.sb_rextents - len; }Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] xfs: replace do_mod with native operations
Quoted 16 lines · Darrick J. Wong
Quoted 15 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.Signed-off-by Dave Chinner <[email protected]>---
.....
Quoted 19 lines
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1090,7 +1094,7 @@ xfs_adjust_extent_unmap_boundaries(struct xfs_mount *mp = ip->i_mount;struct xfs_bmbt_irec imap;int nimap, error; -xfs_extlen_t mod =0 ; +xfs_rtblock_t mod =0 ; nimap =1 ; error =xfs_bmapi_read (ip, *startoffset_fsb,1 , &imap, &nimap,0 );fs/xfs/xfs_bmap_util.c xfs_adjust_extent_unmap_boundaries( · line 1106
Quoted 5 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1099,7 +1103,7 @@ xfs_adjust_extent_unmap_boundaries(if (nimap && imap.br_startblock !=HOLESTARTBLOCK ) {ASSERT (imap.br_startblock !=DELAYSTARTBLOCK ); - mod =do_mod (imap.br_startblock, mp->m_sb.sb_rextsize); +div64_u64_rem (imap.br_startblock, mp->m_sb.sb_rextsize, &mod);Why does this need to be a
div64_u64_rem?sb_rextsizeis 32-bit, so the remainder won't exceed 2^32-1, right?
Quoted 4 lines
fs/xfs/xfs_bmap_util.c xfs_adjust_extent_unmap_boundaries( · line 1108
Quoted 2 lines
fs/xfs/xfs_bmap_util.c +0
-0if (mod) *startoffset_fsb += mp->m_sb.sb_rextsize - mod;Indeed if it ever did that would screw up this logic, wouldn't it?
Yeah, i think I screwed that one up, probably confused rextsize with rextents. IOWs mod can remain as a xfs_extlen_t and this can become div_u64_rem().
I'll fix and repost.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 2/3 xfs: replace do_mod with native operations
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
do_mod() is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed to do_mod() could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.
As such, we can convert all the do_mod() callers to platform optimised modulus operations as defined by linux/math64.h. Individual conversions depend on the types of variables being used.
---
Version 2:
- fix typos
- remove unnecessary temp var from xfs_rtextent_pick
- use div_u64_rem() in xfs_adjust_extent_unmap_boundaries()
fs/xfs/libxfs/xfs_bmap.c | 37 +++++++++++++++++++++++-------------- fs/xfs/xfs_bmap_util.c | 12 ++++++++---- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iomap.h | 4 ++-- fs/xfs/xfs_linux.h | 19 ------------------- fs/xfs/xfs_log_recover.c | 32 +++++++++++++++++++++++++------- fs/xfs/xfs_rtalloc.c | 10 +++++++--- 7 files changed, 66 insertions(+), 50 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +23 -14
@@ -2923,7 +2923,7 @@ xfs_bmap_extsize_align(* perform this alignment, or if a truncate shot us in the * foot. */ - temp =do_mod (orig_off, extsz); +div_u64_rem (orig_off, extsz, &temp);if (temp) { align_alen += temp; align_off -= temp;
@@ -3497,15 +3497,17 @@ xfs_bmap_btalloc(/* apply extent size hints if obtained earlier */ if (align) { args.prod = align; -if ((args.mod = (xfs_extlen_t )do_mod (ap->offset, args.prod))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }else if (mp->m_sb.sb_blocksize >=PAGE_SIZE ) { args.prod =1 ; args.mod =0 ; }else { args.prod =PAGE_SIZE >> mp->m_sb.sb_blocklog; -if ((args.mod = (xfs_extlen_t)(do_mod (ap->offset, args.prod)))) - args.mod = (xfs_extlen_t)(args.prod - args.mod); +div_u64_rem (ap->offset, args.prod, &args.mod); +if (args.mod) + args.mod = args.prod - args.mod; }/* * If we are not low on available data blocks, and the
@@ -4953,13 +4955,15 @@ xfs_bmap_del_extent_real(if (whichfork ==XFS_DATA_FORK &&XFS_IS_REALTIME_INODE (ip)) {xfs_fsblock_t bno;xfs_filblks_t len; +xfs_extlen_t mod; + + bno =div_u64_rem (del->br_startblock, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); + len =div_u64_rem (del->br_blockcount, mp->m_sb.sb_rextsize, + &mod); +ASSERT (mod ==0 ); -ASSERT (do_mod (del->br_blockcount, mp->m_sb.sb_rextsize) ==0 ); -ASSERT (do_mod (del->br_startblock, mp->m_sb.sb_rextsize) ==0 ); - bno = del->br_startblock; - len = del->br_blockcount; -do_div (bno, mp->m_sb.sb_rextsize); -do_div (len, mp->m_sb.sb_rextsize); error =xfs_rtfree_extent (tp, bno, (xfs_extlen_t )len);if (error) goto done;
@@ -5296,9 +5300,12 @@ __xfs_bunmapi( del.br_blockcount = max_len; } +if (!isrt) + goto delete; + sum = del.br_startblock + del.br_blockcount; -if (isrt && - (mod =do_mod (sum, mp->m_sb.sb_rextsize))) { +div_u64_rem (sum, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent not lined up at the end. * The extent could have been split into written
@@ -5345,7 +5352,8 @@ __xfs_bunmapi( goto error0; goto nodelete; } -if (isrt && (mod =do_mod (del.br_startblock, mp->m_sb.sb_rextsize))) { +div_u64_rem (del.br_startblock, mp->m_sb.sb_rextsize, &mod); +if (mod) {/* * Realtime extent is lined up at the end but not * at the front. We'll get rid of full extents if
@@ -5414,6 +5422,7 @@ __xfs_bunmapi( } } +delete:if (wasdel) { error =xfs_bmap_del_extent_delay (ip, whichfork, &icur, &got, &del);
fs/xfs/xfs_bmap_util.c +8 -4
@@ -80,6 +80,7 @@ xfs_bmap_rtalloc(int error;/* error return value */ xfs_mount_t *mp;/* mount point structure */ xfs_extlen_t prod =0 ;/* product factor for allocators */ +xfs_extlen_t mod =0 ;/* product factor for allocators */ xfs_extlen_t ralen =0 ;/* realtime allocation length */ xfs_extlen_t align;/* minimum allocation alignment */ xfs_rtblock_t rtb;
@@ -99,7 +100,8 @@ xfs_bmap_rtalloc(* If the offset & length are not perfectly aligned * then kill prod, it will just get us in trouble. */ -if (do_mod (ap->offset, align) || ap->length % align) +div_u64_rem (ap->offset, align, &mod); +if (mod || ap->length % align) prod =1 ;/* * Set ralen to be the actual requested length in rtextents.
@@ -936,9 +938,11 @@ xfs_alloc_file_space(do_div (s, extsz); s *= extsz; e = startoffset_fsb + allocatesize_fsb; -if ((temp =do_mod (startoffset_fsb, extsz))) +div_u64_rem (startoffset_fsb, extsz, &temp); +if (temp) e += temp; -if ((temp =do_mod (e, extsz))) +div_u64_rem (e, extsz, &temp); +if (temp) e += extsz - temp; }else { s =0 ;
@@ -1099,7 +1103,7 @@ xfs_adjust_extent_unmap_boundaries(if (nimap && imap.br_startblock !=HOLESTARTBLOCK ) {ASSERT (imap.br_startblock !=DELAYSTARTBLOCK ); - mod =do_mod (imap.br_startblock, mp->m_sb.sb_rextsize); +div_u64_rem (imap.br_startblock, mp->m_sb.sb_rextsize, &mod);if (mod) *startoffset_fsb += mp->m_sb.sb_rextsize - mod; }
fs/xfs/xfs_inode.c +1 -1
@@ -2258,7 +2258,7 @@ xfs_ifree_cluster(*/ ioffset = inum - xic->first_ino;if ((xic->alloc &XFS_INOBT_MASK (ioffset)) ==0 ) { -ASSERT (do_mod (ioffset, inodes_per_cluster) ==0 ); +ASSERT (ioffset % inodes_per_cluster ==0 );continue ; }
fs/xfs/xfs_iomap.h +2 -2
@@ -30,10 +30,10 @@ xfs_aligned_fsb_count(if (extsz) {xfs_extlen_t align; - align =do_mod (offset_fsb, extsz); +div_u64_rem (offset_fsb, extsz, &align);if (align) count_fsb += align; - align =do_mod (count_fsb, extsz); +div_u64_rem (count_fsb, extsz, &align);if (align) count_fsb += extsz - align; }
fs/xfs/xfs_linux.h +0 -19
@@ -209,25 +209,6 @@ static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)#define xfs_sort (a,n,s,fn) sort(a,n,s,fn,NULL)#define xfs_stack_trace () dump_stack() -/* Side effect free 64 bit mod operation */ -static inline __u32 xfs_do_mod (void *a,__u32 b,int n) -{ -switch (n) { -case 4 : -return *(__u32 *)a % b; -case 8 : - { -__u64 c = *(__u64 *)a; -return do_div (c, b); - } - } - -/* NOTREACHED */ -return 0 ; -} - -#define do_mod (a, b) xfs_do_mod(&(a), (b), sizeof(a)) -static inline uint64_t roundup_64 (uint64_t x,uint32_t y) { x += y -1 ;
fs/xfs/xfs_log_recover.c +25 -7
@@ -1235,6 +1235,25 @@ xlog_verify_head( be32_to_cpu((*rhead)->h_size)); } +/* +* We need to make sure we handle log wrapping properly, so we can't use the +* calculated logbno directly. Make sure it wraps to the correct bno inside the +* log. +* +* The log is limited to 32 bit sizes, so we use the appropriate modulus +* operation here and cast it back to a 64 bit daddr on return. +*/ +static inline xfs_daddr_t +xlog_wrap_logbno ( +struct xlog *log, +xfs_daddr_t bno) +{ +int mod; + +div_s64_rem (bno, log->l_logBBsize, &mod); +return mod; +} +/* * Check whether the head of the log points to an unmount record. In other * words, determine whether the log is clean. If so, update the in-core state
@@ -1283,12 +1302,13 @@ xlog_check_unmount_rec( }else { hblks =1 ; } - after_umount_blk = rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len)); - after_umount_blk =do_mod (after_umount_blk, log->l_logBBsize); + + after_umount_blk =xlog_wrap_logbno (log, + rhead_blk + hblks +BTOBB (be32_to_cpu (rhead->h_len))); +if (*head_blk == after_umount_blk &&be32_to_cpu (rhead->h_num_logops) ==1 ) { - umount_data_blk = rhead_blk + hblks; - umount_data_blk =do_mod (umount_data_blk, log->l_logBBsize); + umount_data_blk =xlog_wrap_logbno (log, rhead_blk + hblks); error =xlog_bread (log, umount_data_blk,1 , bp, &offset);if (error)return error;
@@ -5459,9 +5479,7 @@ xlog_do_recovery_pass(*/ if (blk_no + bblks <= log->l_logBBsize || blk_no >= log->l_logBBsize) { -/* mod blk_no in case the header wrapped and -* pushed it beyond the end of the log */ - rblk_no =do_mod (blk_no, log->l_logBBsize); + rblk_no =xlog_wrap_logbno (log, blk_no); error =xlog_bread (log, rblk_no, bblks, dbp, &offset);if (error)
fs/xfs/xfs_rtalloc.c +7 -3
@@ -301,8 +301,12 @@ xfs_rtallocate_extent_block(/* * If size should be a multiple of prod, make that so. */ -if (prod >1 && (p =do_mod (bestlen, prod))) - bestlen -= p; +if (prod >1 ) { +div_u64_rem (bestlen, prod, &p); +if (p) + bestlen -= p; + } +/* * Allocate besti for bestlen & return that. */
@@ -1263,7 +1267,7 @@ xfs_rtpick_extent( b = (mp->m_sb.sb_rextents * ((resid <<1 ) +1ULL )) >> (log2 +1 );if (b >= mp->m_sb.sb_rextents) - b =do_mod (b, mp->m_sb.sb_rextents); +div64_u64_rem (b, mp->m_sb.sb_rextents, &b);if (b + len > mp->m_sb.sb_rextents) b = mp->m_sb.sb_rextents - len; }
Re: [PATCH 2/3 V2] xfs: replace do_mod with native operations
Quoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.
Quoted 3 lines
As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.
I have to admit the XFS helpers are much more intuitive.
Quoted 1 line
7 files changed, 66 insertions(+), 50 deletions(-)
And the diffstat agrees with me.
I'd rather see the XFS helpers lifted to the kernel on an as-needed basis than making the code bigger and more hairy.
Re: [PATCH 2/3 V2] xfs: replace do_mod with native operations
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
do_mod()is a hold-over from when we have different sizes for file offsets and and other internal values for 40 bit XFS filesystems. Hence depending on build flags variables passed todo_mod()could change size. We no longer support those small format filesystems and hence everything is of fixed size theses days, even on 32 bit platforms.
Quoted 5 lines
Quoted 3 lines
As such, we can convert all the
do_mod()callers to platform optimised modulus operations as defined bylinux/math64.h. Individual conversions depend on the types of variables being used.I have to admit the XFS helpers are much more intuitive.
I've always found them opaque and clunky, especially with the return value casts they seem to be frequently (but not consistently) associated with.
Quoted 3 lines
Quoted 1 line
7 files changed, 66 insertions(+), 50 deletions(-)And the diffstat agrees with me.
No, it's doesn't, actually. The diffstat changes because I separated calculations from logic operations, just like we do catching and checking error returns from functions. i.e. the code goes from this horrible mess or assignments, casts and calculations intermingled with flow/logic decisions:
if ((args.mod = (xfs_extlen_t)do_mod(ap->offset, args.prod)))
args.mod = (xfs_extlen_t)(args.prod - args.mod);Into a clear separation of calculation and logic statements like this:
div_u64_rem(ap->offset, args.prod, &args.mod);
if (args.mod)
args.mod = args.prod - args.mod;That is also our preferred style for all the code (e.g. for catching and checking errors). Yes, that means a slight growth in code size, but I'll take that any day of the week if it means the code is easier to read....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH 3/3 xfs: clean up MIN/MAX
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Get rid of the MIN/MAX macros and just use the native min/max macros directly in the XFS code.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 8 ++++---- fs/xfs/libxfs/xfs_dir2_leaf.c | 8 ++++---- fs/xfs/libxfs/xfs_sb.c | 2 +- fs/xfs/libxfs/xfs_trans_resv.c | 16 ++++++++-------- fs/xfs/xfs_buf_item.c | 2 +- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_itable.c | 2 +- fs/xfs/xfs_linux.h | 2 -- fs/xfs/xfs_log.c | 4 ++-- fs/xfs/xfs_log_recover.c | 6 +++--- fs/xfs/xfs_mount.h | 2 +- fs/xfs/xfs_super.c | 2 +- 15 files changed, 32 insertions(+), 34 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +1 -1
@@ -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 */
fs/xfs/libxfs/xfs_bmap.c +1 -1
@@ -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) {
fs/xfs/libxfs/xfs_da_btree.c +1 -1
@@ -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,
fs/xfs/libxfs/xfs_dir2_block.c +4 -4
@@ -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 ); }
fs/xfs/libxfs/xfs_dir2_leaf.c +4 -4
@@ -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]; }
fs/xfs/libxfs/xfs_sb.c +1 -1
@@ -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;
fs/xfs/libxfs/xfs_trans_resv.c +8 -8
@@ -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 uintxfs_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,
fs/xfs/xfs_buf_item.c +1 -1
@@ -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++;
fs/xfs/xfs_iomap.c +3 -3
@@ -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;
fs/xfs/xfs_itable.c +1 -1
@@ -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;
fs/xfs/xfs_linux.h +0 -2
@@ -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)
fs/xfs/xfs_log.c +2 -2
@@ -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 ;
fs/xfs/xfs_log_recover.c +3 -3
@@ -1824,7 +1824,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) {/*
@@ -2892,14 +2892,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);
fs/xfs/xfs_mount.h +1 -1
@@ -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 )); }
fs/xfs/xfs_super.c +1 -1
@@ -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,
Signature · 1 line
2.17.0
Re: [PATCH 3/3] xfs: clean up MIN/MAX
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
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 <[email protected]>---
Quoted 338 lines
fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 2 +- fs/xfs/libxfs/xfs_dir2_block.c | 8 ++++---- fs/xfs/libxfs/xfs_dir2_leaf.c | 8 ++++---- fs/xfs/libxfs/xfs_sb.c | 2 +- fs/xfs/libxfs/xfs_trans_resv.c | 16 ++++++++-------- fs/xfs/xfs_buf_item.c | 2 +- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_itable.c | 2 +- fs/xfs/xfs_linux.h | 2 -- fs/xfs/xfs_log.c | 4 ++-- fs/xfs/xfs_log_recover.c | 6 +++--- fs/xfs/xfs_mount.h | 2 +- fs/xfs/xfs_super.c | 2 +- 15 files changed, 32 insertions(+), 34 deletions(-)fs/xfs/libxfs/xfs_attr_leaf.c +1
-1@@ -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 */ fs/xfs/libxfs/xfs_bmap.c +1
-1@@ -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) {fs/xfs/libxfs/xfs_da_btree.c +1
-1@@ -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,fs/xfs/libxfs/xfs_dir2_block.c +4
-4@@ -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 ); }fs/xfs/libxfs/xfs_dir2_leaf.c +4
-4@@ -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]; }fs/xfs/libxfs/xfs_sb.c +1
-1@@ -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;fs/xfs/libxfs/xfs_trans_resv.c +8
-8@@ -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 uintxfs_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,fs/xfs/xfs_buf_item.c +1
-1@@ -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++;fs/xfs/xfs_iomap.c +3
-3@@ -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;fs/xfs/xfs_itable.c +1
-1@@ -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;fs/xfs/xfs_linux.h +0
-2@@ -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)fs/xfs/xfs_log.c +2
-2@@ -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 ;fs/xfs/xfs_log_recover.c +3
-3@@ -1824,7 +1824,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) {/* @@ -2892,14 +2892,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);fs/xfs/xfs_mount.h +1
-1@@ -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 )); }fs/xfs/xfs_super.c +1
-1@@ -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,Signature · 6 lines
2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] xfs: clean up MIN/MAX
In reply to Dave ChinnerQuoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
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 <[email protected]>
Looks good,