From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: Update of file offset on write() etc. is non-atomic with I/O Date: Mon, 3 Mar 2014 21:45:36 +0000 Message-ID: <20140303214536.GK18016@ZenIV.linux.org.uk> References: <53022DB1.4070805@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Michael Kerrisk (man-pages)" , lkml , Miklos Szeredi , Theodore T'so , Christoph Hellwig , Chris Mason , Dave Chinner , Linux-Fsdevel , "J. Bruce Fields" , Yongzhi Pan To: Linus Torvalds Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Mon, Mar 03, 2014 at 09:36:58AM -0800, Linus Torvalds wrote: > +static struct fd fdget_pos(int fd) > +{ > + struct fd f = fdget(fd); > + struct file *file = f.file; > + > + if (file && (file->f_mode & FMODE_ATOMIC_POS)) { > + if (f.need_put || file_count(file) > 1) { Um... That's odd - we *could* get there with f.need_put and file_count(file) equal to 1, but why would we want to take f_pos_lock in that case? And it looks like you've missed compat counterparts. Other than that, it'd probably work... Let me check if there are other paths we might need to take care of, though. PS: apologies for being pretty much MIA for the last two weeks; I'd been ears-deep in interesting scalability crap around vfsmount handling ;-/ Will post the resulting patches for review shortly...