Re: Problem with USB-to-SATA adapters (was: AS2105-based enclosure size issues with >2TB HDDs)

Dale R. Worley
2014-09-04T20:49:26Z

> From: James Bottomley <James.Bottomley@HansenPartnership.com>

> Before we embark on elaborate hacks, why don't we just make the capacity
> writeable (by root) in sysfs from userspace (will require block change)?
> We can then encode all the nasty heuristics (including gpt reading) in
> userspace as a udev rule.

Looking in from the outside, this makes sense to me. All the nasty
hueristics can be put in userspace -- perhaps as even a
special-purpose program, where we can directly warn the user as to
what he's getting himself into. (I do not demand that this all work
automatically.) And the hueristics can be improved easily, without
kernel changes.

The only gotcha that I see is that once the recorded device size is
changed, the kernel may now consider the partition table to be valid,
and should now parse it and set up the special device numbers for the
partitions. So that needs to get triggered properly.

I suppose there is some complexity if the block-handling layer already
has blocks cached and the device size is reduced below the addresses
of the cached blocks. But as long as the kernel doesn't crash or
write blocks in incorrect places, I don't see that as a problem -- if
you set the device size as less than the block numbers you've already
written to, that's your problem.

Dale