Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

create, mknod, mkdir, symlink should call unlock_new_inode after dent…

…ry is being instantiated. This, along with related zfs commit, fixes the iput BUG (inode->i_state == I_CLEAR).

- Code working on 2.6.32 need to check with 2.6.37
  • Loading branch information...
commit 31380082d65e32fde526cfc8162249ef313f3a27 1 parent d4ac855
Prasad Joshi authored
View
2  include/lzfs_xattr.h
@@ -31,7 +31,7 @@ int
lzfs_removexattr(struct dentry *dentry, const char *name);
int
-lzfs_init_security(struct dentry *dentry, struct inode *dir);
+lzfs_init_security(struct inode *inode, struct inode *dir);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
extern int
View
77 module/lzfs_vnops.c
@@ -95,6 +95,7 @@ lzfs_vnop_create(struct inode *dir, struct dentry *dentry, int mode,
vnode_t *vp;
vnode_t *dvp;
vattr_t *vap;
+ struct inode *inode;
const cred_t *cred = get_current_cred();
int err;
@@ -124,14 +125,25 @@ lzfs_vnop_create(struct inode *dir, struct dentry *dentry, int mode,
err = -err;
goto failed;
}
- d_instantiate(dentry, LZFS_VTOI(vp));
+
+ inode = LZFS_VTOI(vp);
+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
- if ((err = lzfs_acl_init(dentry->d_inode, dir))) {
+ if ((err = lzfs_acl_init(inode, dir))) {
/* XXX need more error handling */
+ unlock_new_inode(inode);
+ iput(inode);
goto failed;
}
#endif
- err = lzfs_init_security(dentry, dir);
+ if ((err = lzfs_init_security(inode, dir))) {
+ /* XXX need more error handling */
+ unlock_new_inode(inode);
+ iput(inode);
+ goto failed;
+ }
+ d_instantiate(dentry, inode);
+ unlock_new_inode(inode);
failed:
tsd_exit();
SEXIT;
@@ -280,8 +292,10 @@ lzfs_vnop_symlink (struct inode *dir, struct dentry *dentry,
vnode_t *dvp;
vnode_t *vp;
vattr_t *vap;
+ struct inode *inode;
const cred_t *cred = get_current_cred();
int err;
+
SENTRY;
err = checkname((char *)dentry->d_name.name);
if(err)
@@ -306,15 +320,26 @@ lzfs_vnop_symlink (struct inode *dir, struct dentry *dentry,
err = -err;
goto failed;
}
- d_instantiate(dentry, LZFS_VTOI(vp));
+
+ inode = LZFS_VTOI(vp);
+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
- err = lzfs_acl_init(dentry->d_inode, dir);
+ err = lzfs_acl_init(inode, dir);
if(err) {
/* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
goto failed;
}
#endif
- err = lzfs_init_security(dentry, dir);
+ if ((err = lzfs_init_security(inode, dir))) {
+ /* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
+ goto failed;
+ }
+ d_instantiate(dentry, inode);
+ unlock_new_inode(inode);
failed:
tsd_exit();
SEXIT;
@@ -327,8 +352,10 @@ lzfs_vnop_mkdir(struct inode *dir, struct dentry *dentry, int mode)
vnode_t *vp;
vnode_t *dvp;
vattr_t *vap;
+ struct inode *inode;
const cred_t *cred = get_current_cred();
int err;
+
SENTRY;
err = checkname((char *)dentry->d_name.name);
if(err)
@@ -351,15 +378,27 @@ lzfs_vnop_mkdir(struct inode *dir, struct dentry *dentry, int mode)
err = -err;
goto failed;
}
- d_instantiate(dentry, LZFS_VTOI(vp));
+
+ inode = LZFS_VTOI(vp);
+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
- err = lzfs_acl_init(dentry->d_inode,dir);
+ err = lzfs_acl_init(inode, dir);
if(err) {
/* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
goto failed;
}
#endif
- err = lzfs_init_security(dentry, dir);
+ if ((err = lzfs_init_security(inode, dir))) {
+ /* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
+ goto failed;
+ }
+
+ d_instantiate(dentry, inode);
+ unlock_new_inode(inode);
failed:
tsd_exit();
SEXIT;
@@ -399,6 +438,7 @@ lzfs_vnop_mknod(struct inode * dir, struct dentry *dentry, int mode,
vnode_t *dvp;
vattr_t *vap;
const cred_t *cred = get_current_cred();
+ struct inode *inode;
int err;
SENTRY;
@@ -429,17 +469,28 @@ lzfs_vnop_mknod(struct inode * dir, struct dentry *dentry, int mode,
err = -err;
goto failed;
}
- d_instantiate(dentry, LZFS_VTOI(vp));
- init_special_inode(dentry->d_inode,mode,rdev);
+
+ inode = LZFS_VTOI(vp);
+ init_special_inode(inode, mode, rdev);
+
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31)
- err = lzfs_acl_init(dentry->d_inode,dir);
+ err = lzfs_acl_init(inode, dir);
if(err) {
/* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
goto failed;
}
#endif
- err = lzfs_init_security(dentry, dir);
+ if ((err = lzfs_init_security(inode, dir))) {
+ /* XXX error handling */
+ unlock_new_inode(inode);
+ iput(inode);
+ goto failed;
+ }
+ d_instantiate(dentry, inode);
+ unlock_new_inode(inode);
failed:
tsd_exit();
SEXIT;
View
39 module/lzfs_xattr_security.c
@@ -53,21 +53,11 @@ lzfs_xattr_security_get(struct dentry *dentry, const char *name,
return rc;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
-static int
-lzfs_xattr_security_set(struct inode *inode, const char *name,
- const void *value, size_t size, int flags)
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
-static int
-lzfs_xattr_security_set(struct dentry *dentry, const char *name,
- const void *value, size_t size, int flags, int type)
-#endif
+int lzfs_xattr_security_set2(struct inode *inode, const char *name,
+ const void *value, size_t size, int flags)
{
char *xattr_name;
int rc;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
- struct inode *inode = dentry->d_inode;
-#endif
xattr_name = kzalloc(strlen(name) + 10, GFP_KERNEL);
if (!xattr_name)
return -ENOMEM;
@@ -81,6 +71,22 @@ lzfs_xattr_security_set(struct dentry *dentry, const char *name,
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+static int
+lzfs_xattr_security_set(struct inode *inode, const char *name,
+ const void *value, size_t size, int flags)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+static int
+lzfs_xattr_security_set(struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags, int type)
+#endif
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ struct inode *inode = dentry->d_inode;
+#endif
+ return lzfs_xattr_security_set2(inode, name, value, size, flags);
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
static size_t
lzfs_xattr_security_list(struct inode *inode, char *list, size_t list_size,
const char *name, size_t name_len)
@@ -101,24 +107,29 @@ lzfs_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
}
int
-lzfs_init_security(struct dentry *dentry, struct inode *dir)
+lzfs_init_security(struct inode *inode, struct inode *dir)
{
int err;
size_t len;
void *value;
char *name;
- err = security_inode_init_security(dentry->d_inode, dir, &name, &value, &len);
+ err = security_inode_init_security(inode, dir, &name, &value, &len);
if (err) {
if (err == -EOPNOTSUPP)
return 0;
return err;
}
+#if 0
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
err = lzfs_xattr_security_set(dentry->d_inode, name, value, len, 0);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
err = lzfs_xattr_security_set(dentry, name, value, len, 0, 0);
#endif
+#endif
+
+ err = lzfs_xattr_security_set2(inode, name, value, len, 0);
+
kfree(name);
kfree(value);
return err;
Please sign in to comment.
Something went wrong with that request. Please try again.