diff options
Diffstat (limited to 'fs/gfs2/dir.c')
-rw-r--r-- | fs/gfs2/dir.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index b9dd88a78dd4..5c356d09c321 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -79,6 +79,9 @@ | |||
79 | #define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) | 79 | #define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) |
80 | #define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) | 80 | #define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) |
81 | 81 | ||
82 | struct qstr gfs2_qdot __read_mostly; | ||
83 | struct qstr gfs2_qdotdot __read_mostly; | ||
84 | |||
82 | typedef int (*leaf_call_t) (struct gfs2_inode *dip, u32 index, u32 len, | 85 | typedef int (*leaf_call_t) (struct gfs2_inode *dip, u32 index, u32 len, |
83 | u64 leaf_no, void *data); | 86 | u64 leaf_no, void *data); |
84 | typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent, | 87 | typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent, |
@@ -127,8 +130,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf, | |||
127 | 130 | ||
128 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 131 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
129 | memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); | 132 | memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); |
130 | if (ip->i_disksize < offset + size) | 133 | if (ip->i_inode.i_size < offset + size) |
131 | ip->i_disksize = offset + size; | 134 | i_size_write(&ip->i_inode, offset + size); |
132 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; | 135 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; |
133 | gfs2_dinode_out(ip, dibh->b_data); | 136 | gfs2_dinode_out(ip, dibh->b_data); |
134 | 137 | ||
@@ -225,8 +228,8 @@ out: | |||
225 | if (error) | 228 | if (error) |
226 | return error; | 229 | return error; |
227 | 230 | ||
228 | if (ip->i_disksize < offset + copied) | 231 | if (ip->i_inode.i_size < offset + copied) |
229 | ip->i_disksize = offset + copied; | 232 | i_size_write(&ip->i_inode, offset + copied); |
230 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; | 233 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; |
231 | 234 | ||
232 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 235 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
@@ -275,12 +278,13 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset, | |||
275 | unsigned int o; | 278 | unsigned int o; |
276 | int copied = 0; | 279 | int copied = 0; |
277 | int error = 0; | 280 | int error = 0; |
281 | u64 disksize = i_size_read(&ip->i_inode); | ||
278 | 282 | ||
279 | if (offset >= ip->i_disksize) | 283 | if (offset >= disksize) |
280 | return 0; | 284 | return 0; |
281 | 285 | ||
282 | if (offset + size > ip->i_disksize) | 286 | if (offset + size > disksize) |
283 | size = ip->i_disksize - offset; | 287 | size = disksize - offset; |
284 | 288 | ||
285 | if (!size) | 289 | if (!size) |
286 | return 0; | 290 | return 0; |
@@ -727,7 +731,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, | |||
727 | unsigned hsize = 1 << ip->i_depth; | 731 | unsigned hsize = 1 << ip->i_depth; |
728 | unsigned index; | 732 | unsigned index; |
729 | u64 ln; | 733 | u64 ln; |
730 | if (hsize * sizeof(u64) != ip->i_disksize) { | 734 | if (hsize * sizeof(u64) != i_size_read(inode)) { |
731 | gfs2_consist_inode(ip); | 735 | gfs2_consist_inode(ip); |
732 | return ERR_PTR(-EIO); | 736 | return ERR_PTR(-EIO); |
733 | } | 737 | } |
@@ -879,7 +883,7 @@ static int dir_make_exhash(struct inode *inode) | |||
879 | for (x = sdp->sd_hash_ptrs; x--; lp++) | 883 | for (x = sdp->sd_hash_ptrs; x--; lp++) |
880 | *lp = cpu_to_be64(bn); | 884 | *lp = cpu_to_be64(bn); |
881 | 885 | ||
882 | dip->i_disksize = sdp->sd_sb.sb_bsize / 2; | 886 | i_size_write(inode, sdp->sd_sb.sb_bsize / 2); |
883 | gfs2_add_inode_blocks(&dip->i_inode, 1); | 887 | gfs2_add_inode_blocks(&dip->i_inode, 1); |
884 | dip->i_diskflags |= GFS2_DIF_EXHASH; | 888 | dip->i_diskflags |= GFS2_DIF_EXHASH; |
885 | 889 | ||
@@ -1057,11 +1061,12 @@ static int dir_double_exhash(struct gfs2_inode *dip) | |||
1057 | u64 *buf; | 1061 | u64 *buf; |
1058 | u64 *from, *to; | 1062 | u64 *from, *to; |
1059 | u64 block; | 1063 | u64 block; |
1064 | u64 disksize = i_size_read(&dip->i_inode); | ||
1060 | int x; | 1065 | int x; |
1061 | int error = 0; | 1066 | int error = 0; |
1062 | 1067 | ||
1063 | hsize = 1 << dip->i_depth; | 1068 | hsize = 1 << dip->i_depth; |
1064 | if (hsize * sizeof(u64) != dip->i_disksize) { | 1069 | if (hsize * sizeof(u64) != disksize) { |
1065 | gfs2_consist_inode(dip); | 1070 | gfs2_consist_inode(dip); |
1066 | return -EIO; | 1071 | return -EIO; |
1067 | } | 1072 | } |
@@ -1072,7 +1077,7 @@ static int dir_double_exhash(struct gfs2_inode *dip) | |||
1072 | if (!buf) | 1077 | if (!buf) |
1073 | return -ENOMEM; | 1078 | return -ENOMEM; |
1074 | 1079 | ||
1075 | for (block = dip->i_disksize >> sdp->sd_hash_bsize_shift; block--;) { | 1080 | for (block = disksize >> sdp->sd_hash_bsize_shift; block--;) { |
1076 | error = gfs2_dir_read_data(dip, (char *)buf, | 1081 | error = gfs2_dir_read_data(dip, (char *)buf, |
1077 | block * sdp->sd_hash_bsize, | 1082 | block * sdp->sd_hash_bsize, |
1078 | sdp->sd_hash_bsize, 1); | 1083 | sdp->sd_hash_bsize, 1); |
@@ -1370,7 +1375,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, | |||
1370 | unsigned depth = 0; | 1375 | unsigned depth = 0; |
1371 | 1376 | ||
1372 | hsize = 1 << dip->i_depth; | 1377 | hsize = 1 << dip->i_depth; |
1373 | if (hsize * sizeof(u64) != dip->i_disksize) { | 1378 | if (hsize * sizeof(u64) != i_size_read(inode)) { |
1374 | gfs2_consist_inode(dip); | 1379 | gfs2_consist_inode(dip); |
1375 | return -EIO; | 1380 | return -EIO; |
1376 | } | 1381 | } |
@@ -1784,7 +1789,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data) | |||
1784 | int error = 0; | 1789 | int error = 0; |
1785 | 1790 | ||
1786 | hsize = 1 << dip->i_depth; | 1791 | hsize = 1 << dip->i_depth; |
1787 | if (hsize * sizeof(u64) != dip->i_disksize) { | 1792 | if (hsize * sizeof(u64) != i_size_read(&dip->i_inode)) { |
1788 | gfs2_consist_inode(dip); | 1793 | gfs2_consist_inode(dip); |
1789 | return -EIO; | 1794 | return -EIO; |
1790 | } | 1795 | } |