25 Feb, 2012

3 commits

  • signalfd_cleanup() ensures that ->signalfd_wqh is not used, but
    this is not enough. eppoll_entry->whead still points to the memory
    we are going to free, ep_unregister_pollwait()->remove_wait_queue()
    is obviously unsafe.

    Change ep_poll_callback(POLLFREE) to set eppoll_entry->whead = NULL,
    change ep_unregister_pollwait() to check pwq->whead != NULL under
    rcu_read_lock() before remove_wait_queue(). We add the new helper,
    ep_remove_wait_queue(), for this.

    This works because sighand_cachep is SLAB_DESTROY_BY_RCU and because
    ->signalfd_wqh is initialized in sighand_ctor(), not in copy_sighand.
    ep_unregister_pollwait()->remove_wait_queue() can play with already
    freed and potentially reused ->sighand, but this is fine. This memory
    must have the valid ->signalfd_wqh until rcu_read_unlock().

    Reported-by: Maxime Bizon
    Cc:
    Signed-off-by: Oleg Nesterov
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • This patch is intentionally incomplete to simplify the review.
    It ignores ep_unregister_pollwait() which plays with the same wqh.
    See the next change.

    epoll assumes that the EPOLL_CTL_ADD'ed file controls everything
    f_op->poll() needs. In particular it assumes that the wait queue
    can't go away until eventpoll_release(). This is not true in case
    of signalfd, the task which does EPOLL_CTL_ADD uses its ->sighand
    which is not connected to the file.

    This patch adds the special event, POLLFREE, currently only for
    epoll. It expects that init_poll_funcptr()'ed hook should do the
    necessary cleanup. Perhaps it should be defined as EPOLLFREE in
    eventpoll.

    __cleanup_sighand() is changed to do wake_up_poll(POLLFREE) if
    ->signalfd_wqh is not empty, we add the new signalfd_cleanup()
    helper.

    ep_poll_callback(POLLFREE) simply does list_del_init(task_list).
    This make this poll entry inconsistent, but we don't care. If you
    share epoll fd which contains our sigfd with another process you
    should blame yourself. signalfd is "really special". I simply do
    not know how we can define the "right" semantics if it used with
    epoll.

    The main problem is, epoll calls signalfd_poll() once to establish
    the connection with the wait queue, after that signalfd_poll(NULL)
    returns the different/inconsistent results depending on who does
    EPOLL_CTL_MOD/signalfd_read/etc. IOW: apart from sigmask, signalfd
    has nothing to do with the file, it works with the current thread.

    In short: this patch is the hack which tries to fix the symptoms.
    It also assumes that nobody can take tasklist_lock under epoll
    locks, this seems to be true.

    Note:

    - we do not have wake_up_all_poll() but wake_up_poll()
    is fine, poll/epoll doesn't use WQ_FLAG_EXCLUSIVE.

    - signalfd_cleanup() uses POLLHUP along with POLLFREE,
    we need a couple of simple changes in eventpoll.c to
    make sure it can't be "lost".

    Reported-by: Maxime Bizon
    Cc:
    Signed-off-by: Oleg Nesterov
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Quoth Chris:
    "This is later than I wanted because I got backed up running through
    btrfs bugs from the Oracle QA teams. But they are all bug fixes that
    we've queued and tested since rc1.

    Nothing in particular stands out, this just reflects bug fixing and QA
    done in parallel by all the btrfs developers. The most user visible
    of these is:

    Btrfs: clear the extent uptodate bits during parent transid failures

    Because that helps deal with out of date drives (say an iscsi disk
    that has gone away and come back). The old code wasn't always
    properly retrying the other mirror for this type of failure."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (24 commits)
    Btrfs: fix compiler warnings on 32 bit systems
    Btrfs: increase the global block reserve estimates
    Btrfs: clear the extent uptodate bits during parent transid failures
    Btrfs: add extra sanity checks on the path names in btrfs_mksubvol
    Btrfs: make sure we update latest_bdev
    Btrfs: improve error handling for btrfs_insert_dir_item callers
    Btrfs: be less strict on finding next node in clear_extent_bit
    Btrfs: fix a bug on overcommit stuff
    Btrfs: kick out redundant stuff in convert_extent_bit
    Btrfs: skip states when they does not contain bits to clear
    Btrfs: check return value of lookup_extent_mapping() correctly
    Btrfs: fix deadlock on page lock when doing auto-defragment
    Btrfs: fix return value check of extent_io_ops
    btrfs: honor umask when creating subvol root
    btrfs: silence warning in raid array setup
    btrfs: fix structs where bitfields and spinlock/atomic share 8B word
    btrfs: delalloc for page dirtied out-of-band in fixup worker
    Btrfs: fix memory leak in load_free_space_cache()
    btrfs: don't check DUP chunks twice
    Btrfs: fix trim 0 bytes after a device delete
    ...

    Linus Torvalds
     

24 Feb, 2012

3 commits

  • The enospc tracing code added some interesting uses of
    u64 pointer casts.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • With kernel 3.1, Christoph removed i_alloc_sem and replaced it with
    calls (namely inode_dio_wait() and inode_dio_done()) which are
    EXPORT_SYMBOL_GPL() thus they cannot be used by non-GPL file systems and
    further inode_dio_wait() was pushed from notify_change() into the file
    system ->setattr() method but no non-GPL file system can make this call.

    That means non-GPL file systems cannot exist any more unless they do not
    use any VFS functionality related to reading/writing as far as I can
    tell or at least as long as they want to implement direct i/o.

    Both Linus and Al (and others) have said on LKML that this breakage of
    the VFS API should not have happened and that the change was simply
    missed as it was not documented in the change logs of the patches that
    did those changes.

    This patch changes the two function exports in question to be
    EXPORT_SYMBOL() thus restoring the VFS API as it used to be - accessible
    for all modules.

    Christoph, who introduced the two functions and exported them GPL-only
    is CC-ed on this patch to give him the opportunity to object to the
    symbols being changed in this manner if he did indeed intend them to be
    GPL-only and does not want them to become available to all modules.

    Signed-off-by: Anton Altaparmakov
    CC: Christoph Hellwig
    Signed-off-by: Linus Torvalds

    Anton Altaparmakov
     
  • A fix from Jesper Juhl removes an assignment in an ASSERT when a compare
    is intended. Two fixes from Mitsuo Hayasaka address off-by-ones in XFS
    quota enforcement.

    * 'for-linus' of git://oss.sgi.com/xfs/xfs:
    xfs: make inode quota check more general
    xfs: change available ranges of softlimit and hardlimit in quota check
    XFS: xfs_trans_add_item() - don't assign in ASSERT() when compare is intended

    Linus Torvalds
     

23 Feb, 2012

6 commits

  • When doing IO with large amounts of data fragmentation, the global block
    reserve calulations are too low. This increases them to avoid
    ENOSPC crashes.

    Signed-off-by: Liu Bo
    Signed-off-by: Chris Mason

    Liu Bo
     
  • If btrfs reads a block and finds a parent transid mismatch, it clears
    the uptodate flags on the extent buffer, and the pages inside it. But
    we only clear the uptodate bits in the state tree if the block straddles
    more than one page.

    This is from an old optimization from to reduce contention on the extent
    state tree. But it is buggy because the code that retries a read from
    a different copy of the block is going to find the uptodate state bits
    set and skip the IO.

    The end result of the bug is that we'll never actually read the good
    copy (if there is one).

    The fix here is to always clear the uptodate state bits, which is safe
    because this code is only called when the parent transid fails.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • Signed-off-by: Chris Mason

    Chris Mason
     
  • When we are setting up the mount, we close all the
    devices that were not actually part of the metadata we found.

    But, we don't make sure that one of those devices wasn't
    fs_devices->latest_bdev, which means we can do a use after free
    on the one we closed.

    This updates latest_bdev as it goes.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • This allows us to gracefully continue if we aren't able to insert
    directory items, both for normal files/dirs and snapshots.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • Bugfixes for the NFS client.

    Fix a nasty Oops in the NFSv4 getacl code, another source of infinite
    loops in the NFSv4 state recovery code, and a regression in NFSv4.1
    session initialisation.

    Also deal with an NFSv4.1 memory leak.

    * tag 'nfs-for-3.3-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
    NFSv4: fix server_scope memory leak
    NFSv4.1: Fix a NFSv4.1 session initialisation regression
    NFSv4: Ensure we throw out bad delegation stateids on NFS4ERR_BAD_STATEID
    NFSv4: Fix an Oops in the NFSv4 getacl code

    Linus Torvalds
     

22 Feb, 2012

3 commits

  • The 'poll()' system call timeout parameter is supposed to be 'int', not
    'long'.

    Now, the reason this matters is that right now 32-bit compat mode is
    broken on at least x86-64, because the 32-bit code just calls
    'sys_poll()' directly on x86-64, and the 32-bit argument will have been
    zero-extended, turning a signed 'int' into a large unsigned 'long'
    value.

    We could just introduce a 'compat_sys_poll()' function for this, and
    that may eventually be what we have to do, but since the actual standard
    poll() semantics is *supposed* to be 'int', and since at least on x86-64
    glibc sign-extends the argument before invocing the system call (so
    nobody can actually use a 64-bit timeout value in user space _anyway_,
    even in 64-bit binaries), the simpler solution would seem to be to just
    fix the definition of the system call to match what it should have been
    from the very start.

    If it turns out that somebody somehow circumvents the user-level libc
    64-bit sign extension and actually uses a large unsigned 64-bit timeout
    despite that not being how poll() is supposed to work, we will need to
    do the compat_sys_poll() approach.

    Reported-by: Thomas Meyer
    Acked-by: Eric Dumazet
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • The xfs checks quota when reserving disk blocks and inodes. In the block
    reservation, it checks if the total number of blocks including current
    usage and new reservation exceed quota. In the inode reservation,
    it checks using the total number of inodes including only current usage
    without new reservation. However, this inode quota check works well
    since the caller of xfs_trans_dquot() always sets the argument of the
    number of new inode reservation to 1 or 0 and inode is reserved one by
    one in current xfs.

    To make it more general, this patch changes it to the same way as the
    block quota check.

    Signed-off-by: Mitsuo Hayasaka
    Cc: Ben Myers
    Cc: Alex Elder
    Cc: Christoph Hellwig
    Reviewed-by: Mark Tinguely
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Ben Myers

    Mitsuo Hayasaka
     
  • In general, quota allows us to use disk blocks and inodes up to each
    limit, that is, they are available if they don't exceed their limitations.
    Current xfs sets their available ranges to lower than them except disk
    inode quota check. So, this patch changes the ranges to not beyond them.

    Signed-off-by: Mitsuo Hayasaka
    Cc: Ben Myers
    Cc: Alex Elder
    Cc: Christoph Hellwig
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Mark Tinguely
    Signed-off-by: Ben Myers

    Mitsuo Hayasaka
     

21 Feb, 2012

2 commits


18 Feb, 2012

2 commits

  • server_scope would never be freed if nfs4_check_cl_exchange_flags() returned
    non-zero

    Signed-off-by: Weston Andros Adamson
    Cc: stable@vger.kernel.org
    Signed-off-by: Trond Myklebust

    Weston Andros Adamson
     
  • Commit aacd553 (NFSv4.1: cleanup init and reset of session slot tables)
    introduces a regression in the session initialisation code. New tables
    now find their sequence ids initialised to 0, rather than the mandated
    value of 1 (see RFC5661).

    Fix the problem by merging nfs4_reset_slot_table() and nfs4_init_slot_table().
    Since the tbl->max_slots is initialised to 0, the test in
    nfs4_reset_slot_table for max_reqs != tbl->max_slots will automatically
    pass for an empty table.

    Reported-by: Vitaliy Gusev
    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

17 Feb, 2012

9 commits

  • Signed-off-by: Cong Wang
    Signed-off-by: Tyler Hicks

    Cong Wang
     
  • After passing through a ->setxattr() call, eCryptfs needs to copy the
    inode attributes from the lower inode to the eCryptfs inode, as they
    may have changed in the lower filesystem's ->setxattr() path.

    One example is if an extended attribute containing a POSIX Access
    Control List is being set. The new ACL may cause the lower filesystem to
    modify the mode of the lower inode and the eCryptfs inode would need to
    be updated to reflect the new mode.

    https://launchpad.net/bugs/926292

    Signed-off-by: Tyler Hicks
    Reported-by: Sebastien Bacher
    Cc: John Johansen
    Cc:

    Tyler Hicks
     
  • statfs() calls on eCryptfs files returned the wrong filesystem type and,
    when using filename encryption, the wrong maximum filename length.

    If mount-wide filename encryption is enabled, the cipher block size and
    the lower filesystem's max filename length will determine the max
    eCryptfs filename length. Pre-tested, known good lengths are used when
    the lower filesystem's namelen is 255 and a cipher with 8 or 16 byte
    block sizes is used. In other, less common cases, we fall back to a safe
    rounded-down estimate when determining the eCryptfs namelen.

    https://launchpad.net/bugs/885744

    Signed-off-by: Tyler Hicks
    Reported-by: Kees Cook
    Reviewed-by: Kees Cook
    Reviewed-by: John Johansen

    Tyler Hicks
     
  • When overcommitting, we should check the sum of pinned space and
    bytes for delayed item.

    Signed-off-by: Liu Bo

    Liu Bo
     
  • clear_state_bit will do merge_state for us, so kick out the redundant one.

    Signed-off-by: Liu Bo

    Liu Bo
     
  • Clearing a range's bits is different with setting them, since we don't
    need to touch them when states do not contain bits we want.

    Signed-off-by: Liu Bo

    Liu Bo
     
  • This patch corrects error checking of lookup_extent_mapping().

    Signed-off-by: Tsutomu Itoh

    Tsutomu Itoh
     
  • When I ran xfstests circularly on a auto-defragment btrfs, the deadlock
    happened.

    Steps to reproduce:
    [tty0]
    # export MOUNT_OPTIONS="-o autodefrag"
    # export TEST_DEV=
    # export TEST_DIR=
    # export SCRATCH_DEV=
    # export SCRATCH_MNT=
    # while [ 1 ]
    > do
    > ./check 091 127 263
    > sleep 1
    > done
    [tty1]
    # while [ 1 ]
    > do
    > echo 3 > /proc/sys/vm/drop_caches
    > done

    Several hours later, the test processes will hang on, and the deadlock will
    happen on page lock.

    The reason is that:
    Auto defrag task Flush thread Test task
    btrfs_writepages()
    add ordered extent
    (including page 1, 2)
    set page 1 writeback
    set page 2 writeback
    endio_fn()
    end page 2 writeback
    release page 2
    lock page 1
    alloc and lock page 2
    page 2 is not uptodate
    btrfs_readpage()
    start ordered extent()
    btrfs_writepages()
    try to lock page 1

    so deadlock happens.

    Fix this bug by unlocking the page which is in writeback, and re-locking it
    after the writeback end.

    Signed-off-by: Miao Xie

    Miao Xie
     
  • This patch adds the check on the return value of extent_io_ops.

    Signed-off-by: Tsutomu Itoh

    Tsutomu Itoh
     

16 Feb, 2012

1 commit


15 Feb, 2012

9 commits

  • Raid array setup code creates an extent buffer in an usual way. When the
    PAGE_CACHE_SIZE is > super block size, the extent pages are not marked
    up-to-date, which triggers a WARN_ON in the following
    write_extent_buffer call. Add an explicit up-to-date call to silence the
    warning.

    Signed-off-by: David Sterba

    David Sterba
     
  • On ia64, powerpc64 and sparc64 the bitfield is modified through a RMW cycle and current
    gcc rewrites the adjacent 4B word, which in case of a spinlock or atomic has
    disaterous effect.

    https://lkml.org/lkml/2012/2/1/220

    Signed-off-by: David Sterba

    David Sterba
     
  • We encountered an issue that was easily observable on s/390 systems but
    could really happen anywhere. The timing just seemed to hit reliably
    on s/390 with limited memory.

    The gist is that when an unexpected set_page_dirty() happened, we'd
    run into the BUG() in btrfs_writepage_fixup_worker since it wasn't
    properly set up for delalloc.

    This patch does the following:
    - Performs the missing delalloc in the fixup worker
    - Allow the start hook to return -EBUSY which informs __extent_writepage
    that it should mark the page skipped and not to redirty it. This is
    required since the fixup worker can fail with -ENOSPC and the page
    will have already been redirtied. That causes an Oops in
    drop_outstanding_extents later. Retrying the fixup worker could
    lead to an infinite loop. Deferring the page redirty also saves us
    some cycles since the page would be stuck in a resubmit-redirty loop
    until the fixup worker completes. It's not harmful, just wasteful.
    - If the fixup worker fails, we mark the page and mapping as errored,
    and end the writeback, similar to what we would do had the page
    actually been submitted to writeback.

    Signed-off-by: Jeff Mahoney

    Jeff Mahoney
     
  • load_free_space_cache() has forgotten to free path.

    Signed-off-by: Tsutomu Itoh

    Tsutomu Itoh
     
  • Because scrub enumerates the dev extent tree to find the chunks to scrub,
    it currently finds each DUP chunk twice and also scrubs it twice. This
    patch makes sure that scrub_chunk only checks that part of the chunk the
    dev extent has been found for. This only changes the behaviour for DUP
    chunks.

    Reported-and-tested-by: Stefan Behrens
    Signed-off-by: Arne Jansen

    Arne Jansen
     
  • A user reported a bug of btrfs's trim, that is we will trim 0 bytes
    after a device delete.

    The reproducer:

    $ mkfs.btrfs disk1
    $ mkfs.btrfs disk2
    $ mount disk1 /mnt
    $ fstrim -v /mnt
    $ btrfs device add disk2 /mnt
    $ btrfs device del disk1 /mnt
    $ fstrim -v /mnt

    This is because after we delete the device, the block group may start from
    a non-zero place, which will confuse trim to discard nothing.

    Reported-by: Lutz Euler
    Signed-off-by: Liu Bo

    Liu Bo
     
  • …led for SEEK_DATA/SEEK_HOLE inquiry

    Given that ENXIO only means "offset beyond EOF" for either SEEK_DATA or SEEK_HOLE inquiry
    in a desired file range, so we should return the internal error unchanged if btrfs_get_extent_fiemap()
    call failed, rather than ENXIO.

    Cc: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Jie Liu <jeff.liu@oracle.com>

    Jeff Liu
     
  • inode_ref_info() returns 1 when the element wasn't found and < 0 on error,
    just like btrfs_search_slot(). In iref_to_path() it's an error when the
    inode ref can't be found, thus we return ERR_PTR(ret) in that case. In order
    to avoid ERR_PTR(1), we now set ret to -ENOENT in that case.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • Gracefully fail when trying to mount a BTRFS file system that has a
    sectorsize smaller than PAGE_SIZE.

    On PPC it is possible to build a FS while using a 4k PAGE_SIZE kernel
    then boot into a 64K PAGE_SIZE kernel. Presently open_ctree fails in an
    endless loop and hangs the machine in this situation.

    My debugging has show this Sector size < Page size to be a non trivial
    situation and a graceful exit from the situation would be nice for the
    time being.

    Signed-off-by: Keith Mannthey

    Keith Mannthey
     

14 Feb, 2012

2 commits