cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/2] gfs2: Add support for IOMAP_ZERO
Date: Sat,  6 Jul 2019 01:56:22 +0200	[thread overview]
Message-ID: <20190705235622.22368-3-agruenba@redhat.com> (raw)
In-Reply-To: <20190705235622.22368-1-agruenba@redhat.com>

Add support for the IOMAP_ZERO flag, which indicates a request to write
zeroes into a file without filling holes.  Used by iomap_zero_range.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/bmap.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index e2c58c6a1276..aabd78a1ae59 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1029,7 +1029,7 @@ static int __gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
 	iomap->flags |= IOMAP_F_BUFFER_HEAD;
 
 	ret = gfs2_iomap_get(inode, pos, length, flags, iomap, mp);
-	if (ret || !(flags & IOMAP_WRITE))
+	if (ret || !(flags & (IOMAP_WRITE | IOMAP_ZERO)))
 		return ret;
 	if (flags & IOMAP_DIRECT) {
 		/*
@@ -1040,6 +1040,10 @@ static int __gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
 			return -ENOTBLK;
 		return 0;
 	}
+	if (flags & IOMAP_ZERO) {
+		if (iomap->type == IOMAP_HOLE)
+			return 0;
+	}
 
 	unstuff = gfs2_is_stuffed(ip) &&
 		  pos + length > gfs2_max_stuffed_size(ip);
@@ -1156,8 +1160,12 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,
 	struct gfs2_inode *ip = GFS2_I(inode);
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
 
-	if (!(flags & IOMAP_WRITE) || (flags & IOMAP_DIRECT))
+	if (!(flags & (IOMAP_WRITE | IOMAP_ZERO)) || (flags & IOMAP_DIRECT))
 		goto out;
+	if (flags & IOMAP_ZERO) {
+		if (iomap->type == IOMAP_HOLE)
+			goto out;
+	}
 
 	if (!gfs2_is_stuffed(ip))
 		gfs2_ordered_add_inode(ip);
@@ -1181,7 +1189,8 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,
 
 	if (ip->i_qadata && ip->i_qadata->qa_qd_num)
 		gfs2_quota_unlock(ip);
-	gfs2_write_unlock(inode);
+	if (flags & IOMAP_WRITE)
+		gfs2_write_unlock(inode);
 
 out:
 	return 0;
-- 
2.20.1



  parent reply	other threads:[~2019-07-05 23:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 23:56 [Cluster-devel] Make "gfs2: implement gfs2_block_zero_range using iomap_zero_range" work properly Andreas Gruenbacher
2019-07-05 23:56 ` [Cluster-devel] [PATCH 1/2] gfs2: gfs2_iomap_begin cleanup Andreas Gruenbacher
2019-07-05 23:56 ` Andreas Gruenbacher [this message]
2019-07-08 17:06   ` [Cluster-devel] [PATCH 2/2] gfs2: Add support for IOMAP_ZERO Christoph Hellwig
2019-07-08 18:07     ` Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190705235622.22368-3-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).