15 Oct, 2018

1 commit

  • There are two members in struct btrfs_root which indicate root's
    objectid: objectid and root_key.objectid.

    They are both set to the same value in __setup_root():

    static void __setup_root(struct btrfs_root *root,
    struct btrfs_fs_info *fs_info,
    u64 objectid)
    {
    ...
    root->objectid = objectid;
    ...
    root->root_key.objectid = objecitd;
    ...
    }

    and not changed to other value after initialization.

    grep in btrfs directory shows both are used in many places:
    $ grep -rI "root->root_key.objectid" | wc -l
    133
    $ grep -rI "root->objectid" | wc -l
    55
    (4.17, inc. some noise)

    It is confusing to have two similar variable names and it seems
    that there is no rule about which should be used in a certain case.

    Since ->root_key itself is needed for tree reloc tree, let's remove
    'objecitd' member and unify code to use ->root_key.objectid in all places.

    Signed-off-by: Misono Tomohiro
    Reviewed-by: Qu Wenruo
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Misono Tomohiro
     

12 Apr, 2018

1 commit


22 Jan, 2018

1 commit

  • Since tree-checker has verified leaf when reading from disk, we don't
    need the existing verify_dir_item() or btrfs_is_name_len_valid() checks.

    Signed-off-by: Qu Wenruo
    Reviewed-by: Nikolay Borisov
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Qu Wenruo
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

22 Jun, 2017

1 commit


14 Feb, 2017

2 commits

  • Currently btrfs_ino takes a struct inode and this causes a lot of
    internal btrfs functions which consume this ino to take a VFS inode,
    rather than btrfs' own struct btrfs_inode. In order to fix this "leak"
    of VFS structs into the internals of btrfs first it's necessary to
    eliminate all uses of struct inode for the purpose of inode. This patch
    does that by using BTRFS_I to convert an inode to btrfs_inode. With
    this problem eliminated subsequent patches will start eliminating the
    passing of struct inode altogether, eventually resulting in a lot cleaner
    code.

    Signed-off-by: Nikolay Borisov
    [ fix btrfs_get_extent tracepoint prototype ]
    Signed-off-by: David Sterba

    Nikolay Borisov
     
  • The check for a null inode is redundant since the function
    is a callback for exportfs, which will itself crash if
    dentry->d_inode or parent->d_inode is NULL. Removing the
    null check makes this consistent with other file systems.

    Also remove the redundant null dir check too.

    Found with static analysis by CoverityScan, CID 1389472

    Kudos to Jeff Mahoney for reviewing and explaining the error in
    my original patch (most of this explanation went into the above
    commit message) and David Sterba for pointing out that the dir
    check is also redundant.

    Signed-off-by: Colin Ian King
    Signed-off-by: David Sterba

    Colin Ian King
     

06 Dec, 2016

1 commit


06 Oct, 2015

1 commit

  • The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
    that returned by encode_fh - it may be larger.

    With NFSv2, the filehandle is fixed length, so it may appear longer
    than expected and be zero-padded.

    So we must test that fh_len is at least some value, not exactly equal
    to it.

    Signed-off-by: NeilBrown
    Acked-by: David Sterba

    NeilBrown
     

16 Apr, 2015

1 commit


18 Sep, 2014

1 commit


12 Nov, 2013

1 commit

  • fs/btrfs/compat.h only contained trivial macro wrappers of drop_nlink()
    and inc_nlink(). This doesn't belong in mainline.

    Signed-off-by: Zach Brown
    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Zach Brown
     

14 Jun, 2013

1 commit


26 Feb, 2013

1 commit


30 May, 2012

1 commit

  • pass inode + parent's inode or NULL instead of dentry + bool saying
    whether we want the parent or not.

    NOTE: that needs ceph fix folded in.

    Signed-off-by: Al Viro

    Al Viro
     

22 Mar, 2012

1 commit

  • btrfs currently handles most errors with BUG_ON. This patch is a work-in-
    progress but aims to handle most errors other than internal logic
    errors and ENOMEM more gracefully.

    This iteration prevents most crashes but can run into lockups with
    the page lock on occasion when the timing "works out."

    Signed-off-by: Jeff Mahoney

    Jeff Mahoney
     

09 Jan, 2012

1 commit


21 May, 2011

1 commit


25 Apr, 2011

1 commit

  • There's a potential problem in 32bit system when we exhaust 32bit inode
    numbers and start to allocate big inode numbers, because btrfs uses
    inode->i_ino in many places.

    So here we always use BTRFS_I(inode)->location.objectid, which is an
    u64 variable.

    There are 2 exceptions that BTRFS_I(inode)->location.objectid !=
    inode->i_ino: the btree inode (0 vs 1) and empty subvol dirs (256 vs 2),
    and inode->i_ino will be used in those cases.

    Another reason to make this change is I'm going to use a special inode
    to save free ino cache, and the inode number must be > (u64)-256.

    Signed-off-by: Li Zefan

    Li Zefan
     

14 Mar, 2011

1 commit

  • The exportfs encode handle function should return the minimum required
    handle size. This helps user to find out the handle size by passing 0
    handle size in the first step and then redoing to the call again with
    the returned handle size value.

    Acked-by: Serge Hallyn
    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Al Viro

    Aneesh Kumar K.V
     

08 Feb, 2011

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: (33 commits)
    Btrfs: Fix page count calculation
    btrfs: Drop __exit attribute on btrfs_exit_compress
    btrfs: cleanup error handling in btrfs_unlink_inode()
    Btrfs: exclude super blocks when we read in block groups
    Btrfs: make sure search_bitmap finds something in remove_from_bitmap
    btrfs: fix return value check of btrfs_start_transaction()
    btrfs: checking NULL or not in some functions
    Btrfs: avoid uninit variable warnings in ordered-data.c
    Btrfs: catch errors from btrfs_sync_log
    Btrfs: make shrink_delalloc a little friendlier
    Btrfs: handle no memory properly in prepare_pages
    Btrfs: do error checking in btrfs_del_csums
    Btrfs: use the global block reserve if we cannot reserve space
    Btrfs: do not release more reserved bytes to the global_block_rsv than we need
    Btrfs: fix check_path_shared so it returns the right value
    btrfs: check return value of btrfs_start_ioctl_transaction() properly
    btrfs: fix return value check of btrfs_join_transaction()
    fs/btrfs/inode.c: Add missing IS_ERR test
    btrfs: fix missing break in switch phrase
    btrfs: fix several uncheck memory allocations
    ...

    Linus Torvalds
     

29 Jan, 2011

1 commit

  • To make btrfs more stable, add several missing necessary memory allocation
    checks, and when no memory, return proper errno.

    We've checked that some of those -ENOMEM errors will be returned to
    userspace, and some will be catched by BUG_ON() in the upper callers,
    and none will be ignored silently.

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

    liubo
     

13 Jan, 2011

1 commit


07 Jan, 2011

1 commit

  • Reduce some branches and memory accesses in dcache lookup by adding dentry
    flags to indicate common d_ops are set, rather than having to check them.
    This saves a pointer memory access (dentry->d_op) in common path lookup
    situations, and saves another pointer load and branch in cases where we
    have d_op but not the particular operation.

    Patched with:

    git grep -E '[.>]([[:space:]])*d_op([[:space:]])*=' | xargs sed -e 's/\([^\t ]*\)->d_op = \(.*\);/d_set_d_op(\1, \2);/' -e 's/\([^\t ]*\)\.d_op = \(.*\);/d_set_d_op(\&\1, \2);/' -i

    Signed-off-by: Nick Piggin

    Nick Piggin
     

21 Dec, 2010

1 commit

  • Buggered-in: 76dda93c6ae2 ("Btrfs: add snapshot/subvolume destroy
    ioctl")

    Signed-off-by: Al Viro
    Acked-by: Chris Mason
    Signed-off-by: Linus Torvalds

    Al Viro
     

22 Nov, 2010

1 commit

  • People kept reporting NFS issues, specifically getting ESTALE alot. I figured
    out how to reproduce the problem

    SERVER
    mkfs.btrfs /dev/sda1
    mount /dev/sda1 /mnt/btrfs-test

    btrfs subvol create /mnt/btrfs-test/foo
    service nfs start

    CLIENT
    mount server:/mnt/btrfs /mnt/test
    cd /mnt/test/foo
    ls

    SERVER
    echo 3 > /proc/sys/vm/drop_caches

    CLIENT
    ls
    Signed-off-by: Chris Mason

    Josef Bacik
     

15 Mar, 2010

1 commit

  • This work is in preperation for being able to set a different root as the
    default mounting root.

    There is currently a problem with how we mount subvolumes. We cannot currently
    mount a subvolume of a subvolume, you can only mount subvolumes/snapshots of the
    default subvolume. So say you take a snapshot of the default subvolume and call
    it snap1, and then take a snapshot of snap1 and call it snap2, so now you have

    /
    /snap1
    /snap1/snap2

    as your available volumes. Currently you can only mount / and /snap1,
    you cannot mount /snap1/snap2. To fix this problem instead of passing
    subvolid= you must pass in subvolid=, where is
    the tree id that gets spit out via the subvolume listing you get from
    the subvolume listing patches (btrfs filesystem list). This allows us
    to mount /, /snap1 and /snap1/snap2 as the root volume.

    In addition to the above, we also now read the default dir item in the
    tree root to get the root key that it points to. For now this just
    points at what has always been the default subvolme, but later on I plan
    to change it to point at whatever root you want to be the new default
    root, so you can just set the default mount and not have to mount with
    -o subvolid=. I tested this out with the above scenario and it
    worked perfectly. Thanks,

    mount -o subvol operates inside the selected subvolid. For example:

    mount -o subvol=snap1,subvolid=256 /dev/xxx /mnt

    /mnt will have the snap1 directory for the subvolume with id
    256.

    mount -o subvol=snap /dev/xxx /mnt

    /mnt will be the snap directory of whatever the default subvolume
    is.

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     

22 Sep, 2009

1 commit


10 Jun, 2009

1 commit

  • This commit introduces a new kind of back reference for btrfs metadata.
    Once a filesystem has been mounted with this commit, IT WILL NO LONGER
    BE MOUNTABLE BY OLDER KERNELS.

    When a tree block in subvolume tree is cow'd, the reference counts of all
    extents it points to are increased by one. At transaction commit time,
    the old root of the subvolume is recorded in a "dead root" data structure,
    and the btree it points to is later walked, dropping reference counts
    and freeing any blocks where the reference count goes to 0.

    The increments done during cow and decrements done after commit cancel out,
    and the walk is a very expensive way to go about freeing the blocks that
    are no longer referenced by the new btree root. This commit reduces the
    transaction overhead by avoiding the need for dead root records.

    When a non-shared tree block is cow'd, we free the old block at once, and the
    new block inherits old block's references. When a tree block with reference
    count > 1 is cow'd, we increase the reference counts of all extents
    the new block points to by one, and decrease the old block's reference count by
    one.

    This dead tree avoidance code removes the need to modify the reference
    counts of lower level extents when a non-shared tree block is cow'd.
    But we still need to update back ref for all pointers in the block.
    This is because the location of the block is recorded in the back ref
    item.

    We can solve this by introducing a new type of back ref. The new
    back ref provides information about pointer's key, level and in which
    tree the pointer lives. This information allow us to find the pointer
    by searching the tree. The shortcoming of the new back ref is that it
    only works for pointers in tree blocks referenced by their owner trees.

    This is mostly a problem for snapshots, where resolving one of these
    fuzzy back references would be O(number_of_snapshots) and quite slow.
    The solution used here is to use the fuzzy back references in the common
    case where a given tree block is only referenced by one root,
    and use the full back references when multiple roots have a reference
    on a given block.

    This commit adds per subvolume red-black tree to keep trace of cached
    inodes. The red-black tree helps the balancing code to find cached
    inodes whose inode numbers within a given range.

    This commit improves the balancing code by introducing several data
    structures to keep the state of balancing. The most important one
    is the back ref cache. It caches how the upper level tree blocks are
    referenced. This greatly reduce the overhead of checking back ref.

    The improved balancing code scales significantly better with a large
    number of snapshots.

    This is a very large commit and was written in a number of
    pieces. But, they depend heavily on the disk format change and were
    squashed together to make sure git bisect didn't end up in a
    bad state wrt space balancing or the format change.

    Signed-off-by: Yan Zheng
    Signed-off-by: Chris Mason

    Yan Zheng
     

06 Jan, 2009

1 commit


26 Sep, 2008

1 commit


25 Sep, 2008

5 commits