ceph: remove useless page->mapping check in writepage_nounlock()
PATCH 1/3 ceph: remove useless page->mapping check in writepage_nounlock()
Callers of writepage_nounlock() have already ensured non-null page->mapping.
--- fs/ceph/addr.c | 4 ---- 1 file changed, 4 deletions(-)
fs/ceph/addr.c +0 -4
@@ -534,10 +534,6 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage %p idx %lu\n" , page, page->index); -if (!page->mapping || !page->mapping->host) { -dout ("writepage %p - no mapping\n" , page); -return -EFAULT ; - } inode = page->mapping->host; ci =ceph_inode (inode); fsc =ceph_inode_to_client (inode);
Signature · 1 line
2.9.4
PATCH 2/3 ceph: redirty page when writepage_nounlock() skips unwritable page
Ceph needs to flush dirty page in the order in which in which snap context they belong to. Dirty pages belong to older snap context should be flushed earlier. writepage_nounlock() can not flush a page, it should redirty the page.
--- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/addr.c +2 -1
@@ -551,8 +551,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage %p page %p snapc %p not writeable - noop\n" , inode, page, snapc);/* we should only noop if called by kswapd */ -WARN_ON ((current->flags &PF_MEMALLOC ) ==0 ); +WARN_ON (!(current->flags &PF_MEMALLOC ));ceph_put_snap_context (oldest); +redirty_page_for_writepage (wbc, page); goto out; }ceph_put_snap_context (oldest);
Signature · 1 line
2.9.4
Re: [PATCH 2/3] ceph: redirty page when writepage_nounlock() skips unwritable page
Quoted 16 lines · Zheng
Ceph needs to flush dirty page in the order in which in which snap context they belong to. Dirty pages belong to older snap context should be flushed earlier.
writepage_nounlock()can not flush a page, it should redirty the page.Reported-by Dan Carpenter <[email protected]>Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/ceph/addr.c +0
-0
fs/ceph/addr.c static int writepage_nounlock(struct page *page, struct writeback_control *wbc) · line 559
Quoted 10 lines
fs/ceph/addr.c +2
-1@@ -551,8 +551,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage %p page %p snapc %p not writeable - noop\n" , inode, page, snapc);/* we should only noop if called by kswapd */ -WARN_ON ((current->flags &PF_MEMALLOC ) ==0 ); +WARN_ON (!(current->flags &PF_MEMALLOC ));ceph_put_snap_context (oldest); +redirty_page_for_writepage (wbc, page); goto out; }ceph_put_snap_context (oldest);
PATCH 3/3 ceph: cleanup writepage_nounlock()
In reply to Yan, Zheng--- fs/ceph/addr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/ceph/addr.c +6 -6
@@ -530,7 +530,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)long writeback_stat;u64 truncate_size;u32 truncate_seq; -int err =0 , len =PAGE_SIZE ; +int err, len =PAGE_SIZE ;dout ("writepage %p idx %lu\n" , page, page->index);
@@ -543,7 +543,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) snapc =page_snap_context (page);if (snapc ==NULL ) {dout ("writepage %p page %p not dirty?\n" , inode, page); - goto out; +return 0 ; } oldest =get_oldest_context (inode, &snap_size, &truncate_size, &truncate_seq);
@@ -554,7 +554,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)WARN_ON (!(current->flags &PF_MEMALLOC ));ceph_put_snap_context (oldest);redirty_page_for_writepage (wbc, page); - goto out; +return 0 ; }ceph_put_snap_context (oldest);
@@ -564,8 +564,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)/* is this a partial page at end of file? */ if (page_off >= snap_size) {dout ("%p page eof %llu\n" , page, snap_size); - goto out; +return 0 ; } +if (snap_size < page_off + len) len = snap_size - page_off;
@@ -592,7 +593,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage interrupted page %p\n" , page);redirty_page_for_writepage (wbc, page);end_page_writeback (page); - goto out; +return err; }dout ("writepage setting page/mapping error %d %p\n" , err, page);
@@ -608,7 +609,6 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)end_page_writeback (page);ceph_put_wrbuffer_cap_refs (ci,1 , snapc);ceph_put_snap_context (snapc);/* page's reference */ -out:return err; }
Signature · 1 line
2.9.4
Re: [PATCH 3/3] ceph: cleanup writepage_nounlock()
Quoted 57 lines · Zheng
Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/addr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)fs/ceph/addr.c +6
-5@@ -530,7 +530,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)long writeback_stat;u64 truncate_size;u32 truncate_seq; -int err =0 , len =PAGE_SIZE ; +int err, len =PAGE_SIZE ;dout ("writepage %p idx %lu\n" , page, page->index);@@ -543,7 +543,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) snapc =page_snap_context (page);if (snapc ==NULL ) {dout ("writepage %p page %p not dirty?\n" , inode, page); - goto out; +return 0 ; } oldest =get_oldest_context (inode, &snap_size, &truncate_size, &truncate_seq);@@ -554,7 +554,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)WARN_ON (!(current->flags &PF_MEMALLOC ));ceph_put_snap_context (oldest);redirty_page_for_writepage (wbc, page); - goto out; +return 0 ; }ceph_put_snap_context (oldest);@@ -564,8 +564,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)/* is this a partial page at end of file? */ if (page_off >= snap_size) {dout ("%p page eof %llu\n" , page, snap_size); - goto out; +return 0 ; } +if (snap_size < page_off + len) len = snap_size - page_off;@@ -592,7 +593,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage interrupted page %p\n" , page);redirty_page_for_writepage (wbc, page);end_page_writeback (page); - goto out; +return err; }dout ("writepage setting page/mapping error %d %p\n" , err, page);
fs/ceph/addr.c static int writepage_nounlock(struct page *page, struct writeback_control *wbc) · line 614
Quoted 7 lines
fs/ceph/addr.c +0
-1@@ -608,7 +609,6 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)end_page_writeback (page);ceph_put_wrbuffer_cap_refs (ci,1 , snapc);ceph_put_snap_context (snapc);/* page's reference */ -out:return err; }
Looks correct:
Quoted 14 lines · Zheng
Callers of
writepage_nounlock()have already ensured non-nullpage->mapping.Reported-by Dan Carpenter <[email protected]>Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/addr.c | 4 ---- 1 file changed, 4 deletions(-)fs/ceph/addr.c +0
-0
fs/ceph/addr.c static int writepage_nounlock(struct page *page, struct writeback_control *wbc) · line 539
Quoted 10 lines
fs/ceph/addr.c +0
-4@@ -534,10 +534,6 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)dout ("writepage %p idx %lu\n" , page, page->index); -if (!page->mapping || !page->mapping->host) { -dout ("writepage %p - no mapping\n" , page); -return -EFAULT ; - } inode = page->mapping->host; ci =ceph_inode (inode); fsc =ceph_inode_to_client (inode);