Re: [PATCH 07/13] RFC: pnfs: full mount/umount infrastructure

Christoph Hellwig
2010-09-13T15:07:02Z

On Thu, Sep 02, 2010 at 02:00:13PM -0400, Fred Isaman wrote:
> static struct pnfs_layoutdriver_type *
> find_pnfs_driver(u32 id) {
> - return NULL;
> + struct pnfs_layoutdriver_type *local;
> +
> + spin_lock(&pnfs_spinlock);
> + local = find_pnfs_driver_locked(id);
> + spin_unlock(&pnfs_spinlock);
> + return local;

What about refcounting the structure?

> + spin_lock(&pnfs_spinlock);
> + if (!find_pnfs_driver_locked(ld_type->id)) {
> + list_add(&ld_type->pnfs_tblid, &pnfs_modules_tbl);
> + status = 0;
> + dprintk("%s Registering id:%u name:%s\n", __func__, ld_type->id,
> + ld_type->name);
> + } else
> + printk(KERN_ERR "%s Module with id %d already loaded!\n",
> + __func__, ld_type->id);
> + spin_unlock(&pnfs_spinlock);

In other places we generally don't bother doing these checks, so for
pnfs with just three clients it's even more poinless.