*/
/*
* 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);
}
#endif /* HAVE_D_OBTAIN_ALIAS */
- return result;
+ return (result);
}
static struct dentry *
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 *
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 */
};