Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 319838
b: refs/heads/master
c: cbb7baa
h: refs/heads/master
v: v3
  • Loading branch information
Dave Chinner authored and Ben Myers committed Jul 1, 2012
1 parent 309f633 commit 2f9be83
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 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: 77c1a08fc9ece4cb130b9fd279738e799f0c2864
refs/heads/master: cbb7baab285a540f173ef1ec3d5bcf9d0ad29d16
21 changes: 12 additions & 9 deletions trunk/fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ xfs_buf_alloc(
bp->b_io_length = numblks;
bp->b_flags = flags;
bp->b_bn = blkno;
bp->b_map.bm_bn = blkno;
bp->b_map.bm_len = numblks;
atomic_set(&bp->b_pin_count, 0);
init_waitqueue_head(&bp->b_waiters);

Expand Down Expand Up @@ -327,8 +329,9 @@ xfs_buf_allocate_memory(
}

use_alloc_page:
start = BBTOB(bp->b_bn) >> PAGE_SHIFT;
end = (BBTOB(bp->b_bn + bp->b_length) + PAGE_SIZE - 1) >> PAGE_SHIFT;
start = BBTOB(bp->b_map.bm_bn) >> PAGE_SHIFT;
end = (BBTOB(bp->b_map.bm_bn + bp->b_length) + PAGE_SIZE - 1)
>> PAGE_SHIFT;
page_count = end - start;
error = _xfs_buf_get_pages(bp, page_count, flags);
if (unlikely(error))
Expand Down Expand Up @@ -560,8 +563,6 @@ xfs_buf_get(
if (bp != new_bp)
xfs_buf_free(new_bp);

bp->b_io_length = bp->b_length;

found:
if (!bp->b_addr) {
error = _xfs_buf_map_pages(bp, flags);
Expand All @@ -584,7 +585,7 @@ _xfs_buf_read(
xfs_buf_flags_t flags)
{
ASSERT(!(flags & XBF_WRITE));
ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL);
ASSERT(bp->b_map.bm_bn != XFS_BUF_DADDR_NULL);

bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD);
bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD);
Expand Down Expand Up @@ -665,8 +666,8 @@ xfs_buf_read_uncached(
return NULL;

/* set up the buffer for a read IO */
XFS_BUF_SET_ADDR(bp, daddr);
XFS_BUF_READ(bp);
bp->b_map.bm_bn = daddr;
bp->b_flags |= XBF_READ;

xfsbdstrat(target->bt_mount, bp);
error = xfs_buf_iowait(bp);
Expand Down Expand Up @@ -695,6 +696,8 @@ xfs_buf_set_empty(
bp->b_length = numblks;
bp->b_io_length = numblks;
bp->b_bn = XFS_BUF_DADDR_NULL;
bp->b_map.bm_bn = XFS_BUF_DADDR_NULL;
bp->b_map.bm_len = bp->b_length;
}

static inline struct page *
Expand Down Expand Up @@ -1159,7 +1162,7 @@ _xfs_buf_ioapply(
struct bio *bio;
int offset = bp->b_offset;
int size = BBTOB(bp->b_io_length);
sector_t sector = bp->b_bn;
sector_t sector = bp->b_map.bm_bn;

total_nr_pages = bp->b_page_count;
map_i = 0;
Expand Down Expand Up @@ -1564,7 +1567,7 @@ xfs_buf_cmp(
struct xfs_buf *bp = container_of(b, struct xfs_buf, b_list);
xfs_daddr_t diff;

diff = ap->b_bn - bp->b_bn;
diff = ap->b_map.bm_bn - bp->b_map.bm_bn;
if (diff < 0)
return -1;
if (diff > 0)
Expand Down
27 changes: 23 additions & 4 deletions trunk/fs/xfs/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef enum {
#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
#define _XBF_KMEM (1 << 21)/* backed by heap memory */
#define _XBF_DELWRI_Q (1 << 22)/* buffer on a delwri queue */
#define _XBF_COMPOUND (1 << 23)/* compound buffer */

typedef unsigned int xfs_buf_flags_t;

Expand All @@ -75,7 +76,8 @@ typedef unsigned int xfs_buf_flags_t;
{ XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\
{ _XBF_PAGES, "PAGES" }, \
{ _XBF_KMEM, "KMEM" }, \
{ _XBF_DELWRI_Q, "DELWRI_Q" }
{ _XBF_DELWRI_Q, "DELWRI_Q" }, \
{ _XBF_COMPOUND, "COMPOUND" }

typedef struct xfs_buftarg {
dev_t bt_dev;
Expand All @@ -98,6 +100,11 @@ typedef void (*xfs_buf_iodone_t)(struct xfs_buf *);

#define XB_PAGES 2

struct xfs_buf_map {
xfs_daddr_t bm_bn; /* block number for I/O */
int bm_len; /* size of I/O */
};

typedef struct xfs_buf {
/*
* first cacheline holds all the fields needed for an uncontended cache
Expand All @@ -107,7 +114,7 @@ typedef struct xfs_buf {
* fast-path on locking.
*/
struct rb_node b_rbnode; /* rbtree node */
xfs_daddr_t b_bn; /* block number for I/O */
xfs_daddr_t b_bn; /* block number of buffer */
int b_length; /* size of buffer in BBs */
atomic_t b_hold; /* reference count */
atomic_t b_lru_ref; /* lru reclaim ref count */
Expand All @@ -127,12 +134,14 @@ typedef struct xfs_buf {
struct xfs_trans *b_transp;
struct page **b_pages; /* array of page pointers */
struct page *b_page_array[XB_PAGES]; /* inline pages */
struct xfs_buf_map b_map; /* compound buffer map */
int b_io_length; /* IO size in BBs */
atomic_t b_pin_count; /* pin count */
atomic_t b_io_remaining; /* #outstanding I/O requests */
unsigned int b_page_count; /* size of page array */
unsigned int b_offset; /* page offset in first page */
unsigned short b_error; /* error code on I/O */

#ifdef XFS_BUF_LOCK_TRACKING
int b_last_holder;
#endif
Expand Down Expand Up @@ -233,8 +242,18 @@ void xfs_buf_stale(struct xfs_buf *bp);
#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE)
#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE)

#define XFS_BUF_ADDR(bp) ((bp)->b_bn)
#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno))
/*
* These macros use the IO block map rather than b_bn. b_bn is now really
* just for the buffer cache index for cached buffers. As IO does not use b_bn
* anymore, uncached buffers do not use b_bn at all and hence must modify the IO
* map directly. Uncached buffers are not allowed to be discontiguous, so this
* is safe to do.
*
* In future, uncached buffers will pass the block number directly to the io
* request function and hence these macros will go away at that point.
*/
#define XFS_BUF_ADDR(bp) ((bp)->b_map.bm_bn)
#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_map.bm_bn = (xfs_daddr_t)(bno))

static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
{
Expand Down

0 comments on commit 2f9be83

Please sign in to comment.