aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_vnodeops.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-09-18 16:40:45 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:15:03 -0400
commit5c8ed2021ff291f5e399a9b43c4f699b2fc58fbb (patch)
tree36d8375935324279fb27e50daa7fc6873ff68cea /fs/xfs/xfs_vnodeops.c
parentaef9a89586fc8475bf0333b8736d5aa8aa6f4897 (diff)
xfs: introduce xfs_bmapi_read()
xfs_bmapi() currently handles both extent map reading and allocation. As a result, the code is littered with "if (wr)" branches to conditionally do allocation operations if required. This makes the code much harder to follow and causes significant indent issues with the code. Given that read mapping is much simpler than allocation, we can split out read mapping from xfs_bmapi() and reuse the logic that we have already factored out do do all the hard work of handling the extent map manipulations. The results in a much simpler function for the common extent read operations, and will allow the allocation code to be simplified in another commit. Once xfs_bmapi_read() is implemented, convert all the callers of xfs_bmapi() that are only reading extents to use the new function. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r--fs/xfs/xfs_vnodeops.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 0d1caec873a1..63874a87b378 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -72,8 +72,8 @@ xfs_readlink_bmap(
72 xfs_buf_t *bp; 72 xfs_buf_t *bp;
73 int error = 0; 73 int error = 0;
74 74
75 error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0, 75 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, pathlen), mval, &nmaps,
76 mval, &nmaps, NULL); 76 0);
77 if (error) 77 if (error)
78 goto out; 78 goto out;
79 79
@@ -178,8 +178,7 @@ xfs_free_eofblocks(
178 178
179 nimaps = 1; 179 nimaps = 1;
180 xfs_ilock(ip, XFS_ILOCK_SHARED); 180 xfs_ilock(ip, XFS_ILOCK_SHARED);
181 error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0, 181 error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
182 NULL, 0, &imap, &nimaps, NULL);
183 xfs_iunlock(ip, XFS_ILOCK_SHARED); 182 xfs_iunlock(ip, XFS_ILOCK_SHARED);
184 183
185 if (!error && (nimaps != 0) && 184 if (!error && (nimaps != 0) &&
@@ -297,9 +296,9 @@ xfs_inactive_symlink_rmt(
297 done = 0; 296 done = 0;
298 xfs_bmap_init(&free_list, &first_block); 297 xfs_bmap_init(&free_list, &first_block);
299 nmaps = ARRAY_SIZE(mval); 298 nmaps = ARRAY_SIZE(mval);
300 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), 299 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, size),
301 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, 300 mval, &nmaps, 0);
302 &free_list))) 301 if (error)
303 goto error0; 302 goto error0;
304 /* 303 /*
305 * Invalidate the block(s). 304 * Invalidate the block(s).
@@ -1981,8 +1980,7 @@ xfs_zero_remaining_bytes(
1981 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) { 1980 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
1982 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1981 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1983 nimap = 1; 1982 nimap = 1;
1984 error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0, 1983 error = xfs_bmapi_read(ip, offset_fsb, 1, &imap, &nimap, 0);
1985 NULL, 0, &imap, &nimap, NULL);
1986 if (error || nimap < 1) 1984 if (error || nimap < 1)
1987 break; 1985 break;
1988 ASSERT(imap.br_blockcount >= 1); 1986 ASSERT(imap.br_blockcount >= 1);
@@ -2101,8 +2099,8 @@ xfs_free_file_space(
2101 */ 2099 */
2102 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) { 2100 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
2103 nimap = 1; 2101 nimap = 1;
2104 error = xfs_bmapi(NULL, ip, startoffset_fsb, 2102 error = xfs_bmapi_read(ip, startoffset_fsb, 1,
2105 1, 0, NULL, 0, &imap, &nimap, NULL); 2103 &imap, &nimap, 0);
2106 if (error) 2104 if (error)
2107 goto out_unlock_iolock; 2105 goto out_unlock_iolock;
2108 ASSERT(nimap == 0 || nimap == 1); 2106 ASSERT(nimap == 0 || nimap == 1);
@@ -2116,8 +2114,8 @@ xfs_free_file_space(
2116 startoffset_fsb += mp->m_sb.sb_rextsize - mod; 2114 startoffset_fsb += mp->m_sb.sb_rextsize - mod;
2117 } 2115 }
2118 nimap = 1; 2116 nimap = 1;
2119 error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, 2117 error = xfs_bmapi_read(ip, endoffset_fsb - 1, 1,
2120 1, 0, NULL, 0, &imap, &nimap, NULL); 2118 &imap, &nimap, 0);
2121 if (error) 2119 if (error)
2122 goto out_unlock_iolock; 2120 goto out_unlock_iolock;
2123 ASSERT(nimap == 0 || nimap == 1); 2121 ASSERT(nimap == 0 || nimap == 1);