gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gluster-devel] Can function arguments be modified ?


From: Xavier Hernandez
Subject: [Gluster-devel] Can function arguments be modified ?
Date: Fri, 09 Mar 2012 09:18:57 +0100
User-agent: Roundcube Webmail/0.7.1

Hello,

I've a doubt about the way in which arguments received from upper or lower translators should be handled in case they need to be modified.

Simple arguments are passed by value and there is no problem, but all other data types are passed by reference (dict_t *, fd_t *, inode_t *, struct iatt *, ...). I know that for fd_t and inode_t the way to go is to attach context structures to them associated to my translator without modifying anything, but for dict_t and other structures I may need to make changes before continuing. For example, I need to add some keys into a dict before calling lower translators and I need to remove some keys before propagating response to upper translators. I also need to modify some fields from an struct iatt.

The question is what is the policy used for gluster development ? are translators allowed to modify arguments received from upper layers ? are translators allowed to modify arguments received from callbacks before propagating them ?

My translator can have multiple subvolumes, so if they are allowed to modify the parameters I send to them, I need to send a different copy to each one. Otherwise they can interfere with each other. On the other hand, if they are not allowed to modify my arguments, but I need to modify what I receive, I would need to make a copy before.

The same happens with arguments received from a callback. If translators can modify them, it's supposed that they can't access data after propagating it upper into the chain, otherwise they could see unknown or inconsistent data. If they aren't allowed to modify data, then a copy must be done before making any change.

Making copies is always safe but if it's unnecessary, it's a waste of time and a loss of resources and throughput.

What is the correct behaviour ?

Thank you very much for your help

Xavi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]