Hello List,
together with a user and Hartmut, I guess I found a bug in the function
afs_TruncateAllSegments() in afs_segments.c.
Basically, the pointers (struct dcache *)->validPos and (struct dcache
*)->f.chunkBytes are not kept in sync.
Here the patch :
diff -ur /usr/src/openafs-1.3.71/src/afs/afs_segments.c afs_segments.c
--- /usr/src/openafs-1.3.71/src/afs/afs_segments.c 2004-08-25 09:09:32.000000000
+0200
+++ afs_segments.c 2004-09-10 12:18:08.000000000 +0200
@@ -1041,6 +1041,12 @@
afs_CFileTruncate(tfile, newSize);
afs_CFileClose(tfile);
afs_AdjustSize(tdc, newSize);
+ if (alen < tdc->validPos) {
+ if (alen < AFS_CHUNKTOBASE(tdc->f.chunk))
+ tdc->validPos = 0;
+ else
+ tdc->validPos = alen;
+ }
ConvertWToSLock(&tdc->lock);
}
ReleaseSharedLock(&tdc->lock);
My guess is that the same bug is in the 1.2.x-series as well.
The consequences of this bug can be tested with this program
(you have to set the macro !) :
On rh9 or suse 9.0 on a single CPU machine it gives an i/o-error,
a SMP machine freezes. (At least for me)
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#define FILE_IN_AFS "ABSOLUTE_PATH_TO_AFS_FILE"
int main() {
FILE *fp;
int i,fd;
char fname[]= FILE_IN_AFS;
char pr_string[]=" Hallo\n";
off_t size=0;
fp =fopen(fname,"w+");
for (i=0;i < 1000;i++)
fprintf(fp," Hallo\n");
fclose(fp);
fp =fopen(fname,"a");
fd=fileno(fp);
rewind(fp);
for (i=0;i < 50;i++)
size+=sizeof(pr_string);
fprintf(fp,pr_string);
fflush(fp);
ftruncate(fd,size);
fclose(fp);
return 0;
}
I hope that helps.
Christof Hanke
-----------------------------------------------------------------
Christof Hanke e-mail [EMAIL PROTECTED]
RZG (Rechenzentrum Garching) phone +49-89-3299-1788
Computing Center of the Max-Planck-Gesellschaft (MPG) and the
Institut f�r Plasmaphysik (IPP)
_______________________________________________
OpenAFS-devel mailing list
[EMAIL PROTECTED]
https://lists.openafs.org/mailman/listinfo/openafs-devel