Re: Change device block count from userspace?

2018-04-17 Thread Manuel Lauss
On Wed, Apr 18, 2018 at 12:43 AM, Martin K. Petersen
 wrote:
>
> Manuel,
>
>> I have a SATA SSD which suddenly reports its size as 2.2TB, 0x
>> block count:
>
> "Suddenly" as in out of the blue? Or after a drive firmware update? Or a
> kernel ditto?

Out of the blue, yes.  I think it's actually userspace (udev/udisks?)
which tries
to read a few block from the very end of the device, which confuses
the drive firmware.
Sometimes it recovers and then it can be mounted read-only without issues.
It's not a kernel fault, the drive is broken.

Still, is there a userspace option (sysfs attribute perhaps) to limit
disk capacity to
a certain block count?

Thank you!
 Manuel


Change device block count from userspace?

2018-04-16 Thread Manuel Lauss
Hello,

I have a SATA SSD which suddenly reports its size as 2.2TB, 0x
block count:

[   30.620086] sd 10:0:0:0: [sdc] 4294967295 512-byte logical blocks:
(2.20 TB/2.00 TiB)
[   30.620327] sd 10:0:0:0: [sdc] Write Protect is off
[   30.620329] sd 10:0:0:0: [sdc] Mode Sense: 43 00 00 00
[   30.620771] sd 10:0:0:0: [sdc] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[   34.170412] GPT:Primary header thinks Alt. header is not at the end
of the disk.
[   34.170413] GPT:4004704367 != 4294967294
[   34.170414] GPT:Alternate GPT header not at the end of the disk.
[   34.170414] GPT:4004704367 != 4294967294
[   34.170414] GPT: Use GNU Parted to correct GPT errors.
[   34.170419]  sdc: sdc1
[   34.172408] sd 10:0:0:0: [sdc] Attached SCSI disk
[   64.293698] sd 10:0:0:0: [sdc] tag#15 uas_eh_abort_handler 0
uas-tag 1 inflight: CMD IN
[   64.293702] sd 10:0:0:0: [sdc] tag#15 CDB: Read(10) 28 00 ff ff ff
00 00 00 08 00

It's impossible to access this device with either dd or any other
tools because apparently
the kernel tries to access higher blocks which, one after the other,
time out after around 5 minutes.  It's possible to access the disk on
Windows with an Ext4 driver, data seems fine but retrieval is very
slow.

Is there a way from userspace to tell the block layer that this device
has only 4004704368 blocks, and that it should not touch the higher
ones?

Thanks!
  Manuel