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: Tue, 4 Mar 2014 00:23:43 +0000 Message-ID: <20140304002342.GS18016@ZenIV.linux.org.uk> References: <20140303210359.26624.qmail@science.horizon.com> <20140303212642.GJ18016@ZenIV.linux.org.uk> <20140303220106.GL18016@ZenIV.linux.org.uk> <20140303232858.GO18016@ZenIV.linux.org.uk> <20140303234207.GQ18016@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: George Spelvin , linux-fsdevel , Linux Kernel Mailing List 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 03:59:36PM -0800, Linus Torvalds wrote: > I doubt it's worth caring about. Even when passing things in memory, > the end result isn't that much worse than the fget_light() model that > passes just one of the two fields in memory. I'm not sure if that's the right approach, TBH. I wonder if something like static inline struct fd fdget(int fd) { unsigned long v = __fdget(fd); return (struct fd){(struct file *)(v & ~1), v & 1}; } would not be a better starting point, with __fdget(fd) being { struct files_struct *files = current->files; struct file *file; if (atomic_read(&files->count) == 1) { file = __fcheck_files(files, fd); if (file && (file->f_mode & FMODE_PATH)) return 0; return (unsigned long)file; } else { file = __fget(fd, FMODE_PATH); return file ? 1 | (unsigned long)file : 0; } }