Detect unsupported PREVENT ALLOW MEDIUM REMOVAL and SYNCHRONIZE CACHE(10)
to not spam devices with useless commands and logs with errors.

(cherry picked from commit b7dc63ce7af91ed317559e27f577183d27b9aa6d)
Oops, revert unwanted part of r253721.

(cherry picked from commit 37cdfcd8aa9ef97da5657d3925333a9f461c22cc)
Synchronize device cache on close only if there were some write operations.
While these operations are not really needed otherwise, at least for SCSI
they may cause extra errors if some other initiator holds write exclusive
reservation on the LUN (SYNCHRONIZE CACHE handled as "write" operation).

(cherry picked from commit 9932d6357cd2745b8b313b513e4c8711a63cb77c)