Commit 957d0ebe authored by David Chinner's avatar David Chinner Committed by Tim Shimmin

[XFS] Cleanup inode extent size hint extraction

SGI-PV: 966004
SGI-Modid: xfs-linux-melb:xfs-kern:28866a
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent 84e1e99f
...@@ -2609,8 +2609,7 @@ xfs_bmap_rtalloc( ...@@ -2609,8 +2609,7 @@ xfs_bmap_rtalloc(
xfs_rtblock_t rtb; xfs_rtblock_t rtb;
mp = ap->ip->i_mount; mp = ap->ip->i_mount;
align = ap->ip->i_d.di_extsize ? align = xfs_get_extsz_hint(ap->ip);
ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize;
prod = align / mp->m_sb.sb_rextsize; prod = align / mp->m_sb.sb_rextsize;
error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
align, 1, ap->eof, 0, align, 1, ap->eof, 0,
...@@ -2715,9 +2714,7 @@ xfs_bmap_btalloc( ...@@ -2715,9 +2714,7 @@ xfs_bmap_btalloc(
int error; int error;
mp = ap->ip->i_mount; mp = ap->ip->i_mount;
align = (ap->userdata && ap->ip->i_d.di_extsize && align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0;
(ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ?
ap->ip->i_d.di_extsize : 0;
if (unlikely(align)) { if (unlikely(align)) {
error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
align, 0, ap->eof, 0, ap->conv, align, 0, ap->eof, 0, ap->conv,
...@@ -2817,9 +2814,9 @@ xfs_bmap_btalloc( ...@@ -2817,9 +2814,9 @@ xfs_bmap_btalloc(
args.total = ap->total; args.total = ap->total;
args.minlen = ap->minlen; args.minlen = ap->minlen;
} }
if (unlikely(ap->userdata && ap->ip->i_d.di_extsize && /* apply extent size hints if obtained earlier */
(ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) { if (unlikely(align)) {
args.prod = ap->ip->i_d.di_extsize; args.prod = align;
if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod)))
args.mod = (xfs_extlen_t)(args.prod - args.mod); args.mod = (xfs_extlen_t)(args.prod - args.mod);
} else if (mp->m_sb.sb_blocksize >= NBPP) { } else if (mp->m_sb.sb_blocksize >= NBPP) {
...@@ -4868,12 +4865,7 @@ xfs_bmapi( ...@@ -4868,12 +4865,7 @@ xfs_bmapi(
xfs_extlen_t extsz; xfs_extlen_t extsz;
/* Figure out the extent size, adjust alen */ /* Figure out the extent size, adjust alen */
if (rt) { extsz = xfs_get_extsz_hint(ip);
if (!(extsz = ip->i_d.di_extsize))
extsz = mp->m_sb.sb_rextsize;
} else {
extsz = ip->i_d.di_extsize;
}
if (extsz) { if (extsz) {
error = xfs_bmap_extsize_align(mp, error = xfs_bmap_extsize_align(mp,
&got, &prev, extsz, &got, &prev, extsz,
...@@ -5813,8 +5805,7 @@ xfs_getbmap( ...@@ -5813,8 +5805,7 @@ xfs_getbmap(
ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
if (whichfork == XFS_DATA_FORK) { if (whichfork == XFS_DATA_FORK) {
if ((ip->i_d.di_extsize && (ip->i_d.di_flags & if (xfs_get_extsz_hint(ip) ||
(XFS_DIFLAG_REALTIME|XFS_DIFLAG_EXTSIZE))) ||
ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
prealloced = 1; prealloced = 1;
fixlen = XFS_MAXIOFFSET(mp); fixlen = XFS_MAXIOFFSET(mp);
......
...@@ -451,19 +451,14 @@ xfs_iomap_write_direct( ...@@ -451,19 +451,14 @@ xfs_iomap_write_direct(
return XFS_ERROR(error); return XFS_ERROR(error);
rt = XFS_IS_REALTIME_INODE(ip); rt = XFS_IS_REALTIME_INODE(ip);
if (unlikely(rt)) { extsz = xfs_get_extsz_hint(ip);
if (!(extsz = ip->i_d.di_extsize))
extsz = mp->m_sb.sb_rextsize;
} else {
extsz = ip->i_d.di_extsize;
}
isize = ip->i_size; isize = ip->i_size;
if (io->io_new_size > isize) if (io->io_new_size > isize)
isize = io->io_new_size; isize = io->io_new_size;
offset_fsb = XFS_B_TO_FSBT(mp, offset); offset_fsb = XFS_B_TO_FSBT(mp, offset);
last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
if ((offset + count) > isize) { if ((offset + count) > isize) {
error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz, error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz,
&last_fsb); &last_fsb);
...@@ -666,13 +661,7 @@ xfs_iomap_write_delay( ...@@ -666,13 +661,7 @@ xfs_iomap_write_delay(
if (error) if (error)
return XFS_ERROR(error); return XFS_ERROR(error);
if (XFS_IS_REALTIME_INODE(ip)) { extsz = xfs_get_extsz_hint(ip);
if (!(extsz = ip->i_d.di_extsize))
extsz = mp->m_sb.sb_rextsize;
} else {
extsz = ip->i_d.di_extsize;
}
offset_fsb = XFS_B_TO_FSBT(mp, offset); offset_fsb = XFS_B_TO_FSBT(mp, offset);
retry: retry:
......
...@@ -77,6 +77,28 @@ xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb) ...@@ -77,6 +77,28 @@ xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb)
#define XFS_FREE_EOF_LOCK (1<<0) #define XFS_FREE_EOF_LOCK (1<<0)
#define XFS_FREE_EOF_NOLOCK (1<<1) #define XFS_FREE_EOF_NOLOCK (1<<1)
/*
* helper function to extract extent size hint from inode
*/
STATIC_INLINE xfs_extlen_t
xfs_get_extsz_hint(
xfs_inode_t *ip)
{
xfs_extlen_t extsz;
if (unlikely(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) {
extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
? ip->i_d.di_extsize
: ip->i_mount->m_sb.sb_rextsize;
ASSERT(extsz);
} else {
extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)
? ip->i_d.di_extsize : 0;
}
return extsz;
}
/* /*
* Prototypes for functions in xfs_rw.c. * Prototypes for functions in xfs_rw.c.
*/ */
......
...@@ -183,9 +183,8 @@ xfs_getattr( ...@@ -183,9 +183,8 @@ xfs_getattr(
* realtime extent size or the realtime volume's * realtime extent size or the realtime volume's
* extent size. * extent size.
*/ */
vap->va_blocksize = ip->i_d.di_extsize ? vap->va_blocksize =
(ip->i_d.di_extsize << mp->m_sb.sb_blocklog) : xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog;
(mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog);
} }
break; break;
} }
...@@ -4055,22 +4054,16 @@ xfs_alloc_file_space( ...@@ -4055,22 +4054,16 @@ xfs_alloc_file_space(
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
rt = XFS_IS_REALTIME_INODE(ip);
if (unlikely(rt)) {
if (!(extsz = ip->i_d.di_extsize))
extsz = mp->m_sb.sb_rextsize;
} else {
extsz = ip->i_d.di_extsize;
}
if ((error = XFS_QM_DQATTACH(mp, ip, 0))) if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
return error; return error;
if (len <= 0) if (len <= 0)
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
rt = XFS_IS_REALTIME_INODE(ip);
extsz = xfs_get_extsz_hint(ip);
count = len; count = len;
error = 0;
imapp = &imaps[0]; imapp = &imaps[0];
nimaps = 1; nimaps = 1;
bmapi_flag = XFS_BMAPI_WRITE | (alloc_type ? XFS_BMAPI_PREALLOC : 0); bmapi_flag = XFS_BMAPI_WRITE | (alloc_type ? XFS_BMAPI_PREALLOC : 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment