1. 13 4月, 2014 2 次提交
    • Z
      ext4: fix byte order problems introduced by the COLLAPSE_RANGE patches · 847c6c42
      Zheng Liu 提交于
      This commit tries to fix some byte order issues that is found by sparse
      check.
      
      $ make M=fs/ext4 C=2 CF=-D__CHECK_ENDIAN__
      ...
        CHECK   fs/ext4/extents.c
      fs/ext4/extents.c:5232:41: warning: restricted __le32 degrades to integer
      fs/ext4/extents.c:5236:52: warning: bad assignment (-=) to restricted __le32
      fs/ext4/extents.c:5258:45: warning: bad assignment (-=) to restricted __le32
      fs/ext4/extents.c:5303:28: warning: restricted __le32 degrades to integer
      fs/ext4/extents.c:5318:18: warning: incorrect type in assignment (different base types)
      fs/ext4/extents.c:5318:18:    expected unsigned int [unsigned] [usertype] ex_start
      fs/ext4/extents.c:5318:18:    got restricted __le32 [usertype] ee_block
      fs/ext4/extents.c:5319:24: warning: restricted __le32 degrades to integer
      fs/ext4/extents.c:5334:31: warning: incorrect type in assignment (different base types)
      ...
      
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Namjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NZheng Liu <wenqing.lz@taobao.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      847c6c42
    • T
      ext4: use i_size_read in ext4_unaligned_aio() · 6e6358fc
      Theodore Ts'o 提交于
      We haven't taken i_mutex yet, so we need to use i_size_read().
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      6e6358fc
  2. 12 4月, 2014 4 次提交
  3. 11 4月, 2014 3 次提交
    • T
      ext4: move ext4_update_i_disksize() into mpage_map_and_submit_extent() · 622cad13
      Theodore Ts'o 提交于
      The function ext4_update_i_disksize() is used in only one place, in
      the function mpage_map_and_submit_extent().  Move its code to simplify
      the code paths, and also move the call to ext4_mark_inode_dirty() into
      the i_data_sem's critical region, to be consistent with all of the
      other places where we update i_disksize.  That way, we also keep the
      raw_inode's i_disksize protected, to avoid the following race:
      
            CPU #1                                 CPU #2
      
         down_write(&i_data_sem)
         Modify i_disk_size
         up_write(&i_data_sem)
                                              down_write(&i_data_sem)
                                              Modify i_disk_size
                                              Copy i_disk_size to on-disk inode
                                              up_write(&i_data_sem)
         Copy i_disk_size to on-disk inode
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Cc: stable@vger.kernel.org
      622cad13
    • Y
      ext4: return ENOMEM rather than EIO when find_###_page() fails · c57ab39b
      Younger Liu 提交于
      Return ENOMEM rather than EIO when find_get_page() fails in
      ext4_mb_get_buddy_page_lock() and find_or_create_page() fails in
      ext4_mb_load_buddy().
      Signed-off-by: NYounger Liu <younger.liucn@gmail.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      c57ab39b
    • N
      ext4: fix COLLAPSE_RANGE test failure in data journalling mode · 1ce01c4a
      Namjae Jeon 提交于
      When mounting ext4 with data=journal option, xfstest shared/002 and
      shared/004 are currently failing as checksum computed for testfile
      does not match with the checksum computed in other journal modes.
      In case of data=journal mode, a call to filemap_write_and_wait_range
      will not flush anything to disk as buffers are not marked dirty in
      write_end. In collapse range this call is followed by a call to
      truncate_pagecache_range. Due to this, when checksum is computed,
      a portion of file is re-read from disk which replace valid data with
      NULL bytes and hence the reason for the difference in checksum.
      
      Calling ext4_force_commit before filemap_write_and_wait_range solves
      the issue as it will mark the buffers dirty during commit transaction
      which can be later synced by a call to filemap_write_and_wait_range.
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAshish Sangwan <a.sangwan@samsung.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      1ce01c4a
  4. 08 4月, 2014 1 次提交
    • T
      ext4: update PF_MEMALLOC handling in ext4_write_inode() · 87f7e416
      Theodore Ts'o 提交于
      The special handling of PF_MEMALLOC callers in ext4_write_inode()
      shouldn't be necessary as there shouldn't be any. Warn about it. Also
      update comment before the function as it seems somewhat outdated.
      
      (Changes modeled on an ext3 patch posted by Jan Kara to the linux-ext4
      mailing list on Februaryt 28, 2014, which apparently never went into
      the ext3 tree.)
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: Jan Kara <jack@suse.cz>
      87f7e416
  5. 07 4月, 2014 5 次提交
    • J
      ext4: fix jbd2 warning under heavy xattr load · ec4cb1aa
      Jan Kara 提交于
      When heavily exercising xattr code the assertion that
      jbd2_journal_dirty_metadata() shouldn't return error was triggered:
      
      WARNING: at /srv/autobuild-ceph/gitbuilder.git/build/fs/jbd2/transaction.c:1237
      jbd2_journal_dirty_metadata+0x1ba/0x260()
      
      CPU: 0 PID: 8877 Comm: ceph-osd Tainted: G    W 3.10.0-ceph-00049-g68d04c9 #1
      Hardware name: Dell Inc. PowerEdge R410/01V648, BIOS 1.6.3 02/07/2011
       ffffffff81a1d3c8 ffff880214469928 ffffffff816311b0 ffff880214469968
       ffffffff8103fae0 ffff880214469958 ffff880170a9dc30 ffff8802240fbe80
       0000000000000000 ffff88020b366000 ffff8802256e7510 ffff880214469978
      Call Trace:
       [<ffffffff816311b0>] dump_stack+0x19/0x1b
       [<ffffffff8103fae0>] warn_slowpath_common+0x70/0xa0
       [<ffffffff8103fb2a>] warn_slowpath_null+0x1a/0x20
       [<ffffffff81267c2a>] jbd2_journal_dirty_metadata+0x1ba/0x260
       [<ffffffff81245093>] __ext4_handle_dirty_metadata+0xa3/0x140
       [<ffffffff812561f3>] ext4_xattr_release_block+0x103/0x1f0
       [<ffffffff81256680>] ext4_xattr_block_set+0x1e0/0x910
       [<ffffffff8125795b>] ext4_xattr_set_handle+0x38b/0x4a0
       [<ffffffff810a319d>] ? trace_hardirqs_on+0xd/0x10
       [<ffffffff81257b32>] ext4_xattr_set+0xc2/0x140
       [<ffffffff81258547>] ext4_xattr_user_set+0x47/0x50
       [<ffffffff811935ce>] generic_setxattr+0x6e/0x90
       [<ffffffff81193ecb>] __vfs_setxattr_noperm+0x7b/0x1c0
       [<ffffffff811940d4>] vfs_setxattr+0xc4/0xd0
       [<ffffffff8119421e>] setxattr+0x13e/0x1e0
       [<ffffffff811719c7>] ? __sb_start_write+0xe7/0x1b0
       [<ffffffff8118f2e8>] ? mnt_want_write_file+0x28/0x60
       [<ffffffff8118c65c>] ? fget_light+0x3c/0x130
       [<ffffffff8118f2e8>] ? mnt_want_write_file+0x28/0x60
       [<ffffffff8118f1f8>] ? __mnt_want_write+0x58/0x70
       [<ffffffff811946be>] SyS_fsetxattr+0xbe/0x100
       [<ffffffff816407c2>] system_call_fastpath+0x16/0x1b
      
      The reason for the warning is that buffer_head passed into
      jbd2_journal_dirty_metadata() didn't have journal_head attached. This is
      caused by the following race of two ext4_xattr_release_block() calls:
      
      CPU1                                CPU2
      ext4_xattr_release_block()          ext4_xattr_release_block()
      lock_buffer(bh);
      /* False */
      if (BHDR(bh)->h_refcount == cpu_to_le32(1))
      } else {
        le32_add_cpu(&BHDR(bh)->h_refcount, -1);
        unlock_buffer(bh);
                                          lock_buffer(bh);
                                          /* True */
                                          if (BHDR(bh)->h_refcount == cpu_to_le32(1))
                                            get_bh(bh);
                                            ext4_free_blocks()
                                              ...
                                              jbd2_journal_forget()
                                                jbd2_journal_unfile_buffer()
                                                -> JH is gone
        error = ext4_handle_dirty_xattr_block(handle, inode, bh);
        -> triggers the warning
      
      We fix the problem by moving ext4_handle_dirty_xattr_block() under the
      buffer lock. Sadly this cannot be done in nojournal mode as that
      function can call sync_dirty_buffer() which would deadlock. Luckily in
      nojournal mode the race is harmless (we only dirty already freed buffer)
      and thus for nojournal mode we leave the dirtying outside of the buffer
      lock.
      Reported-by: NSage Weil <sage@inktank.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      ec4cb1aa
    • M
      ext4: note the error in ext4_end_bio() · 9503c67c
      Matthew Wilcox 提交于
      ext4_end_bio() currently throws away the error that it receives.  Chances
      are this is part of a spate of errors, one of which will end up getting
      the error returned to userspace somehow, but we shouldn't take that risk.
      Also print out the errno to aid in debug.
      Signed-off-by: NMatthew Wilcox <matthew.r.wilcox@intel.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Cc: stable@vger.kernel.org
      9503c67c
    • A
      ext4: initialize multi-block allocator before checking block descriptors · 00764937
      Azat Khuzhin 提交于
      With EXT4FS_DEBUG ext4_count_free_clusters() will call
      ext4_read_block_bitmap() without s_group_info initialized, so we need to
      initialize multi-block allocator before.
      
      And dependencies that must be solved, to allow this:
      - multi-block allocator needs in group descriptors
      - need to install s_op before initializing multi-block allocator,
        because in ext4_mb_init_backend() new inode is created.
      - initialize number of group desc blocks (s_gdb_count) otherwise
        number of clusters returned by ext4_free_clusters_after_init() is not correct.
        (see ext4_bg_num_gdb_nometa())
      
      Here is the stack backtrace:
      
      (gdb) bt
       #0  ext4_get_group_info (group=0, sb=0xffff880079a10000) at ext4.h:2430
       #1  ext4_validate_block_bitmap (sb=sb@entry=0xffff880079a10000,
           desc=desc@entry=0xffff880056510000, block_group=block_group@entry=0,
           bh=bh@entry=0xffff88007bf2b2d8) at balloc.c:358
       #2  0xffffffff81232202 in ext4_wait_block_bitmap (sb=sb@entry=0xffff880079a10000,
           block_group=block_group@entry=0,
           bh=bh@entry=0xffff88007bf2b2d8) at balloc.c:476
       #3  0xffffffff81232eaf in ext4_read_block_bitmap (sb=sb@entry=0xffff880079a10000,
           block_group=block_group@entry=0) at balloc.c:489
       #4  0xffffffff81232fc0 in ext4_count_free_clusters (sb=sb@entry=0xffff880079a10000) at balloc.c:665
       #5  0xffffffff81259ffa in ext4_check_descriptors (first_not_zeroed=<synthetic pointer>,
           sb=0xffff880079a10000) at super.c:2143
       #6  ext4_fill_super (sb=sb@entry=0xffff880079a10000, data=<optimized out>,
           data@entry=0x0 <irq_stack_union>, silent=silent@entry=0) at super.c:3851
           ...
      Signed-off-by: NAzat Khuzhin <a3at.mail@gmail.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      00764937
    • K
      ext4: FIBMAP ioctl causes BUG_ON due to handle EXT_MAX_BLOCKS · 4adb6ab3
      Kazuya Mio 提交于
      When we try to get 2^32-1 block of the file which has the extent
      (ee_block=2^32-2, ee_len=1) with FIBMAP ioctl, it causes BUG_ON
      in ext4_ext_put_gap_in_cache().
      
      To avoid the problem, ext4_map_blocks() needs to check the file logical block
      number. ext4_ext_put_gap_in_cache() called via ext4_map_blocks() cannot
      handle 2^32-1 because the maximum file logical block number is 2^32-2.
      
      Note that ext4_ind_map_blocks() returns -EIO when the block number is invalid.
      So ext4_map_blocks() should also return the same errno.
      Signed-off-by: NKazuya Mio <k-mio@sx.jp.nec.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      4adb6ab3
    • C
      ext4: fix 64-bit number truncation warning · 666525df
      Chen Gang 提交于
      '0x7FDEADBEEF' will be truncated to 32-bit number under unicore32. Need
      append 'ULL' for it.
      
      The related warning (with allmodconfig under unicore32):
      
          CC [M]  fs/ext4/extents_status.o
        fs/ext4/extents_status.c: In function "__es_remove_extent":
        fs/ext4/extents_status.c:813: warning: integer constant is too large for "long" type
      Signed-off-by: NChen Gang <gang.chen.5i5j@gmail.com>
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      666525df
  6. 04 4月, 2014 25 次提交