Skip to contentSkip to conversation

dirty pages path in kernel

DISCUSSION David Chow 3 participants 5 messages Jan 28, 2003 – Feb 1, 2003 Memory management

lore
Share & tools
lore

David Chow

author
#0 lore raw

Hi,

If I do the following to an inode mapping page .

1. Generate a "struct page" from read_cache_page()
2. kmap() the page, do some memset() (Dirty the page)
3. kunmap() and page_cache_release() the page.

Since I didn't change any flags in the struct page, and I don't call to the corresponding commit_write() path. How is this page handled afterwards? Does the kernel will call its corresponding writepage() routine when unmap? Or it will ignore the dirty page as the kernel doesn't detects it. What will happen then? Will I loose any changes to that page data? I'm trying to implement some asynchronous mechasim on purging dirty pages on disk writes. Please give advice.

regards,
David

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#1 lore raw
Quoted 9 lines · David Chow

Hi,

If I do the following to an inode mapping page .

1. Generate a "struct page" from read_cache_page()
2. kmap() the page, do some memset() (Dirty the page)
3. kunmap() and page_cache_release() the page.

The VFS does not know that the page has changed.

You should do:

	lock_page(page);
	memset()
	set_page_dirty(page);
	unlock_page(page);

the page will be written to disk on the next kupdate cycle. --
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#2 lore raw
Quoted 14 lines · Andrew Morton
Quoted 9 lines · David Chow

Hi,

If I do the following to an inode mapping page .

1. Generate a "struct page" from read_cache_page()
2. kmap() the page, do some memset() (Dirty the page)
3. kunmap() and page_cache_release() the page.

The VFS does not know that the page has changed.

Quoted 8 lines

You should do:

        lock_page(page);
        memset()
        set_page_dirty(page);
        unlock_page(page);

the page will be written to disk on the next kupdate cycle.

Make that:

	lock_page(page);
	kaddr = kmap_atomic(page, KM_USER0);
	memset(kaddr, ...);
	flush_dcache_page(page)
	kunmap_atomic(kaddr, KM_USER0);
	set_page_dirty(page);
	unlock_page(page);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#3 lore raw
Quoted 24 lines · Andrew Morton
Quoted 14 lines · Andrew Morton
Quoted 9 lines · David Chow

Hi,

If I do the following to an inode mapping page .

1. Generate a "struct page" from read_cache_page()
2. kmap() the page, do some memset() (Dirty the page)
3. kunmap() and page_cache_release() the page.

The VFS does not know that the page has changed.

Quoted 8 lines

You should do:

        lock_page(page);
        memset()
        set_page_dirty(page);
        unlock_page(page);

the page will be written to disk on the next kupdate cycle.

Quoted 8 lines

Make that:

	lock_page(page);
	kaddr = kmap_atomic(page, KM_USER0);
	memset(kaddr, ...);
	flush_dcache_page(page)
	kunmap_atomic(kaddr, KM_USER0);
	set_page_dirty(page);

Shouldn't mark_page_accessed() go here?

Quoted 1 line
	unlock_page(page);

Nikita.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

author
#4 lore raw
Quoted 72 lines
Quoted 52 lines · Andrew Morton
Quoted 42 lines · Andrew Morton
Quoted 10 lines · David Chow

Hi,

If I do the following to an inode mapping page .

Quoted 7 lines

1. Generate a "struct page" from read_cache_page()

2. kmap() the page, do some memset() (Dirty the page)

3. kunmap() and page_cache_release() the page.

The VFS does not know that the page has changed.

You should do:

        lock_page(page);

        memset()

        set_page_dirty(page);

        unlock_page(page);
Quoted 1 line

the page will be written to disk on the next kupdate cycle.

Make that:

Quoted 11 lines
	lock_page(page);

	kaddr = kmap_atomic(page, KM_USER0);

	memset(kaddr, ...);

	flush_dcache_page(page)

	kunmap_atomic(kaddr, KM_USER0);

	set_page_dirty(page);

Shouldn't mark_page_accessed() go here?

Quoted 5 lines
Quoted 1 line
	unlock_page(page);

Nikita.

Thanks for your help. However, do I have to deal with page ref cnts?

regards,
David

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/