[OpenAFS-devel] Client bug in afs_segments.c

Hartmut Reuter reuter@rzg.mpg.de
Fri, 10 Sep 2004 15:41:20 +0200


Christof forgot to mention one detail of this error:

The I/O erorr or freezing of the client happens only if you try to copy=20
the file
after it has been created by the test program!

Hartmut

Christof Hanke wrote:
> Hello List,
>=20
> 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.
>=20
> Here the patch :
>=20
> 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:0=
9: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 =3D 0;
> +                else
> +                    tdc->validPos =3D alen;
> +            }
>             ConvertWToSLock(&tdc->lock);
>         }
>         ReleaseSharedLock(&tdc->lock);
> My guess is that the same bug is in the 1.2.x-series as well.
>=20
> The consequences of this bug can be tested with this program
> (you have to set the macro !) :
>=20
> 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)
> =20
>=20
> #include <stdio.h>
> #include <unistd.h>
> #include <sys/types.h>
>=20
> #define FILE_IN_AFS "ABSOLUTE_PATH_TO_AFS_FILE"
>=20
> int main() {
>   FILE *fp;
>   int i,fd;
>   char fname[]=3D FILE_IN_AFS;
>   char pr_string[]=3D" Hallo\n";
>   off_t size=3D0;
>   fp =3Dfopen(fname,"w+");
>   for (i=3D0;i < 1000;i++)
>      fprintf(fp," Hallo\n");
>   fclose(fp);
>   fp =3Dfopen(fname,"a");
>   fd=3Dfileno(fp);
>   rewind(fp);
>   for (i=3D0;i < 50;i++)
>      size+=3Dsizeof(pr_string);
>      fprintf(fp,pr_string);
>   fflush(fp);
>   ftruncate(fd,size);
>   fclose(fp);
>  return 0;
> }
>=20
>=20
> I hope that helps.
>=20
> Christof Hanke
>=20
> -----------------------------------------------------------------
> Christof Hanke                 		e-mail hanke@rzg.mpg.de
> RZG (Rechenzentrum Garching)		phone +49-89-3299-1788
> Computing Center of the Max-Planck-Gesellschaft (MPG) and the
> Institut f=EF=BF=BDr Plasmaphysik (IPP)
>=20
>=20
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel


--=20
-----------------------------------------------------------------
Hartmut Reuter                           e-mail reuter@rzg.mpg.de
					   phone +49-89-3299-1328
RZG (Rechenzentrum Garching)               fax   +49-89-3299-1301
Computing Center of the Max-Planck-Gesellschaft (MPG) and the
Institut fuer Plasmaphysik (IPP)
-----------------------------------------------------------------