aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2017-11-06 13:58:36 -0500
committerBob Peterson <rpeterso@redhat.com>2018-01-18 16:18:55 -0500
commit88b65ce5fdd9ac75df1534cf6503db0ccb230ecb (patch)
treefb88eb5dc785a5e4067cc957c376bc0ffb44f6fb
parent235628c5c76040b0ec206ea9ab9e017771e0d78e (diff)
gfs2: Minor gfs2_page_add_databufs cleanup
The to parameter of gfs2_page_add_databufs is passed inconsistently: once as from + len, once as from + len - 1. Just pass len instead. In addition, once we're past the end, we can immediately break out of the loop. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r--fs/gfs2/aops.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 38e403a9e543..ac4a1e89da1e 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -39,18 +39,21 @@
39 39
40 40
41static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, 41static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
42 unsigned int from, unsigned int to) 42 unsigned int from, unsigned int len)
43{ 43{
44 struct buffer_head *head = page_buffers(page); 44 struct buffer_head *head = page_buffers(page);
45 unsigned int bsize = head->b_size; 45 unsigned int bsize = head->b_size;
46 struct buffer_head *bh; 46 struct buffer_head *bh;
47 unsigned int to = from + len;
47 unsigned int start, end; 48 unsigned int start, end;
48 49
49 for (bh = head, start = 0; bh != head || !start; 50 for (bh = head, start = 0; bh != head || !start;
50 bh = bh->b_this_page, start = end) { 51 bh = bh->b_this_page, start = end) {
51 end = start + bsize; 52 end = start + bsize;
52 if (end <= from || start >= to) 53 if (end <= from)
53 continue; 54 continue;
55 if (start >= to)
56 break;
54 if (gfs2_is_jdata(ip)) 57 if (gfs2_is_jdata(ip))
55 set_buffer_uptodate(bh); 58 set_buffer_uptodate(bh);
56 gfs2_trans_add_data(ip->i_gl, bh); 59 gfs2_trans_add_data(ip->i_gl, bh);
@@ -189,7 +192,7 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *w
189 create_empty_buffers(page, inode->i_sb->s_blocksize, 192 create_empty_buffers(page, inode->i_sb->s_blocksize,
190 BIT(BH_Dirty)|BIT(BH_Uptodate)); 193 BIT(BH_Dirty)|BIT(BH_Uptodate));
191 } 194 }
192 gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1); 195 gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize);
193 } 196 }
194 return gfs2_write_full_page(page, gfs2_get_block_noalloc, wbc); 197 return gfs2_write_full_page(page, gfs2_get_block_noalloc, wbc);
195} 198}
@@ -889,8 +892,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
889 struct gfs2_sbd *sdp = GFS2_SB(inode); 892 struct gfs2_sbd *sdp = GFS2_SB(inode);
890 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 893 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
891 struct buffer_head *dibh; 894 struct buffer_head *dibh;
892 unsigned int from = pos & (PAGE_SIZE - 1);
893 unsigned int to = from + len;
894 int ret; 895 int ret;
895 struct gfs2_trans *tr = current->journal_info; 896 struct gfs2_trans *tr = current->journal_info;
896 BUG_ON(!tr); 897 BUG_ON(!tr);
@@ -908,7 +909,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
908 return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page); 909 return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page);
909 910
910 if (!gfs2_is_writeback(ip)) 911 if (!gfs2_is_writeback(ip))
911 gfs2_page_add_databufs(ip, page, from, to); 912 gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len);
912 913
913 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); 914 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
914 if (tr->tr_num_buf_new) 915 if (tr->tr_num_buf_new)