Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201748
b: refs/heads/master
c: 3070451
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and Alex Elder committed Jul 26, 2010
1 parent fa62491 commit 86ccf36
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7a36c8a98a7dd05756bb147be2ac350325ff5830
refs/heads/master: 3070451eea1ed8e3bde0573183c7d8ac25fd5e97
52 changes: 28 additions & 24 deletions trunk/fs/xfs/xfs_iomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ xfs_iomap_write_direct(
xfs_off_t offset,
size_t count,
int flags,
xfs_bmbt_irec_t *ret_imap,
xfs_bmbt_irec_t *imap,
int *nmaps)
{
xfs_mount_t *mp = ip->i_mount;
Expand All @@ -256,7 +256,6 @@ xfs_iomap_write_direct(
int quota_flag;
int rt;
xfs_trans_t *tp;
xfs_bmbt_irec_t imap;
xfs_bmap_free_t free_list;
uint qblocks, resblks, resrtextents;
int committed;
Expand All @@ -280,10 +279,10 @@ xfs_iomap_write_direct(
if (error)
goto error_out;
} else {
if (*nmaps && (ret_imap->br_startblock == HOLESTARTBLOCK))
if (*nmaps && (imap->br_startblock == HOLESTARTBLOCK))
last_fsb = MIN(last_fsb, (xfs_fileoff_t)
ret_imap->br_blockcount +
ret_imap->br_startoff);
imap->br_blockcount +
imap->br_startoff);
}
count_fsb = last_fsb - offset_fsb;
ASSERT(count_fsb > 0);
Expand Down Expand Up @@ -336,12 +335,15 @@ xfs_iomap_write_direct(
bmapi_flag |= XFS_BMAPI_PREALLOC;

/*
* Issue the xfs_bmapi() call to allocate the blocks
* Issue the xfs_bmapi() call to allocate the blocks.
*
* From this point onwards we overwrite the imap pointer that the
* caller gave to us.
*/
xfs_bmap_init(&free_list, &firstfsb);
nimaps = 1;
error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag,
&firstfsb, 0, &imap, &nimaps, &free_list);
&firstfsb, 0, imap, &nimaps, &free_list);
if (error)
goto error0;

Expand All @@ -363,12 +365,11 @@ xfs_iomap_write_direct(
goto error_out;
}

if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) {
error = xfs_cmn_err_fsblock_zero(ip, &imap);
if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip))) {
error = xfs_cmn_err_fsblock_zero(ip, imap);
goto error_out;
}

*ret_imap = imap;
*nmaps = 1;
return 0;

Expand Down Expand Up @@ -542,7 +543,7 @@ xfs_iomap_write_allocate(
xfs_inode_t *ip,
xfs_off_t offset,
size_t count,
xfs_bmbt_irec_t *map,
xfs_bmbt_irec_t *imap,
int *retmap)
{
xfs_mount_t *mp = ip->i_mount;
Expand All @@ -551,7 +552,6 @@ xfs_iomap_write_allocate(
xfs_fsblock_t first_block;
xfs_bmap_free_t free_list;
xfs_filblks_t count_fsb;
xfs_bmbt_irec_t imap;
xfs_trans_t *tp;
int nimaps, committed;
int error = 0;
Expand All @@ -567,8 +567,8 @@ xfs_iomap_write_allocate(
return XFS_ERROR(error);

offset_fsb = XFS_B_TO_FSBT(mp, offset);
count_fsb = map->br_blockcount;
map_start_fsb = map->br_startoff;
count_fsb = imap->br_blockcount;
map_start_fsb = imap->br_startoff;

XFS_STATS_ADD(xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb));

Expand Down Expand Up @@ -647,10 +647,15 @@ xfs_iomap_write_allocate(
}
}

/* Go get the actual blocks */
/*
* Go get the actual blocks.
*
* From this point onwards we overwrite the imap
* pointer that the caller gave to us.
*/
error = xfs_bmapi(tp, ip, map_start_fsb, count_fsb,
XFS_BMAPI_WRITE, &first_block, 1,
&imap, &nimaps, &free_list);
imap, &nimaps, &free_list);
if (error)
goto trans_cancel;

Expand All @@ -669,13 +674,12 @@ xfs_iomap_write_allocate(
* See if we were able to allocate an extent that
* covers at least part of the callers request
*/
if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip)))
return xfs_cmn_err_fsblock_zero(ip, &imap);
if (!(imap->br_startblock || XFS_IS_REALTIME_INODE(ip)))
return xfs_cmn_err_fsblock_zero(ip, imap);

if ((offset_fsb >= imap.br_startoff) &&
(offset_fsb < (imap.br_startoff +
imap.br_blockcount))) {
*map = imap;
if ((offset_fsb >= imap->br_startoff) &&
(offset_fsb < (imap->br_startoff +
imap->br_blockcount))) {
*retmap = 1;
XFS_STATS_INC(xs_xstrat_quick);
return 0;
Expand All @@ -685,8 +689,8 @@ xfs_iomap_write_allocate(
* So far we have not mapped the requested part of the
* file, just surrounding data, try again.
*/
count_fsb -= imap.br_blockcount;
map_start_fsb = imap.br_startoff + imap.br_blockcount;
count_fsb -= imap->br_blockcount;
map_start_fsb = imap->br_startoff + imap->br_blockcount;
}

trans_cancel:
Expand Down

0 comments on commit 86ccf36

Please sign in to comment.