Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269916
b: refs/heads/master
c: 3815832
h: refs/heads/master
v: v3
  • Loading branch information
Dave Chinner authored and Alex Elder committed Oct 12, 2011
1 parent fa22a4f commit a466a96
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ddc3415aba1cb2f86d1fcad720cea834ee178f54
refs/heads/master: 3815832a2aa4df9815d15dac05227e0c8551833f
48 changes: 28 additions & 20 deletions trunk/fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ _xfs_buf_find(

/* No match found */
if (new_bp) {
_xfs_buf_initialize(new_bp, btp, range_base,
range_length, flags);
rb_link_node(&new_bp->b_rbnode, parent, rbp);
rb_insert_color(&new_bp->b_rbnode, &pag->pag_buf_tree);
/* the buffer keeps the perag reference until it is freed */
Expand Down Expand Up @@ -521,35 +519,53 @@ _xfs_buf_find(
}

/*
* Assembles a buffer covering the specified range.
* Storage in memory for all portions of the buffer will be allocated,
* although backing storage may not be.
* Assembles a buffer covering the specified range. The code is optimised for
* cache hits, as metadata intensive workloads will see 3 orders of magnitude
* more hits than misses.
*/
xfs_buf_t *
struct xfs_buf *
xfs_buf_get(
xfs_buftarg_t *target,/* target for buffer */
xfs_off_t ioff, /* starting offset of range */
size_t isize, /* length of range */
xfs_buf_flags_t flags)
{
xfs_buf_t *bp, *new_bp;
struct xfs_buf *bp;
struct xfs_buf *new_bp;
int error = 0;

bp = _xfs_buf_find(target, ioff, isize, flags, NULL);
if (likely(bp))
goto found;

new_bp = xfs_buf_allocate(flags);
if (unlikely(!new_bp))
return NULL;

_xfs_buf_initialize(new_bp, target,
ioff << BBSHIFT, isize << BBSHIFT, flags);

bp = _xfs_buf_find(target, ioff, isize, flags, new_bp);
if (!bp) {
xfs_buf_deallocate(new_bp);
return NULL;
}

if (bp == new_bp) {
error = xfs_buf_allocate_memory(bp, flags);
if (error)
goto no_buffer;
} else {
} else
xfs_buf_deallocate(new_bp);
if (unlikely(bp == NULL))
return NULL;
}

/*
* Now we have a workable buffer, fill in the block number so
* that we can do IO on it.
*/
bp->b_bn = ioff;
bp->b_count_desired = bp->b_buffer_length;

found:
if (!(bp->b_flags & XBF_MAPPED)) {
error = _xfs_buf_map_pages(bp, flags);
if (unlikely(error)) {
Expand All @@ -560,18 +576,10 @@ xfs_buf_get(
}

XFS_STATS_INC(xb_get);

/*
* Always fill in the block number now, the mapped cases can do
* their own overlay of this later.
*/
bp->b_bn = ioff;
bp->b_count_desired = bp->b_buffer_length;

trace_xfs_buf_get(bp, flags, _RET_IP_);
return bp;

no_buffer:
no_buffer:
if (flags & (XBF_LOCK | XBF_TRYLOCK))
xfs_buf_unlock(bp);
xfs_buf_rele(bp);
Expand Down

0 comments on commit a466a96

Please sign in to comment.