[574] in Athena Bugs
[Chris Torek: Re: Is write(2) "atomic" ?]
daemon@ATHENA.MIT.EDU (Ken Raeburn)
Mon Aug 1 19:55:52 1988
Date: Mon, 1 Aug 88 19:55:09 EDT
From: Ken Raeburn <raeburn@ATHENA.MIT.EDU>
To: "Bugs `R' Us" <bugs@ATHENA.MIT.EDU>, John T Kohl <jtkohl@ATHENA.MIT.EDU>
I believe this is in relation to opening files with O_APPEND ("append
on each write"); we should check both our current code and the new NFS
code to see if ours has the problem as well.
------- Forwarded Message
From: <raeburn@ATHENA.MIT.EDU>
Date: Sun, 17 Jul 88 16:00:58 EDT
To: raeburn@ATHENA.MIT.EDU
Path: bloom-beacon!tut.cis.ohio-state.edu!husc6!uwvax!oddjob!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.unix.wizards
Subject: Re: Is write(2) "atomic" ?
Message-ID: <12471@mimsy.UUCP>
Date: 14 Jul 88 15:11:47 GMT
References: <11410005@eecs.nwu.edu> <11410006@eecs.nwu.edu>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 49
In article <11410006@eecs.nwu.edu> naim@eecs.nwu.edu (Naim Abdullah) writes:
>Chris Torek pointed out that the fact that concurrent writes may
>result in loss of data, is due to a bug in 4.2BSD. The bug persists
>in 4.3BSD (at least in Mt. Xinu's 4.3+NFS).
Sure enough, it does. (I should have checked my own RCS files...) I
copied the fix for this in January. Here it is:
[/sys/sys/sys_inode.c]
*** /tmp/,RCSt1015268 Thu Jul 14 11:08:14 1988
--- /tmp/,RCSt2015268 Thu Jul 14 11:08:16 1988
***************
*** 36,49 ****
{
register struct inode *ip = (struct inode *)fp->f_data;
! int error;
! if ((ip->i_mode&IFMT) == IFREG) {
ILOCK(ip);
! if (fp->f_flag&FAPPEND && rw == UIO_WRITE)
! uio->uio_offset = fp->f_offset = ip->i_size;
! error = rwip(ip, uio, rw);
IUNLOCK(ip);
- } else
- error = rwip(ip, uio, rw);
return (error);
}
--- 36,53 ----
{
register struct inode *ip = (struct inode *)fp->f_data;
! int count, error;
! if ((ip->i_mode&IFMT) != IFCHR)
ILOCK(ip);
! if ((ip->i_mode&IFMT) == IFREG &&
! (fp->f_flag&FAPPEND) &&
! rw == UIO_WRITE)
! fp->f_offset = ip->i_size;
! uio->uio_offset = fp->f_offset;
! count = uio->uio_resid;
! error = rwip(ip, uio, rw);
! fp->f_offset += count - uio->uio_resid;
! if ((ip->i_mode&IFMT) != IFCHR)
IUNLOCK(ip);
return (error);
}
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
------- End Forwarded Message