+/**
+ * Check if a string begins with a given prefix.
+ *
+ * \param str String to check
+ * \param prefix Substring to check at the beginning of \a str
+ * \return true/false whether the condition is verified.
+ */
+static inline bool has_prefix(const char *str, const char *prefix)
+{
+ return strncmp(prefix, str, strlen(prefix)) == 0;
+}
+
+/**
+ * Indicate the kind of changelog to store (if any) for a xattr set/del.
+ *
+ * \param[in] xattr_name Full extended attribute name.
+ *
+ * \return The type of changelog to use, or -1 if no changelog is to be emitted.
+ */
+static enum changelog_rec_type
+mdd_xattr_changelog_type(const struct lu_env *env, struct mdd_device *mdd,
+ const char *xattr_name)
+{
+ /* Layout changes systematically recorded */
+ if (strcmp(XATTR_NAME_LOV, xattr_name) == 0)
+ return CL_LAYOUT;
+
+ /* HSM information changes systematically recorded */
+ if (strcmp(XATTR_NAME_HSM, xattr_name) == 0)
+ return CL_HSM;
+
+ if (has_prefix(xattr_name, XATTR_USER_PREFIX) ||
+ has_prefix(xattr_name, XATTR_NAME_POSIX_ACL_ACCESS) ||
+ has_prefix(xattr_name, XATTR_NAME_POSIX_ACL_DEFAULT))
+ return CL_XATTR;
+
+ return -1;
+}
+