Commit 36585c6b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[XFS] split pagebuf_get into xfs_buf_get_flags and xfs_buf_read_flags.

SGI-PV: 923980
SGI-Modid: xfs-linux:xfs-kern:181653a
Signed-off-by: default avatarChristoph Hellwig <hch@sgi.com>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 543ed3e8
......@@ -486,7 +486,7 @@ _pagebuf_map_pages(
* which may imply that this call will block until those buffers
* are unlocked. No I/O is implied by this call.
*/
STATIC xfs_buf_t *
xfs_buf_t *
_pagebuf_find( /* find buffer for block */
xfs_buftarg_t *target,/* target for block */
loff_t ioff, /* starting offset of range */
......@@ -578,39 +578,14 @@ _pagebuf_find( /* find buffer for block */
return (pb);
}
/*
* pagebuf_find
*
* pagebuf_find returns a buffer matching the specified range of
* data for the specified target, if any of the relevant blocks
* are in memory. The buffer may have unallocated holes, if
* some, but not all, of the blocks are in memory. Even where
* pages are present in the buffer, not all of every page may be
* valid.
*/
xfs_buf_t *
pagebuf_find( /* find buffer for block */
/* if the block is in memory */
xfs_buftarg_t *target,/* target for block */
loff_t ioff, /* starting offset of range */
size_t isize, /* length of range */
page_buf_flags_t flags) /* PBF_TRYLOCK */
{
return _pagebuf_find(target, ioff, isize, flags, NULL);
}
/*
* pagebuf_get
* xfs_buf_get_flags assembles a buffer covering the specified range.
*
* pagebuf_get assembles a buffer covering the specified range.
* Some or all of the blocks in the range may be valid. Storage
* in memory for all portions of the buffer will be allocated,
* although backing storage may not be. If PBF_READ is set in
* flags, pagebuf_iostart is called also.
* Storage in memory for all portions of the buffer will be allocated,
* although backing storage may not be.
*/
xfs_buf_t *
pagebuf_get( /* allocate a buffer */
xfs_buf_get_flags( /* allocate a buffer */
xfs_buftarg_t *target,/* target for buffer */
loff_t ioff, /* starting offset of range */
size_t isize, /* length of range */
......@@ -640,8 +615,8 @@ pagebuf_get( /* allocate a buffer */
if (!(pb->pb_flags & PBF_MAPPED)) {
error = _pagebuf_map_pages(pb, flags);
if (unlikely(error)) {
printk(KERN_WARNING
"pagebuf_get: failed to map pages\n");
printk(KERN_WARNING "%s: failed to map pages\n",
__FUNCTION__);
goto no_buffer;
}
}
......@@ -655,30 +630,50 @@ pagebuf_get( /* allocate a buffer */
pb->pb_bn = ioff;
pb->pb_count_desired = pb->pb_buffer_length;
if (flags & PBF_READ) {
PB_TRACE(pb, "get", (unsigned long)flags);
return pb;
no_buffer:
if (flags & (PBF_LOCK | PBF_TRYLOCK))
pagebuf_unlock(pb);
pagebuf_rele(pb);
return NULL;
}
xfs_buf_t *
xfs_buf_read_flags(
xfs_buftarg_t *target,
loff_t ioff,
size_t isize,
page_buf_flags_t flags)
{
xfs_buf_t *pb;
flags |= PBF_READ;
pb = xfs_buf_get_flags(target, ioff, isize, flags);
if (pb) {
if (PBF_NOT_DONE(pb)) {
PB_TRACE(pb, "get_read", (unsigned long)flags);
PB_TRACE(pb, "read", (unsigned long)flags);
XFS_STATS_INC(pb_get_read);
pagebuf_iostart(pb, flags);
} else if (flags & PBF_ASYNC) {
PB_TRACE(pb, "get_read_async", (unsigned long)flags);
PB_TRACE(pb, "read_async", (unsigned long)flags);
/*
* Read ahead call which is already satisfied,
* drop the buffer
*/
goto no_buffer;
} else {
PB_TRACE(pb, "get_read_done", (unsigned long)flags);
PB_TRACE(pb, "read_done", (unsigned long)flags);
/* We do not want read in the flags */
pb->pb_flags &= ~PBF_READ;
}
} else {
PB_TRACE(pb, "get_write", (unsigned long)flags);
}
return pb;
no_buffer:
no_buffer:
if (flags & (PBF_LOCK | PBF_TRYLOCK))
pagebuf_unlock(pb);
pagebuf_rele(pb);
......@@ -724,7 +719,7 @@ pagebuf_readahead(
return;
flags |= (PBF_TRYLOCK|PBF_READ|PBF_ASYNC|PBF_READ_AHEAD);
pagebuf_get(target, ioff, isize, flags);
xfs_buf_get_flags(target, ioff, isize, flags);
}
xfs_buf_t *
......
......@@ -168,20 +168,36 @@ typedef struct xfs_buf {
/* Finding and Reading Buffers */
extern xfs_buf_t *pagebuf_find( /* find buffer for block if */
extern xfs_buf_t *_pagebuf_find( /* find buffer for block if */
/* the block is in memory */
xfs_buftarg_t *, /* inode for block */
loff_t, /* starting offset of range */
size_t, /* length of range */
page_buf_flags_t); /* PBF_LOCK */
page_buf_flags_t, /* PBF_LOCK */
xfs_buf_t *); /* newly allocated buffer */
extern xfs_buf_t *pagebuf_get( /* allocate a buffer */
#define xfs_incore(buftarg,blkno,len,lockit) \
_pagebuf_find(buftarg, blkno ,len, lockit, NULL)
extern xfs_buf_t *xfs_buf_get_flags( /* allocate a buffer */
xfs_buftarg_t *, /* inode for buffer */
loff_t, /* starting offset of range */
size_t, /* length of range */
page_buf_flags_t); /* PBF_LOCK, PBF_READ, */
/* PBF_ASYNC */
#define xfs_buf_get(target, blkno, len, flags) \
xfs_buf_get_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED)
extern xfs_buf_t *xfs_buf_read_flags( /* allocate and read a buffer */
xfs_buftarg_t *, /* inode for buffer */
loff_t, /* starting offset of range */
size_t, /* length of range */
page_buf_flags_t); /* PBF_LOCK, PBF_ASYNC */
#define xfs_buf_read(target, blkno, len, flags) \
xfs_buf_read_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED)
extern xfs_buf_t *pagebuf_lookup(
xfs_buftarg_t *,
loff_t, /* starting offset of range */
......@@ -472,18 +488,6 @@ extern inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset)
#define XFS_BUF_SET_VTYPE(bp, type)
#define XFS_BUF_SET_REF(bp, ref)
#define xfs_buf_read(target, blkno, len, flags) \
pagebuf_get((target), (blkno), (len), \
PBF_LOCK | PBF_READ | PBF_MAPPED)
#define xfs_buf_get(target, blkno, len, flags) \
pagebuf_get((target), (blkno), (len), \
PBF_LOCK | PBF_MAPPED)
#define xfs_buf_read_flags(target, blkno, len, flags) \
pagebuf_get((target), (blkno), (len), PBF_READ | (flags))
#define xfs_buf_get_flags(target, blkno, len, flags) \
pagebuf_get((target), (blkno), (len), (flags))
static inline int xfs_bawrite(void *mp, xfs_buf_t *bp)
{
bp->pb_fspriv3 = mp;
......@@ -508,10 +512,6 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
#define xfs_biodone(pb) \
pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
#define xfs_incore(buftarg,blkno,len,lockit) \
pagebuf_find(buftarg, blkno ,len, lockit)
#define xfs_biomove(pb, off, len, data, rw) \
pagebuf_iomove((pb), (off), (len), (data), \
((rw) == XFS_B_WRITE) ? PBRW_WRITE : PBRW_READ)
......
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