On Thu, Oct 16, 2014 at 12:20:47PM +0200, Mathieu Desnoyers wrote: > > +/* > > + * The user has performed a load from a hole in the file. Allocating > > + * a new page in the file would cause excessive storage usage for > > + * workloads with sparse files. We allocate a page cache page instead. > > + * We'll kick it out of the page cache if it's ever written to, > > + * otherwise it will simply fall out of the page cache under memory > > + * pressure without ever having been dirtied. > > Nice trick :) It's basically what the page cache does. Unfortunately, I had to step out of the room while Calvin detailed his trick for doing it differently, but if his patch goes in, we should follow suit. > > + if (!page) { > > + mutex_lock(&mapping->i_mmap_mutex); > > + /* Check we didn't race with truncate */ > > + size = (i_size_read(inode) + PAGE_SIZE - 1) >> > > + PAGE_SHIFT; > > + if (vmf->pgoff >= size) { > > + mutex_unlock(&mapping->i_mmap_mutex); > > + error = -EIO; > > + goto out; > > + } > > + } > > If page is non-NULL, is it possible that we return VM_FAULT_LOCKED > without actually holding i_mmap_mutex ? Is it on purpose ? > > > + return VM_FAULT_LOCKED; > > + } That's right; this is the original meaning of VM_FAULT_LOCKED, that the page lock is held. We took it before the call to get_block(), ensuring that we don't hit the truncate race. Er ... hang on. At some point in the revising of patches, I dropped the stanza where we re-check i_size after grabbing the page lock. Sod ... a v12 of this patchset will have to be forthcoming! -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html