Commit Graph

2596 Commits (62c0666378eb70285b6a3052bf4144d2132a5891)
 

Author SHA1 Message Date
Jeff Mahoney 62c0666378 btrfs-progs: udev: add rules for dm devices
Systemd's btrfs rule runs btrfs dev ready on each device
as it's discovered.  The btrfs command is executed as a builtin
command via an IMPORT{builtin} rule, which means it gets
executed at rule evaluation time, not rule execution time.  That
means that the device mapper links haven't been setup yet and the only
nodes that can be depended upon are /dev/dm-#.  That we see
/dev/mapper/name names in /proc/mounts is only because we replace the
device name we have cached with the one passed in via mount.  If
we have a multi-device file system and the primary device is removed,
the remaining devices will show /dev/dm-#.  In addition, if the
udev rule is executed again by someone generating a change event (e.g.
partprobe), the names are also replaced by the /dev/dm-# names.

This patch adds a new rule that adds a run rule that calls btrfs dev
ready again using the device mapper links once they're created.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
Satoru Takeuchi 640391b299 btrfs-progs: prop: remove conditions which never be satisfied
parse_args() always set at least one parameter, 'object', for
{get,list} subcommands. In addition, it always set all three
parameters, 'object', 'name', and 'value' for set subcommand.
So the following conditions can be removed.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:43:42 +02:00
Satoru Takeuchi ad474ff50c btrfs-progs: prop: simplify parse_args()
Since <object> parameter is mandatory for all subcommands,
'object' is always set by parse_args()'s callers.
In addition, on setting '*name' and '*value', if 'optind < argc'
is satisfied here, they are always set by parse_args()'s callers.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:43:41 +02:00
David Sterba b72438362b
Btrfs progs v4.5.3
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:40:33 +02:00
David Sterba 4ad85e4e33 btrfs-progs: update CHANGES for 4.5.3
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:39:28 +02:00
Liu Bo f2873c47d7 btrfs-progs: add fuzzed testing images, superblock and chunks
This adds 4 fuzz testing images, btrfsck either doesn't detect errors
in them or crashes immediately.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:48 +02:00
Liu Bo e58105df60 btrfs-progs: replace printf with message helpers in check_super
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:47 +02:00
Liu Bo df2236d73b btrfs-progs: add three more validation checks for superblock
This adds validation checks for super_total_bytes, super_bytes_used and
super_stripesize.

Since these checks are made after superblock finishes checksum

 checking, this also adds a notice of "superblock checksum matches but..".

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
[ adjusted message wording ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:45 +02:00
Liu Bo 9988284574 btrfs-progs: add validation checks for chunk loading
To survive fuzz filesystem images, we need various validation checks to
make btrfsck detect any invalid value inside chunks including those in
 sys_array.

Note that these checks may not be sufficient to cover all corner cases,
we may need to add more later.

This also refractor previous various checks into a helper function so
that we can add more checks into it in the future.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:23 +02:00
Satoru Takeuchi ece1cef709 btrfs-progs: prop: convert error messages to use error()
props.c uses 'fprintf(stderr, "ERROR: ...")' as its error messages,
however we have generic error() function.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba 21dc9050b5 btrfs-progs: docs: clarify why mkfs selects single for SSDs
The section raised some user questions on IRC.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba 5079ae684a btrfs-progs: docs: update btrfs-check
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba ce69f8c36e btrfs-progs: docs: update btrfs-select-super
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba ae213f7633 btrfs-progs: docs: update btrfs-receive
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba eb3092c2a1 btrfs-progs: docs: update btrfs-send
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba 162257574a btrfs-progs: docs: update btrfs-scrub
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
David Sterba b3751c131a btrfs-progs: docs: update btrfs-man5
Wording, added new options.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
Noah Massey 00fd553853 btrfs-progs: Adjust timing of safety delay countdown
When printing the countdown in the safety delay, the number should
correspond to the number of seconds remaining to wait at the time the
delay is printed.

In other words, there should be a one second sleep after printing '1'.

Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
Marek Rusinowski a6bbbe6087 btrfs-progs: subvolume sync: fix handling of -s option
Setting check interval for subvolume sync resulted
in picking wrong element from argv for it's value:

  $ btrfs subvolume sync -s 10 ./dir
  ERROR: invalid sleep interval ./dir
  $ btrfs subvolume sync ./dir -s 10
  Segmentation fault

Signed-off-by: Marek Rusinowski <marekrusinowski@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:12 +02:00
Liu Bo 5c5a622772 btrfs-progs: fix incorrect flag check while recovering super
The flag OPEN_CTREE_RECOVER_SUPER is set when it's going to recover
any bad superblock copy, the current code doesn't match that.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 16:37:07 +02:00
David Sterba 1e4abbdf96 btrfs-progs: use ioctl search headers everywhere
Generated by following semantic patch and manually tweaked.

<SmPL>
@@
struct btrfs_ioctl_search_header *SH;
@@
(
- SH->objectid
+ btrfs_search_header_objectid(SH)
|
- SH->offset
+ btrfs_search_header_offset(SH)
|
- SH->transid
+ btrfs_search_header_transid(SH)
|
- SH->len
+ btrfs_search_header_len(SH)
|
- SH->type
+ btrfs_search_header_type(SH)
)
</SmPL>

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=112131
Reported-and-tested-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:16 +02:00
David Sterba 64a4800875 btrfs-progs: add getters for ioctl search_header
The search header is usually accessed in an unaligned way, we could
trigger errors (SIGBUS) on architectures that do not support that.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:16 +02:00
David Sterba a6ffadee7b btrfs-progs: kerncompat: introduce get_unaligned helpers
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:16 +02:00
David Sterba 9971f00edd btrfs-progs: fi du: switch to negative error codes
We're using the kernel-style negative error numbers.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:15 +02:00
Qu Wenruo e6de81e959 btrfs-progs: check: fix found bytes accounting error
In the new add_extent_rec_nolookup() function, we add bytes_used to
update found bytes accounting.

However there is a typo that we used tmpl->nr, which should be rec->nr.
This will make us to add 1 for data backref, instead the correct size.

Reported-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:06 +02:00
David Sterba 25b93eefe2 btrfs-progs: check: check stripe crossing against nodesize
The extent record's max_size might be 0 and the stripe crossing check
will report a false positive, should use the filesyste nodesize. There's
a global fs_info available.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:50:31 +02:00
David Sterba b241a46c7c btrfs-progs: check: refactor add_extent_rec, reduce argument count
Similar to add_extent_rec_nolookup, pass the arguments via a temporary
structure. In case the extent is found, some of the values are not
assigned directly so the semantics is preserved.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:50:29 +02:00
David Sterba 5b1bbc8924 btrfs-progs: check: reduce size of extent_record
There are just 3 values of flag_block_full_backref, we can utilize a
bitfield and save 8 bytes (192 now).

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:50:26 +02:00
David Sterba 427643f069 btrfs-progs: check: simplify assignments in add_extent_rec_nolookup
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:50:24 +02:00
David Sterba a087884799 btrfs-progs: check: pass a template to add_extent_rec_nolookup
Reduce number of parameters that just fill the extent_record from a
temporary template that's supposed to be zeroed and filled by the
callers.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:50:21 +02:00
David Sterba b70aa412d7
Btrfs progs v4.5.2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 15:34:39 +02:00
David Sterba f859b26147 btrfs-progs: update CHANGES for 4.5.2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 15:32:02 +02:00
David Sterba 5fcc6e93f0 btrfs-progs: handle memory allocation error in cmd_device_stats
Resolves-coverity-id: 1359012
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 15:03:24 +02:00
David Sterba 0121270a79 btrfs-progs: tests: add 002-balance-full-no-filters
Coverage of new balance option --full-balance.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:59:48 +02:00
Qu Wenruo ec4f8776fd btrfs-progs: Restrict e2fsprogs version for convert
We want to support version 1.41 due to longterm and enterprise distros,
make the check explicit.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:45:00 +02:00
David Sterba c54b5a545e btrfs-progs: add safety delay before starting full balance
A short delay with a warning before starting a full balance should
improve usability. We have been getting reports from people who run full
balance after following some random advice and then get surprised by the
performance impact.

The countdown is done even when run from scripts, but as the whole
balance takes significanly more time, this shouldn't be an issue.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:44:56 +02:00
David Sterba aeda5acb4f btrfs-progs: add CHANGES 3.12 - 4.5.1
The changes are posted to the mailinglist and to the wiki, but for
packaging reasons it's good to have them locally in the git as well.

The initial conversion from wiki was done by Nick, then adjusted by me.

Reported-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:44:42 +02:00
Qu Wenruo 6bdf962fe3 btrfs-progs: Read qgroup status for qgroup verify
Read qgroup status for its flags like QGROUP_STATUS_FLAG_RESCAN and
QGROUP_STATUS_FLAG_INCONSISTENT.

This will help to avoid false alert for case like qgroup rescan is still
running when un-mounted.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:44:33 +02:00
Qu Wenruo 90a60f178d btrfs-progs: Fix an extent buffer leak in qgroups check
Qgroup verify codes will read fs root to check if the subvolume exists.
But it forgot to free the extent buffer read out, only freeing the
memory.

Fix it by also freeing the extent buffers.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:42:32 +02:00
Qu Wenruo f172bd2b8d btrfs-progs: Fix return value bug of qgroups check
Before this patch, although btrfsck will check qgroups if quota is
enabled, it always return 0 even qgroup numbers are corrupted.

Fix it by allowing return value from report_qgroups function (formally
defined as print_qgroup_difference).

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:42:28 +02:00
Satoru Takeuchi b652aeeb38 btrfs-progs: prop: remove an unnecessary condition on parse_args
>From commit c742debab1 ('btrfs-progs: fix a regression that
"property" with -t option doesn't work'), the number of arguments
is checked strictly. So the following condition never be
satisfied.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:42:13 +02:00
Satoru Takeuchi 1c40f6916b btrfs-progs: "device ready" accepts just one device
* actual result

  =======================================
  # ./btrfs device ready /dev/sdb foo
  #
  =======================================

* expecting result

  =======================================
  # ./btrfs device ready /dev/sdb foo
  btrfs device ready: too many arguments
  usage: btrfs device ready <device>

      Check device to see if it has all of its devices in cache for mounting

  #
  =======================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:42:09 +02:00
Yauhen Kharuzhy eba0d8925c btrfs-progs: Check if the FSID was seen by comparing full UUID
is_seen_fsid() uses simple hash to check if FS was seen before at
walking on FS list in 'filesystem show' command: hash key is first byte
of the UUID. This function doesn't check full UUID then, so, if there
are two FS with same first byte in UUIDs exist, only one will be shown:

root@test:~# btrfs fi show
Label: 'System'  uuid: 688cb918-7bac-4c8e-9b11-8d047eb14cf4
        Total devices 2 FS bytes used 1.76GiB
        devid    1 size 3.46TiB used 4.01GiB path /dev/sda2
        devid    2 size 6.91TiB used 4.01GiB path /dev/sdb2

Global spare

root@test:~# grep btrfs /proc/mounts
/dev/sda2 / btrfs rw,relatime,space_cache,subvolid=256,subvol=/root 0 0
/dev/sdc /media/688cb918-7bac-4c8e-9b11-8d047eb14cf4 btrfs rw,relatime,space_cache,subvolid=5,subvol=/ 0 0

root@test:~# btrfs fi show --all-devices
Label: 'System'  uuid: 688cb918-7bac-4c8e-9b11-8d047eb14cf4
        Total devices 2 FS bytes used 1.76GiB
        devid    1 size 3.46TiB used 4.03GiB path /dev/sda2
        devid    2 size 6.91TiB used 4.01GiB path /dev/sdb2

Label: 'test'  uuid: 683b1a80-ca7f-4c4d-b87b-7155401a4d18
        Total devices 7 FS bytes used 2.06MiB
        devid    1 size 7.28TiB used 1.57GiB path /dev/sdc
        devid    2 size 7.28TiB used 1.57GiB path /dev/sdd
        devid    3 size 7.28TiB used 1.57GiB path /dev/sde
        devid    4 size 7.28TiB used 1.57GiB path /dev/sdf
        devid    5 size 7.28TiB used 1.57GiB path /dev/sdg
        devid    6 size 7.28TiB used 1.57GiB path /dev/sdh
        devid    7 size 7.28TiB used 1.57GiB path /dev/sdi

To resolve this collision, search for full FSID in the list of seen
filesystems.

Signed-off-by: Yauhen Kharuzhy <yauhen.kharuzhy@zavadatar.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:42:04 +02:00
David Sterba e8ac13098d btrfs-progs: convert: fix typo in original image subvolume name
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:58 +02:00
Patrik Lundquist a963abc3d3 btrfs-progs: device stats: Print devid instead of null
Print e.g. "[devid:4].write_io_errs   6" instead of
"[(null)].write_io_errs   6" when device is missing.

Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:54 +02:00
Anand Jain 972cfbe32f btrfs-progs: fix re-declared get_device_info()
The other get_device_info() is in the same file, 4 lines above.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:47 +02:00
David Sterba 5f8cd780b9 btrfs-progs: check: use add_extent_rec_nolookup after lookups
The lookup was duplicated, use the helper that does not do it.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:35 +02:00
David Sterba e1a5ecc206 btrfs-progs: check: refactor add_extent_rec, separate lookup
Separate the part of add_extent_rec that comes after the lookup does not
succeed, there are callers interested in just this.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:27 +02:00
David Sterba e83012d57e btrfs-progs: check: cleanup, move structure definitions to the beginning
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:41:07 +02:00
David Sterba 3be6e3e7c9 btrfs-progs: deprecate and stop using btrfs_level_size
Size of a b-tree node is always nodesize, regardless of the level.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:40:23 +02:00