diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2017-11-14 16:53:12 +0100 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2018-01-18 14:18:53 -0700 |
commit | 235628c5c76040b0ec206ea9ab9e017771e0d78e (patch) | |
tree | ab8a3c322a8d59ab5814a14d61f9cf6050d0d0d7 /fs/gfs2/bmap.c | |
parent | 9db115a0e3d3814e41eb703082b83a261d81736c (diff) |
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 <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 2ec11981e694..86863792f36a 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -69,8 +69,8 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, void *kaddr = kmap(page); u64 dsize = i_size_read(inode); - 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); @@ -1692,8 +1692,7 @@ static int do_grow(struct inode *inode, u64 size) int error; int unstuff = 0; - if (gfs2_is_stuffed(ip) && - (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { + if (gfs2_is_stuffed(ip) && size > gfs2_max_stuffed_size(ip)) { error = gfs2_quota_lock_check(ip, &ap); if (error) return error; @@ -1928,8 +1927,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, return 0; if (gfs2_is_stuffed(ip)) { - if (offset + len > - sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) + if (offset + len > gfs2_max_stuffed_size(ip)) return 1; return 0; } |