* Re: shmem: convert to using splice instead of sendfile() [not found] <200707102300.l6AN0xM4026841@hera.kernel.org> @ 2007-07-11 1:43 ` Andrew Morton 2007-07-11 6:20 ` Jens Axboe 0 siblings, 1 reply; 3+ messages in thread From: Andrew Morton @ 2007-07-11 1:43 UTC (permalink / raw) To: Jens Axboe; +Cc: linux-kernel On Tue, 10 Jul 2007 23:00:59 GMT Linux Kernel Mailing List <linux-kernel@vger.kernel.org> wrote: > +static int shmem_readpage(struct file *file, struct page *page) > +{ > + struct inode *inode = page->mapping->host; > + int error = shmem_getpage(inode, page->index, &page, SGP_CACHE, NULL); > + unlock_page(page); > + return error; > +} Worried. shmem_getpage() does done: if (*pagep != filepage) { unlock_page(filepage); *pagep = filepage; } return 0; so we end up unlocking an unlocked page? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shmem: convert to using splice instead of sendfile() 2007-07-11 1:43 ` shmem: convert to using splice instead of sendfile() Andrew Morton @ 2007-07-11 6:20 ` Jens Axboe 2007-07-11 16:33 ` Hugh Dickins 0 siblings, 1 reply; 3+ messages in thread From: Jens Axboe @ 2007-07-11 6:20 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-kernel, hugh On Tue, Jul 10 2007, Andrew Morton wrote: > On Tue, 10 Jul 2007 23:00:59 GMT Linux Kernel Mailing List <linux-kernel@vger.kernel.org> wrote: > > > +static int shmem_readpage(struct file *file, struct page *page) > > +{ > > + struct inode *inode = page->mapping->host; > > + int error = shmem_getpage(inode, page->index, &page, SGP_CACHE, NULL); > > + unlock_page(page); > > + return error; > > +} > > Worried. shmem_getpage() does > > done: > if (*pagep != filepage) { > unlock_page(filepage); > *pagep = filepage; > } > return 0; > > so we end up unlocking an unlocked page? It certainly looks like it - Hugh? -- Jens Axboe ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shmem: convert to using splice instead of sendfile() 2007-07-11 6:20 ` Jens Axboe @ 2007-07-11 16:33 ` Hugh Dickins 0 siblings, 0 replies; 3+ messages in thread From: Hugh Dickins @ 2007-07-11 16:33 UTC (permalink / raw) To: Jens Axboe; +Cc: Andrew Morton, linux-kernel On Wed, 11 Jul 2007, Jens Axboe wrote: > On Tue, Jul 10 2007, Andrew Morton wrote: > > On Tue, 10 Jul 2007 23:00:59 GMT Linux Kernel Mailing List <linux-kernel@vger.kernel.org> wrote: > > > > > +static int shmem_readpage(struct file *file, struct page *page) > > > +{ > > > + struct inode *inode = page->mapping->host; > > > + int error = shmem_getpage(inode, page->index, &page, SGP_CACHE, NULL); > > > + unlock_page(page); > > > + return error; > > > +} > > > > Worried. shmem_getpage() does > > > > done: > > if (*pagep != filepage) { > > unlock_page(filepage); > > *pagep = filepage; > > } > > return 0; > > > > so we end up unlocking an unlocked page? > > It certainly looks like it - Hugh? No, it's fine. The relevant comment is up at the entry to shmem_getpage: struct page *filepage = *pagep; /* (moved down, I'm cheating!) */ /* * Normally, filepage is NULL on entry, and either found * uptodate immediately, or allocated and zeroed, or read * in under swappage, which is then assigned to filepage. * But shmem_readpage and shmem_prepare_write pass in a locked * filepage, which may be found not uptodate by other callers * too, and may need to be copied from the swappage read in. */ So down at the exit from shmem_getpage, in the shmem_readpage case, filepage _is_ *pagep, and so it skips that unlock_page - the caller passed in a locked page, it's up to the caller to unlock it; but the general ->readpage interface then demands that shmem_readpage unlock the page which was passed in to it with lock held. (The *pagep != filepage test is also trying to skip the unlock_page in the case when shmem_getpage needed to allocate the page itself, but couldn't: both *pagep and filepage NULL.) Ironically, the need for shmem_getpage to handle the case of a page passed into it almost vanished - Nick's upcoming aops ->write_begin abolishes the shmem_prepare_write case - but now it is needed for readpage for splice: but I'm hoping perhaps we'll devise a readpage replacement more like write_begin/write_end, then can eliminate it. Hugh ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-11 16:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200707102300.l6AN0xM4026841@hera.kernel.org>
2007-07-11 1:43 ` shmem: convert to using splice instead of sendfile() Andrew Morton
2007-07-11 6:20 ` Jens Axboe
2007-07-11 16:33 ` Hugh Dickins
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox