From: <ta...@us...> - 2007-10-05 13:34:49
|
Revision: 3842 http://gfarm.svn.sourceforge.net/gfarm/?rev=3842&view=rev Author: tatebe Date: 2007-10-05 06:34:53 -0700 (Fri, 05 Oct 2007) Log Message: ----------- add GFARM_FILE_CREATE_REPLICA to just add a file replica to the existing file. Consistency between file replicas should be maintained by a client program since there is no consistency checking for now. This flag is experimentally introduced for Gfarm-JuxMem collaboration to make it possible to create multiple file replicas in parallel by multiple JuxMem providers that keep an identical copy of data. Modified Paths: -------------- gfarm/branches/gfarm_v2/include/gfarm/gfs.h gfarm/branches/gfarm_v2/server/gfmd/process.c Modified: gfarm/branches/gfarm_v2/include/gfarm/gfs.h =================================================================== --- gfarm/branches/gfarm_v2/include/gfarm/gfs.h 2007-10-05 13:26:59 UTC (rev 3841) +++ gfarm/branches/gfarm_v2/include/gfarm/gfs.h 2007-10-05 13:34:53 UTC (rev 3842) @@ -79,6 +79,7 @@ #define GFARM_FILE_NOT_RETRY 0x08000000 #endif #define GFARM_FILE_UNBUFFERED 0x10000000 +#define GFARM_FILE_CREATE_REPLICA 0x20000000 #ifdef GFARM_INTERNAL_USE /* internal use only */ #define GFARM_FILE_BEQUEATHED 0x40000000 #define GFARM_FILE_CKSUM_INVALIDATED 0x80000000 @@ -90,7 +91,7 @@ GFARM_FILE_UNBUFFERED) #else #define GFARM_FILE_USER_MODE (GFARM_FILE_ACCMODE|GFARM_FILE_TRUNC| \ - GFARM_FILE_UNBUFFERED) + GFARM_FILE_UNBUFFERED|GFARM_FILE_CREATE_REPLICA) #endif /* not yet on Gfarm v2 */ #endif /* GFARM_INTERNAL_USE */ Modified: gfarm/branches/gfarm_v2/server/gfmd/process.c =================================================================== --- gfarm/branches/gfarm_v2/server/gfmd/process.c 2007-10-05 13:26:59 UTC (rev 3841) +++ gfarm/branches/gfarm_v2/server/gfmd/process.c 2007-10-05 13:34:53 UTC (rev 3842) @@ -458,7 +458,7 @@ { struct file_opening *fo; gfarm_error_t e = process_get_file_opening(process, fd, &fo); - int to_create; + int to_create, is_creating_file_replica; if (e != GFARM_ERR_NO_ERROR) return (e); @@ -468,9 +468,15 @@ return (GFARM_ERR_OPERATION_NOT_PERMITTED); to_create = inode_is_creating_file(fo->inode); + is_creating_file_replica = (fo->flag & GFARM_FILE_CREATE_REPLICA) != 0; if ((accmode_to_op(fo->flag) & GFS_W_OK) != 0 || to_create) { - if (!inode_schedule_confirm_for_write(fo->inode, + if (is_creating_file_replica) { + e = inode_add_replica(fo->inode, spool_host, 0); + if (e != GFARM_ERR_NO_ERROR) + return (e); + } + else if (!inode_schedule_confirm_for_write(fo->inode, spool_host, to_create)) return (GFARM_ERR_FILE_MIGRATED); if (to_create) { @@ -489,7 +495,7 @@ *genp = inode_get_gen(fo->inode); *modep = inode_get_mode(fo->inode); *flagsp = fo->flag & GFARM_FILE_USER_MODE; - *to_createp = to_create; + *to_createp = to_create || is_creating_file_replica; return (GFARM_ERR_NO_ERROR); } @@ -575,6 +581,7 @@ { struct file_opening *fo; gfarm_error_t e = process_get_file_opening(process, fd, &fo); + struct host *spool_host; if (e != GFARM_ERR_NO_ERROR) return (e); @@ -586,15 +593,25 @@ return (GFARM_ERR_BAD_FILE_DESCRIPTOR); if (fo->opener != peer && fo->opener != NULL) { + spool_host = fo->u.f.spool_host; /* closing REOPENed file, but the client is still opening */ - - /* invalidate file replicas if updated */ - if (gfarm_timespec_cmp(inode_get_mtime(fo->inode), mtime)) + fo->u.f.spool_opener = NULL; + fo->u.f.spool_host = NULL; + /* + * GFARM_FILE_CREATE_REPLICA means just to create a + * file replica. + */ + if ((fo->flag & GFARM_FILE_CREATE_REPLICA) != 0) { + e = inode_add_replica(fo->inode, spool_host, 1); + /* if this is not the first replica, return */ + if (e != GFARM_ERR_ALREADY_EXISTS) + return (e); + } + else if (gfarm_timespec_cmp(inode_get_mtime(fo->inode), mtime)) + /* invalidate file replicas if updated */ inode_remove_every_other_replicas( - fo->inode, fo->u.f.spool_host); + fo->inode, spool_host); - fo->u.f.spool_opener = NULL; - fo->u.f.spool_host = NULL; inode_set_size(fo->inode, size); inode_set_atime(fo->inode, atime); inode_set_mtime(fo->inode, mtime); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |