On Wed, 2018-12-05 at 22:59 +0800, Weiping Zhang wrote:
> Weiping Zhang <[email protected]> 于2018年12月5日周三 下午10:49写道:
> > Christoph Hellwig <[email protected]> 于2018年12月5日周三 下午10:40写道:
> > > Can you please also send a patch to not show this attribute for
> > > drivers without a timeout handler?  Thanks!
> 
> Is there a simple way do that ?

How about checking the timeout member of struct blk_mq_ops for blk-mq and
checking the rq_timed_out_fn member in struct request_queue for the legacy
block layer?

> Shall we return -ENOTSUPP when user read/write this attribute when
> driver has no timeout handler ?

A much more elegant solution is to introduce a sysfs attribute group for the
io_timeout attribute and to make that group visible only if a timeout handler
has been defined. See e.g. disk_attr_group in block/genhd.c for an example.

Bart.

Reply via email to