[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140304002342.GS18016@ZenIV.linux.org.uk>
Date: Tue, 4 Mar 2014 00:23:43 +0000
From: Al Viro <viro@...IV.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: George Spelvin <linux@...izon.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: Update of file offset on write() etc. is non-atomic with I/O
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;
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists