1. 01 Aug, 2011 3 commits
  2. 30 Jul, 2011 3 commits
    • Dan Carpenter's avatar
      ext4: add missing kfree() on error return path in add_new_gdb() · c49bafa3
      Dan Carpenter authored
      We added some more error handling in b4097142 "ext4: add error
      checking to calls to ext4_handle_dirty_metadata()".  But we need to
      call kfree() as well to avoid a memory leak.
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      c49bafa3
    • Theodore Ts'o's avatar
      ext4: change umode_t in tracepoint headers to be an explicit __u16 · 59be8e72
      Theodore Ts'o authored
      As requested by Al Viro, since umode_t may be changing to a u32 for
      some architectures.
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      59be8e72
    • Theodore Ts'o's avatar
      ext4: fix races in ext4_sync_parent() · d59729f4
      Theodore Ts'o authored
      Fix problems if fsync() races against a rename of a parent directory
      as pointed out by Al Viro in his own inimitable way:
      
      >While we are at it, could somebody please explain what the hell is ext4
      >doing in
      >static int ext4_sync_parent(struct inode *inode)
      >{
      >        struct writeback_control wbc;
      >        struct dentry *dentry = NULL;
      >        int ret = 0;
      >
      >        while (inode && ext4_test_inode_state(inode, EXT4_STATE_NEWENTRY)) {
      >                ext4_clear_inode_state(inode, EXT4_STATE_NEWENTRY);
      >                dentry = list_entry(inode->i_dentry.next,
      >                                    struct dentry, d_alias);
      >                if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
      >                        break;
      >                inode = dentry->d_parent->d_inode;
      >                ret = sync_mapping_buffers(inode->i_mapping);
      >                ...
      >Note that dentry obviously can't be NULL there.  dentry->d_parent is never
      >NULL.  And dentry->d_parent would better not be negative, for crying out
      >loud!  What's worse, there's no guarantees that dentry->d_parent will
      >remain our parent over that sync_mapping_buffers() *and* that inode won't
      >just be freed under us (after rename() and memory pressure leading to
      >eviction of what used to be our dentry->d_parent)......
      Reported-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      d59729f4
  3. 28 Jul, 2011 5 commits
  4. 27 Jul, 2011 8 commits
  5. 26 Jul, 2011 1 commit
    • Jan Kara's avatar
      ext4: fix data corruption in inodes with journalled data · 2d859db3
      Jan Kara authored
      When journalling data for an inode (either because it is a symlink or
      because the filesystem is mounted in data=journal mode), ext4_evict_inode()
      can discard unwritten data by calling truncate_inode_pages(). This is
      because we don't mark the buffer / page dirty when journalling data but only
      add the buffer to the running transaction and thus mm does not know there
      are still unwritten data.
      
      Fix the problem by carefully tracking transaction containing inode's data,
      committing this transaction, and writing uncheckpointed buffers when inode
      should be reaped.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      2d859db3
  6. 24 Jul, 2011 3 commits
  7. 23 Jul, 2011 3 commits
  8. 18 Jul, 2011 6 commits
  9. 16 Jul, 2011 1 commit
  10. 11 Jul, 2011 7 commits
    • Lukas Czerner's avatar
      ext4: remove unnecessary comments in ext4_orphan_add() · afb86178
      Lukas Czerner authored
      The comment from Al Viro about possible race in the ext4_orphan_add() is
      not justified. There is no race possible as we always have either i_mutex
      locked, or the inode can not be referenced from outside hence the
      J_ASSERS should not be hit from the reason described in comment.
      
      This commit replaces it with notion that we are holding i_mutex so it
      should not be possible for i_nlink to be changed while waiting for
      s_orphan_lock.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      afb86178
    • Tao Ma's avatar
      ext4: Fix a double free of sbi->s_group_info in ext4_mb_init_backend · caaf7a29
      Tao Ma authored
      If we meet with an error in ext4_mb_add_groupinfo, we kfree
      sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)], but fail to
      reset it to NULL. So the caller ext4_mb_init_backend will try to kfree
      it again and causes a double free. So fix it by resetting it to NULL.
      
      Some typo in comments of mballoc.c are also changed.
      Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      caaf7a29
    • Tao Ma's avatar
      ext4: fix a race which could leak memory in ext4_groupinfo_create_slab() · 823ba01f
      Tao Ma authored
      In ext4_groupinfo_create_slab, we create ext4_groupinfo_caches within
      ext4_grpinfo_slab_create_mutex, but set it outside the lock, and there
      does exist some case that we may create it twice and causes a memory
      leak.  So set it before we call mutex_unlock.
      Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      823ba01f
    • Robin Dong's avatar
      ext4: avoid unneeded ext4_ext_next_leaf_block() while inserting extents · 598dbdf2
      Robin Dong authored
      Optimize ext4_ext_insert_extent() by avoiding
      ext4_ext_next_leaf_block() when the result is not used/needed.
      Signed-off-by: default avatarRobin Dong <sanbai@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      598dbdf2
    • Robin Dong's avatar
      ext4: remove redundant goto in ext4_ext_insert_extent() · ffb505ff
      Robin Dong authored
      If eh->eh_entries is smaller than eh->eh_max, the routine will
      go to the "repeat" and then go to "has_space" directlly ,
      since argument "depth" and "eh" are not even changed.
      
      Therefore, goto "has_space" directly and remove redundant "repeat" tag.
      Signed-off-by: default avatarRobin Dong <sanbai@taobao.com>
      ffb505ff
    • Tao Ma's avatar
      ext4: Change the wrong param comment for ext4_trim_all_free · 22612283
      Tao Ma authored
      at ext4_trim_all_free() comment, there is no longer an @e4b parameter,
      instead it is @group.
      Reported-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      22612283
    • Tao Ma's avatar
      ext4: Speed up FITRIM by recording flags in ext4_group_info · 3d56b8d2
      Tao Ma authored
      In ext4, when FITRIM is called every time, we iterate all the
      groups and do trim one by one. It is a bit time wasting if the
      group has been trimmed and there is no change since the last
      trim.
      
      So this patch adds a new flag in ext4_group_info->bb_state to
      indicate that the group has been trimmed, and it will be cleared
      if some blocks is freed(in release_blocks_on_commit). Another
      trim_minlen is added in ext4_sb_info to record the last minlen
      we use to trim the volume, so that if the caller provide a small
      one, we will go on the trim regardless of the bb_state.
      
      A simple test with my intel x25m ssd:
      df -h shows:
      /dev/sdb1              40G   21G   17G  56% /mnt/ext4
      Block size:               4096
      
      run the FITRIM with the following parameter:
      range.start = 0;
      range.len = UINT64_MAX;
      range.minlen = 1048576;
      
      without the patch:
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m5.505s
      user	0m0.000s
      sys	0m1.224s
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m5.359s
      user	0m0.000s
      sys	0m1.178s
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m5.228s
      user	0m0.000s
      sys	0m1.151s
      
      with the patch:
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m5.625s
      user	0m0.000s
      sys	0m1.269s
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m0.002s
      user	0m0.000s
      sys	0m0.001s
      [root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a
      real	0m0.002s
      user	0m0.000s
      sys	0m0.001s
      
      A big improvement for the 2nd and 3rd run.
      
      Even after I delete some big image files, it is still much
      faster than iterating the whole disk.
      
      [root@boyu-tm test]# time ./ftrim /mnt/ext4/a
      real	0m1.217s
      user	0m0.000s
      sys	0m0.196s
      
      Cc: Lukas Czerner <lczerner@redhat.com>
      Reviewed-by: default avatarAndreas Dilger <adilger.kernel@dilger.ca>
      Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      3d56b8d2