Delayed operations cannot return error codes. So we must check for these conditions first before starting set or remove operations Signed-off-by: Allison Collins <allison.henderson@xxxxxxxxxx> --- libxfs/xfs_attr.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 289fee2..357824c 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -445,6 +445,18 @@ xfs_attr_set( goto out_trans_cancel; xfs_trans_ijoin(args.trans, dp, 0); + + error = xfs_has_attr(&args); + if (error == -EEXIST) { + if (name->type & ATTR_CREATE) + goto out_trans_cancel; + else + name->type |= ATTR_REPLACE; + } + + if (error == -ENOATTR && (name->type & ATTR_REPLACE)) + goto out_trans_cancel; + error = xfs_attr_set_args(&args); if (error) goto out_trans_cancel; @@ -533,6 +545,10 @@ xfs_attr_remove( */ xfs_trans_ijoin(args.trans, dp, 0); + error = xfs_has_attr(&args); + if (error != -EEXIST) + goto out; + error = xfs_attr_remove_args(&args); if (error) goto out; -- 2.7.4