aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/gfs2/bmap.c13
-rw-r--r--fs/gfs2/file.c29
-rw-r--r--fs/gfs2/incore.h3
3 files changed, 14 insertions, 31 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index ce4a978e0c18..685c305cbeb6 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -491,14 +491,12 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
491{ 491{
492 struct gfs2_inode *ip = GFS2_I(inode); 492 struct gfs2_inode *ip = GFS2_I(inode);
493 struct gfs2_sbd *sdp = GFS2_SB(inode); 493 struct gfs2_sbd *sdp = GFS2_SB(inode);
494 struct super_block *sb = sdp->sd_vfs;
495 struct buffer_head *dibh = mp->mp_bh[0]; 494 struct buffer_head *dibh = mp->mp_bh[0];
496 u64 bn; 495 u64 bn;
497 unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0; 496 unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0;
498 unsigned dblks = 0; 497 unsigned dblks = 0;
499 unsigned ptrs_per_blk; 498 unsigned ptrs_per_blk;
500 const unsigned end_of_metadata = mp->mp_fheight - 1; 499 const unsigned end_of_metadata = mp->mp_fheight - 1;
501 int ret;
502 enum alloc_state state; 500 enum alloc_state state;
503 __be64 *ptr; 501 __be64 *ptr;
504 __be64 zero_bn = 0; 502 __be64 zero_bn = 0;
@@ -607,15 +605,6 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
607 iomap->flags |= IOMAP_F_NEW; 605 iomap->flags |= IOMAP_F_NEW;
608 while (n-- > 0) 606 while (n-- > 0)
609 *ptr++ = cpu_to_be64(bn++); 607 *ptr++ = cpu_to_be64(bn++);
610 if (flags & IOMAP_ZERO) {
611 ret = sb_issue_zeroout(sb, iomap->addr >> inode->i_blkbits,
612 dblks, GFP_NOFS);
613 if (ret) {
614 fs_err(sdp,
615 "Failed to zero data buffers\n");
616 flags &= ~IOMAP_ZERO;
617 }
618 }
619 break; 608 break;
620 } 609 }
621 } while (iomap->addr == IOMAP_NULL_ADDR); 610 } while (iomap->addr == IOMAP_NULL_ADDR);
@@ -846,8 +835,6 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
846 835
847 if (create) 836 if (create)
848 flags |= IOMAP_WRITE; 837 flags |= IOMAP_WRITE;
849 if (buffer_zeronew(bh_map))
850 flags |= IOMAP_ZERO;
851 ret = gfs2_iomap_begin(inode, (loff_t)lblock << inode->i_blkbits, 838 ret = gfs2_iomap_begin(inode, (loff_t)lblock << inode->i_blkbits,
852 bh_map->b_size, flags, &iomap); 839 bh_map->b_size, flags, &iomap);
853 if (ret) { 840 if (ret) {
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 2edd3a9a7b79..4b71f021a9e2 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -729,11 +729,12 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
729static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len, 729static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
730 int mode) 730 int mode)
731{ 731{
732 struct super_block *sb = inode->i_sb;
732 struct gfs2_inode *ip = GFS2_I(inode); 733 struct gfs2_inode *ip = GFS2_I(inode);
734 loff_t end = offset + len;
733 struct buffer_head *dibh; 735 struct buffer_head *dibh;
736 struct iomap iomap;
734 int error; 737 int error;
735 unsigned int nr_blks;
736 sector_t lblock = offset >> inode->i_blkbits;
737 738
738 error = gfs2_meta_inode_buffer(ip, &dibh); 739 error = gfs2_meta_inode_buffer(ip, &dibh);
739 if (unlikely(error)) 740 if (unlikely(error))
@@ -747,21 +748,19 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
747 goto out; 748 goto out;
748 } 749 }
749 750
750 while (len) { 751 while (offset < end) {
751 struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 }; 752 error = gfs2_iomap_begin(inode, offset, end - offset,
752 bh_map.b_size = len; 753 IOMAP_WRITE, &iomap);
753 set_buffer_zeronew(&bh_map); 754 if (error)
754
755 error = gfs2_block_map(inode, lblock, &bh_map, 1);
756 if (unlikely(error))
757 goto out; 755 goto out;
758 len -= bh_map.b_size; 756 offset = iomap.offset + iomap.length;
759 nr_blks = bh_map.b_size >> inode->i_blkbits; 757 if (iomap.type != IOMAP_HOLE)
760 lblock += nr_blks;
761 if (!buffer_new(&bh_map))
762 continue; 758 continue;
763 if (unlikely(!buffer_zeronew(&bh_map))) { 759 error = sb_issue_zeroout(sb, iomap.addr >> inode->i_blkbits,
764 error = -EIO; 760 iomap.length >> inode->i_blkbits,
761 GFP_NOFS);
762 if (error) {
763 fs_err(GFS2_SB(inode), "Failed to zero data buffers\n");
765 goto out; 764 goto out;
766 } 765 }
767 } 766 }
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index e0557b8a590a..1b6b1e3f5caf 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -130,15 +130,12 @@ static inline bool gfs2_rbm_eq(const struct gfs2_rbm *rbm1,
130enum gfs2_state_bits { 130enum gfs2_state_bits {
131 BH_Pinned = BH_PrivateStart, 131 BH_Pinned = BH_PrivateStart,
132 BH_Escaped = BH_PrivateStart + 1, 132 BH_Escaped = BH_PrivateStart + 1,
133 BH_Zeronew = BH_PrivateStart + 2,
134}; 133};
135 134
136BUFFER_FNS(Pinned, pinned) 135BUFFER_FNS(Pinned, pinned)
137TAS_BUFFER_FNS(Pinned, pinned) 136TAS_BUFFER_FNS(Pinned, pinned)
138BUFFER_FNS(Escaped, escaped) 137BUFFER_FNS(Escaped, escaped)
139TAS_BUFFER_FNS(Escaped, escaped) 138TAS_BUFFER_FNS(Escaped, escaped)
140BUFFER_FNS(Zeronew, zeronew)
141TAS_BUFFER_FNS(Zeronew, zeronew)
142 139
143struct gfs2_bufdata { 140struct gfs2_bufdata {
144 struct buffer_head *bd_bh; 141 struct buffer_head *bd_bh;