int _rsDataObjPut( rsComm_t *rsComm, dataObjInp_t *dataObjInp, bytesBuf_t *dataObjInpBBuf, portalOprOut_t **portalOprOut ) { int status; int l1descInx; int retval; openedDataObjInp_t dataObjCloseInp; int allFlag; transferStat_t *transStat = NULL; dataObjInp_t replDataObjInp; if ( getValByKey( &dataObjInp->condInput, ALL_KW ) != NULL ) { allFlag = 1; } else { allFlag = 0; } if ( getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL ) { /* single buffer put */ status = l3DataPutSingleBuf( rsComm, dataObjInp, dataObjInpBBuf ); if ( status >= 0 && allFlag == 1 ) { /* update the rest of copies */ addKeyVal( &dataObjInp->condInput, UPDATE_REPL_KW, "" ); status = rsDataObjRepl( rsComm, dataObjInp, &transStat ); if ( transStat != NULL ) { free( transStat ); } } if ( status >= 0 ) { status = applyRuleForPostProcForWrite( rsComm, dataObjInpBBuf, dataObjInp->objPath ); if ( status >= 0 ) { status = 0; } } return status; } /* get down here. will do parallel I/O */ /* so that mmap will work */ dataObjInp->openFlags |= O_RDWR; l1descInx = rsDataObjCreate( rsComm, dataObjInp ); if ( l1descInx < 0 ) { return l1descInx; } L1desc[l1descInx].oprType = PUT_OPR; L1desc[l1descInx].dataSize = dataObjInp->dataSize; if ( getStructFileType( L1desc[l1descInx].dataObjInfo->specColl ) >= 0 ) { // JMC - backport 4682 *portalOprOut = ( portalOprOut_t * ) malloc( sizeof( portalOprOut_t ) ); bzero( *portalOprOut, sizeof( portalOprOut_t ) ); ( *portalOprOut )->l1descInx = l1descInx; return l1descInx; } status = preProcParaPut( rsComm, l1descInx, portalOprOut ); if ( status < 0 ) { memset( &dataObjCloseInp, 0, sizeof( dataObjCloseInp ) ); dataObjCloseInp.l1descInx = l1descInx; L1desc[l1descInx].oprStatus = status; rsDataObjClose( rsComm, &dataObjCloseInp ); return status; } if ( allFlag == 1 ) { /* need to save dataObjInp. get freed in sendAndRecvBranchMsg */ memset( &replDataObjInp, 0, sizeof( replDataObjInp ) ); rstrcpy( replDataObjInp.objPath, dataObjInp->objPath, MAX_NAME_LEN ); addKeyVal( &replDataObjInp.condInput, UPDATE_REPL_KW, "" ); addKeyVal( &replDataObjInp.condInput, ALL_KW, "" ); } /* return portalOprOut to the client and wait for the rcOprComplete * call. That is when the parallel I/O is done */ retval = sendAndRecvBranchMsg( rsComm, rsComm->apiInx, status, ( void * ) * portalOprOut, NULL ); if ( retval < 0 ) { memset( &dataObjCloseInp, 0, sizeof( dataObjCloseInp ) ); dataObjCloseInp.l1descInx = l1descInx; L1desc[l1descInx].oprStatus = retval; rsDataObjClose( rsComm, &dataObjCloseInp ); if ( allFlag == 1 ) { clearKeyVal( &replDataObjInp.condInput ); } } else if ( allFlag == 1 ) { status = rsDataObjRepl( rsComm, &replDataObjInp, &transStat ); if ( transStat != NULL ) { free( transStat ); } clearKeyVal( &replDataObjInp.condInput ); } /* already send the client the status */ return SYS_NO_HANDLER_REPLY_MSG; }
int rsDataObjPut( rsComm_t *rsComm, dataObjInp_t *dataObjInp, bytesBuf_t *dataObjInpBBuf, portalOprOut_t **portalOprOut ) { int status; int status2; int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; resolveLinkedPath( rsComm, dataObjInp->objPath, &specCollCache, &dataObjInp->condInput ); remoteFlag = getAndConnRemoteZone( rsComm, dataObjInp, &rodsServerHost, REMOTE_CREATE ); if ( const char* acl_string = getValByKey( &dataObjInp->condInput, ACL_INCLUDED_KW ) ) { try { irods::deserialize_acl( acl_string ); } catch ( const irods::exception& e ) { rodsLog( LOG_ERROR, "%s", e.what() ); return e.code(); } } if ( const char* metadata_string = getValByKey( &dataObjInp->condInput, METADATA_INCLUDED_KW ) ) { try { irods::deserialize_metadata( metadata_string ); } catch ( const irods::exception& e ) { rodsLog( LOG_ERROR, "%s", e.what() ); return e.code(); } } if ( remoteFlag < 0 ) { return remoteFlag; } else if ( remoteFlag == LOCAL_HOST ) { // =-=-=-=-=-=-=- // working on the "home zone", determine if we need to redirect to a different // server in this zone for this operation. if there is a RESC_HIER_STR_KW then // we know that the redirection decision has already been made std::string hier; if ( getValByKey( &dataObjInp->condInput, RESC_HIER_STR_KW ) == NULL ) { irods::error ret = irods::resolve_resource_hierarchy( irods::CREATE_OPERATION, rsComm, dataObjInp, hier ); if ( !ret.ok() ) { std::stringstream msg; msg << __FUNCTION__; msg << " :: failed in irods::irods::resolve_resource_hierarchy for ["; msg << dataObjInp->objPath << "]"; irods::log( PASSMSG( msg.str(), ret ) ); return ret.code(); } // =-=-=-=-=-=-=- // we resolved the redirect and have a host, set the hier str for subsequent // api calls, etc. addKeyVal( &dataObjInp->condInput, RESC_HIER_STR_KW, hier.c_str() ); } // if keyword status2 = applyRuleForPostProcForWrite( rsComm, dataObjInpBBuf, dataObjInp->objPath ); if ( status2 < 0 ) { return ( status2 ); } dataObjInp->openFlags = O_RDWR; status = _rsDataObjPut( rsComm, dataObjInp, dataObjInpBBuf, portalOprOut ); } else { int l1descInx; status = _rcDataObjPut( rodsServerHost->conn, dataObjInp, dataObjInpBBuf, portalOprOut ); if ( status < 0 || getValByKey( &dataObjInp->condInput, DATA_INCLUDED_KW ) != NULL ) { return status; } else { /* have to allocate a local l1descInx to keep track of things * since the file is in remote zone. It sets remoteL1descInx, * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that * rsComplete knows what to do */ l1descInx = allocAndSetL1descForZoneOpr( ( *portalOprOut )->l1descInx, dataObjInp, rodsServerHost, NULL ); if ( l1descInx < 0 ) { return l1descInx; } ( *portalOprOut )->l1descInx = l1descInx; return status; } } return status; }
int rsDataObjPut (rsComm_t *rsComm, dataObjInp_t *dataObjInp, bytesBuf_t *dataObjInpBBuf, portalOprOut_t **portalOprOut) { int status; int status2; int remoteFlag; rodsServerHost_t *rodsServerHost; specCollCache_t *specCollCache = NULL; resolveLinkedPath (rsComm, dataObjInp->objPath, &specCollCache, &dataObjInp->condInput); #if 0 status = resolvePathInSpecColl (rsComm, dataObjInp->objPath, READ_COLL_PERM, 0, &dataObjInfo); if (dataObjInfo != NULL) { if (dataObjInfo->specColl != NULL && dataObjInfo->specColl->collClass == LINKED_COLL) { rstrcpy (dataObjInp->objPath, dataObjInfo->objPath, MAX_NAME_LEN); } freeAllDataObjInfo (dataObjInfo); } #endif remoteFlag = getAndConnRemoteZone (rsComm, dataObjInp, &rodsServerHost, REMOTE_CREATE); if (remoteFlag < 0) { return (remoteFlag); } else if (remoteFlag == LOCAL_HOST) { /** since the object is written here, we apply pre procesing RAJA * Dec 2 2010 **/ status2 = applyRuleForPostProcForWrite(rsComm, dataObjInpBBuf, dataObjInp->objPath); if (status2 < 0) return(status2); /* need to dealloc anything??? */ /** since the object is written here, we apply pre procesing RAJA * Dec 2 2010 **/ dataObjInp->openFlags = O_RDWR; status = _rsDataObjPut (rsComm, dataObjInp, dataObjInpBBuf, portalOprOut, BRANCH_MSG); } else { int l1descInx; status = _rcDataObjPut (rodsServerHost->conn, dataObjInp, dataObjInpBBuf, portalOprOut); if (status < 0 || getValByKey (&dataObjInp->condInput, DATA_INCLUDED_KW) != NULL) { return (status); } else { /* have to allocate a local l1descInx to keep track of things * since the file is in remote zone. It sets remoteL1descInx, * oprType = REMOTE_ZONE_OPR and remoteZoneHost so that * rsComplete knows what to do */ l1descInx = allocAndSetL1descForZoneOpr ( (*portalOprOut)->l1descInx, dataObjInp, rodsServerHost, NULL); if (l1descInx < 0) return l1descInx; (*portalOprOut)->l1descInx = l1descInx; return status; } } return (status); }