Commit de2a4f59 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: add discontiguous buffer support to transactions

Now that the buffer cache supports discontiguous buffers, add
support to the transaction buffer interface for getting and reading
buffers.

Note that this patch does not convert the buffer item logging to
support discontiguous buffers. That will be done as a separate
commit.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 6dde2707
...@@ -448,11 +448,51 @@ xfs_trans_t *xfs_trans_dup(xfs_trans_t *); ...@@ -448,11 +448,51 @@ xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
uint, uint); uint, uint);
void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t,
int, uint); struct xfs_buf *xfs_trans_get_buf_map(struct xfs_trans *tp,
int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *, struct xfs_buftarg *target,
struct xfs_buftarg *, xfs_daddr_t, int, uint, struct xfs_buf_map *map, int nmaps,
struct xfs_buf **); uint flags);
static inline struct xfs_buf *
xfs_trans_get_buf(
struct xfs_trans *tp,
struct xfs_buftarg *target,
xfs_daddr_t blkno,
int numblks,
uint flags)
{
struct xfs_buf_map map = {
.bm_bn = blkno,
.bm_len = numblks,
};
return xfs_trans_get_buf_map(tp, target, &map, 1, flags);
}
int xfs_trans_read_buf_map(struct xfs_mount *mp,
struct xfs_trans *tp,
struct xfs_buftarg *target,
struct xfs_buf_map *map, int nmaps,
xfs_buf_flags_t flags,
struct xfs_buf **bpp);
static inline int
xfs_trans_read_buf(
struct xfs_mount *mp,
struct xfs_trans *tp,
struct xfs_buftarg *target,
xfs_daddr_t blkno,
int numblks,
xfs_buf_flags_t flags,
struct xfs_buf **bpp)
{
struct xfs_buf_map map = {
.bm_bn = blkno,
.bm_len = numblks,
};
return xfs_trans_read_buf_map(mp, tp, target, &map, 1, flags, bpp);
}
struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int); struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *); void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
......
...@@ -41,21 +41,27 @@ STATIC struct xfs_buf * ...@@ -41,21 +41,27 @@ STATIC struct xfs_buf *
xfs_trans_buf_item_match( xfs_trans_buf_item_match(
struct xfs_trans *tp, struct xfs_trans *tp,
struct xfs_buftarg *target, struct xfs_buftarg *target,
xfs_daddr_t blkno, struct xfs_buf_map *map,
int len) int nmaps)
{ {
struct xfs_log_item_desc *lidp; struct xfs_log_item_desc *lidp;
struct xfs_buf_log_item *blip; struct xfs_buf_log_item *blip;
int len = 0;
int i;
for (i = 0; i < nmaps; i++)
len += map[i].bm_len;
len = BBTOB(len);
list_for_each_entry(lidp, &tp->t_items, lid_trans) { list_for_each_entry(lidp, &tp->t_items, lid_trans) {
blip = (struct xfs_buf_log_item *)lidp->lid_item; blip = (struct xfs_buf_log_item *)lidp->lid_item;
if (blip->bli_item.li_type == XFS_LI_BUF && if (blip->bli_item.li_type == XFS_LI_BUF &&
blip->bli_buf->b_target == target && blip->bli_buf->b_target == target &&
XFS_BUF_ADDR(blip->bli_buf) == blkno && XFS_BUF_ADDR(blip->bli_buf) == map[0].bm_bn &&
BBTOB(blip->bli_buf->b_length) == len) blip->bli_buf->b_length == len) {
ASSERT(blip->bli_buf->b_map_count == nmaps);
return blip->bli_buf; return blip->bli_buf;
} }
}
return NULL; return NULL;
} }
...@@ -128,21 +134,19 @@ xfs_trans_bjoin( ...@@ -128,21 +134,19 @@ xfs_trans_bjoin(
* If the transaction pointer is NULL, make this just a normal * If the transaction pointer is NULL, make this just a normal
* get_buf() call. * get_buf() call.
*/ */
xfs_buf_t * struct xfs_buf *
xfs_trans_get_buf(xfs_trans_t *tp, xfs_trans_get_buf_map(
xfs_buftarg_t *target_dev, struct xfs_trans *tp,
xfs_daddr_t blkno, struct xfs_buftarg *target,
int len, struct xfs_buf_map *map,
uint flags) int nmaps,
xfs_buf_flags_t flags)
{ {
xfs_buf_t *bp; xfs_buf_t *bp;
xfs_buf_log_item_t *bip; xfs_buf_log_item_t *bip;
/* if (!tp)
* Default to a normal get_buf() call if the tp is NULL. return xfs_buf_get_map(target, map, nmaps, flags);
*/
if (tp == NULL)
return xfs_buf_get(target_dev, blkno, len, flags);
/* /*
* If we find the buffer in the cache with this transaction * If we find the buffer in the cache with this transaction
...@@ -150,7 +154,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, ...@@ -150,7 +154,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
* have it locked. In this case we just increment the lock * have it locked. In this case we just increment the lock
* recursion count and return the buffer to the caller. * recursion count and return the buffer to the caller.
*/ */
bp = xfs_trans_buf_item_match(tp, target_dev, blkno, len); bp = xfs_trans_buf_item_match(tp, target, map, nmaps);
if (bp != NULL) { if (bp != NULL) {
ASSERT(xfs_buf_islocked(bp)); ASSERT(xfs_buf_islocked(bp));
if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) { if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) {
...@@ -167,7 +171,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, ...@@ -167,7 +171,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
return (bp); return (bp);
} }
bp = xfs_buf_get(target_dev, blkno, len, flags); bp = xfs_buf_get_map(target, map, nmaps, flags);
if (bp == NULL) { if (bp == NULL) {
return NULL; return NULL;
} }
...@@ -246,26 +250,22 @@ int xfs_error_mod = 33; ...@@ -246,26 +250,22 @@ int xfs_error_mod = 33;
* read_buf() call. * read_buf() call.
*/ */
int int
xfs_trans_read_buf( xfs_trans_read_buf_map(
xfs_mount_t *mp, struct xfs_mount *mp,
xfs_trans_t *tp, struct xfs_trans *tp,
xfs_buftarg_t *target, struct xfs_buftarg *target,
xfs_daddr_t blkno, struct xfs_buf_map *map,
int len, int nmaps,
uint flags, xfs_buf_flags_t flags,
xfs_buf_t **bpp) struct xfs_buf **bpp)
{ {
xfs_buf_t *bp; xfs_buf_t *bp;
xfs_buf_log_item_t *bip; xfs_buf_log_item_t *bip;
int error; int error;
*bpp = NULL; *bpp = NULL;
if (!tp) {
/* bp = xfs_buf_read_map(target, map, nmaps, flags);
* Default to a normal get_buf() call if the tp is NULL.
*/
if (tp == NULL) {
bp = xfs_buf_read(target, blkno, len, flags);
if (!bp) if (!bp)
return (flags & XBF_TRYLOCK) ? return (flags & XBF_TRYLOCK) ?
EAGAIN : XFS_ERROR(ENOMEM); EAGAIN : XFS_ERROR(ENOMEM);
...@@ -303,7 +303,7 @@ xfs_trans_read_buf( ...@@ -303,7 +303,7 @@ xfs_trans_read_buf(
* If the buffer is not yet read in, then we read it in, increment * If the buffer is not yet read in, then we read it in, increment
* the lock recursion count, and return it to the caller. * the lock recursion count, and return it to the caller.
*/ */
bp = xfs_trans_buf_item_match(tp, target, blkno, len); bp = xfs_trans_buf_item_match(tp, target, map, nmaps);
if (bp != NULL) { if (bp != NULL) {
ASSERT(xfs_buf_islocked(bp)); ASSERT(xfs_buf_islocked(bp));
ASSERT(bp->b_transp == tp); ASSERT(bp->b_transp == tp);
...@@ -349,7 +349,7 @@ xfs_trans_read_buf( ...@@ -349,7 +349,7 @@ xfs_trans_read_buf(
return 0; return 0;
} }
bp = xfs_buf_read(target, blkno, len, flags); bp = xfs_buf_read_map(target, map, nmaps, flags);
if (bp == NULL) { if (bp == NULL) {
*bpp = NULL; *bpp = NULL;
return (flags & XBF_TRYLOCK) ? return (flags & XBF_TRYLOCK) ?
......
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