Host-aware SMR drives can be used with the commands to explicitly manage zone state, but they can also be used as normal disks. In the former case it makes perfect sense to allow partitions on them, in the latter it does not, just like for host managed devices. Add a check to add_partition to allow partitions on host aware devices, but give up any zone management capabilities in that case, which also catches the previously missed case of adding a partition vs just scanning it. Because sd can rescan the attribute at runtime it needs to check if a disk has partitions, for which a new helper is added to genhd.h.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -245,6 +245,18 @@ static inline bool disk_part_scan_enabled(struct gendisk *disk) · 244 unmodified lines | ||
| 245 | 245 | !(disk->flags & GENHD_FL_NO_PART_SCAN); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | +static inline bool disk_has_partitions(struct gendisk *disk) | |
| 249 | +{ | |
| 250 | + bool ret = false; | |
| 251 | + | |
| 252 | + rcu_read_lock(); | |
| 253 | + if (rcu_dereference(disk->part_tbl)->len > 1) | |
| 254 | + ret = true; | |
| 255 | + rcu_read_unlock(); | |
| 256 | + | |
| 257 | + return ret; | |
| 258 | +} | |
| 259 | + | |
| 248 | 260 | static inline dev_t disk_devt(struct gendisk *disk) |
| 249 | 261 | { |
| 250 | 262 | return MKDEV(disk->major, disk->first_minor); |