nfs41: close a small race window when adding new layout to global list

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Tom Haynes <Thomas.Haynes@primarydata.com>
This commit is contained in:
Peng Tao 2014-08-22 17:37:40 +08:00 коммит произвёл Tom Haynes
Родитель 72cff4494e
Коммит abb9a0079c
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -1288,7 +1288,6 @@ pnfs_update_layout(struct inode *ino,
struct nfs_client *clp = server->nfs_client; struct nfs_client *clp = server->nfs_client;
struct pnfs_layout_hdr *lo; struct pnfs_layout_hdr *lo;
struct pnfs_layout_segment *lseg = NULL; struct pnfs_layout_segment *lseg = NULL;
bool first;
if (!pnfs_enabled_sb(NFS_SERVER(ino))) if (!pnfs_enabled_sb(NFS_SERVER(ino)))
goto out; goto out;
@ -1321,16 +1320,15 @@ pnfs_update_layout(struct inode *ino,
if (pnfs_layoutgets_blocked(lo, 0)) if (pnfs_layoutgets_blocked(lo, 0))
goto out_unlock; goto out_unlock;
atomic_inc(&lo->plh_outstanding); atomic_inc(&lo->plh_outstanding);
first = list_empty(&lo->plh_layouts) ? true : false;
spin_unlock(&ino->i_lock); spin_unlock(&ino->i_lock);
if (first) { if (list_empty(&lo->plh_layouts)) {
/* The lo must be on the clp list if there is any /* The lo must be on the clp list if there is any
* chance of a CB_LAYOUTRECALL(FILE) coming in. * chance of a CB_LAYOUTRECALL(FILE) coming in.
*/ */
spin_lock(&clp->cl_lock); spin_lock(&clp->cl_lock);
list_add_tail(&lo->plh_layouts, &server->layouts); if (list_empty(&lo->plh_layouts))
list_add_tail(&lo->plh_layouts, &server->layouts);
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
} }