Caching Mode Page and DPOFUA bit handling in sd

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

 



Hi all,

I would like to raise some concern over how the SCSI disk driver
handles Caching Mode Page and DPOFUA bit.

The first thing is what the driver assumes when no Caching Mode Page
is found. By default it "assumes write through", which means it
assumes that the disk has no Caching Mode Page because/so it does not
have volatile write cache.

I am not sure what are the pros or reasons doing so in that case. If I
am not missing something, "assuming write back", which means we assume
there is volatile write cache and send SYNCHRONIZE CACHE commands when
necessary, should be the safer fallback.

The only reason I could think of is, there are devices that are
allergic SYNCHRONIZE CACHE commands. However, I am not sure if it
makes any sense to decide that base on whether the device has Caching
Mode Page.

There has been a commit that takes the safer approach for USB drives
that has the corresponding quirk enabled (Commit b81478d82e38, "[SCSI]
set to WCE if usb cache quirk is present."), which is sort of good,
except the fact that it wasn't made general makes the overall logic
nonsensical.

The second thing is about DPOFUA.

Currently the driver would only read the DPOFUA bit returns from a
MODE SENSE command if Caching Mode Page is found, while the bit does
not belong to the page. It is instead a "device-specific parameter"
like the Write Protect flag. You can even notice that by reading only
the code.

I couldn't found anything in any of the SCSI standards that correlates
the bit and the Caching Mode Page either. Truth is, AFAIK, the DPOFUA
bit to some extent eliminates the necessity of the WCE bit, because if
we send FUA write commands, we shouldn't need to care about whether
write cache is enabled, or if it exists at all.

(It might make some sense by doing something like, "assume write
through if FUA is supported; assume write back if it is not"?)

Also compare sd_set_flush_flag in sd.c and blk_queue_write_cache in
blk-settings.c. The block layer does not "depend" FUA on write cache
as the sd driver does either.

I think sd_read_write_protect_flag should be made general for reading
both the WP and the DPOFUA bits, while sd_read_cache_type should be
freed from the job.

Any comments and insights are welcomed.

Regards,
Tom Yan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux