On Wed, 2011-07-27 at 14:40 -0400, Jim Rees wrote: > From: Peng Tao <bergwolf@xxxxxxxxx> > > Save it in layout header instead of in every segment. > > Signed-off-by: Peng Tao <peng_tao@xxxxxxx> > --- > fs/nfs/pnfs.c | 12 ++++++------ > fs/nfs/pnfs.h | 1 - > 2 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c > index dae19dd..fbebd2a 100644 > --- a/fs/nfs/pnfs.c > +++ b/fs/nfs/pnfs.c > @@ -211,6 +211,7 @@ destroy_layout_hdr(struct pnfs_layout_hdr *lo) > dprintk("%s: freeing layout cache %p\n", __func__, lo); > BUG_ON(!list_empty(&lo->plh_layouts)); > NFS_I(lo->plh_inode)->layout = NULL; > + put_rpccred(lo->plh_lc_cred); > pnfs_free_layout_hdr(lo); > } > > @@ -1007,6 +1008,10 @@ pnfs_update_layout(struct inode *ino, > list_del_init(&lo->plh_layouts); > spin_unlock(&clp->cl_lock); > } > + if (first) { > + lo->plh_lc_cred = > + get_rpccred(ctx->state->owner->so_cred); > + } Hmm... This whole 'first' thing is inherently racy. What if two threads are calling pnfs_update_layout at the same time: they both see list_empty(&lo->plh_segs), and both conclude that they need to initialise the layout header. _BOOM_.... The correct thing to do here is either to initialise the layout header correctly inside pnfs_find_alloc_layout(), or to add a flag for ->plh_flags that can be used with test_and_clear_bit() to get _one_ of the processes to perform the initialisation. Personally, I'd prefer the former. -- Trond Myklebust Linux NFS client maintainer NetApp Trond.Myklebust@xxxxxxxxxx www.netapp.com -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html