From 235628c5c76040b0ec206ea9ab9e017771e0d78e Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Tue, 14 Nov 2017 16:53:12 +0100 Subject: gfs2: Add gfs2_max_stuffed_size Add a small inline function for computing the maximum size of a stuffed inode instead of open coding that in several places throughout the code. Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson --- fs/gfs2/aops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'fs/gfs2/aops.c') diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 44a77b631509..38e403a9e543 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -482,8 +482,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) return error; kaddr = kmap_atomic(page); - if (dsize > (dibh->b_size - sizeof(struct gfs2_dinode))) - dsize = (dibh->b_size - sizeof(struct gfs2_dinode)); + if (dsize > gfs2_max_stuffed_size(ip)) + dsize = gfs2_max_stuffed_size(ip); memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); memset(kaddr + dsize, 0, PAGE_SIZE - dsize); kunmap_atomic(kaddr); @@ -723,7 +723,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, if (gfs2_is_stuffed(ip)) { error = 0; - if (pos + len > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) { + if (pos + len > gfs2_max_stuffed_size(ip)) { error = gfs2_unstuff_dinode(ip, page); if (error == 0) goto prepare_write; @@ -830,7 +830,8 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh, void *kaddr; unsigned char *buf = dibh->b_data + sizeof(struct gfs2_dinode); - BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs2_dinode))); + BUG_ON(pos + len > gfs2_max_stuffed_size(ip)); + kaddr = kmap_atomic(page); memcpy(buf + pos, kaddr + pos, copied); flush_dcache_page(page); -- cgit v1.2.3