]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - module/zfs/zpl_inode.c
Imported Upstream version 0.6.4.2
[mirror_zfs-debian.git] / module / zfs / zpl_inode.c
index c009807cb422c323a8c0372cb69c9b9ff992e3bd..d722714592b9a564669b46889bbd408077f8f8c2 100644 (file)
@@ -40,12 +40,15 @@ zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
        cred_t *cr = CRED();
        struct inode *ip;
        int error;
+       fstrans_cookie_t cookie;
 
        if (dlen(dentry) > ZFS_MAXNAMELEN)
                return (ERR_PTR(-ENAMETOOLONG));
 
        crhold(cr);
+       cookie = spl_fstrans_mark();
        error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, NULL);
+       spl_fstrans_unmark(cookie);
        ASSERT3S(error, <=, 0);
        crfree(cr);
 
@@ -95,11 +98,13 @@ zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
        struct inode *ip;
        vattr_t *vap;
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
        vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
        zpl_vap_init(vap, dir, mode, cr);
 
+       cookie = spl_fstrans_mark();
        error = -zfs_create(dir, dname(dentry), vap, 0, mode, &ip, cr, 0, NULL);
        if (error == 0) {
                VERIFY0(zpl_xattr_security_init(ip, dir, &dentry->d_name));
@@ -107,6 +112,7 @@ zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
                d_instantiate(dentry, ip);
        }
 
+       spl_fstrans_unmark(cookie);
        kmem_free(vap, sizeof (vattr_t));
        crfree(cr);
        ASSERT3S(error, <=, 0);
@@ -122,6 +128,7 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
        struct inode *ip;
        vattr_t *vap;
        int error;
+       fstrans_cookie_t cookie;
 
        /*
         * We currently expect Linux to supply rdev=0 for all sockets
@@ -135,6 +142,7 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
        zpl_vap_init(vap, dir, mode, cr);
        vap->va_rdev = rdev;
 
+       cookie = spl_fstrans_mark();
        error = -zfs_create(dir, dname(dentry), vap, 0, mode, &ip, cr, 0, NULL);
        if (error == 0) {
                VERIFY0(zpl_xattr_security_init(ip, dir, &dentry->d_name));
@@ -142,6 +150,7 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
                d_instantiate(dentry, ip);
        }
 
+       spl_fstrans_unmark(cookie);
        kmem_free(vap, sizeof (vattr_t));
        crfree(cr);
        ASSERT3S(error, <=, 0);
@@ -154,9 +163,12 @@ zpl_unlink(struct inode *dir, struct dentry *dentry)
 {
        cred_t *cr = CRED();
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
+       cookie = spl_fstrans_mark();
        error = -zfs_remove(dir, dname(dentry), cr);
+       spl_fstrans_unmark(cookie);
        crfree(cr);
        ASSERT3S(error, <=, 0);
 
@@ -170,11 +182,13 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, zpl_umode_t mode)
        vattr_t *vap;
        struct inode *ip;
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
        vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
        zpl_vap_init(vap, dir, mode | S_IFDIR, cr);
 
+       cookie = spl_fstrans_mark();
        error = -zfs_mkdir(dir, dname(dentry), vap, &ip, cr, 0, NULL);
        if (error == 0) {
                VERIFY0(zpl_xattr_security_init(ip, dir, &dentry->d_name));
@@ -182,6 +196,7 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, zpl_umode_t mode)
                d_instantiate(dentry, ip);
        }
 
+       spl_fstrans_unmark(cookie);
        kmem_free(vap, sizeof (vattr_t));
        crfree(cr);
        ASSERT3S(error, <=, 0);
@@ -194,9 +209,12 @@ zpl_rmdir(struct inode * dir, struct dentry *dentry)
 {
        cred_t *cr = CRED();
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
+       cookie = spl_fstrans_mark();
        error = -zfs_rmdir(dir, dname(dentry), NULL, cr, 0);
+       spl_fstrans_unmark(cookie);
        crfree(cr);
        ASSERT3S(error, <=, 0);
 
@@ -208,6 +226,7 @@ zpl_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 {
        boolean_t issnap = ITOZSB(dentry->d_inode)->z_issnap;
        int error;
+       fstrans_cookie_t cookie;
 
        /*
         * Ensure MNT_SHRINKABLE is set on snapshots to ensure they are
@@ -220,7 +239,9 @@ zpl_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
        if (unlikely(issnap && !(mnt->mnt_flags & MNT_SHRINKABLE)))
                mnt->mnt_flags |= MNT_SHRINKABLE;
 
+       cookie = spl_fstrans_mark();
        error = -zfs_getattr_fast(dentry->d_inode, stat);
+       spl_fstrans_unmark(cookie);
        ASSERT3S(error, <=, 0);
 
        return (error);
@@ -233,6 +254,7 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
        cred_t *cr = CRED();
        vattr_t *vap;
        int error;
+       fstrans_cookie_t cookie;
 
        error = inode_change_ok(ip, ia);
        if (error)
@@ -249,10 +271,12 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
        vap->va_mtime = ia->ia_mtime;
        vap->va_ctime = ia->ia_ctime;
 
+       cookie = spl_fstrans_mark();
        error = -zfs_setattr(ip, vap, 0, cr);
        if (!error && (ia->ia_valid & ATTR_MODE))
                error = zpl_chmod_acl(ip);
 
+       spl_fstrans_unmark(cookie);
        kmem_free(vap, sizeof (vattr_t));
        crfree(cr);
        ASSERT3S(error, <=, 0);
@@ -266,9 +290,12 @@ zpl_rename(struct inode *sdip, struct dentry *sdentry,
 {
        cred_t *cr = CRED();
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
+       cookie = spl_fstrans_mark();
        error = -zfs_rename(sdip, dname(sdentry), tdip, dname(tdentry), cr, 0);
+       spl_fstrans_unmark(cookie);
        crfree(cr);
        ASSERT3S(error, <=, 0);
 
@@ -282,17 +309,20 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
        vattr_t *vap;
        struct inode *ip;
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
        vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
        zpl_vap_init(vap, dir, S_IFLNK | S_IRWXUGO, cr);
 
+       cookie = spl_fstrans_mark();
        error = -zfs_symlink(dir, dname(dentry), vap, (char *)name, &ip, cr, 0);
        if (error == 0) {
                VERIFY0(zpl_xattr_security_init(ip, dir, &dentry->d_name));
                d_instantiate(dentry, ip);
        }
 
+       spl_fstrans_unmark(cookie);
        kmem_free(vap, sizeof (vattr_t));
        crfree(cr);
        ASSERT3S(error, <=, 0);
@@ -309,6 +339,7 @@ zpl_follow_link(struct dentry *dentry, struct nameidata *nd)
        uio_t uio;
        char *link;
        int error;
+       fstrans_cookie_t cookie;
 
        crhold(cr);
 
@@ -320,7 +351,9 @@ zpl_follow_link(struct dentry *dentry, struct nameidata *nd)
        uio.uio_resid = (MAXPATHLEN - 1);
        uio.uio_segflg = UIO_SYSSPACE;
 
+       cookie = spl_fstrans_mark();
        error = -zfs_readlink(ip, &uio, cr);
+       spl_fstrans_unmark(cookie);
        if (error) {
                kmem_free(link, MAXPATHLEN);
                nd_set_link(nd, ERR_PTR(error));
@@ -347,6 +380,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
        cred_t *cr = CRED();
        struct inode *ip = old_dentry->d_inode;
        int error;
+       fstrans_cookie_t cookie;
 
        if (ip->i_nlink >= ZFS_LINK_MAX)
                return (-EMLINK);
@@ -355,6 +389,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
        ip->i_ctime = CURRENT_TIME_SEC;
        igrab(ip); /* Use ihold() if available */
 
+       cookie = spl_fstrans_mark();
        error = -zfs_link(dir, ip, dname(dentry), cr);
        if (error) {
                iput(ip);
@@ -363,6 +398,7 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
 
        d_instantiate(dentry, ip);
 out:
+       spl_fstrans_unmark(cookie);
        crfree(cr);
        ASSERT3S(error, <=, 0);
 
@@ -375,6 +411,7 @@ zpl_truncate_range(struct inode *ip, loff_t start, loff_t end)
 {
        cred_t *cr = CRED();
        flock64_t bf;
+       fstrans_cookie_t cookie;
 
        ASSERT3S(start, <=, end);
 
@@ -392,7 +429,9 @@ zpl_truncate_range(struct inode *ip, loff_t start, loff_t end)
        bf.l_start = start;
        bf.l_len = end - start;
        bf.l_pid = 0;
+       cookie = spl_fstrans_mark();
        zfs_space(ip, F_FREESP, &bf, FWRITE, start, cr);
+       spl_fstrans_unmark(cookie);
 
        crfree(cr);
 }