* TRIM addressing unwritten space?
@ 2013-03-11 16:15 Andrey Kuzmin
2013-03-12 12:22 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Kuzmin @ 2013-03-11 16:15 UTC (permalink / raw)
To: fio
I may be misreading the fio code, but it looks like there is an issue
with generation of the offset to ttrim if trim_backlog option is not
set.
In this case, get_io_u falls through the check_get_trim (which starts
with the check if td->flags has TD_F_TRIM_BACKLOG set and immediately
returns if not), and the call chain is then
set_io_u_file->fill_io_u->set_rw_dir->get_rw_dir
where, in the last else clause of the conditional, ddir is set to DDIR_TRIM.
Subsequently, the get_next_offset then - say, in the random I/O case -
ends up in the __get_next_rand_offset returning a random offset not
necessarily written to previously. TRIMming an unwritten space is not
necessarily a bug (although some SSD controllers may have different
view), but is hardly the operation fio intended to perform.
The very next portion of the __get_next_rand_offset, dealing with the
random map, could have solved the issue (if it's real), with the write
logic reversed for TRIM (return if the offset is busy and look up the
next busy offset otherwise). For this to work, o_randommap should be
made required for trim jobs without o_trim_backlog set.
Regards,
Andrey
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: TRIM addressing unwritten space?
2013-03-11 16:15 TRIM addressing unwritten space? Andrey Kuzmin
@ 2013-03-12 12:22 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2013-03-12 12:22 UTC (permalink / raw)
To: Andrey Kuzmin; +Cc: fio
On Mon, Mar 11 2013, Andrey Kuzmin wrote:
> I may be misreading the fio code, but it looks like there is an issue
> with generation of the offset to ttrim if trim_backlog option is not
> set.
>
> In this case, get_io_u falls through the check_get_trim (which starts
> with the check if td->flags has TD_F_TRIM_BACKLOG set and immediately
> returns if not), and the call chain is then
>
> set_io_u_file->fill_io_u->set_rw_dir->get_rw_dir
>
> where, in the last else clause of the conditional, ddir is set to DDIR_TRIM.
>
> Subsequently, the get_next_offset then - say, in the random I/O case -
> ends up in the __get_next_rand_offset returning a random offset not
> necessarily written to previously. TRIMming an unwritten space is not
> necessarily a bug (although some SSD controllers may have different
> view), but is hardly the operation fio intended to perform.
>
> The very next portion of the __get_next_rand_offset, dealing with the
> random map, could have solved the issue (if it's real), with the write
> logic reversed for TRIM (return if the offset is busy and look up the
> next busy offset otherwise). For this to work, o_randommap should be
> made required for trim jobs without o_trim_backlog set.
The trim primitive works just like reads or writes. So if you use it
without a backlog explicitly trimming previously written parts, then it
will randomly issue trims just like it would have done a read or a
write.
I can't imagine trimming unwritten extents causing an error on any
device, even the most crappy and cheap ones. First of all, that would
violate any sort of common sense. Secondly, you can expect other
utilities to completely trim a device before using it for eg swap or a
new file system. This will gladly trim any unwritten extent as well.
That said, if you would like fio to explicitly only trim bits that have
previously been written (without using a backlog), then that is a sane
feature to have. It could be done with lfsr magic, or you could use the
randommap (in reverse) as you describe. This would be easy enough to
implement, at least for the pure write case.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-12 12:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 16:15 TRIM addressing unwritten space? Andrey Kuzmin
2013-03-12 12:22 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox