Skip to contentSkip to conversation

Problem in src_cmpxattr?

DISCUSSION Joaquim Rocha 2 participants 2 messages Nov 13, 2014

lore
Share & tools
lore
#0 lore raw

Hi there,

I need to create an object O (if it doesn't exist) and set an xattr on it based on a condition that another xattr in a different object (X) should obey. For this, on the same write operation (called on O) I call create (not exclusively), setxattr and src_cmpxattr (with X as the src_oid), respectively.

What I noticed is that if object O does not exist, the src_cmpxattr returns -ENOENT (even if object X does exist). IMO, this error should only be returned if X didn't exist and not O.

Is this the correct expectation for what src_cmpxattr should do (compare an xattr on the given source object to the parameters given)? Is this somehow expected? If so, is there any other way that I can accomplish what I need as mentioned above?

Thank you in advance,

--
Joaquim Rocha

#1 lore raw

Hi Joaquim,

Quoted 10 lines · Joaquim Rocha

Hi there,

I need to create an object O (if it doesn't exist) and set an xattr on it based on a condition that another xattr in a different object (X) should obey. For this, on the same write operation (called on O) I call create (not exclusively), setxattr and src_cmpxattr (with X as the src_oid), respectively.

What I noticed is that if object O does not exist, the src_cmpxattr returns -ENOENT (even if object X does exist). IMO, this error should only be returned if X didn't exist and not O.

This will only work if you force rados to store O and X in the same PG in the cluster. This is done with the locator_set_key() method, which essentially let's you specify a string other than the object name to decide where the object goes. So you could store O in the 'O' slot (default), then set the locator key to '0' and store X in the same place. Then the src_cmpxattr method should do what you want.

This lets you have a cluster of objects that are stored together and that you can clone data between using clone_range. But you can't do this sort of test-and-set between arbitrary objects in the cluster because they will usually be stored on different OSDs...

Quoted 5 lines

Is this the correct expectation for what src_cmpxattr should do (compare an xattr on the given source object to the parameters given)?

Is this somehow expected? If so, is there any other way that I can accomplish what I need as mentioned above?

Yeah, the ENOENT is telling you that there is no O stored at locator key X.

We would love to add some simple transactional support to rados that would let you do this in the general case, but there's a long list of other important things to get done first!

sage