public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 0/4] Further FITRIM improvements
Date: Mon,  3 Jun 2019 13:05:58 +0300	[thread overview]
Message-ID: <20190603100602.19362-1-nborisov@suse.com> (raw)

Qu reported beyond EOD (end of device) access with latest FITRIM improvements 
that were merged. Further testing also showed that if ranged FITRIM request is 
sent it's possible to cause u64 overflow which in turn cause calculations to 
go off rail in btrfs_issue_discard (because it's called with start and len 
as (u64)-1) and trim used data. 

This patchset aims to rectify this by: 

1. Documenting the internal __etree_search since due to the rather high 
number of output parameters it can be a bit confusing as to what the invariants 
are. Due to this I got initially confused about possible return values on 
boundary conditions. (Patch 1)

2. Remove ranged support in btrfs_trim_free_extents - having range support in 
btrfs_trim_free_extent is problematic because it's interpreted in device physical 
space whilst range values from userspace should always be interpreted in 
logical space. (Patch 2)

3. Change slightly the semantics of find_first_clear_extent_bit to return the 
range that contains the passed address or in case no such range exists the 
next one, document the function and finally add tests (Patch 3 preps 
btrfs_trim_free_extents to handle the change semantics and Patch 4 change 
the semantics). 

This has been fully tested with xfstest and no regressions were found. 

Nikolay Borisov (4):
  btrfs: Document __etree_search
  btrfs: Always trim all unallocated space in btrfs_trim_free_extents
  btrfs: Skip first megabyte on device when trimming
  btrfs: Don't trim returned range based on input value in
    find_first_clear_extent_bit

 fs/btrfs/extent-tree.c           | 32 +++---------
 fs/btrfs/extent_io.c             | 67 +++++++++++++++++++++---
 fs/btrfs/tests/extent-io-tests.c | 89 ++++++++++++++++++++++++++++++++
 3 files changed, 157 insertions(+), 31 deletions(-)

-- 
2.17.1


             reply	other threads:[~2019-06-03 10:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 10:05 Nikolay Borisov [this message]
2019-06-03 10:05 ` [PATCH 1/4] btrfs: Document __etree_search Nikolay Borisov
2019-06-05  8:04   ` Johannes Thumshirn
2019-06-05  9:13   ` Qu Wenruo
2019-06-05 11:50   ` [PATCH v2] " Nikolay Borisov
2019-06-05 11:51     ` Johannes Thumshirn
2019-06-03 10:06 ` [PATCH 2/4] btrfs: Always trim all unallocated space in btrfs_trim_free_extents Nikolay Borisov
2019-06-05  9:13   ` Qu Wenruo
2019-06-03 10:06 ` [PATCH 3/4] btrfs: Skip first megabyte on device when trimming Nikolay Borisov
2019-06-05  8:06   ` Johannes Thumshirn
2019-06-05  9:14   ` Qu Wenruo
2019-06-05 11:18     ` Nikolay Borisov
2019-06-03 10:06 ` [PATCH 4/4] btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit Nikolay Borisov
2019-06-05  9:25   ` Qu Wenruo
2019-06-07 13:28 ` [PATCH 0/4] Further FITRIM improvements David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190603100602.19362-1-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox