1. 14 7月, 2007 19 次提交
    • D
      [XFS] Prevent ENOSPC from aborting transactions that need to succeed · 84e1e99f
      David Chinner 提交于
      During delayed allocation extent conversion or unwritten extent
      conversion, we need to reserve some blocks for transactions reservations.
      We need to reserve these blocks in case a btree split occurs and we need
      to allocate some blocks.
      
      Unfortunately, we've only ever reserved the number of data blocks we are
      allocating, so in both the unwritten and delalloc case we can get ENOSPC
      to the transaction reservation. This is bad because in both cases we
      cannot report the failure to the writing application.
      
      The fix is two-fold:
      
      1 - leverage the reserved block infrastructure XFS already
      has to reserve a small pool of blocks by default to allow
      specially marked transactions to dip into when we are at
      ENOSPC.
      Default setting is min(5%, 1024 blocks).
      
      2 - convert critical transaction reservations to be allowed
      to dip into this pool. Spots changed are delalloc
      conversion, unwritten extent conversion and growing a
      filesystem at ENOSPC.
      This also allows growing the filesytsem to succeed at ENOSPC.
      
      SGI-PV: 964468
      SGI-Modid: xfs-linux-melb:xfs-kern:28865a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      84e1e99f
    • D
      [XFS] Prevent deadlock when flushing inodes on unmount · 641c56fb
      David Chinner 提交于
      When we are unmounting the filesystem, we flush all the inodes to disk.
      Unfortunately, if we have an inode cluster that has just been freed and
      marked stale sitting in an incore log buffer (i.e. hasn't been flushed to
      disk), it will be holding all the flush locks on the inodes in that
      cluster.
      
      xfs_iflush_all() which is called during unmount walks all the inodes
      trying to reclaim them, and it doing so calls xfs_finish_reclaim() on each
      inode. If the inode is dirty, if grabs the flush lock and flushes it.
      Unfortunately, find dirty inodes that already have their flush lock held
      and so we sleep.
      
      At this point in the unmount process, we are running single-threaded.
      There is nothing more that can push on the log to force the transaction
      holding the inode flush locks to disk and hence we deadlock.
      
      The fix is to issue a log force before flushing the inodes on unmount so
      that all the flush locks will be released before we start flushing the
      inodes.
      
      SGI-PV: 964538
      SGI-Modid: xfs-linux-melb:xfs-kern:28862a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      641c56fb
    • T
      [XFS] Log the agf_length change in xfs_growfs_data_private(). · 0164af51
      Tim Shimmin 提交于
      SGI-PV: 963528
      SGI-Modid: xfs-linux-melb:xfs-kern:28856a
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      0164af51
    • D
      [XFS] Map unwritten extents correctly for I/o completion processing · effd120e
      David Chinner 提交于
      If we have multiple unwritten extents within a single page, we fail to
      tell the I/o completion construction handlers we need a new handle for the
      second and subsequent blocks in the page. While we still issue the I/O
      correctly, we do not have the correct ranges recorded in the ioend
      structures and hence when we go to convert the unwritten extents we screw
      it up.
      
      Make sure we start a new ioend every time the mapping changes so that we
      convert the correct ranges on I/O completion.
      
      SGI-PV: 964647
      SGI-Modid: xfs-linux-melb:xfs-kern:28797a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      effd120e
    • D
      [XFS] Apply transaction delta counts atomically to incore counters · 45c34141
      David Chinner 提交于
      With the per-cpu superblock counters, batch updates are no longer atomic
      across the entire batch of changes. This is not an issue if each
      individual change in the batch is applied atomically. Unfortunately, free
      block count changes are not applied atomically, and they are applied in a
      manner guaranteed to cause problems.
      
      Essentially, the free block count reservation that the transaction took
      initially is returned to the in core counters before a second delta takes
      away what is used. because these two operations are not atomic, we can
      race with another thread that can use the returned transaction reservation
      before the transaction takes the space away again and we can then get
      ENOSPC being reported in a spot where we don't have an ENOSPC condition,
      nor should we ever see one there.
      
      Fix it up by rolling the two deltas into the one so it can be applied
      safely (i.e. atomically) to the incore counters.
      
      SGI-PV: 964465
      SGI-Modid: xfs-linux-melb:xfs-kern:28796a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      45c34141
    • D
      [XFS] Handle null returned from xfs_vtoi() in xfs_setfilesize(). · b2826136
      David Chinner 提交于
      SGI-PV: 965636
      SGI-Modid: xfs-linux-melb:xfs-kern:28777a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NOlaf Weber <olaf@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      b2826136
    • D
      [XFS] Block on unwritten extent conversion during synchronous direct I/O. · e927af90
      David Chinner 提交于
      Currently we do not wait on extent conversion to occur, and hence we can
      return to userspace from a synchronous direct I/O write without having
      completed all the actions in the write. Hence a read after the write may
      see zeroes (unwritten extent) rather than the data that was written.
      
      Block the I/O completion by triggering a synchronous workqueue flush to
      ensure that the conversion has occurred before we return to userspace.
      
      SGI-PV: 964092
      SGI-Modid: xfs-linux-melb:xfs-kern:28775a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      e927af90
    • D
      [XFS] Flush the block device before closing it on unmount. · f4a9f28a
      David Chinner 提交于
      SGI-PV: 965630
      SGI-Modid: xfs-linux-melb:xfs-kern:28774a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      f4a9f28a
    • D
      [XFS] xfs_bmapi fails to update the previous extent pointer · 4e5ae838
      David Chinner 提交于
      When processing multiple extent maps, xfs_bmapi needs to keep track of the
      extent behind the one it is currently working on to be able to trim extent
      ranges correctly. Failing to update the previous pointer can result in
      corrupted extent lists in memory and this will result in panics or assert
      failures.
      
      Update the previous pointer correctly when we move to the next extent to
      process.
      
      SGI-PV: 965631
      SGI-Modid: xfs-linux-melb:xfs-kern:28773a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NVlad Apostolov <vapo@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      4e5ae838
    • D
      [XFS] Fix the transaction flags to make lazy superblock counters work. · 210c6f1c
      David Chinner 提交于
      SGI-PV: 964999
      SGI-Modid: xfs-linux-melb:xfs-kern:28653a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      210c6f1c
    • D
      [XFS] Lazy Superblock Counters · 92821e2b
      David Chinner 提交于
      When we have a couple of hundred transactions on the fly at once, they all
      typically modify the on disk superblock in some way.
      create/unclink/mkdir/rmdir modify inode counts, allocation/freeing modify
      free block counts.
      
      When these counts are modified in a transaction, they must eventually lock
      the superblock buffer and apply the mods. The buffer then remains locked
      until the transaction is committed into the incore log buffer. The result
      of this is that with enough transactions on the fly the incore superblock
      buffer becomes a bottleneck.
      
      The result of contention on the incore superblock buffer is that
      transaction rates fall - the more pressure that is put on the superblock
      buffer, the slower things go.
      
      The key to removing the contention is to not require the superblock fields
      in question to be locked. We do that by not marking the superblock dirty
      in the transaction. IOWs, we modify the incore superblock but do not
      modify the cached superblock buffer. In short, we do not log superblock
      modifications to critical fields in the superblock on every transaction.
      In fact we only do it just before we write the superblock to disk every
      sync period or just before unmount.
      
      This creates an interesting problem - if we don't log or write out the
      fields in every transaction, then how do the values get recovered after a
      crash? the answer is simple - we keep enough duplicate, logged information
      in other structures that we can reconstruct the correct count after log
      recovery has been performed.
      
      It is the AGF and AGI structures that contain the duplicate information;
      after recovery, we walk every AGI and AGF and sum their individual
      counters to get the correct value, and we do a transaction into the log to
      correct them. An optimisation of this is that if we have a clean unmount
      record, we know the value in the superblock is correct, so we can avoid
      the summation walk under normal conditions and so mount/recovery times do
      not change under normal operation.
      
      One wrinkle that was discovered during development was that the blocks
      used in the freespace btrees are never accounted for in the AGF counters.
      This was once a valid optimisation to make; when the filesystem is full,
      the free space btrees are empty and consume no space. Hence when it
      matters, the "accounting" is correct. But that means the when we do the
      AGF summations, we would not have a correct count and xfs_check would
      complain. Hence a new counter was added to track the number of blocks used
      by the free space btrees. This is an *on-disk format change*.
      
      As a result of this, lazy superblock counters are a mkfs option and at the
      moment on linux there is no way to convert an old filesystem. This is
      possible - xfs_db can be used to twiddle the right bits and then
      xfs_repair will do the format conversion for you. Similarly, you can
      convert backwards as well. At some point we'll add functionality to
      xfs_admin to do the bit twiddling easily....
      
      SGI-PV: 964999
      SGI-Modid: xfs-linux-melb:xfs-kern:28652a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      92821e2b
    • A
      [XFS] Use generic shrinker interfaces in XFS. · 3260f78a
      Andrew Morton 提交于
      SGI-PV: 964986
      SGI-Modid: xfs-linux-melb:xfs-kern:28642a
      Signed-Off-By: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      3260f78a
    • D
      [XFS] Make hole punching at EOF atomic. · 92dfe8d2
      David Chinner 提交于
      If hole punching at EOF is done as two steps (i.e. truncate then extend)
      the file is in a transient state between the two steps where an
      application can see the incorrect file size. Punching a hole to EOF needs
      to be treated in teh same way as all other hole punching cases so that the
      file size is never seen to change.
      
      SGI-PV: 962012
      SGI-Modid: xfs-linux-melb:xfs-kern:28641a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NVlad Apostolov <vapo@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      92dfe8d2
    • D
      [XFS] Fix vmalloc leak on mount/unmount. · 511105b3
      David Chinner 提交于
      When setting the length of the iclogbuf to write out we should just be
      changing the desired byte count rather completely reassociating the buffer
      memory with the buffer. Reassociating the buffer memory changes the
      apparent length of the buffer and hence when we free the buffer, we don't
      free all the vmap()d space we originally allocated.
      
      SGI-PV: 964983
      SGI-Modid: xfs-linux-melb:xfs-kern:28640a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      511105b3
    • C
      [XFS] Fix double free in xfs_buf_get_noaddr error handling path · ca165b88
      Christoph Hellwig 提交于
      SGI-PV: 964983
      SGI-Modid: xfs-linux-melb:xfs-kern:28639a
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      ca165b88
    • D
      [XFS] Fix use-after-free during log unmount. · 3db296f3
      David Chinner 提交于
      Don't reference the log buffer after running the callbacks as the callback
      can trigger the log buffers to be freed during unmount.
      
      SGI-PV: 964545
      SGI-Modid: xfs-linux-melb:xfs-kern:28567a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      3db296f3
    • D
      [XFS] Sleeping with the ilock waiting for I/O completion is Bad. · 40095b64
      David Chinner 提交于
      Recent fixes to the filesystem freezing code introduced a vn_iowait call
      in the middle of the sync code. Unfortunately, at the point where this
      call was added we are holding the ilock. The ilock is needed by I/O
      completion for unwritten extent conversion and now updating the file size.
      Hence I/o cannot complete if we hold the ilock while waiting for I/O
      completion.
      
      Fix up the bug and clean the code up around it.
      
      SGI-PV: 963674
      SGI-Modid: xfs-linux-melb:xfs-kern:28566a
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      40095b64
    • N
      [XFS] Don't grow filesystems past the size they can index. · 4cc929ee
      Nathan Scott 提交于
      When growing a filesystem we don't check to see if the new size overflows
      the page cache index range, so we can do silly things like grow a
      filesystem page 16TB on a 32bit. Check new filesystem sizes against the
      limits the kernel can support.
      
      SGI-PV: 957886
      SGI-Modid: xfs-linux-melb:xfs-kern:28563a
      Signed-Off-By: NNathan Scott <nscott@aconex.com>
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      4cc929ee
    • C
      [XFS] Only use refcounted pages for I/O · 1fa40b01
      Christoph Hellwig 提交于
      Many block drivers (aoe, iscsi) really want refcountable pages in bios,
      which is what almost everyone send down. XFS unfortunately has a few
      places where it sends down buffers that may come from kmalloc, which
      breaks them.
      
      Fix the places that use kmalloc()d buffers.
      
      SGI-PV: 964546
      SGI-Modid: xfs-linux-melb:xfs-kern:28562a
      Signed-Off-By: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NDavid Chinner <dgc@sgi.com>
      Signed-off-by: NTim Shimmin <tes@sgi.com>
      1fa40b01
  2. 11 7月, 2007 1 次提交
    • P
      Make common helpers for seq_files that work with list_heads · bcf67e16
      Pavel Emelianov 提交于
      Many places in kernel use seq_file API to iterate over a regular list_head.
      The code for such iteration is identical in all the places, so it's worth
      introducing a common helpers.
      
      This makes code about 300 lines smaller:
      
      The first version of this patch made the helper functions static inline
      in the seq_file.h header. This patch moves them to the fs/seq_file.c as
      Andrew proposed. The vmlinux .text section sizes are as follows:
      
      2.6.22-rc1-mm1:              0x001794d5
      with the previous version:   0x00179505
      with this patch:             0x00179135
      
      The config file used was make allnoconfig with the "y" inclusion of all
      the possible options to make the files modified by the patch compile plus
      drivers I have on the test node.
      
      This patch:
      
      Many places in kernel use seq_file API to iterate over a regular list_head.
      The code for such iteration is identical in all the places, so it's worth
      introducing a common helpers.
      Signed-off-by: NPavel Emelianov <xemul@openvz.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      bcf67e16
  3. 10 7月, 2007 20 次提交