]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Illumos 4638 - Panic in ZFS via rfs3_setattr()/rfs3_write(): dirtying snapshot!
authorMarcel Telka <marcel.telka@nexenta.com>
Sun, 10 Jan 2016 22:31:24 +0000 (23:31 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 11 Jan 2016 18:29:48 +0000 (10:29 -0800)
4638 Panic in ZFS via rfs3_setattr()/rfs3_write(): dirtying snapshot!
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Ilya Usvyatsky <ilya.usvyatsky@nexenta.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Garrett D'Amore <garrett@damore.org>

References:
  https://www.illumos.org/issues/4638
  https://github.com/illumos/illumos-gate/commit/2144b12

Porting notes:
- [module/zfs/zfs_vnops.c]
  - 3558fd7 Prototype/structure update for Linux
  - 2cf7f52 Linux compat 2.6.39: mount_nodev()
  - Use zfs_is_readonly() wrapper
  - Remove first line of comment which doesn't apply

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
module/zfs/zfs_vnops.c

index 174c918ab0f626e014ce33b3d20832024dac379b..64412a69dd2fcef19871916a3fa6dd20bb3c4bea 100644 (file)
@@ -21,6 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2015 by Chunwei Chen. All rights reserved.
  */
 
@@ -621,6 +622,15 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
        SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zsb), NULL,
            &zp->z_pflags, 8);
 
+       /*
+        * Callers might not be able to detect properly that we are read-only,
+        * so check it explicitly here.
+        */
+       if (zfs_is_readonly(zsb)) {
+               ZFS_EXIT(zsb);
+               return (SET_ERROR(EROFS));
+       }
+
        /*
         * If immutable or not appending then return EPERM
         */
@@ -4378,6 +4388,15 @@ zfs_space(struct inode *ip, int cmd, flock64_t *bfp, int flag,
                return (SET_ERROR(EINVAL));
        }
 
+       /*
+        * Callers might not be able to detect properly that we are read-only,
+        * so check it explicitly here.
+        */
+       if (zfs_is_readonly(zsb)) {
+               ZFS_EXIT(zsb);
+               return (SET_ERROR(EROFS));
+       }
+
        if ((error = convoff(ip, bfp, 0, offset))) {
                ZFS_EXIT(zsb);
                return (error);