goto out;
}
- ret = btrfs_setxattr_trans(trans, inode, name, value, size, 0);
+ if (trans)
+ ret = btrfs_setxattr(trans, inode, name, value, size, 0);
+ else
+ ret = btrfs_setxattr_trans(NULL, inode, name, value, size, 0);
+
out:
kfree(value);
return -EINVAL;
if (value_len == 0) {
- ret = btrfs_setxattr_trans(trans, inode, handler->xattr_name,
- NULL, 0, flags);
+ if (trans)
+ ret = btrfs_setxattr(trans, inode, handler->xattr_name,
+ NULL, 0, flags);
+ else
+ ret = btrfs_setxattr_trans(NULL, inode,
+ handler->xattr_name, NULL, 0,
+ flags);
if (ret)
return ret;
ret = handler->validate(value, value_len);
if (ret)
return ret;
- ret = btrfs_setxattr_trans(trans, inode, handler->xattr_name,
- value, value_len, flags);
+ if (trans)
+ ret = btrfs_setxattr(trans, inode, handler->xattr_name, value,
+ value_len, flags);
+ else
+ ret = btrfs_setxattr_trans(NULL, inode, handler->xattr_name,
+ value, value_len, flags);
+
if (ret)
return ret;
ret = handler->apply(inode, value, value_len);
if (ret) {
- btrfs_setxattr_trans(trans, inode, handler->xattr_name,
- NULL, 0, flags);
+ if (trans)
+ btrfs_setxattr(trans, inode, handler->xattr_name, NULL,
+ 0, flags);
+ else
+ btrfs_setxattr_trans(NULL, inode, handler->xattr_name,
+ NULL, 0, flags);
return ret;
}
if (ret)
return ret;
- ret = btrfs_setxattr_trans(trans, inode, h->xattr_name, value,
- strlen(value), 0);
+ ret = btrfs_setxattr(trans, inode, h->xattr_name, value,
+ strlen(value), 0);
if (!ret) {
ret = h->apply(inode, value, strlen(value));
if (ret)
- btrfs_setxattr_trans(trans, inode, h->xattr_name,
- NULL, 0, 0);
+ btrfs_setxattr(trans, inode, h->xattr_name,
+ NULL, 0, 0);
else
set_bit(BTRFS_INODE_HAS_PROPS,
&BTRFS_I(inode)->runtime_flags);
size_t name_len = strlen(name);
int ret = 0;
+ ASSERT(trans);
+
if (name_len + size > BTRFS_MAX_XATTR_SIZE(root->fs_info))
return -ENOSPC;
}
strcpy(name, XATTR_SECURITY_PREFIX);
strcpy(name + XATTR_SECURITY_PREFIX_LEN, xattr->name);
- err = btrfs_setxattr_trans(trans, inode, name, xattr->value,
- xattr->value_len, 0);
+ err = btrfs_setxattr(trans, inode, name, xattr->value,
+ xattr->value_len, 0);
kfree(name);
if (err < 0)
break;