提交 0783a25b 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

retry on concurrent create

上级 0b4a7695
...@@ -227,6 +227,7 @@ create(char *path, short type, short major, short minor) ...@@ -227,6 +227,7 @@ create(char *path, short type, short major, short minor)
struct inode *ip, *dp; struct inode *ip, *dp;
char name[DIRSIZ]; char name[DIRSIZ];
retry:
if((dp = nameiparent(path, name)) == 0) if((dp = nameiparent(path, name)) == 0)
return 0; return 0;
if(dp->type != T_DIR) if(dp->type != T_DIR)
...@@ -257,8 +258,13 @@ create(char *path, short type, short major, short minor) ...@@ -257,8 +258,13 @@ create(char *path, short type, short major, short minor)
panic("create dots"); panic("create dots");
} }
if(dirlink(dp, name, ip->inum) < 0) if(dirlink(dp, name, ip->inum) < 0) {
panic("create: dirlink"); // create race
ip->nlink--;
iunlockput(ip);
iput(dp);
goto retry;
}
//nc_insert(dp, name, ip); //nc_insert(dp, name, ip);
iput(dp); iput(dp);
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论