diff options
author | David Chinner <dgc@sgi.com> | 2007-06-18 02:50:37 -0400 |
---|---|---|
committer | Tim Shimmin <tes@chook.melbourne.sgi.com> | 2007-07-14 01:35:36 -0400 |
commit | 957d0ebed04239b734552c7da3fae9094b6f090c (patch) | |
tree | 6f5034b22028a03e31771d1a3fa5ad8d59557c09 /fs/xfs | |
parent | 84e1e99f112dead8f9ba036c02d24a9f5ce7f544 (diff) |
[XFS] Cleanup inode extent size hint extraction
SGI-PV: 966004
SGI-Modid: xfs-linux-melb:xfs-kern:28866a
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 23 | ||||
-rw-r--r-- | fs/xfs/xfs_iomap.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_rw.h | 22 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 17 |
4 files changed, 38 insertions, 43 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 9a654faf0c08..183add2f21b7 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -2609,8 +2609,7 @@ xfs_bmap_rtalloc( | |||
2609 | xfs_rtblock_t rtb; | 2609 | xfs_rtblock_t rtb; |
2610 | 2610 | ||
2611 | mp = ap->ip->i_mount; | 2611 | mp = ap->ip->i_mount; |
2612 | align = ap->ip->i_d.di_extsize ? | 2612 | align = xfs_get_extsz_hint(ap->ip); |
2613 | ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize; | ||
2614 | prod = align / mp->m_sb.sb_rextsize; | 2613 | prod = align / mp->m_sb.sb_rextsize; |
2615 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | 2614 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, |
2616 | align, 1, ap->eof, 0, | 2615 | align, 1, ap->eof, 0, |
@@ -2715,9 +2714,7 @@ xfs_bmap_btalloc( | |||
2715 | int error; | 2714 | int error; |
2716 | 2715 | ||
2717 | mp = ap->ip->i_mount; | 2716 | mp = ap->ip->i_mount; |
2718 | align = (ap->userdata && ap->ip->i_d.di_extsize && | 2717 | align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; |
2719 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ? | ||
2720 | ap->ip->i_d.di_extsize : 0; | ||
2721 | if (unlikely(align)) { | 2718 | if (unlikely(align)) { |
2722 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, | 2719 | error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp, |
2723 | align, 0, ap->eof, 0, ap->conv, | 2720 | align, 0, ap->eof, 0, ap->conv, |
@@ -2817,9 +2814,9 @@ xfs_bmap_btalloc( | |||
2817 | args.total = ap->total; | 2814 | args.total = ap->total; |
2818 | args.minlen = ap->minlen; | 2815 | args.minlen = ap->minlen; |
2819 | } | 2816 | } |
2820 | if (unlikely(ap->userdata && ap->ip->i_d.di_extsize && | 2817 | /* apply extent size hints if obtained earlier */ |
2821 | (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) { | 2818 | if (unlikely(align)) { |
2822 | args.prod = ap->ip->i_d.di_extsize; | 2819 | args.prod = align; |
2823 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) | 2820 | if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod))) |
2824 | args.mod = (xfs_extlen_t)(args.prod - args.mod); | 2821 | args.mod = (xfs_extlen_t)(args.prod - args.mod); |
2825 | } else if (mp->m_sb.sb_blocksize >= NBPP) { | 2822 | } else if (mp->m_sb.sb_blocksize >= NBPP) { |
@@ -4868,12 +4865,7 @@ xfs_bmapi( | |||
4868 | xfs_extlen_t extsz; | 4865 | xfs_extlen_t extsz; |
4869 | 4866 | ||
4870 | /* Figure out the extent size, adjust alen */ | 4867 | /* Figure out the extent size, adjust alen */ |
4871 | if (rt) { | 4868 | extsz = xfs_get_extsz_hint(ip); |
4872 | if (!(extsz = ip->i_d.di_extsize)) | ||
4873 | extsz = mp->m_sb.sb_rextsize; | ||
4874 | } else { | ||
4875 | extsz = ip->i_d.di_extsize; | ||
4876 | } | ||
4877 | if (extsz) { | 4869 | if (extsz) { |
4878 | error = xfs_bmap_extsize_align(mp, | 4870 | error = xfs_bmap_extsize_align(mp, |
4879 | &got, &prev, extsz, | 4871 | &got, &prev, extsz, |
@@ -5813,8 +5805,7 @@ xfs_getbmap( | |||
5813 | ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) | 5805 | ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) |
5814 | return XFS_ERROR(EINVAL); | 5806 | return XFS_ERROR(EINVAL); |
5815 | if (whichfork == XFS_DATA_FORK) { | 5807 | if (whichfork == XFS_DATA_FORK) { |
5816 | if ((ip->i_d.di_extsize && (ip->i_d.di_flags & | 5808 | if (xfs_get_extsz_hint(ip) || |
5817 | (XFS_DIFLAG_REALTIME|XFS_DIFLAG_EXTSIZE))) || | ||
5818 | ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ | 5809 | ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ |
5819 | prealloced = 1; | 5810 | prealloced = 1; |
5820 | fixlen = XFS_MAXIOFFSET(mp); | 5811 | fixlen = XFS_MAXIOFFSET(mp); |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index ab5062199f55..bf57b75acb90 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -451,19 +451,14 @@ xfs_iomap_write_direct( | |||
451 | return XFS_ERROR(error); | 451 | return XFS_ERROR(error); |
452 | 452 | ||
453 | rt = XFS_IS_REALTIME_INODE(ip); | 453 | rt = XFS_IS_REALTIME_INODE(ip); |
454 | if (unlikely(rt)) { | 454 | extsz = xfs_get_extsz_hint(ip); |
455 | if (!(extsz = ip->i_d.di_extsize)) | ||
456 | extsz = mp->m_sb.sb_rextsize; | ||
457 | } else { | ||
458 | extsz = ip->i_d.di_extsize; | ||
459 | } | ||
460 | 455 | ||
461 | isize = ip->i_size; | 456 | isize = ip->i_size; |
462 | if (io->io_new_size > isize) | 457 | if (io->io_new_size > isize) |
463 | isize = io->io_new_size; | 458 | isize = io->io_new_size; |
464 | 459 | ||
465 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 460 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
466 | last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); | 461 | last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count))); |
467 | if ((offset + count) > isize) { | 462 | if ((offset + count) > isize) { |
468 | error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz, | 463 | error = xfs_iomap_eof_align_last_fsb(mp, io, isize, extsz, |
469 | &last_fsb); | 464 | &last_fsb); |
@@ -666,13 +661,7 @@ xfs_iomap_write_delay( | |||
666 | if (error) | 661 | if (error) |
667 | return XFS_ERROR(error); | 662 | return XFS_ERROR(error); |
668 | 663 | ||
669 | if (XFS_IS_REALTIME_INODE(ip)) { | 664 | extsz = xfs_get_extsz_hint(ip); |
670 | if (!(extsz = ip->i_d.di_extsize)) | ||
671 | extsz = mp->m_sb.sb_rextsize; | ||
672 | } else { | ||
673 | extsz = ip->i_d.di_extsize; | ||
674 | } | ||
675 | |||
676 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 665 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
677 | 666 | ||
678 | retry: | 667 | retry: |
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h index ba74000931ec..fcf28dbded7c 100644 --- a/fs/xfs/xfs_rw.h +++ b/fs/xfs/xfs_rw.h | |||
@@ -77,6 +77,28 @@ xfs_fsb_to_db_io(struct xfs_iocore *io, xfs_fsblock_t fsb) | |||
77 | #define XFS_FREE_EOF_LOCK (1<<0) | 77 | #define XFS_FREE_EOF_LOCK (1<<0) |
78 | #define XFS_FREE_EOF_NOLOCK (1<<1) | 78 | #define XFS_FREE_EOF_NOLOCK (1<<1) |
79 | 79 | ||
80 | |||
81 | /* | ||
82 | * helper function to extract extent size hint from inode | ||
83 | */ | ||
84 | STATIC_INLINE xfs_extlen_t | ||
85 | xfs_get_extsz_hint( | ||
86 | xfs_inode_t *ip) | ||
87 | { | ||
88 | xfs_extlen_t extsz; | ||
89 | |||
90 | if (unlikely(ip->i_d.di_flags & XFS_DIFLAG_REALTIME)) { | ||
91 | extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) | ||
92 | ? ip->i_d.di_extsize | ||
93 | : ip->i_mount->m_sb.sb_rextsize; | ||
94 | ASSERT(extsz); | ||
95 | } else { | ||
96 | extsz = (ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) | ||
97 | ? ip->i_d.di_extsize : 0; | ||
98 | } | ||
99 | return extsz; | ||
100 | } | ||
101 | |||
80 | /* | 102 | /* |
81 | * Prototypes for functions in xfs_rw.c. | 103 | * Prototypes for functions in xfs_rw.c. |
82 | */ | 104 | */ |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 6420ca8df5ec..8c830a48165a 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -183,9 +183,8 @@ xfs_getattr( | |||
183 | * realtime extent size or the realtime volume's | 183 | * realtime extent size or the realtime volume's |
184 | * extent size. | 184 | * extent size. |
185 | */ | 185 | */ |
186 | vap->va_blocksize = ip->i_d.di_extsize ? | 186 | vap->va_blocksize = |
187 | (ip->i_d.di_extsize << mp->m_sb.sb_blocklog) : | 187 | xfs_get_extsz_hint(ip) << mp->m_sb.sb_blocklog; |
188 | (mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog); | ||
189 | } | 188 | } |
190 | break; | 189 | break; |
191 | } | 190 | } |
@@ -4055,22 +4054,16 @@ xfs_alloc_file_space( | |||
4055 | if (XFS_FORCED_SHUTDOWN(mp)) | 4054 | if (XFS_FORCED_SHUTDOWN(mp)) |
4056 | return XFS_ERROR(EIO); | 4055 | return XFS_ERROR(EIO); |
4057 | 4056 | ||
4058 | rt = XFS_IS_REALTIME_INODE(ip); | ||
4059 | if (unlikely(rt)) { | ||
4060 | if (!(extsz = ip->i_d.di_extsize)) | ||
4061 | extsz = mp->m_sb.sb_rextsize; | ||
4062 | } else { | ||
4063 | extsz = ip->i_d.di_extsize; | ||
4064 | } | ||
4065 | |||
4066 | if ((error = XFS_QM_DQATTACH(mp, ip, 0))) | 4057 | if ((error = XFS_QM_DQATTACH(mp, ip, 0))) |
4067 | return error; | 4058 | return error; |
4068 | 4059 | ||
4069 | if (len <= 0) | 4060 | if (len <= 0) |
4070 | return XFS_ERROR(EINVAL); | 4061 | return XFS_ERROR(EINVAL); |
4071 | 4062 | ||
4063 | rt = XFS_IS_REALTIME_INODE(ip); | ||
4064 | extsz = xfs_get_extsz_hint(ip); | ||
4065 | |||
4072 | count = len; | 4066 | count = len; |
4073 | error = 0; | ||
4074 | imapp = &imaps[0]; | 4067 | imapp = &imaps[0]; |
4075 | nimaps = 1; | 4068 | nimaps = 1; |
4076 | bmapi_flag = XFS_BMAPI_WRITE | (alloc_type ? XFS_BMAPI_PREALLOC : 0); | 4069 | bmapi_flag = XFS_BMAPI_WRITE | (alloc_type ? XFS_BMAPI_PREALLOC : 0); |