[PVFS-developers] Fix for Cached File Sizes
Porter Don
PorterDE@mercury.hendrix.edu
Mon, 15 Dec 2003 16:59:23 -0600
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C3C35F.14993440
Content-Type: text/plain
Another bug recently uncovered by Martin K. Petersen is that when one
truncates a file, the size is not updated on the manager until the file is
opened and closed.
Attached is a patch which updates the file size stored on the manager upon a
successful truncation.
Also, there was a note that there wasn't any permission checking on this
file, so I added a call to meta_access to check for write permission.
Thanks,
Don Porter
------_=_NextPart_000_01C3C35F.14993440
Content-Type: application/octet-stream;
name="truncate-1.6.2.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="truncate-1.6.2.patch"
diff -ur pvfs-1.6.2/mgr/mgr.c pvfs-1.6.2.trunc/mgr/mgr.c=0A=
--- pvfs-1.6.2/mgr/mgr.c Mon Nov 24 19:51:43 2003=0A=
+++ pvfs-1.6.2.trunc/mgr/mgr.c Mon Dec 15 16:17:05 2003=0A=
@@ -538,13 +538,12 @@=0A=
/* get metadata, check permission to write to file */=0A=
if ((fd =3D meta_open(data_p, O_RDONLY)) < 0=0A=
|| (meta_read(fd, &meta) < 0)=0A=
+ || ((meta_access(fd, data_p, req_p->uid, req_p->gid, W_OK)) < 0)=0A=
|| (meta_close(fd) < 0))=0A=
{=0A=
return(send_error(-1, errno, sock, ack_p));=0A=
}=0A=
=0A=
- /* for the moment permissions aren't checked... */=0A=
-=0A=
/* build request for iods, send it */=0A=
memset(&iodreq, 0, sizeof(iodreq));=0A=
iodreq.majik_nr =3D IOD_MAJIK_NR;=0A=
@@ -561,6 +560,21 @@=0A=
{=0A=
return(send_error(ret, errno, sock, ack_p));=0A=
} =0A=
+=0A=
+#ifdef FAST_STATS=0A=
+ meta.u_stat.st_size =3D req_p->req.truncate.length;=0A=
+ meta.fsize =3D req_p->req.truncate.length;=0A=
+=0A=
+ /* write metadata*/=0A=
+ if ((fd =3D meta_open(data_p, O_RDONLY)) < 0=0A=
+ || (meta_write(fd, &meta) < 0)=0A=
+ || (meta_close(fd) < 0))=0A=
+ {=0A=
+ return(send_error(-1, errno, sock, ack_p));=0A=
+ }=0A=
+ =0A=
+#endif=0A=
+=0A=
if (sock >=3D 0) /* real socket number, send the ack */ {=0A=
ret =3D bsend(sock, ack_p, sizeof(mack));=0A=
if (ret < 0) return(-1);=0A=
------_=_NextPart_000_01C3C35F.14993440--