1. 16 Jan, 2011 5 commits
  2. 04 Jan, 2011 1 commit
  3. 23 Dec, 2010 3 commits
    • Li Zefan's avatar
      Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctls · 0caa102d
      Li Zefan authored
      This allows us to set a snapshot or a subvolume readonly or writable
      on the fly.
      
      Usage:
      
      Set BTRFS_SUBVOL_RDONLY of btrfs_ioctl_vol_arg_v2->flags, and then
      call ioctl(BTRFS_IOCTL_SUBVOL_SETFLAGS);
      
      Changelog for v3:
      
      - Change to pass __u64 as ioctl parameter.
      
      Changelog for v2:
      
      - Add _GETFLAGS ioctl.
      - Check if the passed fd is the root of a subvolume.
      - Change the name from _SNAP_SETFLAGS to _SUBVOL_SETFLAGS.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      0caa102d
    • Li Zefan's avatar
      Btrfs: Add readonly snapshots support · b83cc969
      Li Zefan authored
      Usage:
      
      Set BTRFS_SUBVOL_RDONLY of btrfs_ioctl_vol_arg_v2->flags, and call
      ioctl(BTRFS_I0CTL_SNAP_CREATE_V2).
      
      Implementation:
      
      - Set readonly bit of btrfs_root_item->flags.
      - Add readonly checks in btrfs_permission (inode_permission),
      btrfs_setattr, btrfs_set/remove_xattr and some ioctls.
      
      Changelog for v3:
      
      - Eliminate btrfs_root->readonly, but check btrfs_root->root_item.flags.
      - Rename BTRFS_ROOT_SNAP_RDONLY to BTRFS_ROOT_SUBVOL_RDONLY.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      b83cc969
    • Li Zefan's avatar
      Btrfs: Refactor btrfs_ioctl_snap_create() · fa0d2b9b
      Li Zefan authored
      Split it into two functions for two different ioctls, since they
      share no common code.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      fa0d2b9b
  4. 22 Dec, 2010 6 commits
    • Li Zefan's avatar
      btrfs: Extract duplicate decompress code · 3a39c18d
      Li Zefan authored
      Add a common function to copy decompressed data from working buffer
      to bio pages.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      3a39c18d
    • Li Zefan's avatar
      btrfs: Allow to specify compress method when defrag · 1a419d85
      Li Zefan authored
      Update defrag ioctl, so one can choose lzo or zlib when turning
      on compression in defrag operation.
      
      Changelog:
      
      v1 -> v2
      - Add incompability flag.
      - Fix to check invalid compress type.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      1a419d85
    • Li Zefan's avatar
      btrfs: Add lzo compression support · a6fa6fae
      Li Zefan authored
      Lzo is a much faster compression algorithm than gzib, so would allow
      more users to enable transparent compression, and some users can
      choose from compression ratio and speed for different applications
      
      Usage:
      
       # mount -t btrfs -o compress[=<zlib,lzo>] dev /mnt
      or
       # mount -t btrfs -o compress-force[=<zlib,lzo>] dev /mnt
      
      "-o compress" without argument is still allowed for compatability.
      
      Compatibility:
      
      If we mount a filesystem with lzo compression, it will not be able be
      mounted in old kernels. One reason is, otherwise btrfs will directly
      dump compressed data, which sits in inline extent, to user.
      
      Performance:
      
      The test copied a linux source tarball (~400M) from an ext4 partition
      to the btrfs partition, and then extracted it.
      
      (time in second)
                 lzo        zlib        nocompress
      copy:      10.6       21.7        14.9
      extract:   70.1       94.4        66.6
      
      (data size in MB)
                 lzo        zlib        nocompress
      copy:      185.87     108.69      394.49
      extract:   193.80     132.36      381.21
      
      Changelog:
      
      v1 -> v2:
      - Select LZO_COMPRESS and LZO_DECOMPRESS in btrfs Kconfig.
      - Add incompability flag.
      - Fix error handling in compress code.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      a6fa6fae
    • Li Zefan's avatar
      btrfs: Allow to add new compression algorithm · 261507a0
      Li Zefan authored
      Make the code aware of compression type, instead of always assuming
      zlib compression.
      
      Also make the zlib workspace function as common code for all
      compression types.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      261507a0
    • Li Zefan's avatar
      btrfs: Fix error handling in zlib · 4b72029d
      Li Zefan authored
      Return failure if alloc_page() fails to allocate memory,
      and the upper code will just give up compression.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      4b72029d
    • Li Zefan's avatar
      btrfs: Fix bugs in zlib workspace · 8844355d
      Li Zefan authored
      - Fix a race that can result in alloc_workspace > cpus.
      - Fix to check num_workspace after wakeup.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      8844355d
  5. 14 Dec, 2010 2 commits
    • Chris Mason's avatar
      Btrfs: prevent RAID level downgrades when space is low · 83a50de9
      Chris Mason authored
      The extent allocator has code that allows us to fill
      allocations from any available block group, even if it doesn't
      match the raid level we've requested.
      
      This was put in because adding a new drive to a filesystem
      made with the default mkfs options actually upgrades the metadata from
      single spindle dup to full RAID1.
      
      But, the code also allows us to allocate from a raid0 chunk when we
      really want a raid1 or raid10 chunk.  This can cause big trouble because
      mkfs creates a small (4MB) raid0 chunk for data and metadata which then
      goes unused for raid1/raid10 installs.
      
      The allocator will happily wander in and allocate from that chunk when
      things get tight, which is not correct.
      
      The fix here is to make sure that we provide duplication when the
      caller has asked for it.  It does all the dups to be any raid level,
      which preserves the dup->raid1 upgrade abilities.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      83a50de9
    • Chris Mason's avatar
      Btrfs: account for missing devices in RAID allocation profiles · cd02dca5
      Chris Mason authored
      When we mount in RAID degraded mode without adding a new device to
      replace the failed one, we can end up using the wrong RAID flags for
      allocations.
      
      This results in strange combinations of block groups (raid1 in a raid10
      filesystem) and corruptions when we try to allocate blocks from single
      spindle chunks on drives that are actually missing.
      
      The first device has two small 4MB chunks in it that mkfs creates and
      these are usually unused in a raid1 or raid10 setup.  But, in -o degraded,
      the allocator will fall back to these because the mask of desired raid groups
      isn't correct.
      
      The fix here is to count the missing devices as we build up the list
      of devices in the system.  This count is used when picking the
      raid level to make sure we continue using the same levels that were
      in place before we lost a drive.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      cd02dca5
  6. 13 Dec, 2010 1 commit
    • Chris Mason's avatar
      Btrfs: EIO when we fail to read tree roots · 68433b73
      Chris Mason authored
      If we just get a plain IO error when we read tree roots, the code
      wasn't properly sending that error up the chain.  This allowed mounts to
      continue when they should failed, and allowed operations
      on partially setup root structs.  The end result was usually oopsen
      on spinlocks that hadn't been spun up correctly.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      68433b73
  7. 10 Dec, 2010 7 commits
  8. 09 Dec, 2010 4 commits
  9. 29 Nov, 2010 2 commits
  10. 27 Nov, 2010 6 commits
    • Josef Bacik's avatar
      Btrfs: setup blank root and fs_info for mount time · 450ba0ea
      Josef Bacik authored
      There is a problem with how we use sget, it searches through the list of supers
      attached to the fs_type looking for a super with the same fs_devices as what
      we're trying to mount.  This depends on sb->s_fs_info being filled, but we don't
      fill that in until we get to btrfs_fill_super, so we could hit supers on the
      fs_type super list that have a null s_fs_info.  In order to fix that we need to
      go ahead and setup a blank root with a blank fs_info to hold fs_devices, that
      way our test will work out right and then we can set s_fs_info in
      btrfs_set_super, and then open_ctree will simply use our pre-allocated root and
      fs_info when setting everything up.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      450ba0ea
    • Josef Bacik's avatar
      Btrfs: fix fiemap · 975f84fe
      Josef Bacik authored
      There are two big problems currently with FIEMAP
      
      1) We return extents for holes.  This isn't supposed to happen, we just don't
      return extents for holes and then userspace interprets the lack of an extent as
      a hole.
      
      2) We sometimes don't set FIEMAP_EXTENT_LAST properly.  This is because we wait
      to see a EXTENT_FLAG_VACANCY flag on the em, but this won't happen if say we ask
      fiemap to map up to the last extent in a file, and there is nothing but holes up
      to the i_size.  To fix this we need to lookup the last extent in this file and
      save the logical offset, so if we happen to try and map that extent we can be
      sure to set FIEMAP_EXTENT_LAST.
      
      With this patch we now pass xfstest 225, which we never have before.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      975f84fe
    • Ian Kent's avatar
      Btrfs - fix race between btrfs_get_sb() and umount · 619c8c76
      Ian Kent authored
      When mounting a btrfs file system btrfs_test_super() may attempt to
      use sb->s_fs_info, the btrfs root, of a super block that is going away
      and that has had the btrfs root set to NULL in its ->put_super(). But
      if the super block is going away it cannot be an existing super block
      so we can return false in this case.
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      619c8c76
    • Josef Bacik's avatar
      Btrfs: update inode ctime when using links · bc1cbf1f
      Josef Bacik authored
      Currently we fail xfstest 236 because we're not updating the inode ctime on
      link.  This is a simple fix, and makes it so we pass 236 now.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      bc1cbf1f
    • Josef Bacik's avatar
      Btrfs: make sure new inode size is ok in fallocate · 0ed42a63
      Josef Bacik authored
      We have been failing xfstest 228 forever, because we don't check to make sure
      the new inode size is acceptable as far as RLIMIT is concerned.  Just check to
      make sure it's ok to create a inode with this new size and error out if not.
      With this patch we now pass 228.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      0ed42a63
    • Josef Bacik's avatar
      Btrfs: fix typo in fallocate to make it honor actual size · 55a61d1d
      Josef Bacik authored
      There is a typo in __btrfs_prealloc_file_range() where we set the i_size to
      actual_len/cur_offset, and then just set it to cur_offset again, and do the same
      with btrfs_ordered_update_i_size().  This fixes it back to keeping i_size in a
      local variable and then updating i_size properly.  Tested this with
      
      xfs_io -F -f -c "falloc 0 1" -c "pwrite 0 1" foo
      
      stat'ing foo gives us a size of 1 instead of 4096 like it was.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      55a61d1d
  11. 22 Nov, 2010 3 commits