Commit 5d765b97 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Niv Sardi

kill xfs_buf_iostart

xfs_buf_iostart is a "shared" helper for xfs_buf_read_flags,
xfs_bawrite, and xfs_bdwrite - except that there isn't much shared
code but rather special cases for each caller.

So remove this function and move the functionality to the caller.
xfs_bawrite and xfs_bdwrite are now big enough to be moved out of
line and the xfs_buf_read_flags is moved into a new helper called
_xfs_buf_read.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarNiv Sardi <xaiki@sgi.com>
parent 5cafdeb2
...@@ -630,6 +630,29 @@ xfs_buf_get_flags( ...@@ -630,6 +630,29 @@ xfs_buf_get_flags(
return NULL; return NULL;
} }
STATIC int
_xfs_buf_read(
xfs_buf_t *bp,
xfs_buf_flags_t flags)
{
int status;
XB_TRACE(bp, "_xfs_buf_read", (unsigned long)flags);
ASSERT(!(flags & (XBF_DELWRI|XBF_WRITE)));
ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL);
bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \
XBF_READ_AHEAD | _XBF_RUN_QUEUES);
bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | \
XBF_READ_AHEAD | _XBF_RUN_QUEUES);
status = xfs_buf_iorequest(bp);
if (!status && !(flags & XBF_ASYNC))
status = xfs_buf_iowait(bp);
return status;
}
xfs_buf_t * xfs_buf_t *
xfs_buf_read_flags( xfs_buf_read_flags(
xfs_buftarg_t *target, xfs_buftarg_t *target,
...@@ -646,7 +669,7 @@ xfs_buf_read_flags( ...@@ -646,7 +669,7 @@ xfs_buf_read_flags(
if (!XFS_BUF_ISDONE(bp)) { if (!XFS_BUF_ISDONE(bp)) {
XB_TRACE(bp, "read", (unsigned long)flags); XB_TRACE(bp, "read", (unsigned long)flags);
XFS_STATS_INC(xb_get_read); XFS_STATS_INC(xb_get_read);
xfs_buf_iostart(bp, flags); _xfs_buf_read(bp, flags);
} else if (flags & XBF_ASYNC) { } else if (flags & XBF_ASYNC) {
XB_TRACE(bp, "read_async", (unsigned long)flags); XB_TRACE(bp, "read_async", (unsigned long)flags);
/* /*
...@@ -1048,50 +1071,39 @@ xfs_buf_ioerror( ...@@ -1048,50 +1071,39 @@ xfs_buf_ioerror(
XB_TRACE(bp, "ioerror", (unsigned long)error); XB_TRACE(bp, "ioerror", (unsigned long)error);
} }
/*
* Initiate I/O on a buffer, based on the flags supplied.
* The b_iodone routine in the buffer supplied will only be called
* when all of the subsidiary I/O requests, if any, have been completed.
*/
int int
xfs_buf_iostart( xfs_bawrite(
xfs_buf_t *bp, void *mp,
xfs_buf_flags_t flags) struct xfs_buf *bp)
{ {
int status = 0; XB_TRACE(bp, "bawrite", 0);
XB_TRACE(bp, "iostart", (unsigned long)flags); ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL);
if (flags & XBF_DELWRI) { xfs_buf_delwri_dequeue(bp);
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC);
bp->b_flags |= flags & (XBF_DELWRI | XBF_ASYNC);
xfs_buf_delwri_queue(bp, 1);
return 0;
}
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \ bp->b_flags &= ~(XBF_READ | XBF_DELWRI | XBF_READ_AHEAD);
XBF_READ_AHEAD | _XBF_RUN_QUEUES); bp->b_flags |= (XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES);
bp->b_flags |= flags & (XBF_READ | XBF_WRITE | XBF_ASYNC | \
XBF_READ_AHEAD | _XBF_RUN_QUEUES); bp->b_fspriv3 = mp;
bp->b_strat = xfs_bdstrat_cb;
return xfs_bdstrat_cb(bp);
}
BUG_ON(bp->b_bn == XFS_BUF_DADDR_NULL); void
xfs_bdwrite(
void *mp,
struct xfs_buf *bp)
{
XB_TRACE(bp, "bdwrite", 0);
/* For writes allow an alternate strategy routine to precede bp->b_strat = xfs_bdstrat_cb;
* the actual I/O request (which may not be issued at all in bp->b_fspriv3 = mp;
* a shutdown situation, for example).
*/
status = (flags & XBF_WRITE) ?
xfs_buf_iostrategy(bp) : xfs_buf_iorequest(bp);
/* Wait for I/O if we are not an async request. bp->b_flags &= ~XBF_READ;
* Note: async I/O request completion will release the buffer, bp->b_flags |= (XBF_DELWRI | XBF_ASYNC);
* and that can already be done by this point. So using the
* buffer pointer from here on, after async I/O, is invalid.
*/
if (!status && !(flags & XBF_ASYNC))
status = xfs_buf_iowait(bp);
return status; xfs_buf_delwri_queue(bp, 1);
} }
STATIC_INLINE void STATIC_INLINE void
......
...@@ -214,9 +214,10 @@ extern void xfs_buf_lock(xfs_buf_t *); ...@@ -214,9 +214,10 @@ extern void xfs_buf_lock(xfs_buf_t *);
extern void xfs_buf_unlock(xfs_buf_t *); extern void xfs_buf_unlock(xfs_buf_t *);
/* Buffer Read and Write Routines */ /* Buffer Read and Write Routines */
extern int xfs_bawrite(void *mp, xfs_buf_t *bp);
extern void xfs_bdwrite(void *mp, xfs_buf_t *bp);
extern void xfs_buf_ioend(xfs_buf_t *, int); extern void xfs_buf_ioend(xfs_buf_t *, int);
extern void xfs_buf_ioerror(xfs_buf_t *, int); extern void xfs_buf_ioerror(xfs_buf_t *, int);
extern int xfs_buf_iostart(xfs_buf_t *, xfs_buf_flags_t);
extern int xfs_buf_iorequest(xfs_buf_t *); extern int xfs_buf_iorequest(xfs_buf_t *);
extern int xfs_buf_iowait(xfs_buf_t *); extern int xfs_buf_iowait(xfs_buf_t *);
extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, xfs_caddr_t, extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, xfs_caddr_t,
...@@ -366,14 +367,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *); ...@@ -366,14 +367,6 @@ extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *);
#define XFS_BUF_TARGET(bp) ((bp)->b_target) #define XFS_BUF_TARGET(bp) ((bp)->b_target)
#define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target) #define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target)
static inline int xfs_bawrite(void *mp, xfs_buf_t *bp)
{
bp->b_fspriv3 = mp;
bp->b_strat = xfs_bdstrat_cb;
xfs_buf_delwri_dequeue(bp);
return xfs_buf_iostart(bp, XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES);
}
static inline void xfs_buf_relse(xfs_buf_t *bp) static inline void xfs_buf_relse(xfs_buf_t *bp)
{ {
if (!bp->b_relse) if (!bp->b_relse)
...@@ -414,17 +407,6 @@ static inline int XFS_bwrite(xfs_buf_t *bp) ...@@ -414,17 +407,6 @@ static inline int XFS_bwrite(xfs_buf_t *bp)
return error; return error;
} }
/*
* No error can be returned from xfs_buf_iostart for delwri
* buffers as they are queued and no I/O is issued.
*/
static inline void xfs_bdwrite(void *mp, xfs_buf_t *bp)
{
bp->b_strat = xfs_bdstrat_cb;
bp->b_fspriv3 = mp;
(void)xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC);
}
#define XFS_bdstrat(bp) xfs_buf_iorequest(bp) #define XFS_bdstrat(bp) xfs_buf_iorequest(bp)
#define xfs_iowait(bp) xfs_buf_iowait(bp) #define xfs_iowait(bp) xfs_buf_iowait(bp)
......
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