aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr.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_attr.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_attr.c')
-rw-r--r--fs/xfs/xfs_attr.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index c7dab0c0bdda..41ef02b7185a 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1963,10 +1963,9 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
1963 lblkno = args->rmtblkno; 1963 lblkno = args->rmtblkno;
1964 while (valuelen > 0) { 1964 while (valuelen > 0) {
1965 nmap = ATTR_RMTVALUE_MAPSIZE; 1965 nmap = ATTR_RMTVALUE_MAPSIZE;
1966 error = xfs_bmapi(args->trans, args->dp, (xfs_fileoff_t)lblkno, 1966 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
1967 args->rmtblkcnt, 1967 args->rmtblkcnt, map, &nmap,
1968 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 1968 XFS_BMAPI_ATTRFORK);
1969 NULL, 0, map, &nmap, NULL);
1970 if (error) 1969 if (error)
1971 return(error); 1970 return(error);
1972 ASSERT(nmap >= 1); 1971 ASSERT(nmap >= 1);
@@ -2092,14 +2091,11 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2092 */ 2091 */
2093 xfs_bmap_init(args->flist, args->firstblock); 2092 xfs_bmap_init(args->flist, args->firstblock);
2094 nmap = 1; 2093 nmap = 1;
2095 error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno, 2094 error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
2096 args->rmtblkcnt, 2095 args->rmtblkcnt, &map, &nmap,
2097 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2096 XFS_BMAPI_ATTRFORK);
2098 args->firstblock, 0, &map, &nmap, 2097 if (error)
2099 NULL);
2100 if (error) {
2101 return(error); 2098 return(error);
2102 }
2103 ASSERT(nmap == 1); 2099 ASSERT(nmap == 1);
2104 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 2100 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2105 (map.br_startblock != HOLESTARTBLOCK)); 2101 (map.br_startblock != HOLESTARTBLOCK));
@@ -2155,16 +2151,12 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2155 /* 2151 /*
2156 * Try to remember where we decided to put the value. 2152 * Try to remember where we decided to put the value.
2157 */ 2153 */
2158 xfs_bmap_init(args->flist, args->firstblock);
2159 nmap = 1; 2154 nmap = 1;
2160 error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno, 2155 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
2161 args->rmtblkcnt, 2156 args->rmtblkcnt, &map, &nmap,
2162 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2157 XFS_BMAPI_ATTRFORK);
2163 args->firstblock, 0, &map, &nmap, 2158 if (error)
2164 args->flist);
2165 if (error) {
2166 return(error); 2159 return(error);
2167 }
2168 ASSERT(nmap == 1); 2160 ASSERT(nmap == 1);
2169 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 2161 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2170 (map.br_startblock != HOLESTARTBLOCK)); 2162 (map.br_startblock != HOLESTARTBLOCK));