1. 11 1月, 2011 22 次提交
    • T
      ext4: remove ext4_mb_return_to_preallocation() · a5196f8c
      Theodore Ts'o 提交于
      This function was never implemented, except for a BUG_ON which was
      tripping when ext4 is run without a journal.  The problem is that
      although the comment asserts that "truncate (which is the only way to
      free block) discards all preallocations", ext4_free_blocks() is also
      called in various error recovery paths when blocks have been
      allocated, but for various reasons, we were not able to use those data
      blocks (for example, because we ran out of memory while trying to
      manipulate the extent tree, or some other similar situation).
      
      In addition to the fact that this function isn't implemented except
      for the incorrect BUG_ON, the single caller of this function,
      ext4_free_blocks(), doesn't use it all if the journal is enabled.
      
      So remove the (stub) function entirely for now.  If we decide it's
      better to add it back, it's only going to be useful with a relatively
      large number of code changes anyway.
      
      Google-Bug-Id: 3236408
      
      Cc: Jiaying Zhang <jiayingz@google.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      a5196f8c
    • J
      ext4: flush the i_completed_io_list during ext4_truncate · 3889fd57
      Jiaying Zhang 提交于
      Ted first found the bug when running 2.6.36 kernel with dioread_nolock
      mount option that xfstests #13 complained about wrong file size during fsck.
      However, the bug exists in the older kernels as well although it is
      somehow harder to trigger.
      
      The problem is that ext4_end_io_work() can happen after we have truncated an
      inode to a smaller size. Then when ext4_end_io_work() calls 
      ext4_convert_unwritten_extents(), we may reallocate some blocks that have 
      been truncated, so the inode size becomes inconsistent with the allocated
      blocks. 
      
      The following patch flushes the i_completed_io_list during truncate to reduce 
      the risk that some pending end_io requests are executed later and convert 
      already truncated blocks to initialized. 
      
      Note that although the fix helps reduce the problem a lot there may still 
      be a race window between vmtruncate() and ext4_end_io_work(). The fundamental
      problem is that if vmtruncate() is called without either i_mutex or i_alloc_sem
      held, it can race with an ongoing write request so that the io_end request is
      processed later when the corresponding blocks have been truncated.
      
      Ted and I have discussed the problem offline and we saw a few ways to fix
      the race completely:
      
      a) We guarantee that i_mutex lock and i_alloc_sem write lock are both hold 
      whenever vmtruncate() is called. The i_mutex lock prevents any new write
      requests from entering writeback and the i_alloc_sem prevents the race
      from ext4_page_mkwrite(). Currently we hold both locks if vmtruncate()
      is called from do_truncate(), which is probably the most common case.
      However, there are places where we may call vmtruncate() without holding
      either i_mutex or i_alloc_sem. I would like to ask for other people's
      opinions on what locks are expected to be held before calling vmtruncate().
      There seems a disagreement among the callers of that function.
      
      b) We change the ext4 write path so that we change the extent tree to contain 
      the newly allocated blocks and update i_size both at the same time --- when 
      the write of the data blocks is completed.
      
      c) We add some additional locking to synchronize vmtruncate() and 
      ext4_end_io_work(). This approach may have performance implications so we
      need to be careful.
      
      All of the above proposals may require more substantial changes, so
      we may consider to take the following patch as a bandaid.
      Signed-off-by: NJiaying Zhang <jiayingz@google.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      3889fd57
    • T
      ext4: add error checking to calls to ext4_handle_dirty_metadata() · b4097142
      Theodore Ts'o 提交于
      Call ext4_std_error() in various places when we can't bail out
      cleanly, so the file system can be marked as in error.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      b4097142
    • J
      ext4: fix trimming of a single group · ca6e909f
      Jan Kara 提交于
      When ext4_trim_fs() is called to trim a part of a single group, the
      logic will wrongly set last block of the interval to 'len' instead
      of 'first_block + len'. Thus a shorter interval is possibly trimmed.
      Fix it.
      
      CC: Lukas Czerner <lczerner@redhat.com>
      Cc: stable@kernel.org
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      ca6e909f
    • A
      ext4: fix uninitialized variable in ext4_register_li_request · 6c5a6cb9
      Andrew Morton 提交于
      fs/ext4/super.c: In function 'ext4_register_li_request':
      fs/ext4/super.c:2936: warning: 'ret' may be used uninitialized in this function
      
      It looks buggy to me, too.
      
      Cc: Lukas Czerner <lczerner@redhat.com>
      Cc: stable@kernel.org
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      6c5a6cb9
    • T
      ext4: dynamically allocate the jbd2_inode in ext4_inode_info as necessary · 8aefcd55
      Theodore Ts'o 提交于
      Replace the jbd2_inode structure (which is 48 bytes) with a pointer
      and only allocate the jbd2_inode when it is needed --- that is, when
      the file system has a journal present and the inode has been opened
      for writing.  This allows us to further slim down the ext4_inode_info
      structure.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      8aefcd55
    • T
      ext4: drop i_state_flags on architectures with 64-bit longs · 353eb83c
      Theodore Ts'o 提交于
      We can store the dynamic inode state flags in the high bits of
      EXT4_I(inode)->i_flags, and eliminate i_state_flags.  This saves 8
      bytes from the size of ext4_inode_info structure, which when
      multiplied by the number of the number of in the inode cache, can save
      a lot of memory.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      353eb83c
    • T
      ext4: reorder ext4_inode_info structure elements to remove unneeded padding · 8a2005d3
      Theodore Ts'o 提交于
      By reordering the elements in the ext4_inode_info structure, we can
      reduce the padding needed on an x86_64 system by 16 bytes.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      8a2005d3
    • T
      ext4: drop ec_type from the ext4_ext_cache structure · b05e6ae5
      Theodore Ts'o 提交于
      We can encode the ec_type information by using ee_len == 0 to denote
      EXT4_EXT_CACHE_NO, ee_start == 0 to denote EXT4_EXT_CACHE_GAP, and if
      neither is true, then the cache type must be EXT4_EXT_CACHE_EXTENT.
      This allows us to reduce the size of ext4_ext_inode by another 8
      bytes.  (ec_type is 4 bytes, plus another 4 bytes of padding)
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      b05e6ae5
    • T
      ext4: use ext4_lblk_t instead of sector_t for logical blocks · 01f49d0b
      Theodore Ts'o 提交于
      This fixes a number of places where we used sector_t instead of
      ext4_lblk_t for logical blocks, which for ext4 are still 32-bit data
      types.  No point wasting space in the ext4_inode_info structure, and
      requiring 64-bit arithmetic on 32-bit systems, when it isn't
      necessary.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      01f49d0b
    • T
      ext4: replace i_delalloc_reserved_flag with EXT4_STATE_DELALLOC_RESERVED · f2321097
      Theodore Ts'o 提交于
      Remove the short element i_delalloc_reserved_flag from the
      ext4_inode_info structure and replace it a new bit in i_state_flags.
      Since we have an ext4_inode_info for every ext4 inode cached in the
      inode cache, any savings we can produce here is a very good thing from
      a memory utilization perspective.
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      f2321097
    • K
      ext4: fix 32bit overflow in ext4_ext_find_goal() · ad4fb9ca
      Kazuya Mio 提交于
      ext4_ext_find_goal() returns an ideal physical block number that the block
      allocator tries to allocate first. However, if a required file offset is
      smaller than the existing extent's one, ext4_ext_find_goal() returns
      a wrong block number because it may overflow at
      "block - le32_to_cpu(ex->ee_block)". This patch fixes the problem.
      
      ext4_ext_find_goal() will also return a wrong block number in case
      a file offset of the existing extent is too big. In this case,
      the ideal physical block number is fixed in ext4_mb_initialize_context(),
      so it's no problem.
      
      reproduce:
      # dd if=/dev/zero of=/mnt/mp1/tmp bs=127M count=1 oflag=sync
      # dd if=/dev/zero of=/mnt/mp1/file bs=512K count=1 seek=1 oflag=sync
      # filefrag -v /mnt/mp1/file
      Filesystem type is: ef53
      File size of /mnt/mp1/file is 1048576 (256 blocks, blocksize 4096)
       ext logical physical expected length flags
         0     128    67456             128 eof
      /mnt/mp1/file: 2 extents found
      # rm -rf /mnt/mp1/tmp
      # echo $((512*4096)) > /sys/fs/ext4/loop0/mb_stream_req
      # dd if=/dev/zero of=/mnt/mp1/file bs=512K count=1 oflag=sync conv=notrunc
      
      result (linux-2.6.37-rc2 + ext4 patch queue):
      # filefrag -v /mnt/mp1/file
      Filesystem type is: ef53
      File size of /mnt/mp1/file is 1048576 (256 blocks, blocksize 4096)
       ext logical physical expected length flags
         0       0    33280             128 
         1     128    67456    33407    128 eof
      /mnt/mp1/file: 2 extents found
      
      result(apply this patch):
      # filefrag -v /mnt/mp1/file
      Filesystem type is: ef53
      File size of /mnt/mp1/file is 1048576 (256 blocks, blocksize 4096)
       ext logical physical expected length flags
         0       0    66560             128 
         1     128    67456    66687    128 eof
      /mnt/mp1/file: 2 extents found
      Signed-off-by: NKazuya Mio <k-mio@sx.jp.nec.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      ad4fb9ca
    • N
      ext4: add more error checks to ext4_mkdir() · dabd991f
      Namhyung Kim 提交于
      Check return value of ext4_journal_get_write_access,
      ext4_journal_dirty_metadata and ext4_mark_inode_dirty. Move brelse()
      under 'out_stop' to release bh properly in case of journal error.
      Signed-off-by: NNamhyung Kim <namhyung@gmail.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      dabd991f
    • E
      ext4: ext4_ext_migrate should use NULL not 0 · f1dffc4c
      Eric Paris 提交于
      ext4_ext_migrate() calls ext4_new_inode() and passes 0 instead of a pointer
      to a struct qstr.  This patch uses NULL, to make it obvious to the caller
      that this was a pointer.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      f1dffc4c
    • T
      ext4: Use ext4_error_file() to print the pathname to the corrupted inode · f7c21177
      Theodore Ts'o 提交于
      Where the file pointer is available, use ext4_error_file() instead of
      ext4_error_inode().
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      f7c21177
    • D
      ext4: use IS_ERR() to check for errors in ext4_error_file · f9a62d09
      Dan Carpenter 提交于
      d_path() returns an ERR_PTR and it doesn't return NULL.  This is in
      ext4_error_file() and no one actually calls ext4_error_file().
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      f9a62d09
    • D
      ext4: test the correct variable in ext4_init_pageio() · 13195184
      Dan Carpenter 提交于
      This is a copy and paste error.  The intent was to check
      "io_page_cachep".  We tested "io_page_cachep" earlier.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      13195184
    • W
      1f605b30
    • W
    • T
      ext4: clean up ext4_xattr_list()'s error code checking and return strategy · eaeef867
      Theodore Ts'o 提交于
      Any time you see code that tries to add error codes together, you
      should want to claw your eyes out...
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      eaeef867
    • L
      ext4: remove warning message from ext4_issue_discard helper · 93259636
      Lukas Czerner 提交于
      ext4_issue_discard is supposed to be helper for calling discard, however
      in case that underlying device does not support discard it prints out
      the warning message and clears the DISCARD t_mount_opt flag. Since it
      can be (and is) used by others, it should not do anything and let the
      caller to handle the error case.
      
      This commit removes warning message and flag setting from
      ext4_issue_discard and use it just in place where it is really needed
      (release_blocks_on_commit). FITRIM ioctl should not set any flags nor it
      should print out warning messages, so get rid of the warning as well.
      Signed-off-by: NLukas Czerner <lczerner@redhat.com>
      93259636
    • L
      ext4: fix possible overflow in ext4_trim_fs() · 4f531501
      Lukas Czerner 提交于
      When determining last group through ext4_get_group_no_and_offset() the
      result may be wrong in cases when range->start and range-len are too
      big, because it may overflow when summing up those two numbers.
      
      Fix that by checking range->len and limit its value to
      ext4_blocks_count(). This commit was tested by myself with expected
      result.
      Signed-off-by: NLukas Czerner <lczerner@redhat.com>
      4f531501
  2. 20 12月, 2010 7 次提交
  3. 19 12月, 2010 5 次提交
  4. 17 12月, 2010 3 次提交
  5. 16 12月, 2010 3 次提交