diff options
author | Christoph Hellwig <hch@lst.de> | 2008-12-03 06:20:26 -0500 |
---|---|---|
committer | Niv Sardi <xaiki@sgi.com> | 2008-12-03 23:39:20 -0500 |
commit | 5d765b976c3a41faf9a73718fb8cc5833990a8ef (patch) | |
tree | 05ece6cc9b8b9cbcd1775ecbd9df72ff0e855926 /fs/xfs/linux-2.6 | |
parent | 5cafdeb2891a415a5dbf0ad80f0afedf8369e6bb (diff) |
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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Niv Sardi <xaiki@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 84 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 22 |
2 files changed, 50 insertions, 56 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 36d5fcd3f593..cd89c56715a5 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -630,6 +630,29 @@ xfs_buf_get_flags( | |||
630 | return NULL; | 630 | return NULL; |
631 | } | 631 | } |
632 | 632 | ||
633 | STATIC int | ||
634 | _xfs_buf_read( | ||
635 | xfs_buf_t *bp, | ||
636 | xfs_buf_flags_t flags) | ||
637 | { | ||
638 | int status; | ||
639 | |||
640 | XB_TRACE(bp, "_xfs_buf_read", (unsigned long)flags); | ||
641 | |||
642 | ASSERT(!(flags & (XBF_DELWRI|XBF_WRITE))); | ||
643 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); | ||
644 | |||
645 | bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \ | ||
646 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); | ||
647 | bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | \ | ||
648 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); | ||
649 | |||
650 | status = xfs_buf_iorequest(bp); | ||
651 | if (!status && !(flags & XBF_ASYNC)) | ||
652 | status = xfs_buf_iowait(bp); | ||
653 | return status; | ||
654 | } | ||
655 | |||
633 | xfs_buf_t * | 656 | xfs_buf_t * |
634 | xfs_buf_read_flags( | 657 | xfs_buf_read_flags( |
635 | xfs_buftarg_t *target, | 658 | xfs_buftarg_t *target, |
@@ -646,7 +669,7 @@ xfs_buf_read_flags( | |||
646 | if (!XFS_BUF_ISDONE(bp)) { | 669 | if (!XFS_BUF_ISDONE(bp)) { |
647 | XB_TRACE(bp, "read", (unsigned long)flags); | 670 | XB_TRACE(bp, "read", (unsigned long)flags); |
648 | XFS_STATS_INC(xb_get_read); | 671 | XFS_STATS_INC(xb_get_read); |
649 | xfs_buf_iostart(bp, flags); | 672 | _xfs_buf_read(bp, flags); |
650 | } else if (flags & XBF_ASYNC) { | 673 | } else if (flags & XBF_ASYNC) { |
651 | XB_TRACE(bp, "read_async", (unsigned long)flags); | 674 | XB_TRACE(bp, "read_async", (unsigned long)flags); |
652 | /* | 675 | /* |
@@ -1048,50 +1071,39 @@ xfs_buf_ioerror( | |||
1048 | XB_TRACE(bp, "ioerror", (unsigned long)error); | 1071 | XB_TRACE(bp, "ioerror", (unsigned long)error); |
1049 | } | 1072 | } |
1050 | 1073 | ||
1051 | /* | ||
1052 | * Initiate I/O on a buffer, based on the flags supplied. | ||
1053 | * The b_iodone routine in the buffer supplied will only be called | ||
1054 | * when all of the subsidiary I/O requests, if any, have been completed. | ||
1055 | */ | ||
1056 | int | 1074 | int |
1057 | xfs_buf_iostart( | 1075 | xfs_bawrite( |
1058 | xfs_buf_t *bp, | 1076 | void *mp, |
1059 | xfs_buf_flags_t flags) | 1077 | struct xfs_buf *bp) |
1060 | { | 1078 | { |
1061 | int status = 0; | 1079 | XB_TRACE(bp, "bawrite", 0); |
1062 | 1080 | ||
1063 | XB_TRACE(bp, "iostart", (unsigned long)flags); | 1081 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); |
1064 | 1082 | ||
1065 | if (flags & XBF_DELWRI) { | 1083 | xfs_buf_delwri_dequeue(bp); |
1066 | bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC); | ||
1067 | bp->b_flags |= flags & (XBF_DELWRI | XBF_ASYNC); | ||
1068 | xfs_buf_delwri_queue(bp, 1); | ||
1069 | return 0; | ||
1070 | } | ||
1071 | 1084 | ||
1072 | bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \ | 1085 | bp->b_flags &= ~(XBF_READ | XBF_DELWRI | XBF_READ_AHEAD); |
1073 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); | 1086 | bp->b_flags |= (XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES); |
1074 | bp->b_flags |= flags & (XBF_READ | XBF_WRITE | XBF_ASYNC | \ | 1087 | |
1075 | XBF_READ_AHEAD | _XBF_RUN_QUEUES); | 1088 | bp->b_fspriv3 = mp; |
1089 | bp->b_strat = xfs_bdstrat_cb; | ||
1090 | return xfs_bdstrat_cb(bp); | ||
1091 | } | ||
1076 | 1092 | ||
1077 | BUG_ON(bp->b_bn == XFS_BUF_DADDR_NULL); | 1093 | void |
1094 | xfs_bdwrite( | ||
1095 | void *mp, | ||
1096 | struct xfs_buf *bp) | ||
1097 | { | ||
1098 | XB_TRACE(bp, "bdwrite", 0); | ||
1078 | 1099 | ||
1079 | /* For writes allow an alternate strategy routine to precede | 1100 | bp->b_strat = xfs_bdstrat_cb; |
1080 | * the actual I/O request (which may not be issued at all in | 1101 | bp->b_fspriv3 = mp; |
1081 | * a shutdown situation, for example). | ||
1082 | */ | ||
1083 | status = (flags & XBF_WRITE) ? | ||
1084 | xfs_buf_iostrategy(bp) : xfs_buf_iorequest(bp); | ||
1085 | 1102 | ||
1086 | /* Wait for I/O if we are not an async request. | 1103 | bp->b_flags &= ~XBF_READ; |
1087 | * Note: async I/O request completion will release the buffer, | 1104 | bp->b_flags |= (XBF_DELWRI | XBF_ASYNC); |
1088 | * and that can already be done by this point. So using the | ||
1089 | * buffer pointer from here on, after async I/O, is invalid. | ||
1090 | */ | ||
1091 | if (!status && !(flags & XBF_ASYNC)) | ||
1092 | status = xfs_buf_iowait(bp); | ||
1093 | 1105 | ||
1094 | return status; | 1106 | xfs_buf_delwri_queue(bp, 1); |
1095 | } | 1107 | } |
1096 | 1108 | ||
1097 | STATIC_INLINE void | 1109 | STATIC_INLINE void |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 456519a088c7..0e2aa16f5e41 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -214,9 +214,10 @@ extern void xfs_buf_lock(xfs_buf_t *); | |||
214 | extern void xfs_buf_unlock(xfs_buf_t *); | 214 | extern void xfs_buf_unlock(xfs_buf_t *); |
215 | 215 | ||
216 | /* Buffer Read and Write Routines */ | 216 | /* Buffer Read and Write Routines */ |
217 | extern int xfs_bawrite(void *mp, xfs_buf_t *bp); | ||
218 | extern void xfs_bdwrite(void *mp, xfs_buf_t *bp); | ||
217 | extern void xfs_buf_ioend(xfs_buf_t *, int); | 219 | extern void xfs_buf_ioend(xfs_buf_t *, int); |
218 | extern void xfs_buf_ioerror(xfs_buf_t *, int); | 220 | extern void xfs_buf_ioerror(xfs_buf_t *, int); |
219 | extern int xfs_buf_iostart(xfs_buf_t *, xfs_buf_flags_t); | ||
220 | extern int xfs_buf_iorequest(xfs_buf_t *); | 221 | extern int xfs_buf_iorequest(xfs_buf_t *); |
221 | extern int xfs_buf_iowait(xfs_buf_t *); | 222 | extern int xfs_buf_iowait(xfs_buf_t *); |
222 | extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, xfs_caddr_t, | 223 | 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 | #define XFS_BUF_TARGET(bp) ((bp)->b_target) | 367 | #define XFS_BUF_TARGET(bp) ((bp)->b_target) |
367 | #define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target) | 368 | #define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target) |
368 | 369 | ||
369 | static inline int xfs_bawrite(void *mp, xfs_buf_t *bp) | ||
370 | { | ||
371 | bp->b_fspriv3 = mp; | ||
372 | bp->b_strat = xfs_bdstrat_cb; | ||
373 | xfs_buf_delwri_dequeue(bp); | ||
374 | return xfs_buf_iostart(bp, XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES); | ||
375 | } | ||
376 | |||
377 | static inline void xfs_buf_relse(xfs_buf_t *bp) | 370 | static inline void xfs_buf_relse(xfs_buf_t *bp) |
378 | { | 371 | { |
379 | if (!bp->b_relse) | 372 | if (!bp->b_relse) |
@@ -414,17 +407,6 @@ static inline int XFS_bwrite(xfs_buf_t *bp) | |||
414 | return error; | 407 | return error; |
415 | } | 408 | } |
416 | 409 | ||
417 | /* | ||
418 | * No error can be returned from xfs_buf_iostart for delwri | ||
419 | * buffers as they are queued and no I/O is issued. | ||
420 | */ | ||
421 | static inline void xfs_bdwrite(void *mp, xfs_buf_t *bp) | ||
422 | { | ||
423 | bp->b_strat = xfs_bdstrat_cb; | ||
424 | bp->b_fspriv3 = mp; | ||
425 | (void)xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC); | ||
426 | } | ||
427 | |||
428 | #define XFS_bdstrat(bp) xfs_buf_iorequest(bp) | 410 | #define XFS_bdstrat(bp) xfs_buf_iorequest(bp) |
429 | 411 | ||
430 | #define xfs_iowait(bp) xfs_buf_iowait(bp) | 412 | #define xfs_iowait(bp) xfs_buf_iowait(bp) |