Skip to contentSkip to conversation

gfs2: More iomap enablement

PATCH New Andreas Gruenbacher 2 participants 5 messages Jul 7, 2018 – Jul 9, 2018 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

cover gfs2: More iomap enablement

Hi,

here's another forward-looking fix and two enablement patches. The patches depend on the following branches:

xfs-linux/iomap-4.19-merge
linux-gfs/for-next

The "iomap: add initial support for writes without buffer heads" patch on 'iomap-4.19-merge' introduces the IOMAP_F_BUFFER_HEAD flag which needds to be set for gfs2. I've done that in the merge commit for that branch so that we don't end up with any broken commits.

An 'iomap-misc' branch with all those changes can be found here:

https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/log/?h=iomap-misc

The 'iomap-4.19-merge' branch can be found in the xfs repository:

https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/log/?h=iomap-4.19-merge

Thanks,
Andreas

Andreas Gruenbacher (3):
gfs2: fallocate_chunk: Always initialize struct iomap
gfs2: Use iomap for stuffed direct I/O reads
gfs2: use iomap_readpage for blocksize == PAGE_SIZE

Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH 1/3 gfs2: fallocate_chunk: Always initialize struct iomap

In fallocate_chunk, always initialize the iomap before calling
gfs2_iomap_get_alloc: future changes could otherwise cause things like iomap.flags to leak across calls.

---
 fs/gfs2/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/file.c +2 -1
index f3c6d78659b1..6d895d39158a 100644
@@ -877,7 +877,6 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
 	struct gfs2_inode *ip = GFS2_I(inode);
 	loff_t end = offset + len;
 	struct buffer_head *dibh;
-	struct iomap iomap = { };
 	int error;
 
 	error = gfs2_meta_inode_buffer(ip, &dibh);
@@ -893,6 +892,8 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
 	}
 
 	while (offset < end) {
+		struct iomap iomap = { };
+
 		error = gfs2_iomap_get_alloc(inode, offset, end - offset,
 					     &iomap);
 		if (error)
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH 2/3 gfs2: Use iomap for stuffed direct I/O reads

In reply to Andreas Gruenbacher

Remove the fallback code from direct to buffered I/O for stuffed reads.

For stuffed writes, we must keep the fallback code: the deferred glock we are holding under direct I/O doesn't allow to write to the inode or change the file size.

---
 fs/gfs2/file.c | 6 ------
 1 file changed, 6 deletions(-)
fs/gfs2/file.c +0 -6
index 6d895d39158a..08369c6cd127 100644
@@ -706,14 +706,8 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to)
 	if (ret)
 		goto out_uninit;
 
-	/* fall back to buffered I/O for stuffed files */
-	ret = -ENOTBLK;
-	if (gfs2_is_stuffed(ip))
-		goto out;
-
 	ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL);
 
-out:
 	gfs2_glock_dq(&gh);
 out_uninit:
 	gfs2_holder_uninit(&gh);
Signature · 1 line
2.17.1
author maintainer
#3 lore raw

PATCH 3/3 gfs2: use iomap_readpage for blocksize == PAGE_SIZE

In reply to Andreas Gruenbacher

We only use iomap_readpage for pages that don't have buffer heads attached yet: iomap_readpage would otherwise read pages from disk that are marked buffer_uptodate() but not PageUptodate(). Those pages may actually contain data more recent than what's on disk.

---
 fs/gfs2/aops.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/gfs2/aops.c +5 -1
index cc80fd71f3dd..31e8270d0b26 100644
@@ -508,9 +508,13 @@ static int __gfs2_readpage(void *file, struct page *page)
 {
 	struct gfs2_inode *ip = GFS2_I(page->mapping->host);
 	struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
+
 	int error;
 
-	if (gfs2_is_stuffed(ip)) {
+	if (i_blocksize(page->mapping->host) == PAGE_SIZE &&
+	    !page_has_buffers(page)) {
+		error = iomap_readpage(page, &gfs2_iomap_ops);
+	} else if (gfs2_is_stuffed(ip)) {
 		error = stuffed_readpage(ip, page);
 		unlock_page(page);
 	} else {
Signature · 1 line
2.17.1
#4 lore raw

cover gfs2: More iomap enablement

In reply to Andreas Gruenbacher

Hi Andreas,

----- Original Message -----

Quoted 4 lines

Andreas Gruenbacher (3):
gfs2: fallocate_chunk: Always initialize struct iomap
gfs2: Use iomap for stuffed direct I/O reads
gfs2: use iomap_readpage for blocksize == PAGE_SIZE

These three look good to me. Feel free to add my Reviewed-by.

Bob Peterson