From: NeilBrown Date: Mon, 9 Aug 2010 11:06:34 +0000 (+1000) Subject: Make dir arg to lafs_new_inode optional. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=6c827a73f23f449d6706eb0bc565ee80947a2940;p=LaFS.git Make dir arg to lafs_new_inode optional. After all, some inodes will be created without a directory (root and other special inodes). Make inodbp optional too. Signed-off-by: NeilBrown --- diff --git a/inode.c b/inode.c index 5eb6271..6ff15cb 100644 --- a/inode.c +++ b/inode.c @@ -545,7 +545,7 @@ void lafs_inode_init(struct datablock *b, int type, int mode, struct inode *dir) mode |= S_ISGID; } else l->groupid = cpu_to_le32(current->cred->fsgid); - if (LAFSI(dir)->md.file.treeid) + if (dir && LAFSI(dir)->md.file.treeid) l->treeid = cpu_to_le32(LAFSI(dir)->md.file.treeid); else l->treeid = l->userid; @@ -556,7 +556,7 @@ void lafs_inode_init(struct datablock *b, int type, int mode, struct inode *dir) l->ctime = l->creationtime; l->accesstime = l->creationtime; l->size = 0; - l->parent = cpu_to_le32(dir->i_ino); + l->parent = dir ? cpu_to_le32(dir->i_ino) : 0; l->linkcount = 0; l->attrinode = 0; if (type == TypeDir) { @@ -1497,7 +1497,10 @@ retry: LAFS_BUG(b->my_inode != ino, &b->b); lafs_checkpoint_unlock(fs); - *inodbp = b; + if (inodbp) + *inodbp = b; + else + putdref(b, MKREF(inode_new)); return ino; abort_unlock: