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/inode.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'fs/gfs2/inode.c') diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 4e971b1c7f92..20281992d456 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1184,11 +1184,10 @@ out_inodes: static int gfs2_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { - struct gfs2_sbd *sdp = GFS2_SB(dir); unsigned int size; size = strlen(symname); - if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1) + if (size >= gfs2_max_stuffed_size(GFS2_I(dir))) return -ENAMETOOLONG; return gfs2_create_inode(dir, dentry, NULL, S_IFLNK | S_IRWXUGO, 0, symname, size, 0, NULL); @@ -1205,8 +1204,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { - struct gfs2_sbd *sdp = GFS2_SB(dir); - unsigned dsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); + unsigned dsize = gfs2_max_stuffed_size(GFS2_I(dir)); return gfs2_create_inode(dir, dentry, NULL, S_IFDIR | mode, 0, NULL, dsize, 0, NULL); } -- cgit v1.2.3