Message ID | 20200831130010.454-2-chandanrlinux@gmail.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | xfs: Extend per-inode extent counters | expand |
On Mon, Aug 31, 2020 at 06:30:08PM +0530, Chandan Babu R wrote: > xfs_iext_max() returns the maximum number of extents possible for either > data fork or attribute fork. This helper will be extended further in a > future commit when maximum extent counts associated with data/attribute > forks are increased. > > No functional changes have been made. Hmm.... > Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> > --- > fs/xfs/libxfs/xfs_bmap.c | 9 ++++----- > fs/xfs/libxfs/xfs_inode_buf.c | 8 +++----- > fs/xfs/libxfs/xfs_inode_fork.h | 10 ++++++++++ > 3 files changed, 17 insertions(+), 10 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c > index dcc8eeecd571..16b983b8977d 100644 > --- a/fs/xfs/libxfs/xfs_bmap.c > +++ b/fs/xfs/libxfs/xfs_bmap.c > @@ -74,13 +74,12 @@ xfs_bmap_compute_maxlevels( > * for both ATTR1 and ATTR2 we have to assume the worst case scenario > * of a minimum size available. > */ > - if (whichfork == XFS_DATA_FORK) { > - maxleafents = MAXEXTNUM; > + maxleafents = xfs_iext_max(&mp->m_sb, whichfork); > + if (whichfork == XFS_DATA_FORK) > sz = XFS_BMDR_SPACE_CALC(MINDBTPTRS); > - } else { > - maxleafents = MAXAEXTNUM; > + else > sz = XFS_BMDR_SPACE_CALC(MINABTPTRS); > - } > + > maxrootrecs = xfs_bmdr_maxrecs(sz, 0); > minleafrecs = mp->m_bmap_dmnr[0]; > minnoderecs = mp->m_bmap_dmnr[1]; > diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c > index 8d5dd08eab75..5dcd71bfab2e 100644 > --- a/fs/xfs/libxfs/xfs_inode_buf.c > +++ b/fs/xfs/libxfs/xfs_inode_buf.c > @@ -369,6 +369,7 @@ xfs_dinode_verify_fork( > int whichfork) > { > uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork); > + xfs_extnum_t max_extents; > > switch (XFS_DFORK_FORMAT(dip, whichfork)) { > case XFS_DINODE_FMT_LOCAL: > @@ -390,12 +391,9 @@ xfs_dinode_verify_fork( > return __this_address; > break; > case XFS_DINODE_FMT_BTREE: > - if (whichfork == XFS_ATTR_FORK) { > - if (di_nextents > MAXAEXTNUM) > - return __this_address; > - } else if (di_nextents > MAXEXTNUM) { > + max_extents = xfs_iext_max(&mp->m_sb, whichfork); > + if (di_nextents > max_extents) > return __this_address; > - } > break; > default: > return __this_address; > diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h > index 4219b01f1034..75e07078967e 100644 > --- a/fs/xfs/libxfs/xfs_inode_fork.h > +++ b/fs/xfs/libxfs/xfs_inode_fork.h > @@ -153,6 +153,16 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) > return ifp->if_format; > } > > +static inline xfs_extnum_t xfs_iext_max(struct xfs_sb *sbp, int whichfork) > +{ > + ASSERT(whichfork == XFS_DATA_FORK || whichfork == XFS_ATTR_FORK); > + > + if (whichfork == XFS_DATA_FORK) > + return MAXEXTNUM; > + else > + return MAXAEXTNUM; ...I kinda wish you /had/ made the functional change to make this return MAXEXTNUM for cow forks, even if none of the callers actually care. :) --D > +} > + > struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); > > int xfs_iformat_data_fork(struct xfs_inode *, struct xfs_dinode *); > -- > 2.28.0 >
On Tuesday 1 September 2020 2:13:40 AM IST Darrick J. Wong wrote: > On Mon, Aug 31, 2020 at 06:30:08PM +0530, Chandan Babu R wrote: > > xfs_iext_max() returns the maximum number of extents possible for either > > data fork or attribute fork. This helper will be extended further in a > > future commit when maximum extent counts associated with data/attribute > > forks are increased. > > > > No functional changes have been made. > > Hmm.... > > > Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> > > --- > > fs/xfs/libxfs/xfs_bmap.c | 9 ++++----- > > fs/xfs/libxfs/xfs_inode_buf.c | 8 +++----- > > fs/xfs/libxfs/xfs_inode_fork.h | 10 ++++++++++ > > 3 files changed, 17 insertions(+), 10 deletions(-) > > > > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c > > index dcc8eeecd571..16b983b8977d 100644 > > --- a/fs/xfs/libxfs/xfs_bmap.c > > +++ b/fs/xfs/libxfs/xfs_bmap.c > > @@ -74,13 +74,12 @@ xfs_bmap_compute_maxlevels( > > * for both ATTR1 and ATTR2 we have to assume the worst case scenario > > * of a minimum size available. > > */ > > - if (whichfork == XFS_DATA_FORK) { > > - maxleafents = MAXEXTNUM; > > + maxleafents = xfs_iext_max(&mp->m_sb, whichfork); > > + if (whichfork == XFS_DATA_FORK) > > sz = XFS_BMDR_SPACE_CALC(MINDBTPTRS); > > - } else { > > - maxleafents = MAXAEXTNUM; > > + else > > sz = XFS_BMDR_SPACE_CALC(MINABTPTRS); > > - } > > + > > maxrootrecs = xfs_bmdr_maxrecs(sz, 0); > > minleafrecs = mp->m_bmap_dmnr[0]; > > minnoderecs = mp->m_bmap_dmnr[1]; > > diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c > > index 8d5dd08eab75..5dcd71bfab2e 100644 > > --- a/fs/xfs/libxfs/xfs_inode_buf.c > > +++ b/fs/xfs/libxfs/xfs_inode_buf.c > > @@ -369,6 +369,7 @@ xfs_dinode_verify_fork( > > int whichfork) > > { > > uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork); > > + xfs_extnum_t max_extents; > > > > switch (XFS_DFORK_FORMAT(dip, whichfork)) { > > case XFS_DINODE_FMT_LOCAL: > > @@ -390,12 +391,9 @@ xfs_dinode_verify_fork( > > return __this_address; > > break; > > case XFS_DINODE_FMT_BTREE: > > - if (whichfork == XFS_ATTR_FORK) { > > - if (di_nextents > MAXAEXTNUM) > > - return __this_address; > > - } else if (di_nextents > MAXEXTNUM) { > > + max_extents = xfs_iext_max(&mp->m_sb, whichfork); > > + if (di_nextents > max_extents) > > return __this_address; > > - } > > break; > > default: > > return __this_address; > > diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h > > index 4219b01f1034..75e07078967e 100644 > > --- a/fs/xfs/libxfs/xfs_inode_fork.h > > +++ b/fs/xfs/libxfs/xfs_inode_fork.h > > @@ -153,6 +153,16 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) > > return ifp->if_format; > > } > > > > +static inline xfs_extnum_t xfs_iext_max(struct xfs_sb *sbp, int whichfork) > > +{ > > + ASSERT(whichfork == XFS_DATA_FORK || whichfork == XFS_ATTR_FORK); > > + > > + if (whichfork == XFS_DATA_FORK) > > + return MAXEXTNUM; > > + else > > + return MAXAEXTNUM; > > ...I kinda wish you /had/ made the functional change to make this return > MAXEXTNUM for cow forks, even if none of the callers actually care. :) Ok. I will include that change in the next version. > > --D > > > +} > > + > > struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); > > > > int xfs_iformat_data_fork(struct xfs_inode *, struct xfs_dinode *); >
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index dcc8eeecd571..16b983b8977d 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -74,13 +74,12 @@ xfs_bmap_compute_maxlevels( * for both ATTR1 and ATTR2 we have to assume the worst case scenario * of a minimum size available. */ - if (whichfork == XFS_DATA_FORK) { - maxleafents = MAXEXTNUM; + maxleafents = xfs_iext_max(&mp->m_sb, whichfork); + if (whichfork == XFS_DATA_FORK) sz = XFS_BMDR_SPACE_CALC(MINDBTPTRS); - } else { - maxleafents = MAXAEXTNUM; + else sz = XFS_BMDR_SPACE_CALC(MINABTPTRS); - } + maxrootrecs = xfs_bmdr_maxrecs(sz, 0); minleafrecs = mp->m_bmap_dmnr[0]; minnoderecs = mp->m_bmap_dmnr[1]; diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 8d5dd08eab75..5dcd71bfab2e 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -369,6 +369,7 @@ xfs_dinode_verify_fork( int whichfork) { uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork); + xfs_extnum_t max_extents; switch (XFS_DFORK_FORMAT(dip, whichfork)) { case XFS_DINODE_FMT_LOCAL: @@ -390,12 +391,9 @@ xfs_dinode_verify_fork( return __this_address; break; case XFS_DINODE_FMT_BTREE: - if (whichfork == XFS_ATTR_FORK) { - if (di_nextents > MAXAEXTNUM) - return __this_address; - } else if (di_nextents > MAXEXTNUM) { + max_extents = xfs_iext_max(&mp->m_sb, whichfork); + if (di_nextents > max_extents) return __this_address; - } break; default: return __this_address; diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h index 4219b01f1034..75e07078967e 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.h +++ b/fs/xfs/libxfs/xfs_inode_fork.h @@ -153,6 +153,16 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) return ifp->if_format; } +static inline xfs_extnum_t xfs_iext_max(struct xfs_sb *sbp, int whichfork) +{ + ASSERT(whichfork == XFS_DATA_FORK || whichfork == XFS_ATTR_FORK); + + if (whichfork == XFS_DATA_FORK) + return MAXEXTNUM; + else + return MAXAEXTNUM; +} + struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); int xfs_iformat_data_fork(struct xfs_inode *, struct xfs_dinode *);
xfs_iext_max() returns the maximum number of extents possible for either data fork or attribute fork. This helper will be extended further in a future commit when maximum extent counts associated with data/attribute forks are increased. No functional changes have been made. Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com> --- fs/xfs/libxfs/xfs_bmap.c | 9 ++++----- fs/xfs/libxfs/xfs_inode_buf.c | 8 +++----- fs/xfs/libxfs/xfs_inode_fork.h | 10 ++++++++++ 3 files changed, 17 insertions(+), 10 deletions(-)