On Thu, Jan 26, 2017 at 9:45 AM, Jan Kara <jack@xxxxxxx> wrote: > Instead of storing backing_dev_info inside struct request_queue, > allocate it dynamically, reference count it, and free it when the last > reference is dropped. Currently only request_queue holds the reference > but in the following patch we add other users referencing > backing_dev_info. > > Signed-off-by: Jan Kara <jack@xxxxxxx> [..] > diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h > index e850e76acaaf..4282f21b1611 100644 > --- a/include/linux/backing-dev-defs.h > +++ b/include/linux/backing-dev-defs.h > @@ -144,7 +144,9 @@ struct backing_dev_info { > > char *name; > > - unsigned int capabilities; /* Device capabilities */ > + atomic_t refcnt; /* Reference counter for the structure */ > + unsigned int capabilities:31; /* Device capabilities */ > + unsigned int free_on_put:1; /* Structure will be freed on last bdi_put() */ > unsigned int min_ratio; > unsigned int max_ratio, max_prop_frac; > Any reason to not just use struct kref for this? The "free on final put" should be implicit. In other words, if there is a path that would ever clear this flag, then it really should just be holding its own reference. -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html