Message ID | 20210725055458.29008-7-hch@lst.de (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | [1/8] block: make the block holder code optional | expand |
On Sun, Jul 25 2021 at 1:54P -0400, Christoph Hellwig <hch@lst.de> wrote: > Move setting md->type from both callers into dm_setup_md_queue. > This ensures that md->type is only set to a valid value after the queue > has been fully setup, something we'll rely on future changes. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Snitzer <snitzer@redhat.com> > --- > drivers/md/dm-ioctl.c | 4 ---- > drivers/md/dm.c | 5 +++-- > 2 files changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c > index 2209cbcd84db..2575074a2204 100644 > --- a/drivers/md/dm-ioctl.c > +++ b/drivers/md/dm-ioctl.c > @@ -1436,9 +1436,6 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si > } > > if (dm_get_md_type(md) == DM_TYPE_NONE) { > - /* Initial table load: acquire type of table. */ > - dm_set_md_type(md, dm_table_get_type(t)); > - > /* setup md->queue to reflect md's type (may block) */ > r = dm_setup_md_queue(md, t); > if (r) { > @@ -2187,7 +2184,6 @@ int __init dm_early_create(struct dm_ioctl *dmi, > if (r) > goto err_destroy_table; > > - md->type = dm_table_get_type(t); > /* setup md->queue to reflect md's type (may block) */ > r = dm_setup_md_queue(md, t); > if (r) { > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 7971ec8ce677..f003bd5b93ce 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -2052,9 +2052,9 @@ EXPORT_SYMBOL_GPL(dm_get_queue_limits); > */ > int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) > { > - int r; > + enum dm_queue_mode type = dm_table_get_type(t); > struct queue_limits limits; > - enum dm_queue_mode type = dm_get_md_type(md); > + int r; > > switch (type) { > case DM_TYPE_REQUEST_BASED: > @@ -2081,6 +2081,7 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) > r = dm_table_set_restrictions(t, md->queue, &limits); > if (r) > return r; > + md->type = type; > > blk_register_queue(md->disk); > > -- > 2.30.2 > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 2209cbcd84db..2575074a2204 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1436,9 +1436,6 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si } if (dm_get_md_type(md) == DM_TYPE_NONE) { - /* Initial table load: acquire type of table. */ - dm_set_md_type(md, dm_table_get_type(t)); - /* setup md->queue to reflect md's type (may block) */ r = dm_setup_md_queue(md, t); if (r) { @@ -2187,7 +2184,6 @@ int __init dm_early_create(struct dm_ioctl *dmi, if (r) goto err_destroy_table; - md->type = dm_table_get_type(t); /* setup md->queue to reflect md's type (may block) */ r = dm_setup_md_queue(md, t); if (r) { diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 7971ec8ce677..f003bd5b93ce 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2052,9 +2052,9 @@ EXPORT_SYMBOL_GPL(dm_get_queue_limits); */ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) { - int r; + enum dm_queue_mode type = dm_table_get_type(t); struct queue_limits limits; - enum dm_queue_mode type = dm_get_md_type(md); + int r; switch (type) { case DM_TYPE_REQUEST_BASED: @@ -2081,6 +2081,7 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) r = dm_table_set_restrictions(t, md->queue, &limits); if (r) return r; + md->type = type; blk_register_queue(md->disk);
Move setting md->type from both callers into dm_setup_md_queue. This ensures that md->type is only set to a valid value after the queue has been fully setup, something we'll rely on future changes. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/dm-ioctl.c | 4 ---- drivers/md/dm.c | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-)