]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zpl_export.c
cstyle: Resolve C style issues
[mirror_zfs.git] / module / zfs / zpl_export.c
index f82ee30887fc3a627482b13af0029a9645711410..ac9449433d8e222ccd17e9aef6261496efebc5f2 100644 (file)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2011 Gunnar Beutner
+ * Copyright (c) 2012 Cyril Plisko. All rights reserved.
  */
 
 
 
 
 static int
+#ifdef HAVE_ENCODE_FH_WITH_INODE
+zpl_encode_fh(struct inode *ip, __u32 *fh, int *max_len, struct inode *parent)
+{
+#else
 zpl_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, int connectable)
 {
-       fid_t *fid = (fid_t *)fh;
        struct inode *ip = dentry->d_inode;
+#endif /* HAVE_ENCODE_FH_WITH_INODE */
+       fid_t *fid = (fid_t *)fh;
        int len_bytes, rc;
 
        len_bytes = *max_len * sizeof (__u32);
 
        if (len_bytes < offsetof(fid_t, fid_data))
-               return 255;
+               return (255);
 
        fid->fid_len = len_bytes - offsetof(fid_t, fid_data);
 
@@ -70,7 +76,7 @@ zpl_dentry_obtain_alias(struct inode *ip)
        }
 #endif /* HAVE_D_OBTAIN_ALIAS */
 
-       return result;
+       return (result);
 }
 
 static struct dentry *
@@ -86,16 +92,16 @@ zpl_fh_to_dentry(struct super_block *sb, struct fid *fh,
        if (fh_type != FILEID_INO32_GEN ||
            len_bytes < offsetof(fid_t, fid_data) ||
            len_bytes < offsetof(fid_t, fid_data) + fid->fid_len)
-               return ERR_PTR(-EINVAL);
+               return (ERR_PTR(-EINVAL));
 
        rc = zfs_vget(sb, &ip, fid);
 
        if (rc != 0)
-               return ERR_PTR(-rc);
+               return (ERR_PTR(-rc));
 
        ASSERT((ip != NULL) && !IS_ERR(ip));
 
-       return zpl_dentry_obtain_alias(ip);
+       return (zpl_dentry_obtain_alias(ip));
 }
 
 static struct dentry *
@@ -111,13 +117,32 @@ zpl_get_parent(struct dentry *child)
        ASSERT3S(error, <=, 0);
 
        if (error)
-               return ERR_PTR(error);
+               return (ERR_PTR(error));
+
+       return (zpl_dentry_obtain_alias(ip));
+}
+
+#ifdef HAVE_COMMIT_METADATA
+static int
+zpl_commit_metadata(struct inode *inode)
+{
+       cred_t *cr = CRED();
+       int error;
+
+       crhold(cr);
+       error = -zfs_fsync(inode, 0, cr);
+       crfree(cr);
+       ASSERT3S(error, <=, 0);
 
-       return zpl_dentry_obtain_alias(ip);
+       return (error);
 }
+#endif /* HAVE_COMMIT_METADATA */
 
 const struct export_operations zpl_export_operations = {
-       .encode_fh      = zpl_encode_fh,
-       .fh_to_dentry   = zpl_fh_to_dentry,
-       .get_parent     = zpl_get_parent
+       .encode_fh              = zpl_encode_fh,
+       .fh_to_dentry           = zpl_fh_to_dentry,
+       .get_parent             = zpl_get_parent,
+#ifdef HAVE_COMMIT_METADATA
+       .commit_metadata        = zpl_commit_metadata,
+#endif /* HAVE_COMMIT_METADATA */
 };