Re: best practice to ensure data integrity at a concurrent

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

 



Hi Dongmin,

please find the inlined comments.
On Wed, Feb 17, 2010 at 4:05 PM, Dongmin Yu <min@xxxxxxxxxxxxx> wrote:

Hello,

 

I’m trying to store additional metadata like content-type and etc at extended attribute.

 

My client code are like

 

fd = glusterfs_open( path );

glusterfs_write( fd, data, data_length );

glusterfs_close( fd );       //------

glusterfs_setxattr( path, attr_name, attr_value, value_length,0 );

 

My concern is that above client code runs on multiple machines and multi-threaded.

In higher concurrency, client A could write content, client B write content, client B write its attribute then client A write its attribute.

So to speak, file content comes from client B but attribute comes from client A.

 

If I use a lock server, I can guarantee data integrity. But is there a simpler way to store extended attributes at an atomic environment?


locks should be used to ensure atomicity. There is no other simpler way which I can think of.
 

I see another function, glusterfs_fsetxattr which accepts open glusterfs_file descriptor. If I rewrite as following, can I guarantee the integrity?

 

fd = glusterfs_open( path );

glusterfs_write( fd, data, data_length );

glusterfs_fsetxattr( fd, attr_name, attr_value, value_length,0 );

glusterfs_close( fd );   


No.

One of the solutions I can think of is,

fd = glusterfs_open( path );

glusterfs_fcntl (fd, F_SETLKW, flock); /* flock tries to hold write lock on whole file */

                                                       /* please note usage of F_SETLKW, If you want to use F_SETLK you have to check for */

                                                       /* return value and proceed with writing only after lock has been acquired */

glusterfs_write( fd, data, data_length );

glusterfs_setxattr( path, attr_name, attr_value, value_length,0 );

glusterfs_fcntl (fd, F_SETLKW, flock); /*flock tries to unlock */

glusterfs_close( fd );       //------


 

 

Thanks

 

DongMin Yu

 

HOSTWAY IDC Corp. / R&D Principal Researcher

TEL. +822 2105 6037

FAX. +822 2105 6019

CELL. +8216 2086 1357

EMAIL: min.yu@xxxxxxxxxxxxxxx

Website: http://www.hostway.com

 

NOTICE:  This email and any file transmitted are confidential and/or legally privileged and intended only for the person(s) directly addressed.  If you are not the intended recipient, any use, copying, transmission, distribution, or other forms of dissemination is strictly prohibited.  If you have received this email in error, please notify the sender immediately and permanently delete the email and files, if any.


_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxx
http://lists.nongnu.org/mailman/listinfo/gluster-devel



regards,
--
Raghavendra G


[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux