dslreports logo
 
    All Forums Hot Topics Gallery
spc
uniqs
69

trparky
Premium Member
join:2000-05-24
Cleveland, OH
·AT&T U-Verse

trparky to rusdi

Premium Member

to rusdi

Re: Buggy Intel SSD 520 Series SSD Firmware

I thought that TRIM was supposed to be done even if Windows does it itself. I know that Windows performs a TRIM when you delete files but what about when you overwrite a file?

Microsoft hasn't exactly been very forthcoming with their policy on the TRIM command that's built into the OS. When does a TRIM happen?

rusdi
American V
MVM
join:2001-04-28
Flippin, AR

rusdi

MVM

Click for full size
said by trparky:

I thought that TRIM was supposed to be done even if Windows does it itself. I know that Windows performs a TRIM when you delete files but what about when you overwrite a file?

Microsoft hasn't exactly been very forthcoming with their policy on the TRIM command that's built into the OS. When does a TRIM happen?

It "should" be.

Here's a way to check if it's enabled.

Open a command prompt, (Administrative level).

Command prompt > fsutil behavior query disabledeletenotify

DisableDeleteNotify = 1 (Windows TRIM commands are disabled)
DisableDeleteNotify = 0 (Windows TRIM commands are enabled)

trparky
Premium Member
join:2000-05-24
Cleveland, OH

trparky

Premium Member

I know about that, but appears that that may indicate that a TRIM only happens when you delete files. What about an overwrite of a file?

rusdi
American V
MVM
join:2001-04-28
Flippin, AR

rusdi

MVM

said by trparky:

I know about that, but appears that that may indicate that a TRIM only happens when you delete files. What about an overwrite of a file?

Overwrite doesn't happen with NAND flash. it must be deleted and written in other blocks...

Here's a nice article that might help explain the difference between TRIM, and Garbage collection.
»thessdreview.com/daily-n ··· -primer/

DarkLogix
Texan and Proud
Premium Member
join:2008-10-23
Baytown, TX

1 recommendation

DarkLogix to trparky

Premium Member

to trparky
said by trparky:

I know about that, but appears that that may indicate that a TRIM only happens when you delete files. What about an overwrite of a file?

Due to wear leveling you don't ever overwrite

overwriting nand is very slow and time consuming so instead it writes to a new location and marks the old for GC to clean up

koitsu
MVM
join:2002-07-16
Mountain View, CA
Humax BGW320-500

1 recommendation

koitsu to trparky

MVM

to trparky
said by trparky:

I thought that TRIM was supposed to be done even if Windows does it itself.

No no no. Absolutely not!
said by trparky:

I know that Windows performs a TRIM when you delete files but what about when you overwrite a file?

Microsoft hasn't exactly been very forthcoming with their policy on the TRIM command that's built into the OS. When does a TRIM happen?

The answer lies within truly understanding what TRIM does. The entire point of the TRIM command (more specifically DATA SET MANAGEMENT; that's what it's called per ATA spec) is to allow an OS or host controller to tell the underlying SSD "these LBA ranges are no longer used". Meaning: the entries in the FTL map can be released, and the SSD internally knows anything from LBA x to LBA y is no longer cared about.

Obviously this is used during file deletions; the OS deletes the file from the underlying filesystem ("I no longer care about this file"), and issues the appropriate TRIM command to the controller saying "LBA x through y are no longer used" (and possibly in repeated chunks, since that ATA CDB only supports up to 65536 worth of LBAs). This command can take some time to run (depends on a lot of things I'd rather not get into), and it's atomic.

File overwrites are done similarly -- you need to think about the two conditions that correlate with a file overwrite.

Say you have a file that is 12345 bytes on an NTFS filesystem that uses a 4096-byte cluster (or unit) size. This file takes up 4 clusters/units (4*4096 = 16384). You edit this file, and the new size is 19590 bytes (i.e. is larger). In this case TRIM is not used because there's no removal of data. The file now takes up 5 clusters/units (5*4096 = 20480), despite only 19590 being used.

Understand so far? Okay.

Now alternately let's say you edit the file (in its original state), and the new file size is 7810 bytes. The underlying filesystem shortens the number of clusters/units associated with this file -- it now only requires 2 clusters/units (2*4096 = 8192). The original 2 are no longer used by anything. TRIM is issued on the LBA range that makes up those 2 no-longer-used clusters/units.

TRIM does not operate on byte ranges, it operates on LBA ranges, and the filesystem knows which LBA ranges aren't in use based on file deletions or resizing or whatever else.

So like I said: understanding what TRIM does actually answers the question.

If you have concerns or questions over how your operating system (Windows) behaves, you should ask Microsoft. The best I can find is a Windows 8 API document that briefly describes the behaviour (see last paragraph of "What is TRIM?") except it doesn't mention file truncation (documentation author or engineer who wrote that did not think about the bigger picture): »msdn.microsoft.com/en-us ··· %29.aspx