Re: [PATCH] cramfs corruption after BLKFLSBUF on loop device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2 Jun 2006 10:43:27 +0200
Olaf Hering <[email protected]> wrote:

>  On Thu, Jun 01, Andrew Morton wrote:
> 
> 
> > > Do you want it like that?
> > > 
> > > lock_page(page);
> > > if (PageUptodate(page)) {
> > >         SetPageDirty(page);
> > >         mb();
> > >         return page;
> > > }
> > 
> > Not really ;)  It's hacky.  It'd be better to take a lock.
> 
> Which lock exactly?

Ah, sorry, there isn't such a lock.  I was just carrying on.

> I'm not sure how to proceed from here.

I'd suggest you run SetPagePrivate() and SetPageChecked() on the locked
page and implement a_ops.releasepage(), which will fail if PageChecked(),
and will succeed otherwise:

/*
 * cramfs_releasepage() will fail if cramfs_read() set PG_checked.  This
 * is so that invalidate_inode_pages() cannot zap the page while
 * cramfs_read() is trying to get at its contents.
 */
cramfs_releasepage(...)
{
	if (PageChecked(page))
		return 0;
	return 1;
}


cramfs_read(...)
{
	lock_page(page);
	SetPagePrivate(page);
	SetPageChecked(page);
	read_mapping_page(...);
	lock_page(page);
	if (page->mapping == NULL) {
		/* truncate got there first */
		unlock_page(page);
		bale();
	}
	memcpy();
	ClearPageChecked(page);
	ClearPagePrivate(page);
	unlock_page(page);
}

PG_checked is a filesystem-private flag.  It'll soon be renamed to
PG_fs_misc.

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux