diff options
Diffstat (limited to 'fs/xfs/libxfs/xfs_bmap.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 89 |
1 files changed, 2 insertions, 87 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index b060bca93402..614803bc8a9f 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -1388,7 +1388,7 @@ xfs_bmap_search_multi_extents( | |||
1388 | * Else, *lastxp will be set to the index of the found | 1388 | * Else, *lastxp will be set to the index of the found |
1389 | * entry; *gotp will contain the entry. | 1389 | * entry; *gotp will contain the entry. |
1390 | */ | 1390 | */ |
1391 | STATIC xfs_bmbt_rec_host_t * /* pointer to found extent entry */ | 1391 | xfs_bmbt_rec_host_t * /* pointer to found extent entry */ |
1392 | xfs_bmap_search_extents( | 1392 | xfs_bmap_search_extents( |
1393 | xfs_inode_t *ip, /* incore inode pointer */ | 1393 | xfs_inode_t *ip, /* incore inode pointer */ |
1394 | xfs_fileoff_t bno, /* block number searched for */ | 1394 | xfs_fileoff_t bno, /* block number searched for */ |
@@ -4074,7 +4074,7 @@ xfs_bmapi_read( | |||
4074 | return 0; | 4074 | return 0; |
4075 | } | 4075 | } |
4076 | 4076 | ||
4077 | STATIC int | 4077 | int |
4078 | xfs_bmapi_reserve_delalloc( | 4078 | xfs_bmapi_reserve_delalloc( |
4079 | struct xfs_inode *ip, | 4079 | struct xfs_inode *ip, |
4080 | xfs_fileoff_t aoff, | 4080 | xfs_fileoff_t aoff, |
@@ -4170,91 +4170,6 @@ out_unreserve_quota: | |||
4170 | return error; | 4170 | return error; |
4171 | } | 4171 | } |
4172 | 4172 | ||
4173 | /* | ||
4174 | * Map file blocks to filesystem blocks, adding delayed allocations as needed. | ||
4175 | */ | ||
4176 | int | ||
4177 | xfs_bmapi_delay( | ||
4178 | struct xfs_inode *ip, /* incore inode */ | ||
4179 | xfs_fileoff_t bno, /* starting file offs. mapped */ | ||
4180 | xfs_filblks_t len, /* length to map in file */ | ||
4181 | struct xfs_bmbt_irec *mval, /* output: map values */ | ||
4182 | int *nmap, /* i/o: mval size/count */ | ||
4183 | int flags) /* XFS_BMAPI_... */ | ||
4184 | { | ||
4185 | struct xfs_mount *mp = ip->i_mount; | ||
4186 | struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); | ||
4187 | struct xfs_bmbt_irec got; /* current file extent record */ | ||
4188 | struct xfs_bmbt_irec prev; /* previous file extent record */ | ||
4189 | xfs_fileoff_t obno; /* old block number (offset) */ | ||
4190 | xfs_fileoff_t end; /* end of mapped file region */ | ||
4191 | xfs_extnum_t lastx; /* last useful extent number */ | ||
4192 | int eof; /* we've hit the end of extents */ | ||
4193 | int n = 0; /* current extent index */ | ||
4194 | int error = 0; | ||
4195 | |||
4196 | ASSERT(*nmap >= 1); | ||
4197 | ASSERT(*nmap <= XFS_BMAP_MAX_NMAP); | ||
4198 | ASSERT(!(flags & ~XFS_BMAPI_ENTIRE)); | ||
4199 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | ||
4200 | |||
4201 | if (unlikely(XFS_TEST_ERROR( | ||
4202 | (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS && | ||
4203 | XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), | ||
4204 | mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { | ||
4205 | XFS_ERROR_REPORT("xfs_bmapi_delay", XFS_ERRLEVEL_LOW, mp); | ||
4206 | return -EFSCORRUPTED; | ||
4207 | } | ||
4208 | |||
4209 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
4210 | return -EIO; | ||
4211 | |||
4212 | XFS_STATS_INC(mp, xs_blk_mapw); | ||
4213 | |||
4214 | if (!(ifp->if_flags & XFS_IFEXTENTS)) { | ||
4215 | error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK); | ||
4216 | if (error) | ||
4217 | return error; | ||
4218 | } | ||
4219 | |||
4220 | xfs_bmap_search_extents(ip, bno, XFS_DATA_FORK, &eof, &lastx, &got, &prev); | ||
4221 | end = bno + len; | ||
4222 | obno = bno; | ||
4223 | |||
4224 | while (bno < end && n < *nmap) { | ||
4225 | if (eof || got.br_startoff > bno) { | ||
4226 | error = xfs_bmapi_reserve_delalloc(ip, bno, len, &got, | ||
4227 | &prev, &lastx, eof); | ||
4228 | if (error) { | ||
4229 | if (n == 0) { | ||
4230 | *nmap = 0; | ||
4231 | return error; | ||
4232 | } | ||
4233 | break; | ||
4234 | } | ||
4235 | } | ||
4236 | |||
4237 | /* set up the extent map to return. */ | ||
4238 | xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags); | ||
4239 | xfs_bmapi_update_map(&mval, &bno, &len, obno, end, &n, flags); | ||
4240 | |||
4241 | /* If we're done, stop now. */ | ||
4242 | if (bno >= end || n >= *nmap) | ||
4243 | break; | ||
4244 | |||
4245 | /* Else go on to the next record. */ | ||
4246 | prev = got; | ||
4247 | if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) | ||
4248 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got); | ||
4249 | else | ||
4250 | eof = 1; | ||
4251 | } | ||
4252 | |||
4253 | *nmap = n; | ||
4254 | return 0; | ||
4255 | } | ||
4256 | |||
4257 | |||
4258 | static int | 4173 | static int |
4259 | xfs_bmapi_allocate( | 4174 | xfs_bmapi_allocate( |
4260 | struct xfs_bmalloca *bma) | 4175 | struct xfs_bmalloca *bma) |