1. 10 Nov, 2008 4 commits
    • Dave Chinner's avatar
      [XFS] handle memory allocation failures during log initialisation · 8f330f51
      Dave Chinner authored
      When there is no memory left in the system, xfs_buf_get_noaddr()
      can fail. If this happens at mount time during xlog_alloc_log()
      we fail to catch the error and oops.
      
      Catch the error from xfs_buf_get_noaddr(), and allow other memory
      allocations to fail and catch those errors too. Report the error
      to the console and fail the mount with ENOMEM.
      
      Tested by manually injecting errors into xfs_buf_get_noaddr() and
      xlog_alloc_log().
      
      Version 2:
      o remove unnecessary casts of the returned pointer from kmem_zalloc()
      
      SGI-PV: 987246
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
      8f330f51
    • David Chinner's avatar
      [XFS] Account for allocated blocks when expanding directories · 6f9f51ad
      David Chinner authored
      When we create a directory, we reserve a number of blocks for the maximum
      possible expansion of of the directory due to various btree splits,
      freespace allocation, etc. Unfortunately, each allocation is not reflected
      in the total number of blocks still available to the transaction, so the
      maximal reservation is used over and over again.
      
      This leads to problems where an allocation group has only enough blocks
      for *some* of the allocations required for the directory modification.
      After the first N allocations, the remaining blocks in the allocation
      group drops below the total reservation, and subsequent allocations fail
      because the allocator will not allow the allocation to proceed if the AG
      does not have the enough blocks available for the entire allocation total.
      
      This results in an ENOSPC occurring after an allocation has already
      occurred. This results in aborting the directory operation (leaving the
      directory in an inconsistent state) and cancelling a dirty transaction,
      which results in a filesystem shutdown.
      
      Avoid the problem by reflecting the number of blocks allocated in any
      directory expansion in the total number of blocks available to the
      modification in progress. This prevents a directory modification from
      being aborted part way through with an ENOSPC.
      
      SGI-PV: 988144
      
      SGI-Modid: xfs-linux-melb:xfs-kern:32340a
      Signed-off-by: default avatarDavid Chinner <david@fromorbit.com>
      Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
      6f9f51ad
    • Lachlan McIlroy's avatar
      [XFS] Wait for all I/O on truncate to zero file size · 2cf7f0da
      Lachlan McIlroy authored
      It's possible to have outstanding xfs_ioend_t's queued when the file size
      is zero. This can happen in the direct I/O path when a direct I/O write
      fails due to ENOSPC. In this case the xfs_ioend_t will still be queued (ie
      xfs_end_io_direct() does not know that the I/O failed so can't force the
      xfs_ioend_t to be flushed synchronously).
      
      When we truncate a file on unlink we don't know to wait for these
      xfs_ioend_ts and we can have a use-after-free situation if the inode is
      reclaimed before the xfs_ioend_t is finally processed.
      
      As was suggested by Dave Chinner lets wait for all I/Os to complete when
      truncating the file size to zero.
      
      SGI-PV: 981668
      
      SGI-Modid: xfs-linux-melb:xfs-kern:32216a
      Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
      2cf7f0da
    • Lachlan McIlroy's avatar
      [XFS] Fix use-after-free with log and quotas · 9ccbece5
      Lachlan McIlroy authored
      Destroying the quota stuff on unmount can access the log - ie
      XFS_QM_DONE() ends up in xfs_dqunlock() which calls
      xfs_trans_unlocked_item() and then xfs_log_move_tail(). By this time the
      log has already been destroyed. Just move the cleanup of the quota code
      earlier in xfs_unmountfs() before the call to xfs_log_unmount(). Moving
      XFS_QM_DONE() up near XFS_QM_DQPURGEALL() seems like a good spot.
      
      SGI-PV: 987086
      
      SGI-Modid: xfs-linux-melb:xfs-kern:32148a
      Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarPeter Leckie <pleckie@sgi.com>
      9ccbece5
  2. 04 Nov, 2008 15 commits
  3. 03 Nov, 2008 21 commits