Skip to contentSkip to conversation

gfs2: use iomap for buffered I/O in ordered and writeback mode

PATCH Andreas Gruenbacher 2 participants 2 messages Dec 10, 2019 – Dec 12, 2019

Subsystems (2)
lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

Hi Christoph,

Quoted 4 lines · Andreas Gruenbacher
Quoted 1 line · Christoph Hellwig

On Mon, Aug 05, 2019 at 02:27:21PM +0200, Andreas Gruenbacher wrote:

here are the changes we currently need on top of what you've posted on July 1. [...]

again, thank you for this patch. After fixing some related bugs around this change, it seems I've finally got this to work properly. Below are the minor changes I needed to make on top of your version.

This requires functions iomap_page_create and iomap_set_range_uptodate to be exported; i'll post a patch for that sepatately.

The result can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next.iomap

Thanks,
Andreas

---
 fs/gfs2/bmap.c | 6 ++++--
 fs/gfs2/file.c | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/gfs2/bmap.c +4 -2
index 168ac5147dd0..fcd2043fc466 100644
@@ -75,13 +75,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 		memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize);
 		memset(kaddr + dsize, 0, PAGE_SIZE - dsize);
 		kunmap(page);
-
-		SetPageUptodate(page);
 	}
 
 	if (gfs2_is_jdata(ip)) {
 		struct buffer_head *bh;
 
+		SetPageUptodate(page);
 		if (!page_has_buffers(page))
 			create_empty_buffers(page, BIT(inode->i_blkbits),
 					     BIT(BH_Uptodate));
@@ -93,6 +92,9 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 		set_buffer_uptodate(bh);
 		gfs2_trans_add_data(ip->i_gl, bh);
 	} else {
+		iomap_page_create(inode, page);
+		iomap_set_range_uptodate(page, 0, i_blocksize(inode));
+		set_page_dirty(page);
 		gfs2_ordered_add_inode(ip);
 	}
 
fs/gfs2/file.c +2 -0
index 9d58295ccf7a..9af352ebc904 100644
@@ -555,6 +555,8 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
 out_uninit:
 	gfs2_holder_uninit(&gh);
 	if (ret == 0) {
+		if (!gfs2_is_jdata(ip))
+			iomap_page_create(inode, page);
 		set_page_dirty(page);
 		wait_for_stable_page(page);
 	}
Signature · 1 line
2.20.1
#1 lore raw
Quoted 16 lines · Andreas Gruenbacher
fs/gfs2/bmap.c +1 -2
@@ -75,13 +75,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 		memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize);
 		memset(kaddr + dsize, 0, PAGE_SIZE - dsize);
 		kunmap(page);
-
-		SetPageUptodate(page);
 	}
 
 	if (gfs2_is_jdata(ip)) {
 		struct buffer_head *bh;
 
+		SetPageUptodate(page);
 		if (!page_has_buffers(page))
 			create_empty_buffers(page, BIT(inode->i_blkbits),
 					     BIT(BH_Uptodate));

fs/gfs2/bmap.c static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, · line 99

Quoted 8 lines
fs/gfs2/bmap.c +3 -0
@@ -93,6 +92,9 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 		set_buffer_uptodate(bh);
 		gfs2_trans_add_data(ip->i_gl, bh);
 	} else {
+		iomap_page_create(inode, page);
+		iomap_set_range_uptodate(page, 0, i_blocksize(inode));
+		set_page_dirty(page);
 		gfs2_ordered_add_inode(ip);
 	}

Can you create a helper that copies the data from a passed in kernel pointer, length pair into the page, then marks it uptodate and dirty, please?

fs/gfs2/file.c static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) · line 559

Quoted 6 lines
fs/gfs2/file.c +2 -0
@@ -555,6 +555,8 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
 out_uninit:
 	gfs2_holder_uninit(&gh);
 	if (ret == 0) {
+		if (!gfs2_is_jdata(ip))
+			iomap_page_create(inode, page);

What is this one for? The iomap_page is supposed to use lazy allocation, that is we only allocate it once it is used. What code expects the structure but doesn't see it without this hunk? I guess it is iomap_writepage_map, which should probably just switch to call iomap_page_create.

That being said is there any way we can get gfs2 to use iomap_page_mkwrite for the !jdata case?