* Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
@ 2012-09-17 16:35 Jan Kara
2012-09-17 19:15 ` Hugh Dickins
0 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2012-09-17 16:35 UTC (permalink / raw)
To: linux-mm
[-- Attachment #1: Type: text/plain, Size: 781 bytes --]
Hi,
I tripped over a crash in reiserfs which happened due to PageSwapCache
page being passed to reiserfs_set_page_dirty(). Now it's not that hard to
make reiserfs_set_page_dirty() check that case but I really wonder: Does it
make sense to call mapping->a_ops->set_page_dirty() for a PageSwapCache
page? The page is going to be written via direct IO so from the POV of the
filesystem there's no need for any dirtiness tracking. Also there are
several ->set_page_dirty() implementations which will spectacularly crash
because they do things like page->mapping->host, or call
__set_page_dirty_buffers() which expects buffer heads in page->private.
Or what is the reason for calling filesystem's set_page_dirty() function?
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
[-- Attachment #2: 0001-mm-Remove-swap_set_page_dirty.patch --]
[-- Type: text/x-patch, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
2012-09-17 16:35 Does swap_set_page_dirty() calling ->set_page_dirty() make sense? Jan Kara
@ 2012-09-17 19:15 ` Hugh Dickins
2012-09-18 2:16 ` Jan Kara
2012-09-18 9:58 ` Mel Gorman
0 siblings, 2 replies; 6+ messages in thread
From: Hugh Dickins @ 2012-09-17 19:15 UTC (permalink / raw)
To: Jan Kara; +Cc: Mel Gorman, linux-mm
On Mon, 17 Sep 2012, Jan Kara wrote:
>
> I tripped over a crash in reiserfs which happened due to PageSwapCache
> page being passed to reiserfs_set_page_dirty(). Now it's not that hard to
> make reiserfs_set_page_dirty() check that case but I really wonder: Does it
> make sense to call mapping->a_ops->set_page_dirty() for a PageSwapCache
> page? The page is going to be written via direct IO so from the POV of the
> filesystem there's no need for any dirtiness tracking. Also there are
> several ->set_page_dirty() implementations which will spectacularly crash
> because they do things like page->mapping->host, or call
> __set_page_dirty_buffers() which expects buffer heads in page->private.
> Or what is the reason for calling filesystem's set_page_dirty() function?
This is a question for Mel, really: it used not to call the filesystem.
But my reading of the 3.6 code says that it still will not call the
filesystem, unless the filesystem (only nfs) provides a swap_activate
method, which should be the only case in which SWP_FILE gets set.
And I rather think Mel does want to use the filesystem set_page_dirty
in that case. Am I misreading?
Did you see this on a vanilla kernel? Or is it possible that you have
a private patch merged in, with something else sharing the SWP_FILE bit
(defined in include/linux/swap.h) by mistake?
Hugh
> [PATCH] mm: Remove swap_set_page_dirty()
>
> It doesn't make much sense to call filesystem's ->set_page_dirty() method for
> PageSwapCache page. It will be written through direct IO so filesystem doesn't
> care about its dirtiness and several filesystems actually don't count with such
> pages getting into their ->set_page_dirty() functions.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> mm/page_io.c | 12 ------------
> mm/swap_state.c | 2 +-
> 2 files changed, 1 insertions(+), 13 deletions(-)
>
> diff --git a/mm/page_io.c b/mm/page_io.c
> index 78eee32..8520a4f 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -278,15 +278,3 @@ int swap_readpage(struct page *page)
> out:
> return ret;
> }
> -
> -int swap_set_page_dirty(struct page *page)
> -{
> - struct swap_info_struct *sis = page_swap_info(page);
> -
> - if (sis->flags & SWP_FILE) {
> - struct address_space *mapping = sis->swap_file->f_mapping;
> - return mapping->a_ops->set_page_dirty(page);
> - } else {
> - return __set_page_dirty_no_writeback(page);
> - }
> -}
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index 0cb36fb..01852cd 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -27,7 +27,7 @@
> */
> static const struct address_space_operations swap_aops = {
> .writepage = swap_writepage,
> - .set_page_dirty = swap_set_page_dirty,
> + .set_page_dirty = set_page_dirty_no_writeback,
> .migratepage = migrate_page,
> };
>
> --
> 1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
2012-09-17 19:15 ` Hugh Dickins
@ 2012-09-18 2:16 ` Jan Kara
2012-09-18 8:51 ` Petr Tesarik
2012-09-18 9:58 ` Mel Gorman
1 sibling, 1 reply; 6+ messages in thread
From: Jan Kara @ 2012-09-18 2:16 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Jan Kara, Mel Gorman, linux-mm
On Mon 17-09-12 12:15:46, Hugh Dickins wrote:
> On Mon, 17 Sep 2012, Jan Kara wrote:
> >
> > I tripped over a crash in reiserfs which happened due to PageSwapCache
> > page being passed to reiserfs_set_page_dirty(). Now it's not that hard to
> > make reiserfs_set_page_dirty() check that case but I really wonder: Does it
> > make sense to call mapping->a_ops->set_page_dirty() for a PageSwapCache
> > page? The page is going to be written via direct IO so from the POV of the
> > filesystem there's no need for any dirtiness tracking. Also there are
> > several ->set_page_dirty() implementations which will spectacularly crash
> > because they do things like page->mapping->host, or call
> > __set_page_dirty_buffers() which expects buffer heads in page->private.
> > Or what is the reason for calling filesystem's set_page_dirty() function?
>
> This is a question for Mel, really: it used not to call the filesystem.
>
> But my reading of the 3.6 code says that it still will not call the
> filesystem, unless the filesystem (only nfs) provides a swap_activate
> method, which should be the only case in which SWP_FILE gets set.
> And I rather think Mel does want to use the filesystem set_page_dirty
> in that case. Am I misreading?
>
> Did you see this on a vanilla kernel? Or is it possible that you have
> a private patch merged in, with something else sharing the SWP_FILE bit
> (defined in include/linux/swap.h) by mistake?
Argh, sorry. It is indeed a SLES specific bug. I missed that SWP_FILE bit
gets set only when swap_activate() is provided (SLES code works a bit
differently in this area but I wasn't really looking into that since I was
focused elsewhere).
So just one minor nit for Mel. SWP_FILE looks like a bit confusing name for
a flag that gets set only for some swap files ;) At least I didn't pay
attention to it because I thought it's set for all of them. Maybe call it
SWP_FILE_CALL_AOPS or something like that?
Thanks Hugh for having a look.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
2012-09-18 2:16 ` Jan Kara
@ 2012-09-18 8:51 ` Petr Tesarik
2012-09-18 10:02 ` Mel Gorman
0 siblings, 1 reply; 6+ messages in thread
From: Petr Tesarik @ 2012-09-18 8:51 UTC (permalink / raw)
To: Jan Kara; +Cc: Hugh Dickins, Mel Gorman, linux-mm
Dne Út 18. září 2012 04:16:27 Jan Kara napsal(a):
> On Mon 17-09-12 12:15:46, Hugh Dickins wrote:
> > On Mon, 17 Sep 2012, Jan Kara wrote:
> > > I tripped over a crash in reiserfs which happened due to
> > > PageSwapCache
> > >
> > > page being passed to reiserfs_set_page_dirty(). Now it's not that hard
> > > to make reiserfs_set_page_dirty() check that case but I really wonder:
> > > Does it make sense to call mapping->a_ops->set_page_dirty() for a
> > > PageSwapCache page? The page is going to be written via direct IO so
> > > from the POV of the filesystem there's no need for any dirtiness
> > > tracking. Also there are several ->set_page_dirty() implementations
> > > which will spectacularly crash because they do things like
> > > page->mapping->host, or call
> > > __set_page_dirty_buffers() which expects buffer heads in page->private.
> > > Or what is the reason for calling filesystem's set_page_dirty()
> > > function?
> >
> > This is a question for Mel, really: it used not to call the filesystem.
> >
> > But my reading of the 3.6 code says that it still will not call the
> > filesystem, unless the filesystem (only nfs) provides a swap_activate
> > method, which should be the only case in which SWP_FILE gets set.
> > And I rather think Mel does want to use the filesystem set_page_dirty
> > in that case. Am I misreading?
> >
> > Did you see this on a vanilla kernel? Or is it possible that you have
> > a private patch merged in, with something else sharing the SWP_FILE bit
> > (defined in include/linux/swap.h) by mistake?
>
> Argh, sorry. It is indeed a SLES specific bug. I missed that SWP_FILE bit
> gets set only when swap_activate() is provided (SLES code works a bit
> differently in this area but I wasn't really looking into that since I was
> focused elsewhere).
>
> So just one minor nit for Mel. SWP_FILE looks like a bit confusing name for
> a flag that gets set only for some swap files ;) At least I didn't pay
> attention to it because I thought it's set for all of them. Maybe call it
> SWP_FILE_CALL_AOPS or something like that?
Same here. In fact, I believed that other filesystems only work by accident
(because they don't have to access the mapping). I'm not even sure about the
semantics of the swap_activate operation. Is this documented somewhere?
Petr Tesarik
SUSE Linux
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
2012-09-17 19:15 ` Hugh Dickins
2012-09-18 2:16 ` Jan Kara
@ 2012-09-18 9:58 ` Mel Gorman
1 sibling, 0 replies; 6+ messages in thread
From: Mel Gorman @ 2012-09-18 9:58 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Jan Kara, linux-mm
On Mon, Sep 17, 2012 at 12:15:46PM -0700, Hugh Dickins wrote:
> On Mon, 17 Sep 2012, Jan Kara wrote:
> >
> > I tripped over a crash in reiserfs which happened due to PageSwapCache
> > page being passed to reiserfs_set_page_dirty(). Now it's not that hard to
> > make reiserfs_set_page_dirty() check that case but I really wonder: Does it
> > make sense to call mapping->a_ops->set_page_dirty() for a PageSwapCache
> > page? The page is going to be written via direct IO so from the POV of the
> > filesystem there's no need for any dirtiness tracking. Also there are
> > several ->set_page_dirty() implementations which will spectacularly crash
> > because they do things like page->mapping->host, or call
> > __set_page_dirty_buffers() which expects buffer heads in page->private.
> > Or what is the reason for calling filesystem's set_page_dirty() function?
>
> This is a question for Mel, really: it used not to call the filesystem.
>
And now it should only be called if SWP_FILE is set to perform read/write
of pages through the filesystem. In practice I only expect this to happen
when a swapfile is activated on NFS.
> But my reading of the 3.6 code says that it still will not call the
> filesystem, unless the filesystem (only nfs) provides a swap_activate
> method, which should be the only case in which SWP_FILE gets set.
> And I rather think Mel does want to use the filesystem set_page_dirty
> in that case. Am I misreading?
>
That was the intention at least.
> Did you see this on a vanilla kernel? Or is it possible that you have
> a private patch merged in, with something else sharing the SWP_FILE bit
> (defined in include/linux/swap.h) by mistake?
>
I see that Jan followed up that this was observed on SLES. The
implementaiton there is based on a much earlier revision of
swap-over-NFS than what was finally merged to mainline. I'll check it
out.
Thanks.
--
Mel Gorman
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Does swap_set_page_dirty() calling ->set_page_dirty() make sense?
2012-09-18 8:51 ` Petr Tesarik
@ 2012-09-18 10:02 ` Mel Gorman
0 siblings, 0 replies; 6+ messages in thread
From: Mel Gorman @ 2012-09-18 10:02 UTC (permalink / raw)
To: Petr Tesarik; +Cc: Jan Kara, Hugh Dickins, linux-mm
On Tue, Sep 18, 2012 at 10:51:50AM +0200, Petr Tesarik wrote:
> > <SNIP>
> >
> > So just one minor nit for Mel. SWP_FILE looks like a bit confusing name for
> > a flag that gets set only for some swap files ;) At least I didn't pay
> > attention to it because I thought it's set for all of them. Maybe call it
> > SWP_FILE_CALL_AOPS or something like that?
>
I guess it would be a slightly better name all right.
> Same here. In fact, I believed that other filesystems only work by accident
> (because they don't have to access the mapping). I'm not even sure about the
> semantics of the swap_activate operation. Is this documented somewhere?
>
Documentation/filesystems/vfs.txt *briefly* describes what swap_activate()
does even though now that I read it I see that it's inaccurate. It says
that it proxies to the address spaces swapin_[out|in] method but it really
gets proxied to the direct_IO interface for writes and readpage for reads
(direct_IO could have been used for reads but my recollection was that
the locking was very awkward).
--
Mel Gorman
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-18 10:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 16:35 Does swap_set_page_dirty() calling ->set_page_dirty() make sense? Jan Kara
2012-09-17 19:15 ` Hugh Dickins
2012-09-18 2:16 ` Jan Kara
2012-09-18 8:51 ` Petr Tesarik
2012-09-18 10:02 ` Mel Gorman
2012-09-18 9:58 ` Mel Gorman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).