Current-Users archive

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

Re: effective use of blkdiscard(8)?



On Sat, Jun 25, 2022 at 05:22:02PM +1000, matthew green wrote:
> > However, what about less obvious cases?
> >
> > A large file could be created, for example, with dd:
> >
> > # dd if=/dev/zero of=./testfile bs=4m count=10000
> >
> > Then discarded:
> >
> > # blkdiscard -v ./testfile
> >
> > Would this effectively mark 40GB of this drive unused to its controller?
> 
> that's my understanding, given that the questions you ask below
> are handled to be "yes".  it certainly does seem to be the case
> in my testing -- sometimes reading this data would return the
> same data, sometimes random data (!? where from?), and most of
> the time, zeroes -- so it certainly was triggering the storage.
> 
> an additional thing we could/should add is "fstrim", which is
> designed to be run eg, weekly, and the idea is to tell the disk
> to discard all the unallocated sectors on the disk, which would
> give you the above feature without having to do anything, and
> infact give it to you for all the unused space.  i have not
> looked at how linux implements this, but it clearly needs the
> file system itself to implement the backend.

This is great :)

> > How good are we at propgating TRIM commands through various block device
> > layers?
> >
> > Is fdiscard() effective on a file on FFSv2 on a cgd(4) on a dk(4) wedge?
> >
> > What about ZFS on a dk(4) on a cgd(4) on a dk(4) wedge?
> 
> all of this depends upon what their driver 'd_discard'
> method does.  the only ones that are not assigned to be
> "nodiscard" are:
> 
> /home/src/current/src/sys/dev/ld.c:95:  .d_discard = lddiscard,
> /home/src/current/src/sys/dev/ld.c:110: .d_discard = lddiscard,
> /home/src/current/src/sys/dev/ld.c:123: .d_discard = ld_discard
> /home/src/current/src/sys/dev/ata/wd.c:154:     .d_discard = wddiscard,
> /home/src/current/src/sys/dev/ata/wd.c:171:     .d_discard = wddiscard,
> /home/src/current/src/sys/dev/ata/wd.c:230:     .d_discard = wd_discard
> /home/src/current/src/sys/dev/dkwedge/dk.c:125: .d_discard = dkdiscard,
> /home/src/current/src/sys/dev/dkwedge/dk.c:140: .d_discard = dkdiscard,
> 
> so the vast majority of disk drivers do not support
> this yet.

If I'm reading the code right, dk(4) knows how to pass discard
requests to the underlying device. But we still need to teach cgd
this, I guess.



Home | Main Index | Thread Index | Old Index