Hi,

In nfs_dupreq_start and nfs_dupreq_finish when allocating/freeing a
dupreq_entry we are trying hard to keep both dupreq_q and the rbtree
in sync acquiring both the partition lock and the drc (t->mtx,
drc->mtx). This requires dropping and reacquiring locks at certain
places. Can these nested locks be changed to take locks one after the
other.

For example at the time of allocation, we could choose to do this -

PTHREAD_MUTEX_lock(&t->mtx); /* partition lock */
nv = rbtree_x_cached_lookup(&drc->xt, t, &dk->rbt_k, dk->hk);
if (!nv) {
dk->refcnt = 2;
(void)rbtree_x_cached_insert(&drc->xt, t,
&dk->rbt_k, dk->hk);
PTHREAD_MUTEX_unlock(&t->mtx); /* partition lock */

PTHREAD_MUTEX_lock(&drc->mtx);
TAILQ_INSERT_TAIL(&drc->dupreq_q, dk, fifo_q);
++(drc->size);
PTHREAD_MUTEX_unlock(&drc->mtx);
}

I am assuming this would simplify the lock code a lot.
If there is a case where this would introduce a race please let me know.

Thanks,
Satya.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to