@@ -507,6 +507,7 @@ xfs_attr_set(
int valuelen)
{
struct xfs_mount *mp = dp->i_mount;
+ struct xfs_sb *sbp = &mp->m_sb;
struct xfs_da_args args;
struct xfs_trans_res tres;
int rsvd = (name->type & ATTR_ROOT) != 0;
@@ -565,7 +566,20 @@ xfs_attr_set(
goto out_trans_cancel;
xfs_trans_ijoin(args.trans, dp, 0);
- error = xfs_attr_set_args(&args);
+ if (XFS_SB_VERSION_NUM(sbp) < XFS_SB_VERSION_4)
+ error = xfs_attr_set_args(&args);
+ else {
+ error = xfs_has_attr(&args);
+
+ if (error == -EEXIST && (name->type & ATTR_CREATE))
+ goto out_trans_cancel;
+
+ if (error == -ENOATTR && (name->type & ATTR_REPLACE))
+ goto out_trans_cancel;
+
+ error = xfs_attr_set_deferred(dp, args.trans, name, value,
+ valuelen);
+ }
if (error)
goto out_trans_cancel;
if (!args.trans) {
@@ -650,6 +664,7 @@ xfs_attr_remove(
struct xfs_name *name)
{
struct xfs_mount *mp = dp->i_mount;
+ struct xfs_sb *sbp = &mp->m_sb;
struct xfs_da_args args;
int error;
@@ -691,7 +706,14 @@ xfs_attr_remove(
*/
xfs_trans_ijoin(args.trans, dp, 0);
- error = xfs_attr_remove_args(&args);
+ error = xfs_has_attr(&args);
+ if (error == -ENOATTR)
+ goto out;
+
+ if (XFS_SB_VERSION_NUM(sbp) < XFS_SB_VERSION_4)
+ error = xfs_attr_remove_args(&args);
+ else
+ error = xfs_attr_remove_deferred(dp, args.trans, name);
if (error)
goto out;
Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove. We only do this for v4 and up since we cant add new log entries to old fs versions Signed-off-by: Allison Collins <allison.henderson@oracle.com> --- libxfs/xfs_attr.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)