]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: handle non-fatal errors in btrfs_qgroup_inherit()
authorMark Fasheh <mfasheh@suse.de>
Thu, 31 Mar 2016 00:57:48 +0000 (17:57 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 12 Dec 2016 04:34:58 +0000 (20:34 -0800)
commit3da73c54697e0c8ba8c58b7dcb8d1718c2553527
tree95be8868d3caeaa514c9f3f3c68b37667477f5d0
parentc1e964e9066f633d8808d8f82f476d96f60b36c2
btrfs: handle non-fatal errors in btrfs_qgroup_inherit()

Orabug: 24716895

create_pending_snapshot() will go readonly on _any_ error return from
btrfs_qgroup_inherit(). If qgroups are enabled, a user can crash their fs by
just making a snapshot and asking it to inherit from an invalid qgroup. For
example:

$ btrfs sub snap -i 1/10 /btrfs/ /btrfs/foo

Will cause a transaction abort.

Fix this by only throwing errors in btrfs_qgroup_inherit() when we know
going readonly is acceptable.

The following xfstests test case reproduces this bug:

  seq=`basename $0`
  seqres=$RESULT_DIR/$seq
  echo "QA output created by $seq"

  here=`pwd`
  tmp=/tmp/$$
  status=1 # failure is the default!
  trap "_cleanup; exit \$status" 0 1 2 3 15

  _cleanup()
  {
   cd /
   rm -f $tmp.*
  }

  # get standard environment, filters and checks
  . ./common/rc
  . ./common/filter

  # remove previous $seqres.full before test
  rm -f $seqres.full

  # real QA test starts here
  _supported_fs btrfs
  _supported_os Linux
  _require_scratch

  rm -f $seqres.full

  _scratch_mkfs
  _scratch_mount
  _run_btrfs_util_prog quota enable $SCRATCH_MNT
  # The qgroup '1/10' does not exist and should be silently ignored
  _run_btrfs_util_prog subvolume snapshot -i 1/10 $SCRATCH_MNT $SCRATCH_MNT/snap1

  _scratch_unmount

  echo "Silence is golden"

  status=0
  exit

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 918c2ee103cf9956f1c61d3f848dbb49fd2d104a)
Signed-off-by: Ashish Samant <ashish.samant@oracle.com>
fs/btrfs/qgroup.c