aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/aops.c6
-rw-r--r--fs/gfs2/bmap.c12
-rw-r--r--fs/gfs2/dir.c28
-rw-r--r--fs/gfs2/file.c2
-rw-r--r--fs/gfs2/glops.c5
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/inode.c9
-rw-r--r--fs/gfs2/inode.h13
-rw-r--r--fs/gfs2/ops_fstype.c2
-rw-r--r--fs/gfs2/ops_inode.c10
-rw-r--r--fs/gfs2/quota.c13
-rw-r--r--fs/gfs2/rgrp.c6
-rw-r--r--fs/gfs2/super.c11
13 files changed, 60 insertions, 58 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index f687f25fb7f..c92f36ba3fc 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -800,10 +800,8 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
800 page_cache_release(page); 800 page_cache_release(page);
801 801
802 if (copied) { 802 if (copied) {
803 if (inode->i_size < to) { 803 if (inode->i_size < to)
804 i_size_write(inode, to); 804 i_size_write(inode, to);
805 ip->i_disksize = inode->i_size;
806 }
807 gfs2_dinode_out(ip, di); 805 gfs2_dinode_out(ip, di);
808 mark_inode_dirty(inode); 806 mark_inode_dirty(inode);
809 } 807 }
@@ -874,8 +872,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
874 872
875 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); 873 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
876 if (ret > 0) { 874 if (ret > 0) {
877 if (inode->i_size > ip->i_disksize)
878 ip->i_disksize = inode->i_size;
879 gfs2_dinode_out(ip, dibh->b_data); 875 gfs2_dinode_out(ip, dibh->b_data);
880 mark_inode_dirty(inode); 876 mark_inode_dirty(inode);
881 } 877 }
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 20b971ad497..04513e997df 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -131,7 +131,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
131 if (error) 131 if (error)
132 goto out; 132 goto out;
133 133
134 if (ip->i_disksize) { 134 if (i_size_read(&ip->i_inode)) {
135 /* Get a free block, fill it with the stuffed data, 135 /* Get a free block, fill it with the stuffed data,
136 and write it out to disk */ 136 and write it out to disk */
137 137
@@ -160,7 +160,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
160 di = (struct gfs2_dinode *)dibh->b_data; 160 di = (struct gfs2_dinode *)dibh->b_data;
161 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 161 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
162 162
163 if (ip->i_disksize) { 163 if (i_size_read(&ip->i_inode)) {
164 *(__be64 *)(di + 1) = cpu_to_be64(block); 164 *(__be64 *)(di + 1) = cpu_to_be64(block);
165 gfs2_add_inode_blocks(&ip->i_inode, 1); 165 gfs2_add_inode_blocks(&ip->i_inode, 1);
166 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); 166 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
@@ -985,7 +985,6 @@ static int trunc_start(struct inode *inode, u64 oldsize, u64 newsize)
985 } 985 }
986 986
987 i_size_write(inode, newsize); 987 i_size_write(inode, newsize);
988 ip->i_disksize = newsize;
989 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 988 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
990 gfs2_dinode_out(ip, dibh->b_data); 989 gfs2_dinode_out(ip, dibh->b_data);
991 990
@@ -1051,7 +1050,7 @@ static int trunc_end(struct gfs2_inode *ip)
1051 if (error) 1050 if (error)
1052 goto out; 1051 goto out;
1053 1052
1054 if (!ip->i_disksize) { 1053 if (!i_size_read(&ip->i_inode)) {
1055 ip->i_height = 0; 1054 ip->i_height = 0;
1056 ip->i_goal = ip->i_no_addr; 1055 ip->i_goal = ip->i_no_addr;
1057 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 1056 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
@@ -1167,7 +1166,6 @@ static int do_grow(struct inode *inode, u64 size)
1167 goto do_end_trans; 1166 goto do_end_trans;
1168 1167
1169 i_size_write(inode, size); 1168 i_size_write(inode, size);
1170 ip->i_disksize = size;
1171 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1169 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1172 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1170 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1173 gfs2_dinode_out(ip, dibh->b_data); 1171 gfs2_dinode_out(ip, dibh->b_data);
@@ -1219,7 +1217,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
1219int gfs2_truncatei_resume(struct gfs2_inode *ip) 1217int gfs2_truncatei_resume(struct gfs2_inode *ip)
1220{ 1218{
1221 int error; 1219 int error;
1222 error = trunc_dealloc(ip, ip->i_disksize); 1220 error = trunc_dealloc(ip, i_size_read(&ip->i_inode));
1223 if (!error) 1221 if (!error)
1224 error = trunc_end(ip); 1222 error = trunc_end(ip);
1225 return error; 1223 return error;
@@ -1260,7 +1258,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
1260 1258
1261 shift = sdp->sd_sb.sb_bsize_shift; 1259 shift = sdp->sd_sb.sb_bsize_shift;
1262 BUG_ON(gfs2_is_dir(ip)); 1260 BUG_ON(gfs2_is_dir(ip));
1263 end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize - 1) >> shift; 1261 end_of_file = (i_size_read(&ip->i_inode) + sdp->sd_sb.sb_bsize - 1) >> shift;
1264 lblock = offset >> shift; 1262 lblock = offset >> shift;
1265 lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; 1263 lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
1266 if (lblock_stop > end_of_file) 1264 if (lblock_stop > end_of_file)
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index b9dd88a78dd..c1042ae438c 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -127,8 +127,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
127 127
128 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 128 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
129 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); 129 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
130 if (ip->i_disksize < offset + size) 130 if (ip->i_inode.i_size < offset + size)
131 ip->i_disksize = offset + size; 131 i_size_write(&ip->i_inode, offset + size);
132 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 132 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
133 gfs2_dinode_out(ip, dibh->b_data); 133 gfs2_dinode_out(ip, dibh->b_data);
134 134
@@ -225,8 +225,8 @@ out:
225 if (error) 225 if (error)
226 return error; 226 return error;
227 227
228 if (ip->i_disksize < offset + copied) 228 if (ip->i_inode.i_size < offset + copied)
229 ip->i_disksize = offset + copied; 229 i_size_write(&ip->i_inode, offset + copied);
230 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 230 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
231 231
232 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 232 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
@@ -275,12 +275,13 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
275 unsigned int o; 275 unsigned int o;
276 int copied = 0; 276 int copied = 0;
277 int error = 0; 277 int error = 0;
278 u64 disksize = i_size_read(&ip->i_inode);
278 279
279 if (offset >= ip->i_disksize) 280 if (offset >= disksize)
280 return 0; 281 return 0;
281 282
282 if (offset + size > ip->i_disksize) 283 if (offset + size > disksize)
283 size = ip->i_disksize - offset; 284 size = disksize - offset;
284 285
285 if (!size) 286 if (!size)
286 return 0; 287 return 0;
@@ -727,7 +728,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
727 unsigned hsize = 1 << ip->i_depth; 728 unsigned hsize = 1 << ip->i_depth;
728 unsigned index; 729 unsigned index;
729 u64 ln; 730 u64 ln;
730 if (hsize * sizeof(u64) != ip->i_disksize) { 731 if (hsize * sizeof(u64) != i_size_read(inode)) {
731 gfs2_consist_inode(ip); 732 gfs2_consist_inode(ip);
732 return ERR_PTR(-EIO); 733 return ERR_PTR(-EIO);
733 } 734 }
@@ -879,7 +880,7 @@ static int dir_make_exhash(struct inode *inode)
879 for (x = sdp->sd_hash_ptrs; x--; lp++) 880 for (x = sdp->sd_hash_ptrs; x--; lp++)
880 *lp = cpu_to_be64(bn); 881 *lp = cpu_to_be64(bn);
881 882
882 dip->i_disksize = sdp->sd_sb.sb_bsize / 2; 883 i_size_write(inode, sdp->sd_sb.sb_bsize / 2);
883 gfs2_add_inode_blocks(&dip->i_inode, 1); 884 gfs2_add_inode_blocks(&dip->i_inode, 1);
884 dip->i_diskflags |= GFS2_DIF_EXHASH; 885 dip->i_diskflags |= GFS2_DIF_EXHASH;
885 886
@@ -1057,11 +1058,12 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1057 u64 *buf; 1058 u64 *buf;
1058 u64 *from, *to; 1059 u64 *from, *to;
1059 u64 block; 1060 u64 block;
1061 u64 disksize = i_size_read(&dip->i_inode);
1060 int x; 1062 int x;
1061 int error = 0; 1063 int error = 0;
1062 1064
1063 hsize = 1 << dip->i_depth; 1065 hsize = 1 << dip->i_depth;
1064 if (hsize * sizeof(u64) != dip->i_disksize) { 1066 if (hsize * sizeof(u64) != disksize) {
1065 gfs2_consist_inode(dip); 1067 gfs2_consist_inode(dip);
1066 return -EIO; 1068 return -EIO;
1067 } 1069 }
@@ -1072,7 +1074,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1072 if (!buf) 1074 if (!buf)
1073 return -ENOMEM; 1075 return -ENOMEM;
1074 1076
1075 for (block = dip->i_disksize >> sdp->sd_hash_bsize_shift; block--;) { 1077 for (block = disksize >> sdp->sd_hash_bsize_shift; block--;) {
1076 error = gfs2_dir_read_data(dip, (char *)buf, 1078 error = gfs2_dir_read_data(dip, (char *)buf,
1077 block * sdp->sd_hash_bsize, 1079 block * sdp->sd_hash_bsize,
1078 sdp->sd_hash_bsize, 1); 1080 sdp->sd_hash_bsize, 1);
@@ -1370,7 +1372,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1370 unsigned depth = 0; 1372 unsigned depth = 0;
1371 1373
1372 hsize = 1 << dip->i_depth; 1374 hsize = 1 << dip->i_depth;
1373 if (hsize * sizeof(u64) != dip->i_disksize) { 1375 if (hsize * sizeof(u64) != i_size_read(inode)) {
1374 gfs2_consist_inode(dip); 1376 gfs2_consist_inode(dip);
1375 return -EIO; 1377 return -EIO;
1376 } 1378 }
@@ -1784,7 +1786,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1784 int error = 0; 1786 int error = 0;
1785 1787
1786 hsize = 1 << dip->i_depth; 1788 hsize = 1 << dip->i_depth;
1787 if (hsize * sizeof(u64) != dip->i_disksize) { 1789 if (hsize * sizeof(u64) != i_size_read(&dip->i_inode)) {
1788 gfs2_consist_inode(dip); 1790 gfs2_consist_inode(dip);
1789 return -EIO; 1791 return -EIO;
1790 } 1792 }
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 4edd662c823..daadcd2e755 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -491,7 +491,7 @@ static int gfs2_open(struct inode *inode, struct file *file)
491 goto fail; 491 goto fail;
492 492
493 if (!(file->f_flags & O_LARGEFILE) && 493 if (!(file->f_flags & O_LARGEFILE) &&
494 ip->i_disksize > MAX_NON_LFS) { 494 i_size_read(inode) > MAX_NON_LFS) {
495 error = -EOVERFLOW; 495 error = -EOVERFLOW;
496 goto fail_gunlock; 496 goto fail_gunlock;
497 } 497 }
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 49f97d3bb69..621d80e8fb2 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -262,13 +262,12 @@ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
262 const struct gfs2_inode *ip = gl->gl_object; 262 const struct gfs2_inode *ip = gl->gl_object;
263 if (ip == NULL) 263 if (ip == NULL)
264 return 0; 264 return 0;
265 gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu/%llu\n", 265 gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
266 (unsigned long long)ip->i_no_formal_ino, 266 (unsigned long long)ip->i_no_formal_ino,
267 (unsigned long long)ip->i_no_addr, 267 (unsigned long long)ip->i_no_addr,
268 IF2DT(ip->i_inode.i_mode), ip->i_flags, 268 IF2DT(ip->i_inode.i_mode), ip->i_flags,
269 (unsigned int)ip->i_diskflags, 269 (unsigned int)ip->i_diskflags,
270 (unsigned long long)ip->i_inode.i_size, 270 (unsigned long long)i_size_read(&ip->i_inode));
271 (unsigned long long)ip->i_disksize);
272 return 0; 271 return 0;
273} 272}
274 273
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index fdbf4b366fa..c1197177527 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -267,7 +267,6 @@ struct gfs2_inode {
267 u64 i_no_formal_ino; 267 u64 i_no_formal_ino;
268 u64 i_generation; 268 u64 i_generation;
269 u64 i_eattr; 269 u64 i_eattr;
270 loff_t i_disksize;
271 unsigned long i_flags; /* GIF_... */ 270 unsigned long i_flags; /* GIF_... */
272 struct gfs2_glock *i_gl; /* Move into i_gh? */ 271 struct gfs2_glock *i_gl; /* Move into i_gh? */
273 struct gfs2_holder i_iopen_gh; 272 struct gfs2_holder i_iopen_gh;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 08140f185a3..06370f8bd8c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -359,8 +359,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
359 * to do that. 359 * to do that.
360 */ 360 */
361 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink); 361 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
362 ip->i_disksize = be64_to_cpu(str->di_size); 362 i_size_write(&ip->i_inode, be64_to_cpu(str->di_size));
363 i_size_write(&ip->i_inode, ip->i_disksize);
364 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); 363 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
365 atime.tv_sec = be64_to_cpu(str->di_atime); 364 atime.tv_sec = be64_to_cpu(str->di_atime);
366 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); 365 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec);
@@ -1055,7 +1054,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1055 str->di_uid = cpu_to_be32(ip->i_inode.i_uid); 1054 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
1056 str->di_gid = cpu_to_be32(ip->i_inode.i_gid); 1055 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
1057 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); 1056 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
1058 str->di_size = cpu_to_be64(ip->i_disksize); 1057 str->di_size = cpu_to_be64(i_size_read(&ip->i_inode));
1059 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); 1058 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
1060 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); 1059 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1061 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); 1060 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
@@ -1085,8 +1084,8 @@ void gfs2_dinode_print(const struct gfs2_inode *ip)
1085 (unsigned long long)ip->i_no_formal_ino); 1084 (unsigned long long)ip->i_no_formal_ino);
1086 printk(KERN_INFO " no_addr = %llu\n", 1085 printk(KERN_INFO " no_addr = %llu\n",
1087 (unsigned long long)ip->i_no_addr); 1086 (unsigned long long)ip->i_no_addr);
1088 printk(KERN_INFO " i_disksize = %llu\n", 1087 printk(KERN_INFO " i_size = %llu\n",
1089 (unsigned long long)ip->i_disksize); 1088 (unsigned long long)i_size_read(&ip->i_inode));
1090 printk(KERN_INFO " blocks = %llu\n", 1089 printk(KERN_INFO " blocks = %llu\n",
1091 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode)); 1090 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode));
1092 printk(KERN_INFO " i_goal = %llu\n", 1091 printk(KERN_INFO " i_goal = %llu\n",
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 300ada3f21d..15ff4df20aa 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -80,6 +80,19 @@ static inline void gfs2_inum_out(const struct gfs2_inode *ip,
80 dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr); 80 dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr);
81} 81}
82 82
83static inline int gfs2_check_internal_file_size(struct inode *inode,
84 u64 minsize, u64 maxsize)
85{
86 u64 size = i_size_read(inode);
87 if (size < minsize || size > maxsize)
88 goto err;
89 if (size & ((1 << inode->i_blkbits) - 1))
90 goto err;
91 return 0;
92err:
93 gfs2_consist_inode(GFS2_I(inode));
94 return -EIO;
95}
83 96
84extern void gfs2_set_iop(struct inode *inode); 97extern void gfs2_set_iop(struct inode *inode);
85extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 98extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 4d4b1e8ac64..5b5c87dfbfe 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -586,7 +586,7 @@ static int map_journal_extents(struct gfs2_sbd *sdp)
586 586
587 prev_db = 0; 587 prev_db = 0;
588 588
589 for (lb = 0; lb < ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; lb++) { 589 for (lb = 0; lb < i_size_read(jd->jd_inode) >> sdp->sd_sb.sb_bsize_shift; lb++) {
590 bh.b_state = 0; 590 bh.b_state = 0;
591 bh.b_blocknr = 0; 591 bh.b_blocknr = 0;
592 bh.b_size = 1 << ip->i_inode.i_blkbits; 592 bh.b_size = 1 << ip->i_inode.i_blkbits;
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 1d3f2fb466b..ee6ffd59041 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -406,7 +406,6 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
406 406
407 ip = ghs[1].gh_gl->gl_object; 407 ip = ghs[1].gh_gl->gl_object;
408 408
409 ip->i_disksize = size;
410 i_size_write(inode, size); 409 i_size_write(inode, size);
411 410
412 error = gfs2_meta_inode_buffer(ip, &dibh); 411 error = gfs2_meta_inode_buffer(ip, &dibh);
@@ -461,7 +460,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
461 ip = ghs[1].gh_gl->gl_object; 460 ip = ghs[1].gh_gl->gl_object;
462 461
463 ip->i_inode.i_nlink = 2; 462 ip->i_inode.i_nlink = 2;
464 ip->i_disksize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); 463 i_size_write(inode, sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode));
465 ip->i_diskflags |= GFS2_DIF_JDATA; 464 ip->i_diskflags |= GFS2_DIF_JDATA;
466 ip->i_entries = 2; 465 ip->i_entries = 2;
467 466
@@ -990,7 +989,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
990 struct gfs2_inode *ip = GFS2_I(dentry->d_inode); 989 struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
991 struct gfs2_holder i_gh; 990 struct gfs2_holder i_gh;
992 struct buffer_head *dibh; 991 struct buffer_head *dibh;
993 unsigned int x; 992 unsigned int x, size;
994 char *buf; 993 char *buf;
995 int error; 994 int error;
996 995
@@ -1002,7 +1001,8 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
1002 return NULL; 1001 return NULL;
1003 } 1002 }
1004 1003
1005 if (!ip->i_disksize) { 1004 size = (unsigned int)i_size_read(&ip->i_inode);
1005 if (size == 0) {
1006 gfs2_consist_inode(ip); 1006 gfs2_consist_inode(ip);
1007 buf = ERR_PTR(-EIO); 1007 buf = ERR_PTR(-EIO);
1008 goto out; 1008 goto out;
@@ -1014,7 +1014,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
1014 goto out; 1014 goto out;
1015 } 1015 }
1016 1016
1017 x = ip->i_disksize + 1; 1017 x = size + 1;
1018 buf = kmalloc(x, GFP_NOFS); 1018 buf = kmalloc(x, GFP_NOFS);
1019 if (!buf) 1019 if (!buf)
1020 buf = ERR_PTR(-ENOMEM); 1020 buf = ERR_PTR(-ENOMEM);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 1bc6b5695e6..9bc6dd9a544 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -735,10 +735,8 @@ get_a_page:
735 goto out; 735 goto out;
736 736
737 size = loc + sizeof(struct gfs2_quota); 737 size = loc + sizeof(struct gfs2_quota);
738 if (size > inode->i_size) { 738 if (size > inode->i_size)
739 ip->i_disksize = size;
740 i_size_write(inode, size); 739 i_size_write(inode, size);
741 }
742 inode->i_mtime = inode->i_atime = CURRENT_TIME; 740 inode->i_mtime = inode->i_atime = CURRENT_TIME;
743 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 741 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
744 gfs2_dinode_out(ip, dibh->b_data); 742 gfs2_dinode_out(ip, dibh->b_data);
@@ -1190,18 +1188,17 @@ static void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *
1190int gfs2_quota_init(struct gfs2_sbd *sdp) 1188int gfs2_quota_init(struct gfs2_sbd *sdp)
1191{ 1189{
1192 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); 1190 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
1193 unsigned int blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; 1191 u64 size = i_size_read(sdp->sd_qc_inode);
1192 unsigned int blocks = size >> sdp->sd_sb.sb_bsize_shift;
1194 unsigned int x, slot = 0; 1193 unsigned int x, slot = 0;
1195 unsigned int found = 0; 1194 unsigned int found = 0;
1196 u64 dblock; 1195 u64 dblock;
1197 u32 extlen = 0; 1196 u32 extlen = 0;
1198 int error; 1197 int error;
1199 1198
1200 if (!ip->i_disksize || ip->i_disksize > (64 << 20) || 1199 if (gfs2_check_internal_file_size(sdp->sd_qc_inode, 1, 64 << 20))
1201 ip->i_disksize & (sdp->sd_sb.sb_bsize - 1)) {
1202 gfs2_consist_inode(ip);
1203 return -EIO; 1200 return -EIO;
1204 } 1201
1205 sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block; 1202 sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block;
1206 sdp->sd_quota_chunks = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * PAGE_SIZE); 1203 sdp->sd_quota_chunks = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * PAGE_SIZE);
1207 1204
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 171a744f8e4..370c29b536e 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -500,7 +500,7 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
500 for (rgrps = 0;; rgrps++) { 500 for (rgrps = 0;; rgrps++) {
501 loff_t pos = rgrps * sizeof(struct gfs2_rindex); 501 loff_t pos = rgrps * sizeof(struct gfs2_rindex);
502 502
503 if (pos + sizeof(struct gfs2_rindex) >= ip->i_disksize) 503 if (pos + sizeof(struct gfs2_rindex) >= i_size_read(inode))
504 break; 504 break;
505 error = gfs2_internal_read(ip, &ra_state, buf, &pos, 505 error = gfs2_internal_read(ip, &ra_state, buf, &pos,
506 sizeof(struct gfs2_rindex)); 506 sizeof(struct gfs2_rindex));
@@ -588,7 +588,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
588 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 588 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
589 struct inode *inode = &ip->i_inode; 589 struct inode *inode = &ip->i_inode;
590 struct file_ra_state ra_state; 590 struct file_ra_state ra_state;
591 u64 rgrp_count = ip->i_disksize; 591 u64 rgrp_count = i_size_read(inode);
592 int error; 592 int error;
593 593
594 do_div(rgrp_count, sizeof(struct gfs2_rindex)); 594 do_div(rgrp_count, sizeof(struct gfs2_rindex));
@@ -628,7 +628,7 @@ static int gfs2_ri_update_special(struct gfs2_inode *ip)
628 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { 628 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) {
629 /* Ignore partials */ 629 /* Ignore partials */
630 if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) > 630 if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) >
631 ip->i_disksize) 631 i_size_read(inode))
632 break; 632 break;
633 error = read_rindex_entry(ip, &ra_state); 633 error = read_rindex_entry(ip, &ra_state);
634 if (error) { 634 if (error) {
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 77cb9f830ee..e031fa4965a 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -342,15 +342,14 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
342{ 342{
343 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 343 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
344 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 344 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
345 u64 size = i_size_read(jd->jd_inode);
345 346
346 if (ip->i_disksize < (8 << 20) || ip->i_disksize > (1 << 30) || 347 if (gfs2_check_internal_file_size(jd->jd_inode, 8 << 20, 1 << 30))
347 (ip->i_disksize & (sdp->sd_sb.sb_bsize - 1))) {
348 gfs2_consist_inode(ip);
349 return -EIO; 348 return -EIO;
350 }
351 jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift;
352 349
353 if (gfs2_write_alloc_required(ip, 0, ip->i_disksize)) { 350 jd->jd_blocks = size >> sdp->sd_sb.sb_bsize_shift;
351
352 if (gfs2_write_alloc_required(ip, 0, size)) {
354 gfs2_consist_inode(ip); 353 gfs2_consist_inode(ip);
355 return -EIO; 354 return -EIO;
356 } 355 }