Commit c0dc7828 authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder

xfs: rename xfs_bmapi to xfs_bmapi_write

Now that all the read-only users of xfs_bmapi have been converted to
use xfs_bmapi_read(), we can remove all the read-only handling cases
from xfs_bmapi().

Once this is done, rename xfs_bmapi to xfs_bmapi_write to reflect
the fact it is for allocation only. This enables us to kill the
XFS_BMAPI_WRITE flag as well.

Also clean up xfs_bmapi_write to the style used in the newly added
xfs_bmapi_read/delay functions.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent b447fe5a
...@@ -2039,10 +2039,9 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) ...@@ -2039,10 +2039,9 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
*/ */
xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock);
nmap = 1; nmap = 1;
error = xfs_bmapi(args->trans, dp, (xfs_fileoff_t)lblkno, error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
blkcnt, blkcnt,
XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA | XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
XFS_BMAPI_WRITE,
args->firstblock, args->total, &map, &nmap, args->firstblock, args->total, &map, &nmap,
args->flist); args->flist);
if (!error) { if (!error) {
......
...@@ -4211,7 +4211,6 @@ xfs_bmap_validate_ret( ...@@ -4211,7 +4211,6 @@ xfs_bmap_validate_ret(
ASSERT(i == 0 || ASSERT(i == 0 ||
mval[i - 1].br_startoff + mval[i - 1].br_blockcount == mval[i - 1].br_startoff + mval[i - 1].br_blockcount ==
mval[i].br_startoff); mval[i].br_startoff);
if (flags & XFS_BMAPI_WRITE)
ASSERT(mval[i].br_startblock != DELAYSTARTBLOCK && ASSERT(mval[i].br_startblock != DELAYSTARTBLOCK &&
mval[i].br_startblock != HOLESTARTBLOCK); mval[i].br_startblock != HOLESTARTBLOCK);
ASSERT(mval[i].br_state == XFS_EXT_NORM || ASSERT(mval[i].br_state == XFS_EXT_NORM ||
...@@ -4809,59 +4808,56 @@ xfs_bmapi_convert_unwritten( ...@@ -4809,59 +4808,56 @@ xfs_bmapi_convert_unwritten(
} }
/* /*
* Map file blocks to filesystem blocks. * Map file blocks to filesystem blocks, and allocate blocks or convert the
* File range is given by the bno/len pair. * extent state if necessary. Details behaviour is controlled by the flags
* Adds blocks to file if a write ("flags & XFS_BMAPI_WRITE" set) * parameter. Only allocates blocks from a single allocation group, to avoid
* into a hole or past eof. * locking problems.
* Only allocates blocks from a single allocation group, *
* to avoid locking problems.
* The returned value in "firstblock" from the first call in a transaction * The returned value in "firstblock" from the first call in a transaction
* must be remembered and presented to subsequent calls in "firstblock". * must be remembered and presented to subsequent calls in "firstblock".
* An upper bound for the number of blocks to be allocated is supplied to * An upper bound for the number of blocks to be allocated is supplied to
* the first call in "total"; if no allocation group has that many free * the first call in "total"; if no allocation group has that many free
* blocks then the call will fail (return NULLFSBLOCK in "firstblock"). * blocks then the call will fail (return NULLFSBLOCK in "firstblock").
*/ */
int /* error */ int
xfs_bmapi( xfs_bmapi_write(
xfs_trans_t *tp, /* transaction pointer */ struct xfs_trans *tp, /* transaction pointer */
xfs_inode_t *ip, /* incore inode */ struct xfs_inode *ip, /* incore inode */
xfs_fileoff_t bno, /* starting file offs. mapped */ xfs_fileoff_t bno, /* starting file offs. mapped */
xfs_filblks_t len, /* length to map in file */ xfs_filblks_t len, /* length to map in file */
int flags, /* XFS_BMAPI_... */ int flags, /* XFS_BMAPI_... */
xfs_fsblock_t *firstblock, /* first allocated block xfs_fsblock_t *firstblock, /* first allocated block
controls a.g. for allocs */ controls a.g. for allocs */
xfs_extlen_t total, /* total blocks needed */ xfs_extlen_t total, /* total blocks needed */
xfs_bmbt_irec_t *mval, /* output: map values */ struct xfs_bmbt_irec *mval, /* output: map values */
int *nmap, /* i/o: mval size/count */ int *nmap, /* i/o: mval size/count */
xfs_bmap_free_t *flist) /* i/o: list extents to free */ struct xfs_bmap_free *flist) /* i/o: list extents to free */
{ {
xfs_bmalloca_t bma = { 0 }; /* args for xfs_bmap_alloc */ struct xfs_mount *mp = ip->i_mount;
xfs_btree_cur_t *cur; /* bmap btree cursor */ struct xfs_ifork *ifp;
struct xfs_bmalloca bma = { 0 }; /* args for xfs_bmap_alloc */
struct xfs_btree_cur *cur; /* bmap btree cursor */
xfs_fileoff_t end; /* end of mapped file region */ xfs_fileoff_t end; /* end of mapped file region */
int eof; /* we've hit the end of extents */ int eof; /* after the end of extents */
xfs_bmbt_rec_host_t *ep; /* extent record pointer */
int error; /* error return */ int error; /* error return */
xfs_bmbt_irec_t got; /* current file extent record */ struct xfs_bmbt_irec got; /* current file extent record */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extnum_t lastx; /* last useful extent number */ xfs_extnum_t lastx; /* last useful extent number */
int logflags; /* flags for transaction logging */ int logflags; /* flags for transaction logging */
xfs_extlen_t minleft; /* min blocks left after allocation */ xfs_extlen_t minleft; /* min blocks left after allocation */
xfs_mount_t *mp; /* xfs mount structure */
int n; /* current extent index */ int n; /* current extent index */
int nallocs; /* number of extents alloc'd */ int nallocs; /* number of extents alloc'd */
xfs_fileoff_t obno; /* old block number (offset) */ xfs_fileoff_t obno; /* old block number (offset) */
xfs_bmbt_irec_t prev; /* previous file extent record */ struct xfs_bmbt_irec prev; /* previous file extent record */
int tmp_logflags; /* temp flags holder */ int tmp_logflags; /* temp flags holder */
int whichfork; /* data or attr fork */ int whichfork; /* data or attr fork */
char inhole; /* current location is hole in file */ char inhole; /* current location is hole in file */
char wasdelay; /* old extent was delayed */ char wasdelay; /* old extent was delayed */
char wr; /* this is a write request */
char rt; /* this is a realtime file */
#ifdef DEBUG #ifdef DEBUG
xfs_fileoff_t orig_bno; /* original block number value */ xfs_fileoff_t orig_bno; /* original block number value */
int orig_flags; /* original flags arg value */ int orig_flags; /* original flags arg value */
xfs_filblks_t orig_len; /* original value of len arg */ xfs_filblks_t orig_len; /* original value of len arg */
xfs_bmbt_irec_t *orig_mval; /* original value of mval */ struct xfs_bmbt_irec *orig_mval; /* original value of mval */
int orig_nmap; /* original value of *nmap */ int orig_nmap; /* original value of *nmap */
orig_bno = bno; orig_bno = bno;
...@@ -4870,69 +4866,60 @@ xfs_bmapi( ...@@ -4870,69 +4866,60 @@ xfs_bmapi(
orig_mval = mval; orig_mval = mval;
orig_nmap = *nmap; orig_nmap = *nmap;
#endif #endif
ASSERT(*nmap >= 1); ASSERT(*nmap >= 1);
ASSERT(*nmap <= XFS_BMAP_MAX_NMAP || !(flags & XFS_BMAPI_WRITE)); ASSERT(*nmap <= XFS_BMAP_MAX_NMAP);
ASSERT(!(flags & XFS_BMAPI_IGSTATE));
ASSERT(tp != NULL);
whichfork = (flags & XFS_BMAPI_ATTRFORK) ? whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
XFS_ATTR_FORK : XFS_DATA_FORK; XFS_ATTR_FORK : XFS_DATA_FORK;
mp = ip->i_mount;
if (unlikely(XFS_TEST_ERROR( if (unlikely(XFS_TEST_ERROR(
(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS && (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE && XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL), XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL),
mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) { mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
XFS_ERROR_REPORT("xfs_bmapi", XFS_ERRLEVEL_LOW, mp); XFS_ERROR_REPORT("xfs_bmapi_write", XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_ext_max == ASSERT(ifp->if_ext_max ==
XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t)); XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
if ((wr = (flags & XFS_BMAPI_WRITE)) != 0)
XFS_STATS_INC(xs_blk_mapw); XFS_STATS_INC(xs_blk_mapw);
else
XFS_STATS_INC(xs_blk_mapr);
/*
* IGSTATE flag is used to combine extents which
* differ only due to the state of the extents.
* This technique is used from xfs_getbmap()
* when the caller does not wish to see the
* separation (which is the default).
*
* This technique is also used when writing a
* buffer which has been partially written,
* (usually by being flushed during a chunkread),
* to ensure one write takes place. This also
* prevents a change in the xfs inode extents at
* this time, intentionally. This change occurs
* on completion of the write operation, in
* xfs_strat_comp(), where the xfs_bmapi() call
* is transactioned, and the extents combined.
*/
if ((flags & XFS_BMAPI_IGSTATE) && wr) /* if writing unwritten space */
wr = 0; /* no allocations are allowed */
logflags = 0; logflags = 0;
nallocs = 0; nallocs = 0;
cur = NULL; cur = NULL;
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) { if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL) {
ASSERT(wr && tp); error = xfs_bmap_local_to_extents(tp, ip, firstblock, total,
if ((error = xfs_bmap_local_to_extents(tp, ip, &logflags, whichfork);
firstblock, total, &logflags, whichfork))) if (error)
goto error0; goto error0;
} }
if (wr && *firstblock == NULLFSBLOCK) {
if (*firstblock == NULLFSBLOCK) {
if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
else else
minleft = 1; minleft = 1;
} else } else {
minleft = 0; minleft = 0;
if (!(ifp->if_flags & XFS_IFEXTENTS) && }
(error = xfs_iread_extents(tp, ip, whichfork)))
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
error = xfs_iread_extents(tp, ip, whichfork);
if (error)
goto error0; goto error0;
ep = xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, }
&prev);
xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, &prev);
n = 0; n = 0;
end = bno + len; end = bno + len;
obno = bno; obno = bno;
...@@ -4945,19 +4932,14 @@ xfs_bmapi( ...@@ -4945,19 +4932,14 @@ xfs_bmapi(
bma.userdata = 0; bma.userdata = 0;
while (bno < end && n < *nmap) { while (bno < end && n < *nmap) {
/*
* Reading past eof, act as though there's a hole
* up to end.
*/
if (eof && !wr)
got.br_startoff = end;
inhole = eof || got.br_startoff > bno; inhole = eof || got.br_startoff > bno;
wasdelay = wr && !inhole && isnullstartblock(got.br_startblock); wasdelay = !inhole && isnullstartblock(got.br_startblock);
/* /*
* First, deal with the hole before the allocated space * First, deal with the hole before the allocated space
* that we found, if any. * that we found, if any.
*/ */
if (wr && (inhole || wasdelay)) { if (inhole || wasdelay) {
bma.eof = eof; bma.eof = eof;
bma.conv = !!(flags & XFS_BMAPI_CONVERT); bma.conv = !!(flags & XFS_BMAPI_CONVERT);
bma.wasdel = wasdelay; bma.wasdel = wasdelay;
...@@ -4975,36 +4957,20 @@ xfs_bmapi( ...@@ -4975,36 +4957,20 @@ xfs_bmapi(
minleft = 0; minleft = 0;
if (bma.rval == NULLFSBLOCK) if (bma.rval == NULLFSBLOCK)
break; break;
} else if (inhole) {
/*
* Reading in a hole.
*/
mval->br_startoff = bno;
mval->br_startblock = HOLESTARTBLOCK;
mval->br_blockcount =
XFS_FILBLKS_MIN(len, got.br_startoff - bno);
mval->br_state = XFS_EXT_NORM;
bno += mval->br_blockcount;
len -= mval->br_blockcount;
mval++;
n++;
continue;
} }
/* Deal with the allocated space we found. */ /* Deal with the allocated space we found. */
xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags); xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags);
/* Execute unwritten extent conversion if necessary */ /* Execute unwritten extent conversion if necessary */
if (wr) { error = xfs_bmapi_convert_unwritten(&bma, mval, len, &lastx,
error = xfs_bmapi_convert_unwritten(&bma, mval, len, &cur, firstblock, flist,
&lastx, &cur, firstblock, flist, flags, flags, &tmp_logflags);
&tmp_logflags);
logflags |= tmp_logflags; logflags |= tmp_logflags;
if (error == EAGAIN) if (error == EAGAIN)
continue; continue;
if (error) if (error)
goto error0; goto error0;
}
/* update the extent map to return */ /* update the extent map to return */
xfs_bmapi_update_map(&mval, &bno, &len, obno, end, &n, flags); xfs_bmapi_update_map(&mval, &bno, &len, obno, end, &n, flags);
...@@ -5016,24 +4982,22 @@ xfs_bmapi( ...@@ -5016,24 +4982,22 @@ xfs_bmapi(
*/ */
if (bno >= end || n >= *nmap || nallocs >= *nmap) if (bno >= end || n >= *nmap || nallocs >= *nmap)
break; break;
/*
* Else go on to the next record. /* Else go on to the next record. */
*/
prev = got; prev = got;
if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) { if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
ep = xfs_iext_get_ext(ifp, lastx); xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
xfs_bmbt_get_all(ep, &got); else
} else {
eof = 1; eof = 1;
} }
}
*nmap = n; *nmap = n;
/* /*
* Transform from btree to extents, give it cur. * Transform from btree to extents, give it cur.
*/ */
if (tp && XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE && if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE &&
XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) { XFS_IFORK_NEXTENTS(ip, whichfork) <= ifp->if_ext_max) {
ASSERT(wr && cur); ASSERT(cur);
error = xfs_bmap_btree_to_extents(tp, ip, cur, error = xfs_bmap_btree_to_extents(tp, ip, cur,
&tmp_logflags, whichfork); &tmp_logflags, whichfork);
logflags |= tmp_logflags; logflags |= tmp_logflags;
...@@ -5061,10 +5025,9 @@ xfs_bmapi( ...@@ -5061,10 +5025,9 @@ xfs_bmapi(
* detecting a case where the data is changed, there's an error, * detecting a case where the data is changed, there's an error,
* and it's not logged so we don't shutdown when we should. * and it's not logged so we don't shutdown when we should.
*/ */
if (logflags) { if (logflags)
ASSERT(tp && wr);
xfs_trans_log_inode(tp, ip, logflags); xfs_trans_log_inode(tp, ip, logflags);
}
if (cur) { if (cur) {
if (!error) { if (!error) {
ASSERT(*firstblock == NULLFSBLOCK || ASSERT(*firstblock == NULLFSBLOCK ||
......
...@@ -62,25 +62,23 @@ typedef struct xfs_bmap_free ...@@ -62,25 +62,23 @@ typedef struct xfs_bmap_free
#define XFS_BMAP_MAX_NMAP 4 #define XFS_BMAP_MAX_NMAP 4
/* /*
* Flags for xfs_bmapi * Flags for xfs_bmapi_*
*/ */
#define XFS_BMAPI_WRITE 0x001 /* write operation: allocate space */ #define XFS_BMAPI_ENTIRE 0x001 /* return entire extent, not trimmed */
#define XFS_BMAPI_ENTIRE 0x004 /* return entire extent, not trimmed */ #define XFS_BMAPI_METADATA 0x002 /* mapping metadata not user data */
#define XFS_BMAPI_METADATA 0x008 /* mapping metadata not user data */ #define XFS_BMAPI_ATTRFORK 0x004 /* use attribute fork not data */
#define XFS_BMAPI_ATTRFORK 0x010 /* use attribute fork not data */ #define XFS_BMAPI_PREALLOC 0x008 /* preallocation op: unwritten space */
#define XFS_BMAPI_PREALLOC 0x040 /* preallocation op: unwritten space */ #define XFS_BMAPI_IGSTATE 0x010 /* Ignore state - */
#define XFS_BMAPI_IGSTATE 0x080 /* Ignore state - */
/* combine contig. space */ /* combine contig. space */
#define XFS_BMAPI_CONTIG 0x100 /* must allocate only one extent */ #define XFS_BMAPI_CONTIG 0x020 /* must allocate only one extent */
/* /*
* unwritten extent conversion - this needs write cache flushing and no additional * unwritten extent conversion - this needs write cache flushing and no additional
* allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts * allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts
* from written to unwritten, otherwise convert from unwritten to written. * from written to unwritten, otherwise convert from unwritten to written.
*/ */
#define XFS_BMAPI_CONVERT 0x200 #define XFS_BMAPI_CONVERT 0x040
#define XFS_BMAPI_FLAGS \ #define XFS_BMAPI_FLAGS \
{ XFS_BMAPI_WRITE, "WRITE" }, \
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \
{ XFS_BMAPI_METADATA, "METADATA" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \
{ XFS_BMAPI_ATTRFORK, "ATTRFORK" }, \ { XFS_BMAPI_ATTRFORK, "ATTRFORK" }, \
...@@ -265,39 +263,17 @@ xfs_bmap_read_extents( ...@@ -265,39 +263,17 @@ xfs_bmap_read_extents(
struct xfs_inode *ip, /* incore inode */ struct xfs_inode *ip, /* incore inode */
int whichfork); /* data or attr fork */ int whichfork); /* data or attr fork */
/*
* Map file blocks to filesystem blocks.
* File range is given by the bno/len pair.
* Adds blocks to file if a write ("flags & XFS_BMAPI_WRITE" set)
* into a hole or past eof.
* Only allocates blocks from a single allocation group,
* to avoid locking problems.
* The returned value in "firstblock" from the first call in a transaction
* must be remembered and presented to subsequent calls in "firstblock".
* An upper bound for the number of blocks to be allocated is supplied to
* the first call in "total"; if no allocation group has that many free
* blocks then the call will fail (return NULLFSBLOCK in "firstblock").
*/
int /* error */
xfs_bmapi(
struct xfs_trans *tp, /* transaction pointer */
struct xfs_inode *ip, /* incore inode */
xfs_fileoff_t bno, /* starting file offs. mapped */
xfs_filblks_t len, /* length to map in file */
int flags, /* XFS_BMAPI_... */
xfs_fsblock_t *firstblock, /* first allocated block
controls a.g. for allocs */
xfs_extlen_t total, /* total blocks needed */
struct xfs_bmbt_irec *mval, /* output: map values */
int *nmap, /* i/o: mval size/count */
xfs_bmap_free_t *flist); /* i/o: list extents to free */
int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno, int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
xfs_filblks_t len, struct xfs_bmbt_irec *mval, xfs_filblks_t len, struct xfs_bmbt_irec *mval,
int *nmap, int flags); int *nmap, int flags);
int xfs_bmapi_delay(struct xfs_inode *ip, xfs_fileoff_t bno, int xfs_bmapi_delay(struct xfs_inode *ip, xfs_fileoff_t bno,
xfs_filblks_t len, struct xfs_bmbt_irec *mval, xfs_filblks_t len, struct xfs_bmbt_irec *mval,
int *nmap, int flags); int *nmap, int flags);
int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t bno, xfs_filblks_t len, int flags,
xfs_fsblock_t *firstblock, xfs_extlen_t total,
struct xfs_bmbt_irec *mval, int *nmap,
struct xfs_bmap_free *flist);
/* /*
* Unmap (remove) blocks from a file. * Unmap (remove) blocks from a file.
......
...@@ -1578,9 +1578,8 @@ xfs_da_grow_inode_int( ...@@ -1578,9 +1578,8 @@ xfs_da_grow_inode_int(
*/ */
nmap = 1; nmap = 1;
ASSERT(args->firstblock != NULL); ASSERT(args->firstblock != NULL);
error = xfs_bmapi(tp, dp, *bno, count, error = xfs_bmapi_write(tp, dp, *bno, count,
xfs_bmapi_aflag(w)|XFS_BMAPI_WRITE|XFS_BMAPI_METADATA| xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
XFS_BMAPI_CONTIG,
args->firstblock, args->total, &map, &nmap, args->firstblock, args->total, &map, &nmap,
args->flist); args->flist);
if (error) if (error)
...@@ -1602,9 +1601,8 @@ xfs_da_grow_inode_int( ...@@ -1602,9 +1601,8 @@ xfs_da_grow_inode_int(
for (b = *bno, mapi = 0; b < *bno + count; ) { for (b = *bno, mapi = 0; b < *bno + count; ) {
nmap = MIN(XFS_BMAP_MAX_NMAP, count); nmap = MIN(XFS_BMAP_MAX_NMAP, count);
c = (int)(*bno + count - b); c = (int)(*bno + count - b);
error = xfs_bmapi(tp, dp, b, c, error = xfs_bmapi_write(tp, dp, b, c,
xfs_bmapi_aflag(w)|XFS_BMAPI_WRITE| xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
XFS_BMAPI_METADATA,
args->firstblock, args->total, args->firstblock, args->total,
&mapp[mapi], &nmap, args->flist); &mapp[mapi], &nmap, args->flist);
if (error) if (error)
......
...@@ -379,14 +379,12 @@ xfs_qm_dqalloc( ...@@ -379,14 +379,12 @@ xfs_qm_dqalloc(
xfs_trans_ijoin_ref(tp, quotip, XFS_ILOCK_EXCL); xfs_trans_ijoin_ref(tp, quotip, XFS_ILOCK_EXCL);
nmaps = 1; nmaps = 1;
if ((error = xfs_bmapi(tp, quotip, error = xfs_bmapi_write(tp, quotip, offset_fsb,
offset_fsb, XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
XFS_BMAPI_METADATA | XFS_BMAPI_WRITE, &firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
&firstblock, &map, &nmaps, &flist);
XFS_QM_DQALLOC_SPACE_RES(mp), if (error)
&map, &nmaps, &flist))) {
goto error0; goto error0;
}
ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
ASSERT(nmaps == 1); ASSERT(nmaps == 1);
ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
......
...@@ -210,19 +210,17 @@ xfs_iomap_write_direct( ...@@ -210,19 +210,17 @@ xfs_iomap_write_direct(
xfs_trans_ijoin(tp, ip); xfs_trans_ijoin(tp, ip);
bmapi_flag = XFS_BMAPI_WRITE; bmapi_flag = 0;
if (offset < ip->i_size || extsz) if (offset < ip->i_size || extsz)
bmapi_flag |= XFS_BMAPI_PREALLOC; bmapi_flag |= XFS_BMAPI_PREALLOC;
/* /*
* Issue the xfs_bmapi() call to allocate the blocks.
*
* From this point onwards we overwrite the imap pointer that the * From this point onwards we overwrite the imap pointer that the
* caller gave to us. * caller gave to us.
*/ */
xfs_bmap_init(&free_list, &firstfsb); xfs_bmap_init(&free_list, &firstfsb);
nimaps = 1; nimaps = 1;
error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag, error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, bmapi_flag,
&firstfsb, 0, imap, &nimaps, &free_list); &firstfsb, 0, imap, &nimaps, &free_list);
if (error) if (error)
goto error0; goto error0;
...@@ -582,13 +580,11 @@ xfs_iomap_write_allocate( ...@@ -582,13 +580,11 @@ xfs_iomap_write_allocate(
} }
/* /*
* Go get the actual blocks.
*
* From this point onwards we overwrite the imap * From this point onwards we overwrite the imap
* pointer that the caller gave to us. * pointer that the caller gave to us.
*/ */
error = xfs_bmapi(tp, ip, map_start_fsb, count_fsb, error = xfs_bmapi_write(tp, ip, map_start_fsb,
XFS_BMAPI_WRITE, &first_block, 1, count_fsb, 0, &first_block, 1,
imap, &nimaps, &free_list); imap, &nimaps, &free_list);
if (error) if (error)
goto trans_cancel; goto trans_cancel;
...@@ -703,8 +699,8 @@ xfs_iomap_write_unwritten( ...@@ -703,8 +699,8 @@ xfs_iomap_write_unwritten(
*/ */
xfs_bmap_init(&free_list, &firstfsb); xfs_bmap_init(&free_list, &firstfsb);
nimaps = 1; nimaps = 1;
error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb, XFS_BMAPI_CONVERT, &firstfsb,
1, &imap, &nimaps, &free_list); 1, &imap, &nimaps, &free_list);
if (error) if (error)
goto error_on_bmapi_transaction; goto error_on_bmapi_transaction;
......
...@@ -120,8 +120,8 @@ xfs_growfs_rt_alloc( ...@@ -120,8 +120,8 @@ xfs_growfs_rt_alloc(
*/ */
nmap = 1; nmap = 1;
cancelflags |= XFS_TRANS_ABORT; cancelflags |= XFS_TRANS_ABORT;
error = xfs_bmapi(tp, ip, oblocks, nblocks - oblocks, error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, &firstblock, XFS_BMAPI_METADATA, &firstblock,
resblks, &map, &nmap, &flist); resblks, &map, &nmap, &flist);
if (!error && nmap < 1) if (!error && nmap < 1)
error = XFS_ERROR(ENOSPC); error = XFS_ERROR(ENOSPC);
......
...@@ -1633,10 +1633,9 @@ xfs_symlink( ...@@ -1633,10 +1633,9 @@ xfs_symlink(
first_fsb = 0; first_fsb = 0;
nmaps = SYMLINK_MAPS; nmaps = SYMLINK_MAPS;
error = xfs_bmapi(tp, ip, first_fsb, fs_blocks, error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
XFS_BMAPI_WRITE | XFS_BMAPI_METADATA, XFS_BMAPI_METADATA, &first_block, resblks,
&first_block, resblks, mval, &nmaps, mval, &nmaps, &free_list);
&free_list);
if (error) if (error)
goto error2; goto error2;
...@@ -1782,7 +1781,6 @@ xfs_alloc_file_space( ...@@ -1782,7 +1781,6 @@ xfs_alloc_file_space(
xfs_fileoff_t startoffset_fsb; xfs_fileoff_t startoffset_fsb;
xfs_fsblock_t firstfsb; xfs_fsblock_t firstfsb;
int nimaps; int nimaps;
int bmapi_flag;
int quota_flag; int quota_flag;
int rt; int rt;
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -1810,7 +1808,6 @@ xfs_alloc_file_space( ...@@ -1810,7 +1808,6 @@ xfs_alloc_file_space(
count = len; count = len;
imapp = &imaps[0]; imapp = &imaps[0];
nimaps = 1; nimaps = 1;
bmapi_flag = XFS_BMAPI_WRITE | alloc_type;
startoffset_fsb = XFS_B_TO_FSBT(mp, offset); startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
allocatesize_fsb = XFS_B_TO_FSB(mp, count); allocatesize_fsb = XFS_B_TO_FSB(mp, count);
...@@ -1883,14 +1880,10 @@ xfs_alloc_file_space( ...@@ -1883,14 +1880,10 @@ xfs_alloc_file_space(
xfs_trans_ijoin(tp, ip); xfs_trans_ijoin(tp, ip);
/*
* Issue the xfs_bmapi() call to allocate the blocks
*/
xfs_bmap_init(&free_list, &firstfsb); xfs_bmap_init(&free_list, &firstfsb);
error = xfs_bmapi(tp, ip, startoffset_fsb, error = xfs_bmapi_write(tp, ip, startoffset_fsb,
allocatesize_fsb, bmapi_flag, allocatesize_fsb, alloc_type, &firstfsb,
&firstfsb, 0, imapp, &nimaps, 0, imapp, &nimaps, &free_list);
&free_list);
if (error) { if (error) {
goto error0; goto error0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment