1. 20 10月, 2011 7 次提交
    • J
      Btrfs: calculate checksum space correctly · 7709cde3
      Josef Bacik 提交于
      We have not been reserving enough space for checksums.  We were just reserving
      bytes for the checksum items themselves, we were not taking into account having
      to cow the tree and such.  This patch adds a csum_bytes counter to the inode for
      keeping track of the number of bytes outstanding we have for checksums.  Then we
      calculate how many leaves would be required for the checksums we are given and
      use that to reserve space.  This adds a significant amount of bytes to our
      reservations, but we will handle this later.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      7709cde3
    • J
      Btrfs: skip looking for delalloc if we don't have ->fill_delalloc · 9e487107
      Josef Bacik 提交于
      We always look for delalloc bytes in our io_tree so we can fill in delalloc.
      This is fine in most cases, but if we're writing out the btree_inode this is
      just a superfluous tree search on the io_tree, and if we have a lot of metadata
      dirty this could be an expensive check.  So instead check to see if our io_tree
      has a ->fill_delalloc op, and if not don't even bother doing the lookup.
      Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      9e487107
    • J
      Btrfs: use bytes_may_use for all ENOSPC reservations · fb25e914
      Josef Bacik 提交于
      We have been using bytes_reserved for metadata reservations, which is wrong
      since we use that to keep track of outstanding reservations from the allocator.
      This resulted in us doing a lot of silly things to make sure we don't allocate a
      bunch of metadata chunks since we never had a real view of how much space was
      actually in use by metadata.
      
      This passes Arne's enospc test and xfstests as well as my own enospc tests.
      Hopefully this will get us moving in the right direction.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      fb25e914
    • J
      Btrfs: fix how we mount subvol=<whatever> · 830c4adb
      Josef Bacik 提交于
      We've only been able to mount with subvol=<whatever> where whatever was a subvol
      within whatever root we had as the default.  This allows us to mount -o
      subvol=path/to/subvol/you/want relative from the normal fs_tree root.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      830c4adb
    • J
      Btrfs: use d_obtain_alias when mounting subvol/subvolid · ba5b8958
      Josef Bacik 提交于
      Currently what we do is just wrong.  We either
      
      1) Alloc a new "root" dentry with sb->s_root as it's parent which is just wrong
      as we could walk into this subvol later on via another path and hilarity could
      ensue.  Also we don't check the return value of d_splice_alias which isn't good
      either.
      
      or
      
      2) Do a d_find_alias() which we could have lost our dentry from cache at this
      point and found nothing.
      
      So use d_obtain_alias().  In the case that we already have the inode/dentry in
      cache we will get the correct dentry.  If not we will get a disconnected dentry
      tree so if we walk into it later on everything will be connected up properly.
      Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      ba5b8958
    • J
      Btrfs: kill reserved_bytes in inode · 0cbbdf7c
      Josef Bacik 提交于
      reserved_bytes is not used for anything in the inode, remove it.
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      0cbbdf7c
    • J
      Btrfs: move stuff around in btrfs_inode to get better packing · f1bdcc0a
      Josef Bacik 提交于
      Moving things around to give us better packing in the btrfs_inode.  This reduces
      the size of our inode by 8 bytes.  Thanks,
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      f1bdcc0a
  2. 01 10月, 2011 1 次提交
    • J
      Btrfs: force a page fault if we have a shorty copy on a page boundary · b6316429
      Josef Bacik 提交于
      A user reported a problem where ceph was getting into 100% cpu usage while doing
      some writing.  It turns out it's because we were doing a short write on a not
      uptodate page, which means we'd fall back at one page at a time and fault the
      page in.  The problem is our position is on the page boundary, so our fault in
      logic wasn't actually reading the page, so we'd just spin forever or until the
      page got read in by somebody else.  This will force a readpage if we end up
      doing a short copy.  Alexandre could reproduce this easily with ceph and reports
      it fixes his problem.  I also wrote a reproducer that no longer hangs my box
      with this patch.  Thanks,
      Reported-and-tested-by: NAlexandre Oliva <aoliva@redhat.com>
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      b6316429
  3. 27 9月, 2011 3 次提交
    • L
      vfs: remove LOOKUP_NO_AUTOMOUNT flag · b6c8069d
      Linus Torvalds 提交于
      That flag no longer makes sense, since we don't look up automount points
      as eagerly any more.  Additionally, it turns out that the NO_AUTOMOUNT
      handling was buggy to begin with: it would avoid automounting even for
      cases where we really *needed* to do the automount handling, and could
      return ENOENT for autofs entries that hadn't been instantiated yet.
      
      With our new non-eager automount semantics, one discussion has been
      about adding a AT_AUTOMOUNT flag to vfs_fstatat (and thus the
      newfstatat() and fstatat64() system calls), but it's probably not worth
      it: you can always force at least directory automounting by simply
      adding the final '/' to the filename, which works for *all* of the stat
      family system calls, old and new.
      
      So AT_NO_AUTOMOUNT (and thus LOOKUP_NO_AUTOMOUNT) really were just a
      result of our bad default behavior.
      Acked-by: NIan Kent <raven@themaw.net>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b6c8069d
    • T
      VFS: Fix the remaining automounter semantics regressions · 815d405c
      Trond Myklebust 提交于
      The concensus seems to be that system calls such as stat() etc should
      not trigger an automount.  Neither should the l* versions.
      
      This patch therefore adds a LOOKUP_AUTOMOUNT flag to tag those lookups
      that _should_ trigger an automount on the last path element.
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      [ Edited to leave out the cases that are already covered by LOOKUP_OPEN,
        LOOKUP_DIRECTORY and LOOKUP_CREATE - all of which also fundamentally
        force automounting for their own reasons   - Linus ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      815d405c
    • L
      vfs pathname lookup: Add LOOKUP_AUTOMOUNT flag · d94c177b
      Linus Torvalds 提交于
      Since we've now turned around and made LOOKUP_FOLLOW *not* force an
      automount, we want to add the ability to force an automount event on
      lookup even if we don't happen to have one of the other flags that force
      it implicitly (LOOKUP_OPEN, LOOKUP_DIRECTORY, LOOKUP_PARENT..)
      
      Most cases will never want to use this, since you'd normally want to
      delay automounting as long as possible, which usually implies
      LOOKUP_OPEN (when we open a file or directory, we really cannot avoid
      the automount any more).
      
      But Trond argued sufficiently forcefully that at a minimum bind mounting
      a file and quotactl will want to force the automount lookup.  Some other
      cases (like nfs_follow_remote_path()) could use it too, although
      LOOKUP_DIRECTORY would work there as well.
      
      This commit just adds the flag and logic, no users yet, though.  It also
      doesn't actually touch the LOOKUP_NO_AUTOMOUNT flag that is related, and
      was made irrelevant by the same change that made us not follow on
      LOOKUP_FOLLOW.
      
      Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
      Cc: Ian Kent <raven@themaw.net>
      Cc: Jeff Layton <jlayton@redhat.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Greg KH <gregkh@suse.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d94c177b
  4. 22 9月, 2011 3 次提交
  5. 21 9月, 2011 1 次提交
  6. 20 9月, 2011 4 次提交
  7. 18 9月, 2011 6 次提交
    • J
      Btrfs: only clear the need lookup flag after the dentry is setup · a66e7cc6
      Josef Bacik 提交于
      We can race with readdir and the RCU path walking stuff.  This is because we
      clear the need lookup flag before actually instantiating the inode.  This will
      lead the RCU path walk stuff to find a dentry it thinks is valid without a
      d_inode attached.  So instead unhash the dentry when we first start the lookup,
      and then clear the flag after we've instantiated the dentry so we're garunteed
      to either try the slow lookup, or have the d_inode set properly.
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      a66e7cc6
    • J
      BTRFS: Fix lseek return value for error · 48802c8a
      Jeff Liu 提交于
      The recent reworking of btrfs' lseek lead to incorrect
      values being returned.  This adds checks for seeking
      beyond EOF in SEEK_HOLE and makes sure the error
      values come back correct.
      
      Andi Kleen also sent in similar patches.
      Signed-off-by: NJie Liu <jeff.liu@oracle.com>
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      48802c8a
    • L
      Btrfs: don't change inode flag of the dest clone file · dde820fb
      Li Zefan 提交于
      The dst file will have the same inode flags with dst file after
      file clone, and I think it's unexpected.
      
      For example, the dst file will suddenly become immutable after
      getting some share of data with src file, if the src is immutable.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      dde820fb
    • L
      Btrfs: don't make a file partly checksummed through file clone · 0e7b824c
      Li Zefan 提交于
      To reproduce the bug:
      
        # mount /dev/sda7 /mnt
        # dd if=/dev/zero of=/mnt/src bs=4K count=1
        # umount /mnt
      
        # mount -o nodatasum /dev/sda7 /mnt
        # dd if=/dev/zero of=/mnt/dst bs=4K count=1
        # clone_range -s 4K -l 4K /mnt/src /mnt/dst
      
        # echo 3 > /proc/sys/vm/drop_caches
        # cat /mnt/dst
        # dmesg
        ...
        btrfs no csum found for inode 258 start 0
        btrfs csum failed ino 258 off 0 csum 2566472073 private 0
      
      It's because part of the file is checksummed and the other part is not,
      and then btrfs will complain checksum is not found when we read the file.
      
      Disallow file clone if src and dst file have different checksum flag,
      so we ensure a file is completely checksummed or unchecksummed.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      0e7b824c
    • L
      Btrfs: fix pages truncation in btrfs_ioctl_clone() · 71ef0786
      Li Zefan 提交于
      It's a bug in commit f81c9cdc
      (Btrfs: truncate pages from clone ioctl target range)
      
      We should pass the dest range to the truncate function, but not the
      src range.
      
      Also move the function before locking extent state.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      71ef0786
    • H
      btrfs: fix d_off in the first dirent · 3765fefa
      Hidetoshi Seto 提交于
      Since the d_off in the first dirent for "." (that originates from
      the 4th argument "offset" of filldir() for the 2nd dirent for "..")
      is wrongly assigned in btrfs_real_readdir(), telldir returns same
      offset for different locations.
      
       | # mkfs.btrfs /dev/sdb1
       | # mount /dev/sdb1 fs0
       | # cd fs0
       | # touch file0 file1
       | # ../test
       | telldir: 0
       | readdir: d_off = 2, d_name = "."
       | telldir: 2
       | readdir: d_off = 2, d_name = ".."
       | telldir: 2
       | readdir: d_off = 3, d_name = "file0"
       | telldir: 3
       | readdir: d_off = 2147483647, d_name = "file1"
       | telldir: 2147483647
      
      To fix this problem, pass filp->f_pos (which is loff_t) instead.
      
       | # ../test
       | telldir: 0
       | readdir: d_off = 1, d_name = "."
       | telldir: 1
       | readdir: d_off = 2, d_name = ".."
       | telldir: 2
       | readdir: d_off = 3, d_name = "file0"
       :
      
      At the moment the "offset" for "." is unused because there is no
      preceding dirent, however it is better to pass filp->f_pos to follow
      grammatical usage.
      Signed-off-by: NHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      3765fefa
  8. 16 9月, 2011 2 次提交
  9. 15 9月, 2011 1 次提交
  10. 14 9月, 2011 3 次提交
    • C
      xfs: fix a use after free in xfs_end_io_direct_write · 2d2422ae
      Christoph Hellwig 提交于
      There is a window in which the ioend that we call inode_dio_wake on
      in xfs_end_io_direct_write is already free.  Fix this by storing
      the inode pointer in a local variable.
      
      This is a fix for the regression introduced in 3.1-rc by
      "fs: move inode_dio_done to the end_io handler".
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAlex Elder <aelder@sgi.com>
      2d2422ae
    • S
      nfs: Do not allow multiple mounts on same mountpoint when using -o noac · fb2088cc
      Sachin Prabhu 提交于
      Do not allow multiple mounts on same mountpoint when using -o noac
      
      When you normally attempt to mount a share twice on the same mountpoint,
      a check in do_add_mount causes it to return an error
      
      # mount localhost:/nfsv3 /mnt
      # mount localhost:/nfsv3 /mnt
      mount.nfs: /mnt is already mounted or busy
      
      However when using the option 'noac', the user is able to mount the same
      share on the same mountpoint multiple times. This happens because a
      share mounted with the noac option is automatically assigned the 'sync'
      flag MS_SYNCHRONOUS in nfs_initialise_sb(). This flag is set after the
      check for already existing superblocks is done in sget(). The check for
      the mount flags in nfs_compare_mount_options() does not take into
      account the 'sync' flag applied later on in the code path. This means
      that when using 'noac', a new superblock structure is assigned for every
      new mount of the same share and multiple shares on the same mountpoint
      are allowed.
      
      ie.
      # mount -onoac localhost:/nfsv3 /mnt
      can be run multiple times.
      
      The patch checks for noac and assigns the sync flag before sget() is
      called to obtain an already existing superblock structure.
      Signed-off-by: NSachin Prabhu <sprabhu@redhat.com>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      fb2088cc
    • T
      NFS: Fix a typo in nfs_flush_multi · f13c3620
      Trond Myklebust 提交于
      Fix a typo which causes an Oops in the RPC layer, when using wsize < 4k.
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Tested-by: NSricharan R <r.sricharan@ti.com>
      f13c3620
  11. 13 9月, 2011 2 次提交
  12. 11 9月, 2011 7 次提交