largefile-2nd-try-base-work-20030602
authorR. Lindsay Todd <toddr@rpi.edu>
Mon, 2 Jun 2003 15:27:54 +0000 (15:27 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 2 Jun 2003 15:27:54 +0000 (15:27 +0000)
FIXES 1433

another try at largefile support. macroize so things can be easily cut over

src/config/stds.h
src/viced/afsfileprocs.c
src/vol/vnode.h
src/vol/vol-info.c
src/vol/vol-salvage.c
src/volser/dumpstuff.c
src/volser/volprocs.c

index 7e8b4ff..9dba378 100644 (file)
@@ -93,6 +93,18 @@ typedef afs_int32 afs_size_t;
 typedef afs_uint32 afs_offs_t;
 #endif /* AFS_64BIT_CLIENT */
 
+#ifdef AFS_LARGEFILE_ENV
+typedef afs_int64 afs_foff_t;
+typedef afs_uint64 afs_fsize_t;
+typedef afs_int64 afs_sfsize_t;
+#define SplitOffsetOrSize(t,h,l) SplitInt64(t,h,l)
+#else /* !AFS_LARGEFILE_ENV */
+typedef afs_int32 afs_foff_t;
+typedef afs_uint32 afs_fsize_t;
+typedef afs_int32 afs_sfsize_t;
+#define SplitOffsetOrSize(t,h,l) (h) = 0; (l) = (t);
+#endif /* !AFS_LARGEFILE_ENV */
+
 /* you still have to include <netinet/in.h> to make these work */
 
 #define hton32 htonl
index e66c8d4..c777161 100644 (file)
@@ -1020,7 +1020,7 @@ static int CopyOnWrite(Vnode *targetptr, Volume *volptr)
 
     if (targetptr->disk.type ==        vDirectory) DFlush();   /* just in case? */
 
-    size = targetptr->disk.length;
+    VN_GET_LEN(size, targetptr);
     buff = (char *)malloc(COPYBUFFSIZE);
     if (buff == NULL) {
        return EIO;
@@ -1236,8 +1236,12 @@ DeleteTarget(Vnode *parentptr,
            }
        }
        VN_SET_INO(*targetptr, (Inode)0);
-       VAdjustDiskUsage(&errorCode, volptr,
-                       -(int)nBlocks((*targetptr)->disk.length), 0);
+       {
+           afs_fsize_t adjLength;
+           VN_GET_LEN(adjLength, *targetptr);
+           VAdjustDiskUsage(&errorCode, volptr,
+                            -(int)nBlocks(adjLength), 0);
+       }
     }
     
     (*targetptr)->changed_newTime = 1; /* Status change of deleted file/dir */
@@ -1275,7 +1279,8 @@ Update_ParentVnodeStatus(Vnode *parentptr,
 #endif /* FS_STATS_DETAILED */
                         )
 {
-    afs_uint32 newlength;      /* Holds new directory length */
+    afs_fsize_t newlength;     /* Holds new directory length */
+    afs_fsize_t parentLength;
     int errorCode;
 #if FS_STATS_DETAILED
     Date currDate;             /*Current date*/
@@ -1291,11 +1296,13 @@ Update_ParentVnodeStatus(Vnode *parentptr,
      * XXX But we still don't check the error since we're dealing with dirs here and really the increase
      * of a new entry would be too tiny to worry about failures (since we have all the existing cushion)
      */
-    if (nBlocks(newlength) != nBlocks(parentptr->disk.length))
+    VN_GET_LEN(parentLength, parentptr);
+    if (nBlocks(newlength) != nBlocks(parentLength)) {
        VAdjustDiskUsage(&errorCode, volptr, 
-                        (int)(nBlocks(newlength) - nBlocks(parentptr->disk.length)),
-                        (int)(nBlocks(newlength) - nBlocks(parentptr->disk.length)));
-    parentptr->disk.length = newlength;
+                        (nBlocks(newlength) - nBlocks(parentLength)),
+                        (nBlocks(newlength) - nBlocks(parentLength)));
+    }
+    VN_SET_LEN(parentptr, newlength);
 
 #if FS_STATS_DETAILED
     /*
@@ -1354,7 +1361,7 @@ Update_TargetVnodeStatus(Vnode *targetptr,
                         AFSStoreStatus *InStatus,
                         Vnode *parentptr,
                         Volume *volptr,
-                        afs_int32 length)
+                        afs_fsize_t length)
 {
 #if FS_STATS_DETAILED
     Date currDate;             /*Current date*/
@@ -1364,7 +1371,7 @@ Update_TargetVnodeStatus(Vnode *targetptr,
 
     if (Caller & (TVS_CFILE|TVS_SLINK|TVS_MKDIR))      {   /* initialize new file */
        targetptr->disk.parent = parentptr->vnodeNumber;
-       targetptr->disk.length = length;
+       VN_SET_LEN(targetptr, length);
        /* targetptr->disk.group =      0;  save some cycles */
        targetptr->disk.modeBits = 0777;
        targetptr->disk.owner = client->ViceId;
@@ -1990,8 +1997,11 @@ void GetStatus(Vnode *targetptr,
     else
        status->FileType = Invalid;                     /*invalid type field */
     status->LinkCount = targetptr->disk.linkCount;
-    status->Length_hi = 0;
-    status->Length = targetptr->disk.length;
+    {
+       afs_fsize_t targetLen;
+       VN_GET_LEN(targetLen, targetptr);
+       SplitOffsetOrSize(targetLen, status->Length_hi, status->Length);
+    }
     status->DataVersion = targetptr->disk.dataVersion;
     status->Author = targetptr->disk.author;
     status->Owner = targetptr->disk.owner;
@@ -2828,15 +2838,15 @@ Bad_FetchStatus:
 
 } /*SRXAFS_FetchStatus*/
 
-
-afs_int32 SRXAFS_StoreData (struct rx_call *acall,             
-                           struct AFSFid *Fid,                 
-                           struct AFSStoreStatus *InStatus,    
-                           afs_uint32 Pos,                     
-                           afs_uint32 Length,                  
-                           afs_uint32 FileLength,              
-                           struct AFSFetchStatus *OutStatus,   
-                           struct AFSVolSync *Sync)
+static
+afs_int32 common_StoreData64 (struct rx_call *acall,           
+                             struct AFSFid *Fid,                       
+                             struct AFSStoreStatus *InStatus,  
+                             afs_uint32 Pos,                     
+                             afs_uint32 Length,                  
+                             afs_uint32 FileLength,              
+                             struct AFSFetchStatus *OutStatus, 
+                             struct AFSVolSync *Sync)
 {
     Vnode * targetptr =        0;              /* pointer to input fid */
     Vnode * parentwhentargetnotdir = 0;        /* parent of Fid to get ACL */
@@ -3058,6 +3068,23 @@ Bad_StoreData:
     osi_auditU (acall, StoreDataEvent, errorCode, AUD_FID, Fid, AUD_END);
     return(errorCode);
 
+} /*common_StoreData64*/
+
+afs_int32 SRXAFS_StoreData (struct rx_call *acall,             
+                           struct AFSFid *Fid,                 
+                           struct AFSStoreStatus *InStatus,    
+                           afs_uint32 Pos,                     
+                           afs_uint32 Length,                  
+                           afs_uint32 FileLength,              
+                           struct AFSFetchStatus *OutStatus,   
+                           struct AFSVolSync *Sync)
+{
+    int code;
+
+    code = common_StoreData64 (acall, Fid, InStatus, Pos, Length, FileLength,
+                              OutStatus, Sync);
+    return code;
+
 } /*SRXAFS_StoreData*/
 
 afs_int32 SRXAFS_StoreData64 (struct rx_call *acall,           
@@ -3088,8 +3115,8 @@ afs_int32 SRXAFS_StoreData64 (struct rx_call *acall,
     tFileLength = FileLength.low;
 #endif /* AFS_64BIT_ENV */
 
-    code = SRXAFS_StoreData (acall, Fid, InStatus, tPos, tLength, tFileLength,
-                             OutStatus, Sync);
+    code = common_StoreData64 (acall, Fid, InStatus, tPos, tLength, tFileLength,
+                              OutStatus, Sync);
     return code;
 }
 
@@ -3947,8 +3974,9 @@ SAFSS_Rename (struct rx_call *acall,
        /* Drop the link count */
        newfileptr->disk.linkCount--;
        if (newfileptr->disk.linkCount == 0) {      /* Link count 0 - delete */
-           VAdjustDiskUsage(&errorCode, volptr,
-                            -(int)nBlocks(newfileptr->disk.length), 0);
+           afs_fsize_t newSize;
+           VN_GET_LEN(newSize, newfileptr);
+           VAdjustDiskUsage(&errorCode, volptr, -nBlocks(newSize), 0);
            if (VN_GET_INO(newfileptr)) {
                IH_REALLYCLOSE(newfileptr->handle);
                errorCode = IH_DEC(V_linkHandle(volptr),
@@ -4645,7 +4673,7 @@ SAFSS_MakeDir (struct rx_call *acall,
     SetDirHandle(&dir, targetptr);
     assert(!(MakeDir(&dir, OutFid, DirFid)));
     DFlush();
-    targetptr->disk.length = Length(&dir);
+    VN_SET_LEN(targetptr, Length(&dir));
 
     /* set up return status */
     GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
@@ -6709,16 +6737,20 @@ FetchData_RXStyle(Volume *volptr,
        AFSCallStats.TotalFetchedBytes = AFSCallStats.AccumFetchTime = 0;
     AFSCallStats.AccumFetchTime += ((StopTime.tv_sec - StartTime.tv_sec) * 1000) +
       ((StopTime.tv_usec - StartTime.tv_usec) / 1000);
-    AFSCallStats.TotalFetchedBytes += targetptr->disk.length;
-    AFSCallStats.FetchSize1++;
-    if (targetptr->disk.length < SIZE2)
-       AFSCallStats.FetchSize2++;  
-    else if (targetptr->disk.length < SIZE3)
-       AFSCallStats.FetchSize3++;
-    else if (targetptr->disk.length < SIZE4)
-       AFSCallStats.FetchSize4++;  
-    else
-       AFSCallStats.FetchSize5++;
+    {
+       afs_fsize_t     targLen;
+       VN_GET_LEN(targLen, targetptr);
+       AFSCallStats.TotalFetchedBytes += targLen;
+       AFSCallStats.FetchSize1++;
+       if (targLen < SIZE2)
+           AFSCallStats.FetchSize2++;  
+       else if (targLen < SIZE3)
+           AFSCallStats.FetchSize3++;
+       else if (targLen < SIZE4)
+           AFSCallStats.FetchSize4++;  
+       else
+           AFSCallStats.FetchSize5++;
+    }
     FS_UNLOCK
     return (0);
 
@@ -6850,7 +6882,7 @@ StoreData_RXStyle(Volume *volptr,
        }
        
        if (linkCount != 1) {
-           afs_uint32 size;
+           afs_fsize_t size;
            ViceLog(25, ("StoreData_RXStyle : inode %s has more than onelink\n",
                         PrintInode(NULL, VN_GET_INO(targetptr))));
            /* other volumes share this data, better copy it first */
@@ -6862,7 +6894,7 @@ StoreData_RXStyle(Volume *volptr,
             * of the disk will be recorded...
             */
            FDH_CLOSE(fdP);
-           size = targetptr->disk.length;
+           VN_GET_LEN(size, targetptr);
            volptr->partition->flags &= ~PART_DONTUPDATE;
            VSetPartitionDiskUsage(volptr->partition);
            volptr->partition->flags |= PART_DONTUPDATE;
@@ -6900,7 +6932,11 @@ StoreData_RXStyle(Volume *volptr,
        NewLength = Pos+Length;   /* and write */
 
     /* adjust the disk block count by the difference in the files */
-    adjustSize = (int) (nBlocks(NewLength) - nBlocks(targetptr->disk.length));
+    {
+       afs_fsize_t     targSize;
+       VN_GET_LEN(targSize, targetptr);
+       adjustSize = nBlocks(NewLength) - nBlocks(targSize);
+    }
     if((errorCode = AdjustDiskUsage(volptr, adjustSize,
                                   adjustSize - SpareComp(volptr)))) {
        FDH_CLOSE(fdP);
@@ -6982,8 +7018,9 @@ StoreData_RXStyle(Volume *volptr,
       FDH_SYNC(fdP);
     }
     if (errorCode) {
+       afs_fsize_t     nfSize = FDH_SIZE(fdP);
        /* something went wrong: adjust size and return */
-       targetptr->disk.length = FDH_SIZE(fdP); /* set new file size. */
+       VN_SET_LEN(targetptr, nfSize); /* set new file size. */
        /* changed_newTime is tested in StoreData to detemine if we
         * need to update the target vnode.
         */
@@ -6991,29 +7028,32 @@ StoreData_RXStyle(Volume *volptr,
        FDH_CLOSE(fdP);
        /* set disk usage to be correct */
        VAdjustDiskUsage(&errorCode, volptr,
-                        (int)(nBlocks(targetptr->disk.length)
-                              - nBlocks(NewLength)), 0);
+                        (int)(nBlocks(nfSize) - nBlocks(NewLength)), 0);
        return errorCode;
     }
     FDH_CLOSE(fdP);
 
     TM_GetTimeOfDay(&StopTime, 0);
 
-    targetptr->disk.length = NewLength;
+    VN_SET_LEN(targetptr, NewLength);
 
     /* Update all StoreData related stats */
     FS_LOCK
     if (AFSCallStats.TotalStoredBytes >        2000000000)     /* reset if over 2 billion */
        AFSCallStats.TotalStoredBytes = AFSCallStats.AccumStoreTime = 0;
     AFSCallStats.StoreSize1++;                 /* Piggybacked data */
-    if (targetptr->disk.length < SIZE2)
-       AFSCallStats.StoreSize2++;
-    else if (targetptr->disk.length < SIZE3)
-       AFSCallStats.StoreSize3++;
-    else if (targetptr->disk.length < SIZE4)
-       AFSCallStats.StoreSize4++;
-    else
-       AFSCallStats.StoreSize5++;
+    {
+       afs_fsize_t     targLen;
+       VN_GET_LEN(targLen, targetptr);
+       if (targLen < SIZE2)
+           AFSCallStats.StoreSize2++;
+       else if (targLen < SIZE3)
+           AFSCallStats.StoreSize3++;
+       else if (targLen < SIZE4)
+           AFSCallStats.StoreSize4++;
+       else
+           AFSCallStats.StoreSize5++;
+    }
     FS_UNLOCK
     return(errorCode);
 
index b8058c3..0dabc61 100644 (file)
@@ -154,6 +154,18 @@ typedef struct Vnode {
        (sizeof(struct Vnode) - sizeof(VnodeDiskObject) + SIZEOF_LARGEDISKVNODE)
 #define SIZEOF_SMALLVNODE      (sizeof (struct Vnode))
 
+#ifdef AFS_LARGEFILE_ENV
+#define VN_GET_LEN(N, V) FillInt64(N, (V)->disk.reserved6, (V)->disk.length)
+#define VNDISK_GET_LEN(N, V) FillInt64(N, (V)->reserved6, (V)->length)
+#define VN_SET_LEN(V, N) SplitInt64(N, (V)->disk.reserved6, (V)->disk.length)
+#define VNDISK_SET_LEN(V, N) SplitInt64(N, (V)->reserved6, (V)->length)
+#else /* !AFS_LARGEFILE_ENV */
+#define VN_GET_LEN(N, V) (N) = (V)->disk.length;
+#define VNDISK_GET_LEN(N, V) (N) = (V)->length;
+#define VN_SET_LEN(V, N) (V)->disk.length = (N);
+#define VNDISK_SET_LEN(V, N) (V)->length = (N);
+#endif /* !AFS_LARGEFILE_ENV */
+
 #ifdef AFS_64BIT_IOPS_ENV
 #define VN_GET_INO(V) ((Inode)((V)->disk.vn_ino_lo | \
                               ((V)->disk.vn_ino_hi ? \
index 641961e..27c771f 100644 (file)
@@ -238,9 +238,9 @@ static int handleit(struct cmd_syndesc *as)
        InodeTimes = 1;
     else    
        InodeTimes = 0;
-    if (ti = as->parms[5].items)
+    if ((ti = as->parms[5].items))
        partName = ti->data;
-    if (ti = as->parms[6].items)
+    if ((ti = as->parms[6].items))
        volumeId = atoi(ti->data);
     if (as->parms[7].items)
        dheader = 1;
@@ -815,11 +815,14 @@ void PrintVnode(int offset, VnodeDiskObject *vnode, int vnodeNumber, Inode ino)
     char filename[MAX_PATH];
 #endif
 #endif
-    Vvnodesize += vnode->length;
+    afs_fsize_t fileLength;
+
+    VNDISK_GET_LEN(fileLength, vnode);
+    Vvnodesize += fileLength;
     if (dsizeOnly) return;
-    if (orphaned && (vnode->length ==0 || vnode->parent || !offset)) return;
+    if (orphaned && (fileLength ==0 || vnode->parent || !offset)) return;
     printf("%10d Vnode %u.%u.%u cloned: %d, length: %d linkCount: %d parent: %d",
-        offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion, vnode->cloned, vnode->length, vnode->linkCount, vnode->parent);
+        offset, vnodeNumber, vnode->uniquifier, vnode->dataVersion, vnode->cloned, fileLength, vnode->linkCount, vnode->parent);
     if (DumpInodeNumber)
        printf(" inode: %s", PrintInode(NULL, ino));
     if (DumpDate)
index 9d894a8..923ae2e 100644 (file)
@@ -2315,7 +2315,8 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
     int err = 0;
     StreamHandle_t *file;
     struct VnodeClassInfo *vcp;
-    int size;
+    afs_sfsize_t size;
+    afs_fsize_t vnodeLength;
     int vnodeIndex, nVnodes;
     afs_ino_str_t stmp1, stmp2;
     IHandle_t *handle;
@@ -2491,16 +2492,17 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW,
                        VNDISK_SET_INO(vnode, ip->inodeNumber);
                        vnodeChanged = 1;
                    }
-                   if (ip->byteCount != vnode->length) {
+                   VNDISK_GET_LEN(vnodeLength, vnode);
+                   if (ip->byteCount != vnodeLength) {
                        if (check) {
                            if (!Showmode) Log("Vnode %d: length incorrect; (is %d should be %d)\n",
-                                              vnodeNumber, vnode->length, ip->byteCount);
+                                              vnodeNumber, vnodeLength, ip->byteCount);
                            err = -1;
                            goto zooks;
                        }
                        if (!Showmode) Log("Vnode %d: length incorrect; changed from %d to %d\n",
-                                          vnodeNumber, vnode->length, ip->byteCount);
-                       vnode->length = ip->byteCount;
+                                          vnodeNumber, vnodeLength, ip->byteCount);
+                       VNDISK_SET_LEN(vnode, ip->byteCount);
                        vnodeChanged = 1;
                    }
                    if (!check)
@@ -2684,7 +2686,7 @@ void CopyAndSalvage(register struct DirSummary *dir)
     }
     vnode.cloned = 0;
     VNDISK_SET_INO(&vnode, newinode);
-    vnode.length = Length(&newdir);
+    VNDISK_SET_LEN(&vnode, Length(&newdir));
     code = IH_IWRITE(vnodeInfo[vLarge].handle,
                    vnodeIndexOffset(vcp, dir->vnodeNumber),
                    (char*)&vnode, sizeof (vnode));
@@ -2988,9 +2990,11 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino,
       nVnodes--, vnodeIndex++) {
        if (vnode->type != vNull) {
            register struct VnodeEssence *vep = &vip->vnodes[vnodeIndex];
+           afs_fsize_t vnodeLength;
            vip->nAllocatedVnodes++;
            vep->count = vnode->linkCount;
-           vep->blockCount = nBlocks(vnode->length);
+           VNDISK_GET_LEN(vnodeLength, vnode);
+           vep->blockCount = nBlocks(vnodeLength);
            vip->volumeBlockCount += vep->blockCount;
            vep->parent = vnode->parent;
            vep->unique = vnode->uniquifier;
index 831cb53..f61c653 100644 (file)
@@ -765,9 +765,10 @@ int ProcessIndex(Volume *vp, VnodeClass class, afs_int32 **Bufp, int *sizep,
                    if (vnode->type != vNull && VNDISK_GET_INO(vnode)) {
                        cnt1++;
                        if (DoLogging) {
+                          afs_fsize_t vnodeLength;
                           Log("RestoreVolume %d Cleanup: Removing old vnode=%d inode=%d size=%d\n", 
                               V_id(vp), bitNumberToVnodeNumber(i,class),
-                              VNDISK_GET_INO(vnode), vnode->length);
+                              VNDISK_GET_INO(vnode), vnodeLength);
                        }
                        IH_DEC(V_linkHandle(vp), VNDISK_GET_INO(vnode),
                             V_parentId(vp));
@@ -980,6 +981,7 @@ static int ReadVnodes(register struct iod *iodp, Volume *vp,
                case 'f': {
                    Inode ino;
                    Error error;
+                   afs_fsize_t vnodeLength;
 
                    ino = IH_CREATE(V_linkHandle(vp),
                                    V_device(vp),
@@ -1000,8 +1002,9 @@ static int ReadVnodes(register struct iod *iodp, Volume *vp,
                        IH_RELEASE(tmpH);
                        return VOLSERREAD_DUMPERROR;
                    }
-                   vnode->length = volser_WriteFile(vnodeNumber, iodp, fdP,
-                                                    &error);
+                   vnodeLength = volser_WriteFile(vnodeNumber, iodp, fdP,
+                                                  &error);
+                   VNDISK_SET_LEN(vnode, vnodeLength);
                    FDH_REALLYCLOSE(fdP);
                    IH_RELEASE(tmpH);
                    if (error) {
index 5bad0c1..f5cdd38 100644 (file)
@@ -197,7 +197,7 @@ Volume      * vp;
     IHandle_t *h;
     FdHandle_t *fdP;
     int code;
-    int length;
+    afs_fsize_t length;
 
     memset(vnode, 0, SIZEOF_LARGEDISKVNODE);    
 
@@ -236,7 +236,7 @@ Volume      * vp;
     vnode->cloned = 0;
     vnode->modeBits = 0777;
     vnode->linkCount = 2;
-    vnode->length = length;
+    VNDISK_SET_LEN(vnode, length);
     vnode->uniquifier = 1;
     V_uniquifier(vp) = vnode->uniquifier+1;
     vnode->dataVersion = 1;
@@ -257,7 +257,8 @@ Volume      * vp;
     assert(code == SIZEOF_LARGEDISKVNODE);
     FDH_REALLYCLOSE(fdP);
     IH_RELEASE(h);
-    V_diskused(vp) = nBlocks(vnode->length);
+    VNDISK_GET_LEN(length, vnode);
+    V_diskused(vp) = nBlocks(length);
 
     return 1;
 }