[PATCH v4 07/28] block: Introduce zone write plugging
Christoph Hellwig
hch at lst.de
Tue Apr 2 09:12:13 PDT 2024
> + /* We can remove zone write plugs for zones that are empty or full. */
> + return !zwplug->wp_offset ||
> + zwplug->wp_offset >= disk->zone_capacity;
Nit: this condition easily fits onto a single line.
> +static inline struct blk_zone_wplug *
> +disk_lookup_zone_wplug(struct gendisk *disk, sector_t sector)
> +{
> + unsigned int zno = disk_zone_no(disk, sector);
> + unsigned int idx = hash_32(zno, disk->zone_wplugs_hash_bits);
> + struct blk_zone_wplug *zwplug;
> +
> + rcu_read_lock();
> + hlist_for_each_entry_rcu(zwplug, &disk->zone_wplugs_hash[idx], node) {
> + if (zwplug->zone_no == zno)
> + goto unlock;
> + }
> + zwplug = NULL;
> +
> +unlock:
> + rcu_read_unlock();
> + return zwplug;
> +}
Did we lose an atomic_inc_unless_zero here? This now just does a lookup
under RCU, but nothing to prevent the zwplug from beeing freed?
> + /* Resize the zone write plug memory pool if needed. */
> + if (disk->zone_wplugs_pool->min_nr != pool_size)
> + return mempool_resize(disk->zone_wplugs_pool, pool_size);
Note that a mempool_resize to the current size work just fine. It takes
a pointless lock, but given that this is something that doesn't happen
frequently that probably doesn't matter.
> +#include <linux/mempool.h>
> + mempool_t *zone_wplugs_pool;
Please use struct mempool_s here so that you only need a forward
declaration instead of pulling in another header.
More information about the Linux-nvme
mailing list