Fix evict() deadlock
[zfs.git] / module / zfs / zpl_file.c
index 585f971..d76e62d 100644 (file)
 
 
 static int
+zpl_open(struct inode *ip, struct file *filp)
+{
+       cred_t *cr;
+       int error;
+
+       cr = (cred_t *)get_current_cred();
+       error = -zfs_open(ip, filp->f_mode, filp->f_flags, cr);
+       put_cred(cr);
+       ASSERT3S(error, <=, 0);
+
+       if (error)
+               return (error);
+
+       return generic_file_open(ip, filp);
+}
+
+static int
+zpl_release(struct inode *ip, struct file *filp)
+{
+       cred_t *cr;
+       int error;
+
+       cr = (cred_t *)get_current_cred();
+       error = -zfs_close(ip, filp->f_flags, cr);
+       put_cred(cr);
+       ASSERT3S(error, <=, 0);
+
+       return (error);
+}
+
+static int
 zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
 {
        struct dentry *dentry = filp->f_path.dentry;
@@ -45,8 +76,7 @@ zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
        return (error);
 }
 
-static int
-zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
+ZPL_FSYNC_PROTO(zpl_fsync, filp, unused_dentry, datasync)
 {
        cred_t *cr;
        int error;
@@ -317,7 +347,8 @@ const struct address_space_operations zpl_address_space_operations = {
 };
 
 const struct file_operations zpl_file_operations = {
-       .open           = generic_file_open,
+       .open           = zpl_open,
+       .release        = zpl_release,
        .llseek         = generic_file_llseek,
        .read           = zpl_read,
        .write          = zpl_write,