Commit 72d36d05 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Add support for IOMAP_ZERO

Add support for the IOMAP_ZERO iomap operation so that iomap_zero_range will
work as expected.  In the IOMAP_ZERO case, the caller of iomap_zero_range is
responsible for taking an exclusive glock on the inode, so we need no
additional locking in gfs2_iomap_begin.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 34aad20b
...@@ -1168,7 +1168,7 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, ...@@ -1168,7 +1168,7 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
if (ret) if (ret)
goto out_unlock; goto out_unlock;
switch(flags & IOMAP_WRITE) { switch(flags & (IOMAP_WRITE | IOMAP_ZERO)) {
case IOMAP_WRITE: case IOMAP_WRITE:
if (flags & IOMAP_DIRECT) { if (flags & IOMAP_DIRECT) {
/* /*
...@@ -1180,6 +1180,10 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length, ...@@ -1180,6 +1180,10 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
goto out_unlock; goto out_unlock;
} }
break; break;
case IOMAP_ZERO:
if (iomap->type == IOMAP_HOLE)
goto out_unlock;
break;
default: default:
goto out_unlock; goto out_unlock;
} }
...@@ -1201,11 +1205,15 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length, ...@@ -1201,11 +1205,15 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode); struct gfs2_sbd *sdp = GFS2_SB(inode);
switch (flags & IOMAP_WRITE) { switch (flags & (IOMAP_WRITE | IOMAP_ZERO)) {
case IOMAP_WRITE: case IOMAP_WRITE:
if (flags & IOMAP_DIRECT) if (flags & IOMAP_DIRECT)
return 0; return 0;
break; break;
case IOMAP_ZERO:
if (iomap->type == IOMAP_HOLE)
return 0;
break;
default: default:
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment