From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [RFC] write(2) semantics wrt return values and current position Date: Mon, 6 Apr 2015 21:09:22 +0100 Message-ID: <20150406200922.GP889@ZenIV.linux.org.uk> References: <20150406153641.GL889@ZenIV.linux.org.uk> <9FE2E968-DF4D-43F7-858C-81A13F2C0A75@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "" , Linus Torvalds , Trond Myklebust , Christoph Hellwig , Dave Chinner , Theodore Ts'o , Miklos Szeredi To: "Drokin, Oleg" Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:43561 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753840AbbDFUJ0 (ORCPT ); Mon, 6 Apr 2015 16:09:26 -0400 Content-Disposition: inline In-Reply-To: <9FE2E968-DF4D-43F7-858C-81A13F2C0A75@intel.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Apr 06, 2015 at 08:04:01PM +0000, Drokin, Oleg wrote: > Hello! > > On Apr 6, 2015, at 12:02 PM, Al Viro wrote: > > 2) should we ever update the current position when write() returns 0? > > IOW, what effect should zero-length write() on O_APPEND file have upon its > > current position? POSIX seems to imply that it should do nothing, and > > generally that's what happens, but e.g. ext4 *does* update position to > > the EOF, whether we will write anything or not. So does FUSE when server > > requests to bypass the page cache. AFAICS, lustre is the same way, > > but I might be missing something; everything else definitely does not > > Lustre is not the same way. > drivers/staging/lustre/lustre/llite/file.c::ll_file_io_generic() has this > if (io-> ci_nob > 0) { > result = io->ci_nob; > *ppos = io->u.ci_wr.wr.crw_pos; > } > > and ppos is passed in as &iocb->ki_pos. ci_nob is number of bytes that we managed to read/write, > and if it was 0 (either due to 0 bytes io request or due to error from the get go) > we won't update it. Eh? vvp_io_write_start(): result = generic_file_write_iter(cio->cui_iocb, cio->cui_iter);