Skip to content

Commit

Permalink
Merge tag 'for-linus-Jun-21-2012' of git://oss.sgi.com/xfs/xfs
Browse files Browse the repository at this point in the history
Pull XFS fixes from Ben Myers:
 - Fix stale data exposure with unwritten extents
 - Fix a warning in xfs_alloc_vextent with ODEBUG
 - Fix overallocation and alignment of pages for xfs_bufs
 - Fix a cursor leak
 - Fix a log hang
 - Fix a crash related to xfs_sync_worker
 - Rename xfs log structure from struct log to struct xlog so we can use
   crash dumps effectively

* tag 'for-linus-Jun-21-2012' of git://oss.sgi.com/xfs/xfs:
  xfs: rename log structure to xlog
  xfs: shutdown xfs_sync_worker before the log
  xfs: Fix overallocation in xfs_buf_allocate_memory()
  xfs: fix allocbt cursor leak in xfs_alloc_ag_vextent_near
  xfs: check for stale inode before acquiring iflock on push
  xfs: fix debug_object WARN at xfs_alloc_vextent()
  xfs: xfs_vm_writepage clear iomap_valid when !buffer_uptodate (REV2)
  • Loading branch information
Linus Torvalds committed Jun 22, 2012
2 parents a116371 + f7bdf03 commit 369c4f5
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 131 deletions.
3 changes: 2 additions & 1 deletion fs/xfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ xfs_alloc_ag_vextent_near(
goto restart;
}

xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
trace_xfs_alloc_size_neither(args);
args->agbno = NULLAGBLOCK;
return 0;
Expand Down Expand Up @@ -2441,7 +2442,7 @@ xfs_alloc_vextent(
DECLARE_COMPLETION_ONSTACK(done);

args->done = &done;
INIT_WORK(&args->work, xfs_alloc_vextent_worker);
INIT_WORK_ONSTACK(&args->work, xfs_alloc_vextent_worker);
queue_work(xfs_alloc_wq, &args->work);
wait_for_completion(&done);
return args->result;
Expand Down
11 changes: 8 additions & 3 deletions fs/xfs/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,15 @@ xfs_vm_writepage(
imap_valid = 0;
}
} else {
if (PageUptodate(page)) {
if (PageUptodate(page))
ASSERT(buffer_mapped(bh));
imap_valid = 0;
}
/*
* This buffer is not uptodate and will not be
* written to disk. Ensure that we will put any
* subsequent writeable buffers into a new
* ioend.
*/
imap_valid = 0;
continue;
}

Expand Down
16 changes: 2 additions & 14 deletions fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,7 @@ xfs_buf_alloc(
bp->b_length = numblks;
bp->b_io_length = numblks;
bp->b_flags = flags;

/*
* We do not set the block number here in the buffer because we have not
* finished initialising the buffer. We insert the buffer into the cache
* in this state, so this ensures that we are unable to do IO on a
* buffer that hasn't been fully initialised.
*/
bp->b_bn = XFS_BUF_DADDR_NULL;
bp->b_bn = blkno;
atomic_set(&bp->b_pin_count, 0);
init_waitqueue_head(&bp->b_waiters);

Expand Down Expand Up @@ -567,11 +560,6 @@ xfs_buf_get(
if (bp != new_bp)
xfs_buf_free(new_bp);

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

found:
Expand Down Expand Up @@ -772,7 +760,7 @@ xfs_buf_get_uncached(
int error, i;
xfs_buf_t *bp;

bp = xfs_buf_alloc(target, 0, numblks, 0);
bp = xfs_buf_alloc(target, XFS_BUF_DADDR_NULL, numblks, 0);
if (unlikely(bp == NULL))
goto fail;

Expand Down
17 changes: 8 additions & 9 deletions fs/xfs/xfs_inode_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@ xfs_inode_item_push(
goto out_unlock;
}

/*
* Stale inode items should force out the iclog.
*/
if (ip->i_flags & XFS_ISTALE) {
rval = XFS_ITEM_PINNED;
goto out_unlock;
}

/*
* Someone else is already flushing the inode. Nothing we can do
* here but wait for the flush to finish and remove the item from
Expand All @@ -514,15 +522,6 @@ xfs_inode_item_push(
goto out_unlock;
}

/*
* Stale inode items should force out the iclog.
*/
if (ip->i_flags & XFS_ISTALE) {
xfs_ifunlock(ip);
xfs_iunlock(ip, XFS_ILOCK_SHARED);
return XFS_ITEM_PINNED;
}

ASSERT(iip->ili_fields != 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));
ASSERT(iip->ili_logged == 0 || XFS_FORCED_SHUTDOWN(ip->i_mount));

Expand Down
77 changes: 45 additions & 32 deletions fs/xfs/xfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@
kmem_zone_t *xfs_log_ticket_zone;

/* Local miscellaneous function prototypes */
STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket,
xlog_in_core_t **, xfs_lsn_t *);
STATIC int
xlog_commit_record(
struct xlog *log,
struct xlog_ticket *ticket,
struct xlog_in_core **iclog,
xfs_lsn_t *commitlsnp);

STATIC xlog_t * xlog_alloc_log(xfs_mount_t *mp,
xfs_buftarg_t *log_target,
xfs_daddr_t blk_offset,
int num_bblks);
STATIC int xlog_space_left(struct log *log, atomic64_t *head);
STATIC int
xlog_space_left(
struct xlog *log,
atomic64_t *head);
STATIC int xlog_sync(xlog_t *log, xlog_in_core_t *iclog);
STATIC void xlog_dealloc_log(xlog_t *log);

Expand All @@ -64,16 +72,20 @@ STATIC void xlog_state_switch_iclogs(xlog_t *log,
int eventual_size);
STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog);

STATIC void xlog_grant_push_ail(struct log *log,
int need_bytes);
STATIC void
xlog_grant_push_ail(
struct xlog *log,
int need_bytes);
STATIC void xlog_regrant_reserve_log_space(xlog_t *log,
xlog_ticket_t *ticket);
STATIC void xlog_ungrant_log_space(xlog_t *log,
xlog_ticket_t *ticket);

#if defined(DEBUG)
STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr);
STATIC void xlog_verify_grant_tail(struct log *log);
STATIC void
xlog_verify_grant_tail(
struct xlog *log);
STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog,
int count, boolean_t syncing);
STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
Expand All @@ -89,9 +101,9 @@ STATIC int xlog_iclogs_empty(xlog_t *log);

static void
xlog_grant_sub_space(
struct log *log,
atomic64_t *head,
int bytes)
struct xlog *log,
atomic64_t *head,
int bytes)
{
int64_t head_val = atomic64_read(head);
int64_t new, old;
Expand All @@ -115,9 +127,9 @@ xlog_grant_sub_space(

static void
xlog_grant_add_space(
struct log *log,
atomic64_t *head,
int bytes)
struct xlog *log,
atomic64_t *head,
int bytes)
{
int64_t head_val = atomic64_read(head);
int64_t new, old;
Expand Down Expand Up @@ -165,7 +177,7 @@ xlog_grant_head_wake_all(

static inline int
xlog_ticket_reservation(
struct log *log,
struct xlog *log,
struct xlog_grant_head *head,
struct xlog_ticket *tic)
{
Expand All @@ -182,7 +194,7 @@ xlog_ticket_reservation(

STATIC bool
xlog_grant_head_wake(
struct log *log,
struct xlog *log,
struct xlog_grant_head *head,
int *free_bytes)
{
Expand All @@ -204,7 +216,7 @@ xlog_grant_head_wake(

STATIC int
xlog_grant_head_wait(
struct log *log,
struct xlog *log,
struct xlog_grant_head *head,
struct xlog_ticket *tic,
int need_bytes)
Expand Down Expand Up @@ -256,7 +268,7 @@ xlog_grant_head_wait(
*/
STATIC int
xlog_grant_head_check(
struct log *log,
struct xlog *log,
struct xlog_grant_head *head,
struct xlog_ticket *tic,
int *need_bytes)
Expand Down Expand Up @@ -323,7 +335,7 @@ xfs_log_regrant(
struct xfs_mount *mp,
struct xlog_ticket *tic)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
int need_bytes;
int error = 0;

Expand Down Expand Up @@ -389,7 +401,7 @@ xfs_log_reserve(
bool permanent,
uint t_type)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
struct xlog_ticket *tic;
int need_bytes;
int error = 0;
Expand Down Expand Up @@ -465,7 +477,7 @@ xfs_log_done(
struct xlog_in_core **iclog,
uint flags)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
xfs_lsn_t lsn = 0;

if (XLOG_FORCED_SHUTDOWN(log) ||
Expand Down Expand Up @@ -810,6 +822,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
void
xfs_log_unmount(xfs_mount_t *mp)
{
cancel_delayed_work_sync(&mp->m_sync_work);
xfs_trans_ail_destroy(mp);
xlog_dealloc_log(mp->m_log);
}
Expand Down Expand Up @@ -838,7 +851,7 @@ void
xfs_log_space_wake(
struct xfs_mount *mp)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
int free_bytes;

if (XLOG_FORCED_SHUTDOWN(log))
Expand Down Expand Up @@ -916,7 +929,7 @@ xfs_lsn_t
xlog_assign_tail_lsn_locked(
struct xfs_mount *mp)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
struct xfs_log_item *lip;
xfs_lsn_t tail_lsn;

Expand Down Expand Up @@ -965,7 +978,7 @@ xlog_assign_tail_lsn(
*/
STATIC int
xlog_space_left(
struct log *log,
struct xlog *log,
atomic64_t *head)
{
int free_bytes;
Expand Down Expand Up @@ -1277,7 +1290,7 @@ xlog_alloc_log(xfs_mount_t *mp,
*/
STATIC int
xlog_commit_record(
struct log *log,
struct xlog *log,
struct xlog_ticket *ticket,
struct xlog_in_core **iclog,
xfs_lsn_t *commitlsnp)
Expand Down Expand Up @@ -1311,7 +1324,7 @@ xlog_commit_record(
*/
STATIC void
xlog_grant_push_ail(
struct log *log,
struct xlog *log,
int need_bytes)
{
xfs_lsn_t threshold_lsn = 0;
Expand Down Expand Up @@ -1790,7 +1803,7 @@ xlog_write_start_rec(

static xlog_op_header_t *
xlog_write_setup_ophdr(
struct log *log,
struct xlog *log,
struct xlog_op_header *ophdr,
struct xlog_ticket *ticket,
uint flags)
Expand Down Expand Up @@ -1873,7 +1886,7 @@ xlog_write_setup_copy(

static int
xlog_write_copy_finish(
struct log *log,
struct xlog *log,
struct xlog_in_core *iclog,
uint flags,
int *record_cnt,
Expand Down Expand Up @@ -1958,7 +1971,7 @@ xlog_write_copy_finish(
*/
int
xlog_write(
struct log *log,
struct xlog *log,
struct xfs_log_vec *log_vector,
struct xlog_ticket *ticket,
xfs_lsn_t *start_lsn,
Expand Down Expand Up @@ -2821,7 +2834,7 @@ _xfs_log_force(
uint flags,
int *log_flushed)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
struct xlog_in_core *iclog;
xfs_lsn_t lsn;

Expand Down Expand Up @@ -2969,7 +2982,7 @@ _xfs_log_force_lsn(
uint flags,
int *log_flushed)
{
struct log *log = mp->m_log;
struct xlog *log = mp->m_log;
struct xlog_in_core *iclog;
int already_slept = 0;

Expand Down Expand Up @@ -3147,7 +3160,7 @@ xfs_log_ticket_get(
*/
xlog_ticket_t *
xlog_ticket_alloc(
struct log *log,
struct xlog *log,
int unit_bytes,
int cnt,
char client,
Expand Down Expand Up @@ -3278,7 +3291,7 @@ xlog_ticket_alloc(
*/
void
xlog_verify_dest_ptr(
struct log *log,
struct xlog *log,
char *ptr)
{
int i;
Expand Down Expand Up @@ -3307,7 +3320,7 @@ xlog_verify_dest_ptr(
*/
STATIC void
xlog_verify_grant_tail(
struct log *log)
struct xlog *log)
{
int tail_cycle, tail_blocks;
int cycle, space;
Expand Down
Loading

0 comments on commit 369c4f5

Please sign in to comment.