]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_ctldir.c
cstyle: Resolve C style issues
[mirror_zfs.git] / module / zfs / zfs_ctldir.c
index c08e9dd9b959cd1433df85b63e640ef5f1380a48..96520545a2804d12f187db0e5f9749917de10abb 100644 (file)
@@ -100,7 +100,7 @@ static taskq_t *zfs_expire_taskq;
 static zfs_snapentry_t *
 zfsctl_sep_alloc(void)
 {
-       return kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP);
+       return (kmem_zalloc(sizeof (zfs_snapentry_t), KM_SLEEP));
 }
 
 void
@@ -255,7 +255,6 @@ zfsctl_inode_lookup(zfs_sb_t *zsb, uint64_t id,
 void
 zfsctl_inode_destroy(struct inode *ip)
 {
-       return;
 }
 
 /*
@@ -692,7 +691,7 @@ zfsctl_snapdir_inactive(struct inode *ip)
  * best effort.  In the case where it does fail, perhaps because
  * it's in use, the unmount will fail harmlessly.
  */
-#define SET_UNMOUNT_CMD \
+#define        SET_UNMOUNT_CMD \
        "exec 0</dev/null " \
        "     1>/dev/null " \
        "     2>/dev/null; " \
@@ -801,7 +800,9 @@ zfsctl_unmount_snapshots(zfs_sb_t *zsb, int flags, int *count)
        return ((*count > 0) ? EEXIST : 0);
 }
 
-#define SET_MOUNT_CMD \
+#define        MOUNT_BUSY 0x80         /* Mount failed due to EBUSY (from mntent.h) */
+
+#define        SET_MOUNT_CMD \
        "exec 0</dev/null " \
        "     1>/dev/null " \
        "     2>/dev/null; " \
@@ -839,17 +840,23 @@ zfsctl_mount_snapshot(struct path *path, int flags)
         * function is marked GPL-only and cannot be used.  On error we
         * careful to log the real error to the console and return EISDIR
         * to safely abort the automount.  This should be very rare.
+        *
+        * If the user mode helper happens to return EBUSY, a concurrent
+        * mount is already in progress in which case the error is ignored.
+        * Take note that if the program was executed successfully the return
+        * value from call_usermodehelper() will be (exitcode << 8 + signal).
         */
        argv[2] = kmem_asprintf(SET_MOUNT_CMD, full_name, full_path);
        error = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
        strfree(argv[2]);
-       if (error) {
+       if (error && !(error & MOUNT_BUSY << 8)) {
                printk("ZFS: Unable to automount %s at %s: %d\n",
                    full_name, full_path, error);
                error = SET_ERROR(EISDIR);
                goto error;
        }
 
+       error = 0;
        mutex_enter(&zsb->z_ctldir_lock);
 
        /*