#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <stdio.h>
#include <stdlib.h>
struct afs_FSStats afs_fsstats;
-void ResetDebug(), SetDebug(), Terminate();
-
int LogLevel = 0;
int supported = 1;
int Console = 0;
afs_int32 PctSpare;
extern afs_int32 implicitAdminRights;
extern afs_int32 readonlyServer;
+extern int CopyOnWrite_calls, CopyOnWrite_off0, CopyOnWrite_size0;
+extern afs_fsize_t CopyOnWrite_maxsize;
/*
* Externals used by the xstat code.
int retry_flag = 1;
int code = 0;
char hoststr[16], hoststr2[16];
+#ifdef AFS_PTHREAD_ENV
struct ubik_client *uclient;
-
+#endif
*ahostp = NULL;
if (!tconn) {
/* Is it still necessary to drop this? We hit the net, we should... */
H_UNLOCK;
- if (uclient)
+ if (uclient) {
hpr_End(uclient);
+ uclient = NULL;
+ }
code = hpr_Initialize(&uclient);
if (!code)
struct host *thost;
struct client *tclient;
int translate = 0;
- int held;
H_LOCK;
tclient = h_FindClient_r(aconn);
if (thost->hostFlags & HERRORTRANS)
translate = 1;
h_ReleaseClient_r(tclient);
- held = h_Held_r(thost);
- if (held)
- h_Release_r(thost);
- if (ahost && ahost != thost) {
- char hoststr[16], hoststr2[16];
- ViceLog(0, ("CallPostamble: ahost %s:%d (%x) != thost %s:%d (%x)\n",
- afs_inet_ntoa_r(ahost->host, hoststr), ntohs(ahost->port),
- ahost,
- afs_inet_ntoa_r(thost->host, hoststr2), ntohs(thost->port),
- thost));
- h_Release_r(ahost);
- } else if (!ahost) {
- char hoststr[16];
- ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%x)\n",
- afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port),
- thost));
+
+ if (ahost) {
+ if (ahost != thost) {
+ /* host/client recycle */
+ char hoststr[16], hoststr2[16];
+ ViceLog(0, ("CallPostamble: ahost %s:%d (%p) != thost "
+ "%s:%d (%p)\n",
+ afs_inet_ntoa_r(ahost->host, hoststr),
+ ntohs(ahost->port),
+ ahost,
+ afs_inet_ntoa_r(thost->host, hoststr2),
+ ntohs(thost->port),
+ thost));
+ }
+ /* return the reference taken in CallPreamble */
+ h_Release_r(ahost);
+ } else {
+ char hoststr[16];
+ ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%p)\n",
+ afs_inet_ntoa_r(thost->host, hoststr),
+ ntohs(thost->port),
+ thost));
}
+
+ /* return the reference taken in local h_FindClient_r--h_ReleaseClient_r
+ * does not decrement refcount on client->host */
+ h_Release_r(thost);
+
busyout:
H_UNLOCK;
return (translate ? sys_error_to_et(ret) : ret);
static afs_int32
CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
{
- int fileCode = 0;
- afs_int32 local_errorCode, errorCode = -1;
+ Error fileCode = 0;
+ Error local_errorCode, errorCode = -1;
static struct timeval restartedat = { 0, 0 };
if (fid->Volume == 0 || fid->Vnode == 0) /* not: || fid->Unique == 0) */
assert(Fid != 0);
while (1) {
VnodeId parentvnode;
- int errorCode = 0;
+ Error errorCode = 0;
parentvnode = (*targetptr)->disk.parent;
VPutVnode(&errorCode, *targetptr);
{
struct acl_accessList *aCL; /* Internal access List */
int aCLSize; /* size of the access list */
- int errorCode = 0; /* return code to caller */
+ Error errorCode = 0; /* return code to caller */
if ((errorCode = CheckVnode(Fid, volptr, targetptr, locktype)))
return (errorCode);
PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr,
Vnode * parentptr, Volume * volptr, struct client **client)
{
- int fileCode = 0; /* Error code returned by the volume package */
+ Error fileCode = 0; /* Error code returned by the volume package */
if (parentwhentargetnotdir) {
VPutVnode(&fileCode, parentwhentargetnotdir);
afs_int32 rights, int CallingRoutine,
AFSStoreStatus * InStatus)
{
- int errorCode = 0;
+ Error errorCode = 0;
#define OWNSp(client, target) ((client)->ViceId == (target)->disk.owner)
#define CHOWN(i,t) (((i)->Mask & AFS_SETOWNER) &&((i)->Owner != (t)->disk.owner))
#define CHGRP(i,t) (((i)->Mask & AFS_SETGROUP) &&((i)->Group != (t)->disk.group))
{
char *eACL; /* External access list placeholder */
- if (acl_Externalize
- ((targetptr->disk.type ==
+ if (acl_Externalize_pr
+ (hpr_IdToName, (targetptr->disk.type ==
vDirectory ? VVnodeACL(targetptr) :
VVnodeACL(parentwhentargetnotdir)), &eACL) != 0) {
return EIO;
{
struct acl_accessList *newACL; /* PlaceHolder for new access list */
- if (acl_Internalize(AccessList->AFSOpaque_val, &newACL) != 0)
+ if (acl_Internalize_pr(hpr_NameToId, AccessList->AFSOpaque_val, &newACL)
+ != 0)
return (EINVAL);
if ((newACL->size + 4) > VAclSize(targetptr))
return (E2BIG);
* disk.inodeNumber and cloned)
*/
#define COPYBUFFSIZE 8192
+#define MAXFSIZE (~(afs_fsize_t) 0)
static int
-CopyOnWrite(Vnode * targetptr, Volume * volptr)
+CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len)
{
Inode ino, nearInode;
int rdlen;
DFlush(); /* just in case? */
VN_GET_LEN(size, targetptr);
+ if (size > off)
+ size -= off;
+ else
+ size = 0;
+ if (size > len)
+ size = len;
+
buff = (char *)malloc(COPYBUFFSIZE);
if (buff == NULL) {
return EIO;
newFdP = IH_OPEN(newH);
assert(newFdP != NULL);
+ FDH_SEEK(targFdP, off, SEEK_SET);
+ FDH_SEEK(newFdP, off, SEEK_SET);
while (size > 0) {
if (size > COPYBUFFSIZE) { /* more than a buffer */
length = COPYBUFFSIZE;
* error code indicates that the disk is full, we roll-back to
* the initial state.
*/
- if ((rdlen != length) || (wrlen != length))
+ if ((rdlen != length) || (wrlen != length)) {
if ((wrlen < 0) && (errno == ENOSPC)) { /* disk full */
ViceLog(0,
("CopyOnWrite failed: Partition %s containing volume %u is full\n",
VTakeOffline(volptr);
return EIO;
}
+ }
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll();
#endif /* !AFS_PTHREAD_ENV */
return 0; /* success */
} /*CopyOnWrite */
+static int
+CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_fsize_t off, afs_fsize_t size) {
+ char *buff = (char *)malloc(COPYBUFFSIZE);
+ register int length;
+ int rdlen;
+ int wrlen;
+ int rc;
+
+ FDH_SEEK(targFdP, off, SEEK_SET);
+ FDH_SEEK(newFdP, off, SEEK_SET);
+
+ if (size > FDH_SIZE(targFdP) - off) size = FDH_SIZE(targFdP) - off;
+ while (size > 0) {
+ if (size > COPYBUFFSIZE) { /* more than a buffer */
+ length = COPYBUFFSIZE;
+ size -= COPYBUFFSIZE;
+ } else {
+ length = (int)size;
+ size = 0;
+ }
+ rdlen = FDH_READ(targFdP, buff, length);
+ if (rdlen == length)
+ wrlen = FDH_WRITE(newFdP, buff, length);
+ else
+ wrlen = 0;
+
+ if ((rdlen != length) || (wrlen != length)) {
+ /* no error recovery, at the worst we'll have a "hole" in the file */
+ rc = 1;
+ break;
+ }
+ }
+ free(buff);
+ return rc;
+}
+
/*
* Common code to handle with removing the Name (file when it's called from
DirHandle * dir, AFSFid * fileFid, char *Name, int ChkForDir)
{
DirHandle childdir; /* Handle for dir package I/O */
- int errorCode = 0;
+ Error errorCode = 0;
int code;
/* watch for invalid names */
return (EINVAL);
if (parentptr->disk.cloned) {
ViceLog(25, ("DeleteTarget : CopyOnWrite called\n"));
- if ((errorCode = CopyOnWrite(parentptr, volptr))) {
+ if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE))) {
ViceLog(20,
("DeleteTarget %s: CopyOnWrite failed %d\n", Name,
errorCode));
SetDirHandle(&childdir, *targetptr);
if (IsEmpty(&childdir) != 0)
return (EEXIST);
- DZap(&childdir);
+ DZap((afs_int32 *) &childdir);
FidZap(&childdir);
(*targetptr)->delete = 1;
} else if ((--(*targetptr)->disk.linkCount) == 0)
{
afs_fsize_t newlength; /* Holds new directory length */
afs_fsize_t parentLength;
- int errorCode;
+ Error errorCode;
#if FS_STATS_DETAILED
Date currDate; /*Current date */
int writeIdx; /*Write index to bump */
AdjustDiskUsage(Volume * volptr, afs_sfsize_t length,
afs_sfsize_t checkLength)
{
- int rc;
- int nc;
+ Error rc;
+ Error nc;
VAdjustDiskUsage(&rc, volptr, length, checkLength);
if (rc) {
Vnode ** targetptr, char *Name, struct AFSFid *OutFid,
int FileType, afs_sfsize_t BlocksPreallocatedForVnode)
{
- int errorCode = 0; /* Error code returned back */
- int temp;
+ Error errorCode = 0; /* Error code returned back */
+ Error temp;
Inode inode = 0;
Inode nearInode; /* hint for inode allocation in solaris */
AdjustDiskUsage(volptr, BlocksPreallocatedForVnode,
BlocksPreallocatedForVnode))) {
ViceLog(25,
- ("Insufficient space to allocate %lld blocks\n",
+ ("Insufficient space to allocate %" AFS_INT64_FMT " blocks\n",
(afs_intmax_t) BlocksPreallocatedForVnode));
return (errorCode);
}
if (parentptr->disk.cloned) {
ViceLog(25, ("Alloc_NewVnode : CopyOnWrite called\n"));
- if ((errorCode = CopyOnWrite(parentptr, volptr))) { /* disk full */
+ if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE))) { /* disk full */
ViceLog(25, ("Alloc_NewVnode : CopyOnWrite failed\n"));
/* delete the vnode previously allocated */
(*targetptr)->delete = 1;
}
afs_int32
-SRXAFS_ResidencyCmd(struct rx_call * acall, struct AFSFid * Fid,
- struct ResidencyCmdInputs * Inputs,
- struct ResidencyCmdOutputs * Outputs)
+SRXAFS_FsCmd(struct rx_call * acall, struct AFSFid * Fid,
+ struct FsCmdInputs * Inputs,
+ struct FsCmdOutputs * Outputs)
{
- return EINVAL;
+ afs_int32 code = 0;
+
+ switch (Inputs->command) {
+ default:
+ code = EINVAL;
+ }
+ ViceLog(1,("FsCmd: cmd = %d, code=%d\n",
+ Inputs->command, Outputs->code));
+ return code;
}
#ifdef AFS_NT40_ENV
Vnode *targetptr = 0; /* pointer to vnode to fetch */
Vnode *parentwhentargetnotdir = 0; /* parent vnode if vptr is a file */
Vnode tparentwhentargetnotdir; /* parent vnode for GetStatus */
- int errorCode = 0; /* return code to caller */
- int fileCode = 0; /* return code from vol package */
+ Error errorCode = 0; /* return code to caller */
+ Error fileCode = 0; /* return code from vol package */
Volume *volptr = 0; /* pointer to the volume */
struct client *client = 0; /* pointer to the client data */
struct rx_connection *tcon; /* the connection we're part of */
afs_sfsize_t tPos, tLen;
#ifdef AFS_64BIT_ENV
-#ifndef AFS_LARGEFILE_ENV
- if (Pos + Len > 0x7fffffff)
- return EFBIG;
-#endif /* !AFS_LARGEFILE_ENV */
tPos = (afs_sfsize_t) Pos;
tLen = (afs_sfsize_t) Len;
#else /* AFS_64BIT_ENV */
{
Vnode *targetptr = 0; /* pointer to vnode to fetch */
Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
- int errorCode = 0; /* return error code to caller */
+ Error errorCode = 0; /* return error code to caller */
Volume *volptr = 0; /* pointer to the volume */
struct client *client = 0; /* pointer to the client data */
afs_int32 rights, anyrights; /* rights for this and any user */
{
Vnode *targetptr = 0; /* pointer to vnode to fetch */
Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
- int errorCode = 0; /* return code to caller */
+ Error errorCode = 0; /* return code to caller */
Volume *volptr = 0; /* pointer to the volume */
struct client *client = 0; /* pointer to the client data */
afs_int32 rights, anyrights; /* rights for this and any user */
afs_int32 nfiles;
Vnode *targetptr = 0; /* pointer to vnode to fetch */
Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
- int errorCode = 0; /* return code to caller */
+ Error errorCode = 0; /* return code to caller */
Volume *volptr = 0; /* pointer to the volume */
struct client *client = 0; /* pointer to the client data */
afs_int32 rights, anyrights; /* rights for this and any user */
&rights, &anyrights)))
goto Bad_BulkStatus;
/* set volume synchronization information, but only once per call */
- if (i == nfiles)
+ if (i == 0)
SetVolumeSync(Sync, volptr);
/* Are we allowed to fetch Fid's status? */
afs_int32 nfiles;
Vnode *targetptr = 0; /* pointer to vnode to fetch */
Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
- int errorCode = 0; /* return code to caller */
+ Error errorCode = 0; /* return code to caller */
Volume *volptr = 0; /* pointer to the volume */
struct client *client = 0; /* pointer to the client data */
afs_int32 rights, anyrights; /* rights for this and any user */
struct host *thost;
struct client *t_client = NULL; /* tmp ptr to client data */
AFSFetchStatus *tstatus;
+ int VolSync_set = 0;
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
}
CallBacks->AFSCBs_len = nfiles;
+ /* Zero out return values to avoid leaking information on partial succes */
+ memset(OutStats->AFSBulkStats_val, 0, nfiles * sizeof(struct AFSFetchStatus));
+ memset(CallBacks->AFSCBs_val, 0, nfiles * sizeof(struct AFSCallBack));
+ memset(Sync, 0, sizeof(*Sync));
+
if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))) {
goto Bad_InlineBulkStatus;
}
}
/* set volume synchronization information, but only once per call */
- if (i == nfiles)
+ if (!VolSync_set) {
SetVolumeSync(Sync, volptr);
+ VolSync_set = 1;
+ }
/* Are we allowed to fetch Fid's status? */
if (targetptr->disk.type != vDirectory) {
Vnode *targetptr = 0; /* pointer to input fid */
Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
Vnode tparentwhentargetnotdir; /* parent vnode for GetStatus */
- int errorCode = 0; /* return code for caller */
- int fileCode = 0; /* return code from vol package */
+ Error errorCode = 0; /* return code for caller */
+ Error fileCode = 0; /* return code from vol package */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
afs_fsize_t tFileLength;
#ifdef AFS_64BIT_ENV
-#ifndef AFS_LARGEFILE_ENV
- if (FileLength > 0x7fffffff)
- return EFBIG;
-#endif /* !AFS_LARGEFILE_ENV */
tPos = (afs_fsize_t) Pos;
tLength = (afs_fsize_t) Length;
tFileLength = (afs_fsize_t) FileLength;
{
Vnode *targetptr = 0; /* pointer to input fid */
Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
- int errorCode = 0; /* return code for caller */
+ Error errorCode = 0; /* return code for caller */
struct AFSStoreStatus InStatus; /* Input status for fid */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
{
Vnode *targetptr = 0; /* pointer to input fid */
Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
- int errorCode = 0; /* return code for caller */
+ Error errorCode = 0; /* return code for caller */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
Vnode *targetptr = 0; /* file to be deleted */
Volume *volptr = 0; /* pointer to the volume header */
AFSFid fileFid; /* area for Fid from the directory */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
DirHandle dir; /* Handle for dir package I/O */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
Vnode *targetptr = 0; /* vnode of the new file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
Volume *volptr = 0; /* pointer to the volume header */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
DirHandle dir; /* Handle for dir package I/O */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
Vnode *newfileptr = 0; /* vnode of the file to delete */
Vnode *testvptr = 0; /* used in directory tree walk */
Vnode *parent = 0; /* parent for use in SetAccessList */
- int errorCode = 0; /* error code */
- int fileCode = 0; /* used when writing Vnodes */
+ Error errorCode = 0; /* error code */
+ Error fileCode = 0; /* used when writing Vnodes */
VnodeId testnode; /* used in directory tree walk */
AFSFid fileFid; /* Fid of file to move */
AFSFid newFileFid; /* Fid of new file */
*/
if (oldvptr->disk.cloned) {
ViceLog(25, ("Rename : calling CopyOnWrite on old dir\n"));
- if ((errorCode = CopyOnWrite(oldvptr, volptr)))
+ if ((errorCode = CopyOnWrite(oldvptr, volptr, 0, MAXFSIZE)))
goto Bad_Rename;
}
SetDirHandle(&olddir, oldvptr);
if (newvptr->disk.cloned) {
ViceLog(25, ("Rename : calling CopyOnWrite on new dir\n"));
- if ((errorCode = CopyOnWrite(newvptr, volptr)))
+ if ((errorCode = CopyOnWrite(newvptr, volptr, 0, MAXFSIZE)))
goto Bad_Rename;
}
*/
if ((fileptr->disk.type == vDirectory) && (fileptr->disk.cloned)) {
ViceLog(25, ("Rename : calling CopyOnWrite on target dir\n"));
- if ((errorCode = CopyOnWrite(fileptr, volptr)))
+ if ((errorCode = CopyOnWrite(fileptr, volptr, 0, MAXFSIZE)))
goto Bad_Rename;
}
Vnode *parentptr = 0; /* vnode of input Directory */
Vnode *targetptr = 0; /* vnode of the new link */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
int len, code = 0;
DirHandle dir; /* Handle for dir package I/O */
Volume *volptr = 0; /* pointer to the volume header */
afs_int32
-SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
- OutFidStatus, OutDirStatus, Sync)
- struct AFSVolSync *Sync;
- struct rx_call *acall; /* Rx call */
- struct AFSFid *DirFid; /* Parent dir's fid */
- char *Name; /* File name to create */
- char *LinkContents; /* Contents of the new created file */
- struct AFSStoreStatus *InStatus; /* Input status for the new symbolic link */
- struct AFSFid *OutFid; /* Fid for newly created symbolic link */
- struct AFSFetchStatus *OutFidStatus; /* Output status for new symbolic link */
- struct AFSFetchStatus *OutDirStatus; /* Output status for parent dir */
-
+SRXAFS_Symlink(struct rx_call *acall, /* Rx call */
+ struct AFSFid *DirFid, /* Parent dir's fid */
+ char *Name, /* File name to create */
+ char *LinkContents, /* Contents of the new created file */
+ struct AFSStoreStatus *InStatus, /* Input status for the new symbolic link */
+ struct AFSFid *OutFid, /* Fid for newly created symbolic link */
+ struct AFSFetchStatus *OutFidStatus, /* Output status for new symbolic link */
+ struct AFSFetchStatus *OutDirStatus, /* Output status for parent dir */
+ struct AFSVolSync *Sync)
{
afs_int32 code;
struct rx_connection *tcon;
Vnode *targetptr = 0; /* vnode of the new file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
Volume *volptr = 0; /* pointer to the volume header */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
DirHandle dir; /* Handle for dir package I/O */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
}
if (parentptr->disk.cloned) {
ViceLog(25, ("Link : calling CopyOnWrite on target dir\n"));
- if ((errorCode = CopyOnWrite(parentptr, volptr)))
+ if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE)))
goto Bad_Link; /* disk full error */
}
Vnode *targetptr = 0; /* vnode of the new file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
Volume *volptr = 0; /* pointer to the volume header */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
struct acl_accessList *newACL; /* Access list */
int newACLSize; /* Size of access list */
DirHandle dir; /* Handle for dir package I/O */
/* Actually create the New directory in the directory package */
SetDirHandle(&dir, targetptr);
- assert(!(MakeDir(&dir, OutFid, DirFid)));
+ assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid)));
DFlush();
VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
Vnode *targetptr = 0; /* file to be deleted */
AFSFid fileFid; /* area for Fid from the directory */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
DirHandle dir; /* Handle for dir package I/O */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
{
Vnode *targetptr = 0; /* vnode of input file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
{
Vnode *targetptr = 0; /* vnode of input file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
{
Vnode *targetptr = 0; /* vnode of input file */
Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
afs_int32 code;
struct rx_connection *tcon;
struct host *thost;
- afs_int32 *dataBuffP;
+ afs_uint32 *dataBuffP;
afs_int32 dataBytes;
FS_LOCK;
goto Bad_GetCaps;
dataBytes = 1 * sizeof(afs_int32);
- dataBuffP = (afs_int32 *) malloc(dataBytes);
+ dataBuffP = (afs_uint32 *) malloc(dataBytes);
dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL;
-#if defined(AFS_64BIT_ENV) && defined(AFS_LARGEFILE_ENV)
+#if defined(AFS_64BIT_ENV)
dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
#endif
if (saneacls)
int i;
afs_int32 nids, naddrs;
afs_int32 *vd, *addr;
- int errorCode = 0; /* return code to caller */
+ Error errorCode = 0; /* return code to caller */
struct client *client = 0;
- struct rx_connection *tcon = rx_ConnectionOf(acall);
ViceLog(1, ("SRXAFS_FlushCPS\n"));
FS_LOCK;
{
Vnode *targetptr = 0; /* vnode of the new file */
Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client entry */
afs_int32 rights, anyrights; /* rights for this and any user */
{
Vnode *targetptr = 0; /* vnode of the new file */
Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
- int errorCode = 0; /* error code */
+ Error errorCode = 0; /* error code */
Volume *volptr = 0; /* pointer to the volume header */
struct client *client = 0; /* pointer to client entry */
afs_int32 rights, anyrights; /* rights for this and any user */
char *temp;
struct rx_connection *tcon;
struct host *thost;
+ Error errorCode = 0;
#endif
- int errorCode = 0;
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct timeval opStartTime; /* Start time for RPC op */
)
{
struct timeval StartTime, StopTime; /* used to calculate file transfer rates */
- int errorCode = 0; /* Returned error code to caller */
+ Error errorCode = 0; /* Returned error code to caller */
IHandle_t *ihP;
FdHandle_t *fdP;
#ifdef AFS_NT40_ENV
Len = 0;
}
- if (Pos + Len > tlen)
- Len = tlen - Pos; /* get length we should send */
+ if (Pos + Len > tlen) /* get length we should send */
+ Len = ((tlen - Pos) < 0) ? 0 : tlen - Pos;
+
(void)FDH_SEEK(fdP, Pos, 0);
{
afs_int32 high, low;
{
afs_sfsize_t bytesTransfered; /* number of bytes actually transfered */
struct timeval StartTime, StopTime; /* Used to measure how long the store takes */
- int errorCode = 0; /* Returned error code to caller */
+ Error errorCode = 0; /* Returned error code to caller */
#ifdef AFS_NT40_ENV
register char *tbuffer; /* data copying buffer */
#else /* AFS_NT40_ENV */
afs_fsize_t NewLength; /* size after this store completes */
afs_sfsize_t adjustSize; /* bytes to call VAdjust... with */
int linkCount = 0; /* link count on inode */
- FdHandle_t *fdP;
+ afs_fsize_t CoW_off, CoW_len;
+ FdHandle_t *fdP, *origfdP = NULL;
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
#if FS_STATS_DETAILED
* mechanisms (i.e. copy on write overhead.) Also the right size
* of the disk will be recorded...
*/
- FDH_CLOSE(fdP);
+ origfdP = fdP;
VN_GET_LEN(size, targetptr);
volptr->partition->flags &= ~PART_DONTUPDATE;
VSetPartitionDiskUsage(volptr->partition);
volptr->partition->flags |= PART_DONTUPDATE;
if ((errorCode = VDiskUsage(volptr, nBlocks(size)))) {
volptr->partition->flags &= ~PART_DONTUPDATE;
+ FDH_CLOSE(origfdP);
return (errorCode);
}
- ViceLog(25, ("StoreData : calling CopyOnWrite on target dir\n"));
- if ((errorCode = CopyOnWrite(targetptr, volptr))) {
+ CoW_len = (FileLength >= (Length + Pos)) ? FileLength - Length : Pos;
+ CopyOnWrite_calls++;
+ if (CoW_len == 0) CopyOnWrite_size0++;
+ if (Pos == 0) CopyOnWrite_off0++;
+ if (CoW_len > CopyOnWrite_maxsize) CopyOnWrite_maxsize = CoW_len;
+
+ ViceLog(1, ("StoreData : calling CopyOnWrite on vnode %u.%u (%s) "
+ "off 0x0 size 0x%llx\n",
+ afs_printable_VolumeId_u(V_id(volptr)),
+ afs_printable_VnodeId_u(targetptr->vnodeNumber),
+ V_name(volptr), Pos));
+ if ((errorCode = CopyOnWrite(targetptr, volptr, 0, Pos))) {
ViceLog(25, ("StoreData : CopyOnWrite failed\n"));
volptr->partition->flags &= ~PART_DONTUPDATE;
+ FDH_CLOSE(origfdP);
return (errorCode);
}
volptr->partition->flags &= ~PART_DONTUPDATE;
if (fdP == NULL) {
ViceLog(25,
("StoreData : Reopen after CopyOnWrite failed\n"));
+ FDH_CLOSE(origfdP);
return ENOENT;
}
}
AdjustDiskUsage(volptr, adjustSize,
adjustSize - SpareComp(volptr)))) {
FDH_CLOSE(fdP);
+ if (origfdP) FDH_CLOSE(origfdP);
return (errorCode);
}
#else /* AFS_NT40_ENV */
errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, rlen);
#endif /* AFS_NT40_ENV */
-#if FS_STATS_DETAILED
- (*a_bytesStoredP) += errorCode;
-#endif /* FS_STATS_DETAILED */
if (errorCode <= 0) {
errorCode = -32;
break;
}
+#if FS_STATS_DETAILED
+ (*a_bytesStoredP) += errorCode;
+#endif /* FS_STATS_DETAILED */
rlen = errorCode;
#ifdef AFS_NT40_ENV
errorCode = FDH_WRITE(fdP, tbuffer, rlen);
* need to update the target vnode.
*/
targetptr->changed_newTime = 1;
+ if (origfdP && (bytesTransfered < Length)) /* Need to "finish" CopyOnWrite still */
+ CopyOnWrite2(origfdP, fdP, Pos + bytesTransfered, NewLength - Pos - bytesTransfered);
+ if (origfdP) FDH_CLOSE(origfdP);
FDH_CLOSE(fdP);
/* set disk usage to be correct */
VAdjustDiskUsage(&errorCode, volptr,
nBlocks(NewLength)), 0);
return errorCode;
}
+ if (origfdP) { /* finish CopyOnWrite */
+ if ( (CoW_off = Pos + Length) < NewLength) {
+ errorCode = CopyOnWrite2(origfdP, fdP, CoW_off, CoW_len = NewLength - CoW_off);
+ ViceLog(1, ("StoreData : CopyOnWrite2 on vnode %u.%u (%s) "
+ "off 0x%llx size 0x%llx returns %d\n",
+ afs_printable_VolumeId_u(V_id(volptr)),
+ afs_printable_VnodeId_u(targetptr->vnodeNumber),
+ V_name(volptr), CoW_off, CoW_len, errorCode));
+ }
+ FDH_CLOSE(origfdP);
+ }
FDH_CLOSE(fdP);
FT_GetTimeOfDay(&StopTime, 0);
struct rx_connection *conn;
#endif
- if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &tcallhost))
+ if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &tcallhost)))
goto Bad_CallBackRxConnAddr1;
#ifndef __EXPERIMENTAL_CALLBACK_CONN_MOVING
return 0;
if (in < 0 || in > 511)
return in;
- if (in >= VICE_SPECIAL_ERRORS && in <= VIO || in == VRESTRICTED)
+ if ((in >= VICE_SPECIAL_ERRORS && in <= VIO) || in == VRESTRICTED)
return in;
if (sys2et[in] != 0)
return sys2et[in];