Re: [Patch] tmpfs: add fallocate support

From: Dave Hansen
Date: Wed Nov 16 2011 - 18:22:37 EST


On Wed, 2011-11-16 at 15:21 +0800, Cong Wang wrote:
> ä 2011å11æ16æ 01:43, Dave Hansen åé:
> > On Tue, 2011-11-15 at 18:23 +0800, Cong Wang wrote:
> >>> + if (!(mode& FALLOC_FL_KEEP_SIZE)) {
> >>> + ret = inode_newsize_ok(inode, (offset + len));
> >>> + if (ret)
> >>> + return ret;
> >>> + }
> >
> > inode_newsize_ok()'s comments say:
> >
> > * inode_newsize_ok must be called with i_mutex held.
> >
> > But I don't see any trace of it.
>
> Hmm, even for tmpfs? I see none of the tmpfs code takes
> i_mutex lock though...

Look harder. :)

ramfs/tmpfs for a large part just used the generic VFS functions to do
their work since they're page-cache based. For instance:

static const struct file_operations shmem_file_operations = {
...
.aio_write = generic_file_aio_write,

IOW, you need to check beyond mm/shmem.c.

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/