On Mon, Oct 07, 2019 at 04:17:43PM -0400, Dennis Zhou wrote: > Throttle the maximum size of a discard so that we can provide an upper > bound for the rate of async discard. While the block layer is able to > split discards into the appropriate sized discards, we want to be able > to account more accurately the rate at which we are consuming ncq slots > as well as limit the upper bound of work for a discard. > > Signed-off-by: Dennis Zhou <den...@kernel.org> > --- > fs/btrfs/discard.h | 4 ++++ > fs/btrfs/free-space-cache.c | 47 +++++++++++++++++++++++++++---------- > 2 files changed, 39 insertions(+), 12 deletions(-) > > diff --git a/fs/btrfs/discard.h b/fs/btrfs/discard.h > index acaf56f63b1c..898dd92dbf8f 100644 > --- a/fs/btrfs/discard.h > +++ b/fs/btrfs/discard.h > @@ -8,6 +8,7 @@ > > #include <linux/kernel.h> > #include <linux/jiffies.h> > +#include <linux/sizes.h> > #include <linux/time.h> > #include <linux/workqueue.h> > > @@ -15,6 +16,9 @@ > #include "block-group.h" > #include "free-space-cache.h" > > +/* discard size limits */ > +#define BTRFS_DISCARD_MAX_SIZE (SZ_64M) > +
Let's make this configurable via sysfs as well. I assume at some point in the far, far future SSD's will stop being shitty and it would be nice to be able to easily adjust and test. Also this only applies to async, so BTRFS_ASYNC_DISCARD_MAX_SIZE. You can add a follow up patch for the sysfs stuff, just adjust the name and you can add Reviewed-by: Josef Bacik <jo...@toxicpanda.com> Thanks, Josef