1. 19 5月, 2010 35 次提交
    • C
      xfs: wait for direct I/O to complete in fsync and write_inode · 37bc5743
      Christoph Hellwig 提交于
      We need to wait for all pending direct I/O requests before taking care of
      metadata in fsync and write_inode.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <david@fromorbit.com>
      37bc5743
    • A
      xfs: xfs_trace.c: duplicated include · fce1cad6
      Andrea Gelmini 提交于
      fs/xfs/linux-2.6/xfs_trace.c: xfs_attr_sf.h is included more than once.
      Signed-off-by: NAndrea Gelmini <andrea.gelmini@gelma.net>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      fce1cad6
    • A
      xfs: minor odds and ends in xfs_log_recover.c · 3f943d85
      Alex Elder 提交于
      Odds and ends in "xfs_log_recover.c".  This patch just contains some
      minor things that didn't seem to warrant their own individual
      patches:
      - In xlog_bread_noalign(), drop an assertion that a pointer is
        non-null (the crash will tell us it was a bad pointer).
      - Add a more descriptive header comment for xlog_find_verify_cycle().
      - Make a few additions to the comments in xlog_find_head().  Also
        rearrange some expressions in a few spots to produce the same
        result, but in a way that seems more clear what's being computed.
      
      (Updated in response to Dave's review comments.  Note I did not
      split this patch like I said I would.)
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      3f943d85
    • A
      xfs: avoid repeated pointer dereferences · e3bb2e30
      Alex Elder 提交于
      In xlog_find_cycle_start() use a local variable for some repeated
      operations rather than constantly accessing the memory location
      whose address is passed in.
      
      (This version drops an assertion that a pointer is non-null.)
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      e3bb2e30
    • A
      xfs: change a few labels in xfs_log_recover.c · 9db127ed
      Alex Elder 提交于
      Rename a label used in xlog_find_head() that I thought was poorly
      chosen.  Also combine two adjacent labels xlog_find_tail() into a
      single label, and give it a more generic name.
      
      (Now using Dave's suggested "validate_head" name for first label.)
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      9db127ed
    • C
      xfs: enforce synchronous writes in xfs_bwrite · 8c38366f
      Christoph Hellwig 提交于
      xfs_bwrite is used with the intention of synchronously writing out
      buffers, but currently it does not actually clear the async flag if
      that's left from previous writes but instead implements async
      behaviour if it finds it.  Remove the code handling asynchronous
      writes as we've got rid of those entirely outside of the log and
      delwri buffers, and make sure that we clear the async and read flags
      before writing the buffer.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      8c38366f
    • C
      xfs: remove periodic superblock writeback · df308bcf
      Christoph Hellwig 提交于
      All modifications to the superblock are done transactional through
      xfs_trans_log_buf, so there is no reason to initiate periodic
      asynchronous writeback.  This only removes the superblock from the
      delwri list and will lead to sub-optimal I/O scheduling.
      
      Cut down xfs_sync_fsdata now that it's only used for synchronous
      superblock writes and move the log coverage checks into the two
      callers.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      df308bcf
    • D
      xfs: make the log ticket transaction id random · f9837107
      Dave Chinner 提交于
      The transaction ID that is written to the log for a transaction is
      currently set by taking the lower 32 bits of the memory address of
      the ticket structure.  This is not guaranteed to be unique as
      tickets comes from a slab and slots can be reallocated immediately
      after being freed. As a result, there is no guarantee of uniqueness
      in the ticket ID value.
      
      Fix this by assigning a random number to the ticket ID field so that
      it is extremely unlikely that duplicates will occur and remove the
      possibility of transactions being mixed up during recovery due to
      duplicate IDs.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      f9837107
    • A
      xfs: nothing special about 1-block log sector · 36adecff
      Alex Elder 提交于
      There are a number of places where a log sector size of 1 uses
      special case code.  The round_up() and round_down() macros
      produce the correct result even when the log sector size is 1, and
      this eliminates the need for treating this as a special case.
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      36adecff
    • A
      xfs: encapsulate bbcount validity checking · ff30a622
      Alex Elder 提交于
      Define a function that encapsulates checking the validity of a log
      block count.
      
      (Updated from previous version--no longer includes error reporting in the
      encapsulated validation function.)
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      ff30a622
    • A
      xfs: kill XLOG_SECTOR_ROUND*() · 5c17f533
      Alex Elder 提交于
      XLOG_SECTOR_ROUNDUP_BBCOUNT() and XLOG_SECTOR_ROUNDDOWN_BLKNO()
      are now fairly simple macro translations.  Just get rid of them in
      favor of the round_up() and round_down() macro calls they represent.
      
      Also, in spots in xlog_get_bp() and xlog_write_log_records(),
      round_up() was being called with value 1, which just evaluates
      to the macro's second argument; so just use that instead.
      In the latter case, make use of that value, as long as it's
      already been computed.
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      5c17f533
    • A
      xfs: simplify XLOG_SECTOR_ROUND*() · 8511998b
      Alex Elder 提交于
      XLOG_SECTOR_ROUNDUP_BBCOUNT() is defined in "fs/xfs/xfs_log_recover.c"
      in an overly-complicated way.  It is basically roundup(), but that
      is not at all clear from its definition.  (Actually, there is
      another macro round_up() that applies for power-of-two-based masks
      which I'll be using here.)
      
      The operands in XLOG_SECTOR_ROUNDUP_BBCOUNT() are basically the
      block number (bbs) and the log sector basic block mask
      (log->l_sectbb_mask).  I'll call them B and M for this discussion.
      
      The macro computes is value this way:
      	M && (B & M) ? (B + M + 1) & ~M : B
      
      Put another way, we can break it into 3 cases:
      	1)  ! M          -> B			# 0 mask, no effect
      	2)  ! (B & M)    -> B			# sector aligned
      	3)  M && (B & M) -> (B + M + 1) & ~M	# round up otherwise
      
      The round_up() macro is cleverly defined using a value, v, and a
      power-of-2, p, and the result is the nearest multiple of p greater
      than or equal to v.  Its value is computed something like this:
      	((v - 1) | (p - 1)) + 1
      Let's consider using this in the context of the 3 cases above.
      
      When p = 2^0 = 1, the result boils down to ((v - 1) | 0) + 1, so it
      just translates any value v to itself.  That handles case (1) above.
      
      When p = 2^n, n > 0, we know that (p - 1) will be a mask with all n
      bits 0..n-1 set.  The condition in this case occurs when none of
      those mask bits is set in the value v provided.  If that is the
      case, subtracting 1 from v will have 1's in all those lower bits (at
      least).  Therefore, OR-ing the mask with that decremented value has
      no effect, so adding the 1 back again will just translate the v to
      itself.  This handles case (2).
      
      Otherwise, the value v is greater than some multiple of p, and
      decrementing it will produce a result greater than or equal to that
      multiple.  OR-ing in the mask will produce a value 1 less than the
      next multiple of p, so finally adding 1 back will result in the
      desired rounded-up value.  This handles case (3).
      
      Hopefully this is convincing.
      
      While I was at it, I converted XLOG_SECTOR_ROUNDDOWN_BLKNO() to use
      the round_down() macro.
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      8511998b
    • A
      xfs: fix min bufsize bugs in two places · 6881a229
      Alex Elder 提交于
      This fixes a bug in two places that I found by inspection.  In
      xlog_find_verify_cycle() and xlog_write_log_records(), the code
      attempts to allocate a buffer to hold as many blocks as possible.
      It gives up if the number of blocks to be allocated gets too small.
      Right now it uses log->l_sectbb_log as that lower bound, but I'm
      sure it's supposed to be the actual log sector size instead.  That
      is, the lower bound should be (1 << log->l_sectbb_log).
      
      Also define a simple macro xlog_sectbb(log) to represent the number
      of basic blocks in a sector for the given log.
      
      (No change from original submission; I have implemented Christoph's
      suggestion about storing l_sectsize rather than l_sectbb_log in
      a new, separate patch in this series.)
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      6881a229
    • A
      xfs: add const qualifiers to xfs error function args · a0e856b0
      Alex Elder 提交于
      Change the tag and file name arguments to xfs_error_report() and
      xfs_corruption_error() to use a const qualifier.
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      a0e856b0
    • C
      xfs: remove xfs_dqmarker · 74457cf4
      Christoph Hellwig 提交于
      The xfs_dqmarker structure does not need to exist anymore. Move the
      remaining flags field out of it and remove the structure altogether.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <david@fromorbit.com>
      74457cf4
    • D
      xfs: convert the dquot free list to use list heads · 3a8406f6
      Dave Chinner 提交于
      Convert the dquot free list on the filesystem to use listhead
      infrastructure rather than the roll-your-own in the quota code.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      3a8406f6
    • D
      xfs: convert the dquot hash list to use list heads · e6a81f13
      Dave Chinner 提交于
      Convert the dquot hash list on the filesystem to use listhead
      infrastructure rather than the roll-your-own in the quota code.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      e6a81f13
    • D
      xfs: remove duplicate code from dquot reclaim · 368e1361
      Dave Chinner 提交于
      The dquot shaker and the free-list reclaim code use exactly the same
      algorithm but the code is duplicated and slightly different in each
      case. Make the shaker code use the single dquot reclaim code to
      remove the code duplication.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      368e1361
    • D
      xfs: convert the per-mount dquot list to use list heads · 3a25404b
      Dave Chinner 提交于
      Convert the dquot list on the filesytesm to use listhead
      infrastructure rather than the roll-your-own in the quota code.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      3a25404b
    • D
      xfs: add log item recovery tracing · 9abbc539
      Dave Chinner 提交于
      Currently there is no tracing in log recovery, so it is difficult to
      determine what is going on when something goes wrong.
      
      Add tracing for log item recovery to provide visibility into the log
      recovery process. The tracing added shows regions being extracted
      from the log transactions and added to the transaction hash forming
      recovery items, followed by the reordering, cancelling and finally
      recovery of the items.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      9abbc539
    • C
      xfs: clean up xlog_write_adv_cnt · e6b1f273
      Christoph Hellwig 提交于
      Replace the awkward xlog_write_adv_cnt with an inline helper that makes
      it more obvious that it's modifying it's paramters, and replace the use
      of an integer type for "ptr" with a real void pointer.  Also move
      xlog_write_adv_cnt to xfs_log_priv.h as it will be used outside of
      xfs_log.c in the delayed logging series.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      e6b1f273
    • D
      xfs: introduce new internal log vector structure · 55b66332
      Dave Chinner 提交于
      The current log IO vector structure is a flat array and not
      extensible. To make it possible to keep separate log IO vectors for
      individual log items, we need a method of chaining log IO vectors
      together.
      
      Introduce a new log vector type that can be used to wrap the
      existing log IO vectors on use that internally to the log. This
      means that the existing external interface (xfs_log_write) does not
      change and hence no changes to the transaction commit code are
      required.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      55b66332
    • C
      xfs: reindent xlog_write · 99428ad0
      Christoph Hellwig 提交于
      Reindent xlog_write to normal one tab indents and move all variable
      declarations into the closest enclosing block.
      
      Split from a bigger patch by Dave Chinner.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      99428ad0
    • D
      xfs: factor xlog_write · b5203cd0
      Dave Chinner 提交于
      xlog_write is a mess that takes a lot of effort to understand. It is
      a mass of nested loops with 4 space indents to get it to fit in 80 columns
      and lots of funky variables that aren't obvious what they mean or do.
      
      Break it down into understandable chunks.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      b5203cd0
    • D
      xfs: log ticket reservation underestimates the number of iclogs · 9b9fc2b7
      Dave Chinner 提交于
      When allocation a ticket for a transaction, the ticket is initialised with the
      worst case log space usage based on the number of bytes the transaction may
      consume. Part of this calculation is the number of log headers required for the
      iclog space used up by the transaction.
      
      This calculation makes an undocumented assumption that if the transaction uses
      the log header space reservation on an iclog, then it consumes either the
      entire iclog or it completes. That is - the transaction that is first in an
      iclog is the transaction that the log header reservation is accounted to. If
      the transaction is larger than the iclog, then it will use the entire iclog
      itself. Document this assumption.
      
      Further, the current calculation uses the rule that we can fit iclog_size bytes
      of transaction data into an iclog. This is in correct - the amount of space
      available in an iclog for transaction data is the size of the iclog minus the
      space used for log record headers. This means that the calculation is out by
      512 bytes per 32k of log space the transaction can consume. This is rarely an
      issue because maximally sized transactions are extremely uncommon, and for 4k
      block size filesystems maximal transaction reservations are about 400kb. Hence
      the error in this case is less than the size of an iclog, so that makes it even
      harder to hit.
      
      However, anyone using larger directory blocks (16k directory blocks push the
      maximum transaction size to approx. 900k on a 4k block size filesystem) or
      larger block size (e.g. 64k blocks push transactions to the 3-4MB size) could
      see the error grow to more than an iclog and at this point the transaction is
      guaranteed to get a reservation underrun and shutdown the filesystem.
      
      Fix this by adjusting the calculation to calculate the correct number of iclogs
      required and account for them all up front.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      9b9fc2b7
    • D
      xfs: Clean up xfs_trans_committed code after factoring · b1c1b5b6
      Dave Chinner 提交于
      Now that the code has been factored, clean up all the remaining
      style cruft, simplify the code and re-order functions so that it
      doesn't need forward declarations.
      
      Also move the remaining functions that require forward declarations
      (xfs_trans_uncommit, xfs_trans_free) so that all the forward
      declarations can be removed from the file.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      b1c1b5b6
    • D
      xfs: update and factor xfs_trans_committed() · 8e646a55
      Dave Chinner 提交于
      The function header to xfs-trans_committed has long had this
      comment:
      
       * THIS SHOULD BE REWRITTEN TO USE xfs_trans_next_item()
      
      To prepare for different methods of committing items, convert the
      code to use xfs_trans_next_item() and factor the code into smaller,
      more digestible chunks.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      8e646a55
    • C
      xfs: clean up xfs_trans_commit logic even more · a3ccd2ca
      Christoph Hellwig 提交于
      > +shut_us_down:
      > +	shutdown = XFS_FORCED_SHUTDOWN(mp) ? EIO : 0;
      > +	if (!(tp->t_flags & XFS_TRANS_DIRTY) || shutdown) {
      > +		xfs_trans_unreserve_and_mod_sb(tp);
      > +		/*
      
      This whole area in _xfs_trans_commit is still a complete mess.
      
      So while touching this code, unravel this mess as well to make the
      whole flow of the function simpler and clearer.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <david@fromorbit.com>
      a3ccd2ca
    • D
      xfs: split out iclog writing from xfs_trans_commit() · 0924378a
      Dave Chinner 提交于
      Split the the part of xfs_trans_commit() that deals with writing the
      transaction into the iclog into a separate function. This isolates the
      physical commit process from the logical commit operation and makes
      it easier to insert different transaction commit paths without affecting
      the existing algorithm adversely.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      0924378a
    • D
      xfs: fix reservation release commit flag in xfs_bmap_add_attrfork() · 713bf88b
      Dave Chinner 提交于
      xfs_bmap_add_attrfork() passes XFS_TRANS_PERM_LOG_RES to xfs_trans_commit()
      to indicate that the commit should release the permanent log reservation
      as part of the commit. This is wrong - the correct flag is
      XFS_TRANS_RELEASE_LOG_RES - and it is only by the chance that both these
      flags have the value of 0x4 that the code is doing the right thing.
      
      Fix it by changing to use the correct flag.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      713bf88b
    • D
      xfs: remove stale parameter from ->iop_unpin method · 8e123850
      Dave Chinner 提交于
      The staleness of a object being unpinned can be directly derived
      from the object itself - there is no need to extract it from the
      object then pass it as a parameter into IOP_UNPIN().
      
      This means we can kill the XFS_LID_BUF_STALE flag - it is set,
      checked and cleared in the same places XFS_BLI_STALE flag in the
      xfs_buf_log_item so it is now redundant and hence safe to remove.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      8e123850
    • D
      xfs: Add inode pin counts to traces · 4aaf15d1
      Dave Chinner 提交于
      We don't record pin counts in inode events right now, and this makes
      it difficult to track down problems related to pinning inodes. Add
      the pin count to the inode trace class and add trace events for
      pinning and unpinning inodes.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      4aaf15d1
    • D
      xfs: factor log item initialisation · 43f5efc5
      Dave Chinner 提交于
      Each log item type does manual initialisation of the log item.
      Delayed logging introduces new fields that need initialisation, so
      factor all the open coded initialisation into a common function
      first.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      43f5efc5
    • J
      xfs: add blockdev name to kthreads · e2a07812
      Jan Engelhardt 提交于
      This allows to see in `ps` and similar tools which kthreads are
      allotted to which block device/filesystem, similar to what jbd2
      does. As the process name is a fixed 16-char array, no extra
      space is needed in tasks.
      
        PID TTY      STAT   TIME COMMAND
          2 ?        S      0:00 [kthreadd]
        197 ?        S      0:00  \_ [jbd2/sda2-8]
        198 ?        S      0:00  \_ [ext4-dio-unwrit]
        204 ?        S      0:00  \_ [flush-8:0]
       2647 ?        S      0:00  \_ [xfs_mru_cache]
       2648 ?        S      0:00  \_ [xfslogd/0]
       2649 ?        S      0:00  \_ [xfsdatad/0]
       2650 ?        S      0:00  \_ [xfsconvertd/0]
       2651 ?        S      0:00  \_ [xfsbufd/ram0]
       2652 ?        S      0:00  \_ [xfsaild/ram0]
       2653 ?        S      0:00  \_ [xfssyncd/ram0]
      Signed-off-by: NJan Engelhardt <jengelh@medozas.de>
      Reviewed-by: NDave Chinner <david@fromorbit.com>
      e2a07812
    • Z
      xfs: Fix integer overflow in fs/xfs/linux-2.6/xfs_ioctl*.c · fda168c2
      Zhitong Wang 提交于
      The am_hreq.opcount field in the xfs_attrmulti_by_handle() interface
      is not bounded correctly. The opcount is used to determine the size
      of the buffer required. The size is bounded, but can overflow and so
      the size checks may not be sufficient to catch invalid opcounts.
      Fix it by catching opcount values that would cause overflows before
      calculating the size.
      Signed-off-by: NZhitong Wang <zhitong.wangzt@alibaba-inc.com>
      Reviewed-by: NDave Chinner <david@fromorbit.com>
      fda168c2
  2. 30 4月, 2010 1 次提交
    • D
      xfs: add a shrinker to background inode reclaim · 9bf729c0
      Dave Chinner 提交于
      On low memory boxes or those with highmem, kernel can OOM before the
      background reclaims inodes via xfssyncd. Add a shrinker to run inode
      reclaim so that it inode reclaim is expedited when memory is low.
      
      This is more complex than it needs to be because the VM folk don't
      want a context added to the shrinker infrastructure. Hence we need
      to add a global list of XFS mount structures so the shrinker can
      traverse them.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      9bf729c0
  3. 27 4月, 2010 1 次提交
    • D
      xfs: more swap extent fixes for dynamic fork offsets · dd77ef92
      Dave Chinner 提交于
      A new xfsqa test (226) with a prototype xfs_fsr change to try to
      handle dynamic fork offsets better triggers an assertion failure
      where the inode data fork is in btree format, yet there is room in
      the inode for it to be in extent format. The two inodes look like:
      
      before: ino 0x101 (target), num_extents 11, Max in-fork extents 6, broot size 40, fork offset 96
      before: ino 0x115 (temp),  num_extents 5, Max in-fork extents 3, broot size 40, fork offset 56
      after: ino 0x101 (target), num_extents 5, Max in-fork extents 6, broot size 40, fork offset 96
      after: ino 0x115 (temp), num_extents 11, Max in-fork extents 3, broot size 40, fork offset 56
      
      Basically the target inode ends up with 5 extents in btree format,
      but it had space for 6 extents in extent format, so ends up
      incorrect. Notably here the broot size is the same, and that is
      where the kernel code is going wrong - the btree root will fit, so
      it lets the swap go ahead.
      
      The check should not allow the swap to take place if the number of
      extents while in btree format is less than the number of extents
      that can fit in the inode in extent format. Adding that check will
      prevent this swap and corruption from occurring.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      dd77ef92
  4. 17 4月, 2010 2 次提交
    • D
      xfs: don't warn on EAGAIN in inode reclaim · f1d486a3
      Dave Chinner 提交于
      Any inode reclaim flush that returns EAGAIN will result in the inode
      reclaim being attempted again later. There is no need to issue a
      warning into the logs about this situation.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NAlex Elder <aelder@sgi.com>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      f1d486a3
    • D
      xfs: ensure that sync updates the log tail correctly · b6f8dd49
      Dave Chinner 提交于
      Updates to the VFS layer removed an extra ->sync_fs call into the
      filesystem during the sync process (from the quota code).
      Unfortunately the sync code was unknowingly relying on this call to
      make sure metadata buffers were flushed via a xfs_buftarg_flush()
      call to move the tail of the log forward in memory before the final
      transactions of the sync process were issued.
      
      As a result, the old code would write a very recent log tail value
      to the log by the end of the sync process, and so a subsequent crash
      would leave nothing for log recovery to do. Hence in qa test 182,
      log recovery only replayed a small handle for inode fsync
      transactions in this case.
      
      However, with the removal of the extra ->sync_fs call, the log tail
      was now not moved forward with the inode fsync transactions near the
      end of the sync procese the first (and only) buftarg flush occurred
      after these transactions went to disk. The result is that log
      recovery now sees a large number of transactions for metadata that
      is already on disk.
      
      This usually isn't a problem, but when the transactions include
      inode chunk allocation, the inode create transactions and all
      subsequent changes are replayed as we cannt rely on what is on disk
      is valid. As a result, if the inode was written and contains
      unlogged changes, the unlogged changes are lost, thereby violating
      sync semantics.
      
      The fix is to always issue a transaction after the buftarg flush
      occurs is the log iѕ not idle or covered. This results in a dummy
      transaction being written that contains the up-to-date log tail
      value, which will be very recent. Indeed, it will be at least as
      recent as the old code would have left on disk, so log recovery
      will behave exactly as it used to in this situation.
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      b6f8dd49
  5. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6