Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250072
b: refs/heads/master
c: 4439647
h: refs/heads/master
v: v3
  • Loading branch information
Dave Chinner authored and Alex Elder committed May 19, 2011
1 parent dcabf8b commit 85f6441
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 39 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: ee58abdfcc8201f500107c7ba03f738af8b49b85
refs/heads/master: 44396476a0f24e5174768d3732f1958857c26d22
21 changes: 21 additions & 0 deletions trunk/fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,27 @@ xfs_buf_get_empty(
return bp;
}

/*
* Return a buffer allocated as an empty buffer and associated to external
* memory via xfs_buf_associate_memory() back to it's empty state.
*/
void
xfs_buf_set_empty(
struct xfs_buf *bp,
size_t len)
{
if (bp->b_pages)
_xfs_buf_free_pages(bp);

bp->b_pages = NULL;
bp->b_page_count = 0;
bp->b_addr = NULL;
bp->b_file_offset = 0;
bp->b_buffer_length = bp->b_count_desired = len;
bp->b_bn = XFS_BUF_DADDR_NULL;
bp->b_flags &= ~XBF_MAPPED;
}

static inline struct page *
mem_to_page(
void *addr)
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/xfs/linux-2.6/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ extern xfs_buf_t *xfs_buf_read(xfs_buftarg_t *, xfs_off_t, size_t,
xfs_buf_flags_t);

extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *);
extern void xfs_buf_set_empty(struct xfs_buf *bp, size_t len);
extern xfs_buf_t *xfs_buf_get_uncached(struct xfs_buftarg *, size_t, int);
extern int xfs_buf_associate_memory(xfs_buf_t *, void *, size_t);
extern void xfs_buf_hold(xfs_buf_t *);
Expand Down
8 changes: 7 additions & 1 deletion trunk/fs/xfs/xfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,13 @@ xlog_dealloc_log(xlog_t *log)

xlog_cil_destroy(log);

/*
* always need to ensure that the extra buffer does not point to memory
* owned by another log buffer before we free it.
*/
xfs_buf_set_empty(log->l_xbuf, log->l_iclog_size);
xfs_buf_free(log->l_xbuf);

iclog = log->l_iclog;
for (i=0; i<log->l_iclog_bufs; i++) {
xfs_buf_free(iclog->ic_bp);
Expand All @@ -1458,7 +1465,6 @@ xlog_dealloc_log(xlog_t *log)
}
spinlock_destroy(&log->l_icloglock);

xfs_buf_free(log->l_xbuf);
log->l_mp->m_log = NULL;
kmem_free(log);
} /* xlog_dealloc_log */
Expand Down
75 changes: 38 additions & 37 deletions trunk/fs/xfs/xfs_log_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,35 @@ xlog_bread(
return 0;
}

/*
* Read at an offset into the buffer. Returns with the buffer in it's original
* state regardless of the result of the read.
*/
STATIC int
xlog_bread_offset(
xlog_t *log,
xfs_daddr_t blk_no, /* block to read from */
int nbblks, /* blocks to read */
xfs_buf_t *bp,
xfs_caddr_t offset)
{
xfs_caddr_t orig_offset = XFS_BUF_PTR(bp);
int orig_len = bp->b_buffer_length;
int error, error2;

error = XFS_BUF_SET_PTR(bp, offset, BBTOB(nbblks));
if (error)
return error;

error = xlog_bread_noalign(log, blk_no, nbblks, bp);

/* must reset buffer pointer even on error */
error2 = XFS_BUF_SET_PTR(bp, orig_offset, orig_len);
if (error)
return error;
return error2;
}

/*
* Write out the buffer at the given block for the given number of blocks.
* The buffer is kept locked across the write and is returned locked.
Expand Down Expand Up @@ -1229,20 +1258,12 @@ xlog_write_log_records(
*/
ealign = round_down(end_block, sectbb);
if (j == 0 && (start_block + endcount > ealign)) {
offset = XFS_BUF_PTR(bp);
balign = BBTOB(ealign - start_block);
error = XFS_BUF_SET_PTR(bp, offset + balign,
BBTOB(sectbb));
offset = XFS_BUF_PTR(bp) + BBTOB(ealign - start_block);
error = xlog_bread_offset(log, ealign, sectbb,
bp, offset);
if (error)
break;

error = xlog_bread_noalign(log, ealign, sectbb, bp);
if (error)
break;

error = XFS_BUF_SET_PTR(bp, offset, bufblks);
if (error)
break;
}

offset = xlog_align(log, start_block, endcount, bp);
Expand Down Expand Up @@ -3448,19 +3469,9 @@ xlog_do_recovery_pass(
* - order is important.
*/
wrapped_hblks = hblks - split_hblks;
error = XFS_BUF_SET_PTR(hbp,
offset + BBTOB(split_hblks),
BBTOB(hblks - split_hblks));
if (error)
goto bread_err2;

error = xlog_bread_noalign(log, 0,
wrapped_hblks, hbp);
if (error)
goto bread_err2;

error = XFS_BUF_SET_PTR(hbp, offset,
BBTOB(hblks));
error = xlog_bread_offset(log, 0,
wrapped_hblks, hbp,
offset + BBTOB(split_hblks));
if (error)
goto bread_err2;
}
Expand Down Expand Up @@ -3511,19 +3522,9 @@ xlog_do_recovery_pass(
* _first_, then the log start (LR header end)
* - order is important.
*/
error = XFS_BUF_SET_PTR(dbp,
offset + BBTOB(split_bblks),
BBTOB(bblks - split_bblks));
if (error)
goto bread_err2;

error = xlog_bread_noalign(log, wrapped_hblks,
bblks - split_bblks,
dbp);
if (error)
goto bread_err2;

error = XFS_BUF_SET_PTR(dbp, offset, h_size);
error = xlog_bread_offset(log, 0,
bblks - split_bblks, hbp,
offset + BBTOB(split_bblks));
if (error)
goto bread_err2;
}
Expand Down

0 comments on commit 85f6441

Please sign in to comment.