Re: [PATCH 19/22] btrfs: keep track of discard reuse stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 30, 2019 at 06:33:52PM +0100, David Sterba wrote:
> On Fri, Dec 13, 2019 at 04:22:28PM -0800, Dennis Zhou wrote:
> > Keep track of how much we are discarding and how often we are reusing
> > with async discard.
> > 
> > Signed-off-by: Dennis Zhou <dennis@xxxxxxxxxx>
> > Reviewed-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> > ---
> >  fs/btrfs/ctree.h            |  3 +++
> >  fs/btrfs/discard.c          |  7 +++++++
> >  fs/btrfs/free-space-cache.c | 14 ++++++++++++++
> >  fs/btrfs/sysfs.c            | 36 ++++++++++++++++++++++++++++++++++++
> >  4 files changed, 60 insertions(+)
> > 
> > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> > index dddf51e27bed..edfbe6060e8d 100644
> > --- a/fs/btrfs/ctree.h
> > +++ b/fs/btrfs/ctree.h
> > @@ -474,6 +474,9 @@ struct btrfs_discard_ctl {
> >  	u32 delay;
> >  	u32 iops_limit;
> >  	u64 bps_limit;
> > +	u64 discard_extent_bytes;
> > +	u64 discard_bitmap_bytes;
> > +	atomic64_t discard_bytes_saved;
> >  };
> >  
> >  /* delayed seq elem */
> > diff --git a/fs/btrfs/discard.c b/fs/btrfs/discard.c
> > index 55ad357e65f3..fe73814526ef 100644
> > --- a/fs/btrfs/discard.c
> > +++ b/fs/btrfs/discard.c
> > @@ -419,11 +419,15 @@ static void btrfs_discard_workfn(struct work_struct *work)
> >  				       block_group->discard_cursor,
> >  				       btrfs_block_group_end(block_group),
> >  				       minlen, maxlen, true);
> > +		WRITE_ONCE(discard_ctl->discard_bitmap_bytes,
> > +			   discard_ctl->discard_bitmap_bytes + trimmed);
> 
> The same argument is used for read and write, this does not seem to be a
> clear usage pattern for WRITE_ONCE, is there are cleaner way to do that?
> 

Yeah that doesn't really make any sense. I think we are okay here anyway
as btrfs_discard_workfn() provides synchronization by being a single
work item. So, I've removed the WRITE_ONCE.

> >  	} else {
> >  		btrfs_trim_block_group_extents(block_group, &trimmed,
> >  				       block_group->discard_cursor,
> >  				       btrfs_block_group_end(block_group),
> >  				       minlen, true);
> > +		WRITE_ONCE(discard_ctl->discard_extent_bytes,
> > +			   discard_ctl->discard_extent_bytes + trimmed);



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux