diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/Makefile | 2 | ||||
-rw-r--r-- | fs/gfs2/bmap.c | 4 | ||||
-rw-r--r-- | fs/gfs2/dir.c | 2 | ||||
-rw-r--r-- | fs/gfs2/eattr.c | 6 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 63 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 83 | ||||
-rw-r--r-- | fs/gfs2/inode.h | 10 | ||||
-rw-r--r-- | fs/gfs2/ondisk.c | 246 | ||||
-rw-r--r-- | fs/gfs2/ops_export.c | 10 | ||||
-rw-r--r-- | fs/gfs2/ops_export.h | 22 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 13 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.h | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_inode.c | 4 | ||||
-rw-r--r-- | fs/gfs2/ops_vm.c | 2 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 42 | ||||
-rw-r--r-- | fs/gfs2/recovery.c | 22 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 111 | ||||
-rw-r--r-- | fs/gfs2/super.c | 77 | ||||
-rw-r--r-- | fs/gfs2/super.h | 2 | ||||
-rw-r--r-- | fs/gfs2/util.c | 2 |
20 files changed, 372 insertions, 352 deletions
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index e3f1ada643ac..04ad0caebedb 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | obj-$(CONFIG_GFS2_FS) += gfs2.o | 1 | obj-$(CONFIG_GFS2_FS) += gfs2.o |
2 | gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ | 2 | gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ |
3 | glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \ | 3 | glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \ |
4 | mount.o ondisk.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ | 4 | mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ |
5 | ops_fstype.o ops_inode.o ops_super.o ops_vm.o quota.o \ | 5 | ops_fstype.o ops_inode.o ops_super.o ops_vm.o quota.o \ |
6 | recovery.o rgrp.o super.o sys.o trans.o util.o | 6 | recovery.o rgrp.o super.o sys.o trans.o util.o |
7 | 7 | ||
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index e76a887a89b2..b784cf3c6482 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -718,7 +718,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
718 | for (x = 0; x < rlist.rl_rgrps; x++) { | 718 | for (x = 0; x < rlist.rl_rgrps; x++) { |
719 | struct gfs2_rgrpd *rgd; | 719 | struct gfs2_rgrpd *rgd; |
720 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; | 720 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; |
721 | rg_blocks += rgd->rd_ri.ri_length; | 721 | rg_blocks += rgd->rd_length; |
722 | } | 722 | } |
723 | 723 | ||
724 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); | 724 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); |
@@ -824,7 +824,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size) | |||
824 | goto out_gunlock_q; | 824 | goto out_gunlock_q; |
825 | 825 | ||
826 | error = gfs2_trans_begin(sdp, | 826 | error = gfs2_trans_begin(sdp, |
827 | sdp->sd_max_height + al->al_rgd->rd_ri.ri_length + | 827 | sdp->sd_max_height + al->al_rgd->rd_length + |
828 | RES_JDATA + RES_DINODE + RES_STATFS + RES_QUOTA, 0); | 828 | RES_JDATA + RES_DINODE + RES_STATFS + RES_QUOTA, 0); |
829 | if (error) | 829 | if (error) |
830 | goto out_ipres; | 830 | goto out_ipres; |
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 9cdd71cef59c..2f154049b59d 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -1897,7 +1897,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | |||
1897 | for (x = 0; x < rlist.rl_rgrps; x++) { | 1897 | for (x = 0; x < rlist.rl_rgrps; x++) { |
1898 | struct gfs2_rgrpd *rgd; | 1898 | struct gfs2_rgrpd *rgd; |
1899 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; | 1899 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; |
1900 | rg_blocks += rgd->rd_ri.ri_length; | 1900 | rg_blocks += rgd->rd_length; |
1901 | } | 1901 | } |
1902 | 1902 | ||
1903 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); | 1903 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); |
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 5b83ca6acab1..40e1d37112e6 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c | |||
@@ -254,7 +254,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, | |||
254 | if (error) | 254 | if (error) |
255 | return error; | 255 | return error; |
256 | 256 | ||
257 | error = gfs2_trans_begin(sdp, rgd->rd_ri.ri_length + RES_DINODE + | 257 | error = gfs2_trans_begin(sdp, rgd->rd_length + RES_DINODE + |
258 | RES_EATTR + RES_STATFS + RES_QUOTA, blks); | 258 | RES_EATTR + RES_STATFS + RES_QUOTA, blks); |
259 | if (error) | 259 | if (error) |
260 | goto out_gunlock; | 260 | goto out_gunlock; |
@@ -700,7 +700,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, | |||
700 | goto out_gunlock_q; | 700 | goto out_gunlock_q; |
701 | 701 | ||
702 | error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), | 702 | error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), |
703 | blks + al->al_rgd->rd_ri.ri_length + | 703 | blks + al->al_rgd->rd_length + |
704 | RES_DINODE + RES_STATFS + RES_QUOTA, 0); | 704 | RES_DINODE + RES_STATFS + RES_QUOTA, 0); |
705 | if (error) | 705 | if (error) |
706 | goto out_ipres; | 706 | goto out_ipres; |
@@ -1352,7 +1352,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) | |||
1352 | for (x = 0; x < rlist.rl_rgrps; x++) { | 1352 | for (x = 0; x < rlist.rl_rgrps; x++) { |
1353 | struct gfs2_rgrpd *rgd; | 1353 | struct gfs2_rgrpd *rgd; |
1354 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; | 1354 | rgd = rlist.rl_ghs[x].gh_gl->gl_object; |
1355 | rg_blocks += rgd->rd_ri.ri_length; | 1355 | rg_blocks += rgd->rd_length; |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); | 1358 | error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs); |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index b2079fcd2513..e5069b912d5e 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -28,6 +28,14 @@ struct gfs2_sbd; | |||
28 | 28 | ||
29 | typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret); | 29 | typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret); |
30 | 30 | ||
31 | struct gfs2_log_header_host { | ||
32 | u64 lh_sequence; /* Sequence number of this transaction */ | ||
33 | u32 lh_flags; /* GFS2_LOG_HEAD_... */ | ||
34 | u32 lh_tail; /* Block number of log tail */ | ||
35 | u32 lh_blkno; | ||
36 | u32 lh_hash; | ||
37 | }; | ||
38 | |||
31 | /* | 39 | /* |
32 | * Structure of operations that are associated with each | 40 | * Structure of operations that are associated with each |
33 | * type of element in the log. | 41 | * type of element in the log. |
@@ -60,12 +68,23 @@ struct gfs2_bitmap { | |||
60 | u32 bi_len; | 68 | u32 bi_len; |
61 | }; | 69 | }; |
62 | 70 | ||
71 | struct gfs2_rgrp_host { | ||
72 | u32 rg_flags; | ||
73 | u32 rg_free; | ||
74 | u32 rg_dinodes; | ||
75 | u64 rg_igeneration; | ||
76 | }; | ||
77 | |||
63 | struct gfs2_rgrpd { | 78 | struct gfs2_rgrpd { |
64 | struct list_head rd_list; /* Link with superblock */ | 79 | struct list_head rd_list; /* Link with superblock */ |
65 | struct list_head rd_list_mru; | 80 | struct list_head rd_list_mru; |
66 | struct list_head rd_recent; /* Recently used rgrps */ | 81 | struct list_head rd_recent; /* Recently used rgrps */ |
67 | struct gfs2_glock *rd_gl; /* Glock for this rgrp */ | 82 | struct gfs2_glock *rd_gl; /* Glock for this rgrp */ |
68 | struct gfs2_rindex_host rd_ri; | 83 | u64 rd_addr; /* grp block disk address */ |
84 | u64 rd_data0; /* first data location */ | ||
85 | u32 rd_length; /* length of rgrp header in fs blocks */ | ||
86 | u32 rd_data; /* num of data blocks in rgrp */ | ||
87 | u32 rd_bitbytes; /* number of bytes in data bitmaps */ | ||
69 | struct gfs2_rgrp_host rd_rg; | 88 | struct gfs2_rgrp_host rd_rg; |
70 | u64 rd_rg_vn; | 89 | u64 rd_rg_vn; |
71 | struct gfs2_bitmap *rd_bits; | 90 | struct gfs2_bitmap *rd_bits; |
@@ -211,6 +230,20 @@ enum { | |||
211 | GIF_SW_PAGED = 3, | 230 | GIF_SW_PAGED = 3, |
212 | }; | 231 | }; |
213 | 232 | ||
233 | struct gfs2_dinode_host { | ||
234 | u64 di_size; /* number of bytes in file */ | ||
235 | u64 di_blocks; /* number of blocks in file */ | ||
236 | u64 di_goal_meta; /* rgrp to alloc from next */ | ||
237 | u64 di_goal_data; /* data block goal */ | ||
238 | u64 di_generation; /* generation number for NFS */ | ||
239 | u32 di_flags; /* GFS2_DIF_... */ | ||
240 | u16 di_height; /* height of metadata */ | ||
241 | /* These only apply to directories */ | ||
242 | u16 di_depth; /* Number of bits in the table */ | ||
243 | u32 di_entries; /* The number of entries in the directory */ | ||
244 | u64 di_eattr; /* extended attribute block number */ | ||
245 | }; | ||
246 | |||
214 | struct gfs2_inode { | 247 | struct gfs2_inode { |
215 | struct inode i_inode; | 248 | struct inode i_inode; |
216 | u64 i_no_addr; | 249 | u64 i_no_addr; |
@@ -346,6 +379,12 @@ struct gfs2_jdesc { | |||
346 | unsigned int jd_blocks; | 379 | unsigned int jd_blocks; |
347 | }; | 380 | }; |
348 | 381 | ||
382 | struct gfs2_statfs_change_host { | ||
383 | s64 sc_total; | ||
384 | s64 sc_free; | ||
385 | s64 sc_dinodes; | ||
386 | }; | ||
387 | |||
349 | #define GFS2_GLOCKD_DEFAULT 1 | 388 | #define GFS2_GLOCKD_DEFAULT 1 |
350 | #define GFS2_GLOCKD_MAX 16 | 389 | #define GFS2_GLOCKD_MAX 16 |
351 | 390 | ||
@@ -418,6 +457,28 @@ enum { | |||
418 | 457 | ||
419 | #define GFS2_FSNAME_LEN 256 | 458 | #define GFS2_FSNAME_LEN 256 |
420 | 459 | ||
460 | struct gfs2_inum_host { | ||
461 | u64 no_formal_ino; | ||
462 | u64 no_addr; | ||
463 | }; | ||
464 | |||
465 | struct gfs2_sb_host { | ||
466 | u32 sb_magic; | ||
467 | u32 sb_type; | ||
468 | u32 sb_format; | ||
469 | |||
470 | u32 sb_fs_format; | ||
471 | u32 sb_multihost_format; | ||
472 | u32 sb_bsize; | ||
473 | u32 sb_bsize_shift; | ||
474 | |||
475 | struct gfs2_inum_host sb_master_dir; | ||
476 | struct gfs2_inum_host sb_root_dir; | ||
477 | |||
478 | char sb_lockproto[GFS2_LOCKNAME_LEN]; | ||
479 | char sb_locktable[GFS2_LOCKNAME_LEN]; | ||
480 | }; | ||
481 | |||
421 | struct gfs2_sbd { | 482 | struct gfs2_sbd { |
422 | struct super_block *sd_vfs; | 483 | struct super_block *sd_vfs; |
423 | struct super_block *sd_vfs_meta; | 484 | struct super_block *sd_vfs_meta; |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 58f5a67e1c35..a31a4b80ba3c 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -38,6 +38,11 @@ | |||
38 | #include "trans.h" | 38 | #include "trans.h" |
39 | #include "util.h" | 39 | #include "util.h" |
40 | 40 | ||
41 | struct gfs2_inum_range_host { | ||
42 | u64 ir_start; | ||
43 | u64 ir_length; | ||
44 | }; | ||
45 | |||
41 | static int iget_test(struct inode *inode, void *opaque) | 46 | static int iget_test(struct inode *inode, void *opaque) |
42 | { | 47 | { |
43 | struct gfs2_inode *ip = GFS2_I(inode); | 48 | struct gfs2_inode *ip = GFS2_I(inode); |
@@ -402,6 +407,22 @@ out: | |||
402 | return inode ? inode : ERR_PTR(error); | 407 | return inode ? inode : ERR_PTR(error); |
403 | } | 408 | } |
404 | 409 | ||
410 | static void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf) | ||
411 | { | ||
412 | const struct gfs2_inum_range *str = buf; | ||
413 | |||
414 | ir->ir_start = be64_to_cpu(str->ir_start); | ||
415 | ir->ir_length = be64_to_cpu(str->ir_length); | ||
416 | } | ||
417 | |||
418 | static void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf) | ||
419 | { | ||
420 | struct gfs2_inum_range *str = buf; | ||
421 | |||
422 | str->ir_start = cpu_to_be64(ir->ir_start); | ||
423 | str->ir_length = cpu_to_be64(ir->ir_length); | ||
424 | } | ||
425 | |||
405 | static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino) | 426 | static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino) |
406 | { | 427 | { |
407 | struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); | 428 | struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); |
@@ -741,7 +762,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, | |||
741 | goto fail_quota_locks; | 762 | goto fail_quota_locks; |
742 | 763 | ||
743 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + | 764 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
744 | al->al_rgd->rd_ri.ri_length + | 765 | al->al_rgd->rd_length + |
745 | 2 * RES_DINODE + | 766 | 2 * RES_DINODE + |
746 | RES_STATFS + RES_QUOTA, 0); | 767 | RES_STATFS + RES_QUOTA, 0); |
747 | if (error) | 768 | if (error) |
@@ -1234,3 +1255,63 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) | |||
1234 | return error; | 1255 | return error; |
1235 | } | 1256 | } |
1236 | 1257 | ||
1258 | void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) | ||
1259 | { | ||
1260 | const struct gfs2_dinode_host *di = &ip->i_di; | ||
1261 | struct gfs2_dinode *str = buf; | ||
1262 | |||
1263 | str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | ||
1264 | str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI); | ||
1265 | str->di_header.__pad0 = 0; | ||
1266 | str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI); | ||
1267 | str->di_header.__pad1 = 0; | ||
1268 | str->di_num.no_addr = cpu_to_be64(ip->i_no_addr); | ||
1269 | str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); | ||
1270 | str->di_mode = cpu_to_be32(ip->i_inode.i_mode); | ||
1271 | str->di_uid = cpu_to_be32(ip->i_inode.i_uid); | ||
1272 | str->di_gid = cpu_to_be32(ip->i_inode.i_gid); | ||
1273 | str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); | ||
1274 | str->di_size = cpu_to_be64(di->di_size); | ||
1275 | str->di_blocks = cpu_to_be64(di->di_blocks); | ||
1276 | str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); | ||
1277 | str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); | ||
1278 | str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec); | ||
1279 | |||
1280 | str->di_goal_meta = cpu_to_be64(di->di_goal_meta); | ||
1281 | str->di_goal_data = cpu_to_be64(di->di_goal_data); | ||
1282 | str->di_generation = cpu_to_be64(di->di_generation); | ||
1283 | |||
1284 | str->di_flags = cpu_to_be32(di->di_flags); | ||
1285 | str->di_height = cpu_to_be16(di->di_height); | ||
1286 | str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && | ||
1287 | !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? | ||
1288 | GFS2_FORMAT_DE : 0); | ||
1289 | str->di_depth = cpu_to_be16(di->di_depth); | ||
1290 | str->di_entries = cpu_to_be32(di->di_entries); | ||
1291 | |||
1292 | str->di_eattr = cpu_to_be64(di->di_eattr); | ||
1293 | } | ||
1294 | |||
1295 | void gfs2_dinode_print(const struct gfs2_inode *ip) | ||
1296 | { | ||
1297 | const struct gfs2_dinode_host *di = &ip->i_di; | ||
1298 | |||
1299 | printk(KERN_INFO " no_formal_ino = %llu\n", | ||
1300 | (unsigned long long)ip->i_no_formal_ino); | ||
1301 | printk(KERN_INFO " no_addr = %llu\n", | ||
1302 | (unsigned long long)ip->i_no_addr); | ||
1303 | printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); | ||
1304 | printk(KERN_INFO " di_blocks = %llu\n", | ||
1305 | (unsigned long long)di->di_blocks); | ||
1306 | printk(KERN_INFO " di_goal_meta = %llu\n", | ||
1307 | (unsigned long long)di->di_goal_meta); | ||
1308 | printk(KERN_INFO " di_goal_data = %llu\n", | ||
1309 | (unsigned long long)di->di_goal_data); | ||
1310 | printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags); | ||
1311 | printk(KERN_INFO " di_height = %u\n", di->di_height); | ||
1312 | printk(KERN_INFO " di_depth = %u\n", di->di_depth); | ||
1313 | printk(KERN_INFO " di_entries = %u\n", di->di_entries); | ||
1314 | printk(KERN_INFO " di_eattr = %llu\n", | ||
1315 | (unsigned long long)di->di_eattr); | ||
1316 | } | ||
1317 | |||
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 05fc095d8540..35375fc43fa3 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -38,6 +38,14 @@ static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr, | |||
38 | return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino; | 38 | return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino; |
39 | } | 39 | } |
40 | 40 | ||
41 | static inline void gfs2_inum_out(const struct gfs2_inode *ip, | ||
42 | struct gfs2_dirent *dent) | ||
43 | { | ||
44 | dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); | ||
45 | dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr); | ||
46 | } | ||
47 | |||
48 | |||
41 | void gfs2_inode_attr_in(struct gfs2_inode *ip); | 49 | void gfs2_inode_attr_in(struct gfs2_inode *ip); |
42 | struct inode *gfs2_inode_lookup(struct super_block *sb, u64 no_addr, unsigned type); | 50 | struct inode *gfs2_inode_lookup(struct super_block *sb, u64 no_addr, unsigned type); |
43 | struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr); | 51 | struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr); |
@@ -59,6 +67,8 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); | |||
59 | int gfs2_glock_nq_atime(struct gfs2_holder *gh); | 67 | int gfs2_glock_nq_atime(struct gfs2_holder *gh); |
60 | int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); | 68 | int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); |
61 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); | 69 | struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); |
70 | void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf); | ||
71 | void gfs2_dinode_print(const struct gfs2_inode *ip); | ||
62 | 72 | ||
63 | #endif /* __INODE_DOT_H__ */ | 73 | #endif /* __INODE_DOT_H__ */ |
64 | 74 | ||
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c deleted file mode 100644 index a5b05ea3d4c7..000000000000 --- a/fs/gfs2/ondisk.c +++ /dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
5 | * This copyrighted material is made available to anyone wishing to use, | ||
6 | * modify, copy, or redistribute it subject to the terms and conditions | ||
7 | * of the GNU General Public License version 2. | ||
8 | */ | ||
9 | |||
10 | #include <linux/slab.h> | ||
11 | #include <linux/spinlock.h> | ||
12 | #include <linux/completion.h> | ||
13 | #include <linux/buffer_head.h> | ||
14 | |||
15 | #include "gfs2.h" | ||
16 | #include <linux/gfs2_ondisk.h> | ||
17 | #include <linux/lm_interface.h> | ||
18 | #include "incore.h" | ||
19 | |||
20 | #define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ | ||
21 | struct->member); | ||
22 | |||
23 | /* | ||
24 | * gfs2_xxx_in - read in an xxx struct | ||
25 | * first arg: the cpu-order structure | ||
26 | * buf: the disk-order buffer | ||
27 | * | ||
28 | * gfs2_xxx_out - write out an xxx struct | ||
29 | * first arg: the cpu-order structure | ||
30 | * buf: the disk-order buffer | ||
31 | * | ||
32 | * gfs2_xxx_print - print out an xxx struct | ||
33 | * first arg: the cpu-order structure | ||
34 | */ | ||
35 | |||
36 | void gfs2_inum_out(const struct gfs2_inode *ip, struct gfs2_dirent *dent) | ||
37 | { | ||
38 | dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); | ||
39 | dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr); | ||
40 | } | ||
41 | |||
42 | static void gfs2_meta_header_in(struct gfs2_meta_header_host *mh, const void *buf) | ||
43 | { | ||
44 | const struct gfs2_meta_header *str = buf; | ||
45 | |||
46 | mh->mh_magic = be32_to_cpu(str->mh_magic); | ||
47 | mh->mh_type = be32_to_cpu(str->mh_type); | ||
48 | mh->mh_format = be32_to_cpu(str->mh_format); | ||
49 | } | ||
50 | |||
51 | void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf) | ||
52 | { | ||
53 | const struct gfs2_sb *str = buf; | ||
54 | |||
55 | gfs2_meta_header_in(&sb->sb_header, buf); | ||
56 | |||
57 | sb->sb_fs_format = be32_to_cpu(str->sb_fs_format); | ||
58 | sb->sb_multihost_format = be32_to_cpu(str->sb_multihost_format); | ||
59 | sb->sb_bsize = be32_to_cpu(str->sb_bsize); | ||
60 | sb->sb_bsize_shift = be32_to_cpu(str->sb_bsize_shift); | ||
61 | sb->sb_master_dir.no_addr = be64_to_cpu(str->sb_master_dir.no_addr); | ||
62 | sb->sb_master_dir.no_formal_ino = be64_to_cpu(str->sb_master_dir.no_formal_ino); | ||
63 | sb->sb_root_dir.no_addr = be64_to_cpu(str->sb_root_dir.no_addr); | ||
64 | sb->sb_root_dir.no_formal_ino = be64_to_cpu(str->sb_root_dir.no_formal_ino); | ||
65 | |||
66 | memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN); | ||
67 | memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); | ||
68 | } | ||
69 | |||
70 | void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf) | ||
71 | { | ||
72 | const struct gfs2_rindex *str = buf; | ||
73 | |||
74 | ri->ri_addr = be64_to_cpu(str->ri_addr); | ||
75 | ri->ri_length = be32_to_cpu(str->ri_length); | ||
76 | ri->ri_data0 = be64_to_cpu(str->ri_data0); | ||
77 | ri->ri_data = be32_to_cpu(str->ri_data); | ||
78 | ri->ri_bitbytes = be32_to_cpu(str->ri_bitbytes); | ||
79 | |||
80 | } | ||
81 | |||
82 | void gfs2_rindex_print(const struct gfs2_rindex_host *ri) | ||
83 | { | ||
84 | printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr); | ||
85 | pv(ri, ri_length, "%u"); | ||
86 | |||
87 | printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)ri->ri_data0); | ||
88 | pv(ri, ri_data, "%u"); | ||
89 | |||
90 | pv(ri, ri_bitbytes, "%u"); | ||
91 | } | ||
92 | |||
93 | void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf) | ||
94 | { | ||
95 | const struct gfs2_rgrp *str = buf; | ||
96 | |||
97 | rg->rg_flags = be32_to_cpu(str->rg_flags); | ||
98 | rg->rg_free = be32_to_cpu(str->rg_free); | ||
99 | rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); | ||
100 | rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); | ||
101 | } | ||
102 | |||
103 | void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf) | ||
104 | { | ||
105 | struct gfs2_rgrp *str = buf; | ||
106 | |||
107 | str->rg_flags = cpu_to_be32(rg->rg_flags); | ||
108 | str->rg_free = cpu_to_be32(rg->rg_free); | ||
109 | str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); | ||
110 | str->__pad = cpu_to_be32(0); | ||
111 | str->rg_igeneration = cpu_to_be64(rg->rg_igeneration); | ||
112 | memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); | ||
113 | } | ||
114 | |||
115 | void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf) | ||
116 | { | ||
117 | const struct gfs2_quota *str = buf; | ||
118 | |||
119 | qu->qu_limit = be64_to_cpu(str->qu_limit); | ||
120 | qu->qu_warn = be64_to_cpu(str->qu_warn); | ||
121 | qu->qu_value = be64_to_cpu(str->qu_value); | ||
122 | } | ||
123 | |||
124 | void gfs2_quota_out(const struct gfs2_quota_host *qu, void *buf) | ||
125 | { | ||
126 | struct gfs2_quota *str = buf; | ||
127 | |||
128 | str->qu_limit = cpu_to_be64(qu->qu_limit); | ||
129 | str->qu_warn = cpu_to_be64(qu->qu_warn); | ||
130 | str->qu_value = cpu_to_be64(qu->qu_value); | ||
131 | memset(&str->qu_reserved, 0, sizeof(str->qu_reserved)); | ||
132 | } | ||
133 | |||
134 | void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) | ||
135 | { | ||
136 | const struct gfs2_dinode_host *di = &ip->i_di; | ||
137 | struct gfs2_dinode *str = buf; | ||
138 | |||
139 | str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); | ||
140 | str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI); | ||
141 | str->di_header.__pad0 = 0; | ||
142 | str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI); | ||
143 | str->di_header.__pad1 = 0; | ||
144 | str->di_num.no_addr = cpu_to_be64(ip->i_no_addr); | ||
145 | str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); | ||
146 | str->di_mode = cpu_to_be32(ip->i_inode.i_mode); | ||
147 | str->di_uid = cpu_to_be32(ip->i_inode.i_uid); | ||
148 | str->di_gid = cpu_to_be32(ip->i_inode.i_gid); | ||
149 | str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); | ||
150 | str->di_size = cpu_to_be64(di->di_size); | ||
151 | str->di_blocks = cpu_to_be64(di->di_blocks); | ||
152 | str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); | ||
153 | str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); | ||
154 | str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec); | ||
155 | |||
156 | str->di_goal_meta = cpu_to_be64(di->di_goal_meta); | ||
157 | str->di_goal_data = cpu_to_be64(di->di_goal_data); | ||
158 | str->di_generation = cpu_to_be64(di->di_generation); | ||
159 | |||
160 | str->di_flags = cpu_to_be32(di->di_flags); | ||
161 | str->di_height = cpu_to_be16(di->di_height); | ||
162 | str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && | ||
163 | !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? | ||
164 | GFS2_FORMAT_DE : 0); | ||
165 | str->di_depth = cpu_to_be16(di->di_depth); | ||
166 | str->di_entries = cpu_to_be32(di->di_entries); | ||
167 | |||
168 | str->di_eattr = cpu_to_be64(di->di_eattr); | ||
169 | } | ||
170 | |||
171 | void gfs2_dinode_print(const struct gfs2_inode *ip) | ||
172 | { | ||
173 | const struct gfs2_dinode_host *di = &ip->i_di; | ||
174 | |||
175 | printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)ip->i_no_formal_ino); | ||
176 | printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)ip->i_no_addr); | ||
177 | |||
178 | printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); | ||
179 | printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks); | ||
180 | printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); | ||
181 | printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); | ||
182 | |||
183 | pv(di, di_flags, "0x%.8X"); | ||
184 | pv(di, di_height, "%u"); | ||
185 | |||
186 | pv(di, di_depth, "%u"); | ||
187 | pv(di, di_entries, "%u"); | ||
188 | |||
189 | printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr); | ||
190 | } | ||
191 | |||
192 | void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf) | ||
193 | { | ||
194 | const struct gfs2_log_header *str = buf; | ||
195 | |||
196 | gfs2_meta_header_in(&lh->lh_header, buf); | ||
197 | lh->lh_sequence = be64_to_cpu(str->lh_sequence); | ||
198 | lh->lh_flags = be32_to_cpu(str->lh_flags); | ||
199 | lh->lh_tail = be32_to_cpu(str->lh_tail); | ||
200 | lh->lh_blkno = be32_to_cpu(str->lh_blkno); | ||
201 | lh->lh_hash = be32_to_cpu(str->lh_hash); | ||
202 | } | ||
203 | |||
204 | void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf) | ||
205 | { | ||
206 | const struct gfs2_inum_range *str = buf; | ||
207 | |||
208 | ir->ir_start = be64_to_cpu(str->ir_start); | ||
209 | ir->ir_length = be64_to_cpu(str->ir_length); | ||
210 | } | ||
211 | |||
212 | void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf) | ||
213 | { | ||
214 | struct gfs2_inum_range *str = buf; | ||
215 | |||
216 | str->ir_start = cpu_to_be64(ir->ir_start); | ||
217 | str->ir_length = cpu_to_be64(ir->ir_length); | ||
218 | } | ||
219 | |||
220 | void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf) | ||
221 | { | ||
222 | const struct gfs2_statfs_change *str = buf; | ||
223 | |||
224 | sc->sc_total = be64_to_cpu(str->sc_total); | ||
225 | sc->sc_free = be64_to_cpu(str->sc_free); | ||
226 | sc->sc_dinodes = be64_to_cpu(str->sc_dinodes); | ||
227 | } | ||
228 | |||
229 | void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf) | ||
230 | { | ||
231 | struct gfs2_statfs_change *str = buf; | ||
232 | |||
233 | str->sc_total = cpu_to_be64(sc->sc_total); | ||
234 | str->sc_free = cpu_to_be64(sc->sc_free); | ||
235 | str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); | ||
236 | } | ||
237 | |||
238 | void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf) | ||
239 | { | ||
240 | const struct gfs2_quota_change *str = buf; | ||
241 | |||
242 | qc->qc_change = be64_to_cpu(str->qc_change); | ||
243 | qc->qc_flags = be32_to_cpu(str->qc_flags); | ||
244 | qc->qc_id = be32_to_cpu(str->qc_id); | ||
245 | } | ||
246 | |||
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 51a8a14deb29..d07230ee5fc0 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c | |||
@@ -22,10 +22,18 @@ | |||
22 | #include "glops.h" | 22 | #include "glops.h" |
23 | #include "inode.h" | 23 | #include "inode.h" |
24 | #include "ops_dentry.h" | 24 | #include "ops_dentry.h" |
25 | #include "ops_export.h" | 25 | #include "ops_fstype.h" |
26 | #include "rgrp.h" | 26 | #include "rgrp.h" |
27 | #include "util.h" | 27 | #include "util.h" |
28 | 28 | ||
29 | #define GFS2_SMALL_FH_SIZE 4 | ||
30 | #define GFS2_LARGE_FH_SIZE 10 | ||
31 | |||
32 | struct gfs2_fh_obj { | ||
33 | struct gfs2_inum_host this; | ||
34 | u32 imode; | ||
35 | }; | ||
36 | |||
29 | static struct dentry *gfs2_decode_fh(struct super_block *sb, | 37 | static struct dentry *gfs2_decode_fh(struct super_block *sb, |
30 | __u32 *p, | 38 | __u32 *p, |
31 | int fh_len, | 39 | int fh_len, |
diff --git a/fs/gfs2/ops_export.h b/fs/gfs2/ops_export.h deleted file mode 100644 index f925a955b3b8..000000000000 --- a/fs/gfs2/ops_export.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
5 | * This copyrighted material is made available to anyone wishing to use, | ||
6 | * modify, copy, or redistribute it subject to the terms and conditions | ||
7 | * of the GNU General Public License version 2. | ||
8 | */ | ||
9 | |||
10 | #ifndef __OPS_EXPORT_DOT_H__ | ||
11 | #define __OPS_EXPORT_DOT_H__ | ||
12 | |||
13 | #define GFS2_SMALL_FH_SIZE 4 | ||
14 | #define GFS2_LARGE_FH_SIZE 10 | ||
15 | |||
16 | extern struct export_operations gfs2_export_ops; | ||
17 | struct gfs2_fh_obj { | ||
18 | struct gfs2_inum_host this; | ||
19 | __u32 imode; | ||
20 | }; | ||
21 | |||
22 | #endif /* __OPS_EXPORT_DOT_H__ */ | ||
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c682371717ff..0443e255173d 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "inode.h" | 27 | #include "inode.h" |
28 | #include "lm.h" | 28 | #include "lm.h" |
29 | #include "mount.h" | 29 | #include "mount.h" |
30 | #include "ops_export.h" | ||
31 | #include "ops_fstype.h" | 30 | #include "ops_fstype.h" |
32 | #include "ops_super.h" | 31 | #include "ops_super.h" |
33 | #include "recovery.h" | 32 | #include "recovery.h" |
@@ -116,7 +115,6 @@ static void init_vfs(struct super_block *sb, unsigned noatime) | |||
116 | 115 | ||
117 | static int init_names(struct gfs2_sbd *sdp, int silent) | 116 | static int init_names(struct gfs2_sbd *sdp, int silent) |
118 | { | 117 | { |
119 | struct page *page; | ||
120 | char *proto, *table; | 118 | char *proto, *table; |
121 | int error = 0; | 119 | int error = 0; |
122 | 120 | ||
@@ -126,14 +124,9 @@ static int init_names(struct gfs2_sbd *sdp, int silent) | |||
126 | /* Try to autodetect */ | 124 | /* Try to autodetect */ |
127 | 125 | ||
128 | if (!proto[0] || !table[0]) { | 126 | if (!proto[0] || !table[0]) { |
129 | struct gfs2_sb *sb; | 127 | error = gfs2_read_super(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); |
130 | page = gfs2_read_super(sdp->sd_vfs, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); | 128 | if (error) |
131 | if (!page) | 129 | return error; |
132 | return -ENOBUFS; | ||
133 | sb = kmap(page); | ||
134 | gfs2_sb_in(&sdp->sd_sb, sb); | ||
135 | kunmap(page); | ||
136 | __free_page(page); | ||
137 | 130 | ||
138 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); | 131 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); |
139 | if (error) | 132 | if (error) |
diff --git a/fs/gfs2/ops_fstype.h b/fs/gfs2/ops_fstype.h index 7cc2c296271b..407029b3b2b3 100644 --- a/fs/gfs2/ops_fstype.h +++ b/fs/gfs2/ops_fstype.h | |||
@@ -14,5 +14,6 @@ | |||
14 | 14 | ||
15 | extern struct file_system_type gfs2_fs_type; | 15 | extern struct file_system_type gfs2_fs_type; |
16 | extern struct file_system_type gfs2meta_fs_type; | 16 | extern struct file_system_type gfs2meta_fs_type; |
17 | extern struct export_operations gfs2_export_ops; | ||
17 | 18 | ||
18 | #endif /* __OPS_FSTYPE_DOT_H__ */ | 19 | #endif /* __OPS_FSTYPE_DOT_H__ */ |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index f8ecfec4064b..919a661e4f79 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -206,7 +206,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, | |||
206 | goto out_gunlock_q; | 206 | goto out_gunlock_q; |
207 | 207 | ||
208 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + | 208 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
209 | al->al_rgd->rd_ri.ri_length + | 209 | al->al_rgd->rd_length + |
210 | 2 * RES_DINODE + RES_STATFS + | 210 | 2 * RES_DINODE + RES_STATFS + |
211 | RES_QUOTA, 0); | 211 | RES_QUOTA, 0); |
212 | if (error) | 212 | if (error) |
@@ -711,7 +711,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
711 | goto out_gunlock_q; | 711 | goto out_gunlock_q; |
712 | 712 | ||
713 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + | 713 | error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + |
714 | al->al_rgd->rd_ri.ri_length + | 714 | al->al_rgd->rd_length + |
715 | 4 * RES_DINODE + 4 * RES_LEAF + | 715 | 4 * RES_DINODE + 4 * RES_LEAF + |
716 | RES_STATFS + RES_QUOTA + 4, 0); | 716 | RES_STATFS + RES_QUOTA + 4, 0); |
717 | if (error) | 717 | if (error) |
diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index aa0dbd2aac1b..404b7cc9f8c4 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c | |||
@@ -66,7 +66,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) | |||
66 | if (error) | 66 | if (error) |
67 | goto out_gunlock_q; | 67 | goto out_gunlock_q; |
68 | 68 | ||
69 | error = gfs2_trans_begin(sdp, al->al_rgd->rd_ri.ri_length + | 69 | error = gfs2_trans_begin(sdp, al->al_rgd->rd_length + |
70 | ind_blocks + RES_DINODE + | 70 | ind_blocks + RES_DINODE + |
71 | RES_STATFS + RES_QUOTA, 0); | 71 | RES_STATFS + RES_QUOTA, 0); |
72 | if (error) | 72 | if (error) |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 8a58815dea08..6e546ee8f3d4 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -66,6 +66,18 @@ | |||
66 | #define QUOTA_USER 1 | 66 | #define QUOTA_USER 1 |
67 | #define QUOTA_GROUP 0 | 67 | #define QUOTA_GROUP 0 |
68 | 68 | ||
69 | struct gfs2_quota_host { | ||
70 | u64 qu_limit; | ||
71 | u64 qu_warn; | ||
72 | s64 qu_value; | ||
73 | }; | ||
74 | |||
75 | struct gfs2_quota_change_host { | ||
76 | u64 qc_change; | ||
77 | u32 qc_flags; /* GFS2_QCF_... */ | ||
78 | u32 qc_id; | ||
79 | }; | ||
80 | |||
69 | static u64 qd2offset(struct gfs2_quota_data *qd) | 81 | static u64 qd2offset(struct gfs2_quota_data *qd) |
70 | { | 82 | { |
71 | u64 offset; | 83 | u64 offset; |
@@ -561,6 +573,25 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change) | |||
561 | mutex_unlock(&sdp->sd_quota_mutex); | 573 | mutex_unlock(&sdp->sd_quota_mutex); |
562 | } | 574 | } |
563 | 575 | ||
576 | static void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf) | ||
577 | { | ||
578 | const struct gfs2_quota *str = buf; | ||
579 | |||
580 | qu->qu_limit = be64_to_cpu(str->qu_limit); | ||
581 | qu->qu_warn = be64_to_cpu(str->qu_warn); | ||
582 | qu->qu_value = be64_to_cpu(str->qu_value); | ||
583 | } | ||
584 | |||
585 | static void gfs2_quota_out(const struct gfs2_quota_host *qu, void *buf) | ||
586 | { | ||
587 | struct gfs2_quota *str = buf; | ||
588 | |||
589 | str->qu_limit = cpu_to_be64(qu->qu_limit); | ||
590 | str->qu_warn = cpu_to_be64(qu->qu_warn); | ||
591 | str->qu_value = cpu_to_be64(qu->qu_value); | ||
592 | memset(&str->qu_reserved, 0, sizeof(str->qu_reserved)); | ||
593 | } | ||
594 | |||
564 | /** | 595 | /** |
565 | * gfs2_adjust_quota | 596 | * gfs2_adjust_quota |
566 | * | 597 | * |
@@ -694,7 +725,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
694 | goto out_alloc; | 725 | goto out_alloc; |
695 | 726 | ||
696 | error = gfs2_trans_begin(sdp, | 727 | error = gfs2_trans_begin(sdp, |
697 | al->al_rgd->rd_ri.ri_length + | 728 | al->al_rgd->rd_length + |
698 | num_qd * data_blocks + | 729 | num_qd * data_blocks + |
699 | nalloc * ind_blocks + | 730 | nalloc * ind_blocks + |
700 | RES_DINODE + num_qd + | 731 | RES_DINODE + num_qd + |
@@ -1055,6 +1086,15 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) | |||
1055 | return error; | 1086 | return error; |
1056 | } | 1087 | } |
1057 | 1088 | ||
1089 | static void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf) | ||
1090 | { | ||
1091 | const struct gfs2_quota_change *str = buf; | ||
1092 | |||
1093 | qc->qc_change = be64_to_cpu(str->qc_change); | ||
1094 | qc->qc_flags = be32_to_cpu(str->qc_flags); | ||
1095 | qc->qc_id = be32_to_cpu(str->qc_id); | ||
1096 | } | ||
1097 | |||
1058 | int gfs2_quota_init(struct gfs2_sbd *sdp) | 1098 | int gfs2_quota_init(struct gfs2_sbd *sdp) |
1059 | { | 1099 | { |
1060 | struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); | 1100 | struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); |
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 8bc182c7e2ef..5ada38c99a2c 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c | |||
@@ -116,6 +116,22 @@ void gfs2_revoke_clean(struct gfs2_sbd *sdp) | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | static int gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf) | ||
120 | { | ||
121 | const struct gfs2_log_header *str = buf; | ||
122 | |||
123 | if (str->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) || | ||
124 | str->lh_header.mh_type != cpu_to_be32(GFS2_METATYPE_LH)) | ||
125 | return 1; | ||
126 | |||
127 | lh->lh_sequence = be64_to_cpu(str->lh_sequence); | ||
128 | lh->lh_flags = be32_to_cpu(str->lh_flags); | ||
129 | lh->lh_tail = be32_to_cpu(str->lh_tail); | ||
130 | lh->lh_blkno = be32_to_cpu(str->lh_blkno); | ||
131 | lh->lh_hash = be32_to_cpu(str->lh_hash); | ||
132 | return 0; | ||
133 | } | ||
134 | |||
119 | /** | 135 | /** |
120 | * get_log_header - read the log header for a given segment | 136 | * get_log_header - read the log header for a given segment |
121 | * @jd: the journal | 137 | * @jd: the journal |
@@ -147,12 +163,10 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, | |||
147 | sizeof(u32)); | 163 | sizeof(u32)); |
148 | hash = crc32_le(hash, (unsigned char const *)¬hing, sizeof(nothing)); | 164 | hash = crc32_le(hash, (unsigned char const *)¬hing, sizeof(nothing)); |
149 | hash ^= (u32)~0; | 165 | hash ^= (u32)~0; |
150 | gfs2_log_header_in(&lh, bh->b_data); | 166 | error = gfs2_log_header_in(&lh, bh->b_data); |
151 | brelse(bh); | 167 | brelse(bh); |
152 | 168 | ||
153 | if (lh.lh_header.mh_magic != GFS2_MAGIC || | 169 | if (error || lh.lh_blkno != blk || lh.lh_hash != hash) |
154 | lh.lh_header.mh_type != GFS2_METATYPE_LH || | ||
155 | lh.lh_blkno != blk || lh.lh_hash != hash) | ||
156 | return 1; | 170 | return 1; |
157 | 171 | ||
158 | *head = lh; | 172 | *head = lh; |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 30eb428065c5..027f6ec5b0d9 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -204,7 +204,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
204 | { | 204 | { |
205 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 205 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
206 | struct gfs2_bitmap *bi = NULL; | 206 | struct gfs2_bitmap *bi = NULL; |
207 | u32 length = rgd->rd_ri.ri_length; | 207 | u32 length = rgd->rd_length; |
208 | u32 count[4], tmp; | 208 | u32 count[4], tmp; |
209 | int buf, x; | 209 | int buf, x; |
210 | 210 | ||
@@ -227,7 +227,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
227 | return; | 227 | return; |
228 | } | 228 | } |
229 | 229 | ||
230 | tmp = rgd->rd_ri.ri_data - | 230 | tmp = rgd->rd_data - |
231 | rgd->rd_rg.rg_free - | 231 | rgd->rd_rg.rg_free - |
232 | rgd->rd_rg.rg_dinodes; | 232 | rgd->rd_rg.rg_dinodes; |
233 | if (count[1] + count[2] != tmp) { | 233 | if (count[1] + count[2] != tmp) { |
@@ -253,10 +253,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) | |||
253 | 253 | ||
254 | } | 254 | } |
255 | 255 | ||
256 | static inline int rgrp_contains_block(struct gfs2_rindex_host *ri, u64 block) | 256 | static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block) |
257 | { | 257 | { |
258 | u64 first = ri->ri_data0; | 258 | u64 first = rgd->rd_data0; |
259 | u64 last = first + ri->ri_data; | 259 | u64 last = first + rgd->rd_data; |
260 | return first <= block && block < last; | 260 | return first <= block && block < last; |
261 | } | 261 | } |
262 | 262 | ||
@@ -275,7 +275,7 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk) | |||
275 | spin_lock(&sdp->sd_rindex_spin); | 275 | spin_lock(&sdp->sd_rindex_spin); |
276 | 276 | ||
277 | list_for_each_entry(rgd, &sdp->sd_rindex_mru_list, rd_list_mru) { | 277 | list_for_each_entry(rgd, &sdp->sd_rindex_mru_list, rd_list_mru) { |
278 | if (rgrp_contains_block(&rgd->rd_ri, blk)) { | 278 | if (rgrp_contains_block(rgd, blk)) { |
279 | list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); | 279 | list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); |
280 | spin_unlock(&sdp->sd_rindex_spin); | 280 | spin_unlock(&sdp->sd_rindex_spin); |
281 | return rgd; | 281 | return rgd; |
@@ -354,6 +354,15 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) | |||
354 | mutex_unlock(&sdp->sd_rindex_mutex); | 354 | mutex_unlock(&sdp->sd_rindex_mutex); |
355 | } | 355 | } |
356 | 356 | ||
357 | static void gfs2_rindex_print(const struct gfs2_rgrpd *rgd) | ||
358 | { | ||
359 | printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)rgd->rd_addr); | ||
360 | printk(KERN_INFO " ri_length = %u\n", rgd->rd_length); | ||
361 | printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)rgd->rd_data0); | ||
362 | printk(KERN_INFO " ri_data = %u\n", rgd->rd_data); | ||
363 | printk(KERN_INFO " ri_bitbytes = %u\n", rgd->rd_bitbytes); | ||
364 | } | ||
365 | |||
357 | /** | 366 | /** |
358 | * gfs2_compute_bitstructs - Compute the bitmap sizes | 367 | * gfs2_compute_bitstructs - Compute the bitmap sizes |
359 | * @rgd: The resource group descriptor | 368 | * @rgd: The resource group descriptor |
@@ -367,7 +376,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
367 | { | 376 | { |
368 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 377 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
369 | struct gfs2_bitmap *bi; | 378 | struct gfs2_bitmap *bi; |
370 | u32 length = rgd->rd_ri.ri_length; /* # blocks in hdr & bitmap */ | 379 | u32 length = rgd->rd_length; /* # blocks in hdr & bitmap */ |
371 | u32 bytes_left, bytes; | 380 | u32 bytes_left, bytes; |
372 | int x; | 381 | int x; |
373 | 382 | ||
@@ -378,7 +387,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
378 | if (!rgd->rd_bits) | 387 | if (!rgd->rd_bits) |
379 | return -ENOMEM; | 388 | return -ENOMEM; |
380 | 389 | ||
381 | bytes_left = rgd->rd_ri.ri_bitbytes; | 390 | bytes_left = rgd->rd_bitbytes; |
382 | 391 | ||
383 | for (x = 0; x < length; x++) { | 392 | for (x = 0; x < length; x++) { |
384 | bi = rgd->rd_bits + x; | 393 | bi = rgd->rd_bits + x; |
@@ -399,14 +408,14 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
399 | } else if (x + 1 == length) { | 408 | } else if (x + 1 == length) { |
400 | bytes = bytes_left; | 409 | bytes = bytes_left; |
401 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 410 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
402 | bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; | 411 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
403 | bi->bi_len = bytes; | 412 | bi->bi_len = bytes; |
404 | /* other blocks */ | 413 | /* other blocks */ |
405 | } else { | 414 | } else { |
406 | bytes = sdp->sd_sb.sb_bsize - | 415 | bytes = sdp->sd_sb.sb_bsize - |
407 | sizeof(struct gfs2_meta_header); | 416 | sizeof(struct gfs2_meta_header); |
408 | bi->bi_offset = sizeof(struct gfs2_meta_header); | 417 | bi->bi_offset = sizeof(struct gfs2_meta_header); |
409 | bi->bi_start = rgd->rd_ri.ri_bitbytes - bytes_left; | 418 | bi->bi_start = rgd->rd_bitbytes - bytes_left; |
410 | bi->bi_len = bytes; | 419 | bi->bi_len = bytes; |
411 | } | 420 | } |
412 | 421 | ||
@@ -418,9 +427,9 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
418 | return -EIO; | 427 | return -EIO; |
419 | } | 428 | } |
420 | bi = rgd->rd_bits + (length - 1); | 429 | bi = rgd->rd_bits + (length - 1); |
421 | if ((bi->bi_start + bi->bi_len) * GFS2_NBBY != rgd->rd_ri.ri_data) { | 430 | if ((bi->bi_start + bi->bi_len) * GFS2_NBBY != rgd->rd_data) { |
422 | if (gfs2_consist_rgrpd(rgd)) { | 431 | if (gfs2_consist_rgrpd(rgd)) { |
423 | gfs2_rindex_print(&rgd->rd_ri); | 432 | gfs2_rindex_print(rgd); |
424 | fs_err(sdp, "start=%u len=%u offset=%u\n", | 433 | fs_err(sdp, "start=%u len=%u offset=%u\n", |
425 | bi->bi_start, bi->bi_len, bi->bi_offset); | 434 | bi->bi_start, bi->bi_len, bi->bi_offset); |
426 | } | 435 | } |
@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) | |||
431 | } | 440 | } |
432 | 441 | ||
433 | /** | 442 | /** |
443 | |||
434 | * gfs2_ri_total - Total up the file system space, according to the rindex. | 444 | * gfs2_ri_total - Total up the file system space, according to the rindex. |
435 | * | 445 | * |
436 | */ | 446 | */ |
@@ -439,7 +449,6 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) | |||
439 | u64 total_data = 0; | 449 | u64 total_data = 0; |
440 | struct inode *inode = sdp->sd_rindex; | 450 | struct inode *inode = sdp->sd_rindex; |
441 | struct gfs2_inode *ip = GFS2_I(inode); | 451 | struct gfs2_inode *ip = GFS2_I(inode); |
442 | struct gfs2_rindex_host ri; | ||
443 | char buf[sizeof(struct gfs2_rindex)]; | 452 | char buf[sizeof(struct gfs2_rindex)]; |
444 | struct file_ra_state ra_state; | 453 | struct file_ra_state ra_state; |
445 | int error, rgrps; | 454 | int error, rgrps; |
@@ -455,13 +464,23 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp) | |||
455 | sizeof(struct gfs2_rindex)); | 464 | sizeof(struct gfs2_rindex)); |
456 | if (error != sizeof(struct gfs2_rindex)) | 465 | if (error != sizeof(struct gfs2_rindex)) |
457 | break; | 466 | break; |
458 | gfs2_rindex_in(&ri, buf); | 467 | total_data += be32_to_cpu(((struct gfs2_rindex *)buf)->ri_data); |
459 | total_data += ri.ri_data; | ||
460 | } | 468 | } |
461 | mutex_unlock(&sdp->sd_rindex_mutex); | 469 | mutex_unlock(&sdp->sd_rindex_mutex); |
462 | return total_data; | 470 | return total_data; |
463 | } | 471 | } |
464 | 472 | ||
473 | static void gfs2_rindex_in(struct gfs2_rgrpd *rgd, const void *buf) | ||
474 | { | ||
475 | const struct gfs2_rindex *str = buf; | ||
476 | |||
477 | rgd->rd_addr = be64_to_cpu(str->ri_addr); | ||
478 | rgd->rd_length = be32_to_cpu(str->ri_length); | ||
479 | rgd->rd_data0 = be64_to_cpu(str->ri_data0); | ||
480 | rgd->rd_data = be32_to_cpu(str->ri_data); | ||
481 | rgd->rd_bitbytes = be32_to_cpu(str->ri_bitbytes); | ||
482 | } | ||
483 | |||
465 | /** | 484 | /** |
466 | * read_rindex_entry - Pull in a new resource index entry from the disk | 485 | * read_rindex_entry - Pull in a new resource index entry from the disk |
467 | * @gl: The glock covering the rindex inode | 486 | * @gl: The glock covering the rindex inode |
@@ -500,12 +519,12 @@ static int read_rindex_entry(struct gfs2_inode *ip, | |||
500 | list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); | 519 | list_add_tail(&rgd->rd_list, &sdp->sd_rindex_list); |
501 | list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); | 520 | list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); |
502 | 521 | ||
503 | gfs2_rindex_in(&rgd->rd_ri, buf); | 522 | gfs2_rindex_in(rgd, buf); |
504 | error = compute_bitstructs(rgd); | 523 | error = compute_bitstructs(rgd); |
505 | if (error) | 524 | if (error) |
506 | return error; | 525 | return error; |
507 | 526 | ||
508 | error = gfs2_glock_get(sdp, rgd->rd_ri.ri_addr, | 527 | error = gfs2_glock_get(sdp, rgd->rd_addr, |
509 | &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); | 528 | &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); |
510 | if (error) | 529 | if (error) |
511 | return error; | 530 | return error; |
@@ -626,6 +645,28 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) | |||
626 | return error; | 645 | return error; |
627 | } | 646 | } |
628 | 647 | ||
648 | static void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf) | ||
649 | { | ||
650 | const struct gfs2_rgrp *str = buf; | ||
651 | |||
652 | rg->rg_flags = be32_to_cpu(str->rg_flags); | ||
653 | rg->rg_free = be32_to_cpu(str->rg_free); | ||
654 | rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); | ||
655 | rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); | ||
656 | } | ||
657 | |||
658 | static void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf) | ||
659 | { | ||
660 | struct gfs2_rgrp *str = buf; | ||
661 | |||
662 | str->rg_flags = cpu_to_be32(rg->rg_flags); | ||
663 | str->rg_free = cpu_to_be32(rg->rg_free); | ||
664 | str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); | ||
665 | str->__pad = cpu_to_be32(0); | ||
666 | str->rg_igeneration = cpu_to_be64(rg->rg_igeneration); | ||
667 | memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); | ||
668 | } | ||
669 | |||
629 | /** | 670 | /** |
630 | * gfs2_rgrp_bh_get - Read in a RG's header and bitmaps | 671 | * gfs2_rgrp_bh_get - Read in a RG's header and bitmaps |
631 | * @rgd: the struct gfs2_rgrpd describing the RG to read in | 672 | * @rgd: the struct gfs2_rgrpd describing the RG to read in |
@@ -640,7 +681,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
640 | { | 681 | { |
641 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 682 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
642 | struct gfs2_glock *gl = rgd->rd_gl; | 683 | struct gfs2_glock *gl = rgd->rd_gl; |
643 | unsigned int length = rgd->rd_ri.ri_length; | 684 | unsigned int length = rgd->rd_length; |
644 | struct gfs2_bitmap *bi; | 685 | struct gfs2_bitmap *bi; |
645 | unsigned int x, y; | 686 | unsigned int x, y; |
646 | int error; | 687 | int error; |
@@ -658,7 +699,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
658 | 699 | ||
659 | for (x = 0; x < length; x++) { | 700 | for (x = 0; x < length; x++) { |
660 | bi = rgd->rd_bits + x; | 701 | bi = rgd->rd_bits + x; |
661 | error = gfs2_meta_read(gl, rgd->rd_ri.ri_addr + x, 0, &bi->bi_bh); | 702 | error = gfs2_meta_read(gl, rgd->rd_addr + x, 0, &bi->bi_bh); |
662 | if (error) | 703 | if (error) |
663 | goto fail; | 704 | goto fail; |
664 | } | 705 | } |
@@ -720,7 +761,7 @@ void gfs2_rgrp_bh_hold(struct gfs2_rgrpd *rgd) | |||
720 | void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) | 761 | void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) |
721 | { | 762 | { |
722 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 763 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
723 | int x, length = rgd->rd_ri.ri_length; | 764 | int x, length = rgd->rd_length; |
724 | 765 | ||
725 | spin_lock(&sdp->sd_rindex_spin); | 766 | spin_lock(&sdp->sd_rindex_spin); |
726 | gfs2_assert_warn(rgd->rd_sbd, rgd->rd_bh_count); | 767 | gfs2_assert_warn(rgd->rd_sbd, rgd->rd_bh_count); |
@@ -743,7 +784,7 @@ void gfs2_rgrp_bh_put(struct gfs2_rgrpd *rgd) | |||
743 | void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) | 784 | void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) |
744 | { | 785 | { |
745 | struct gfs2_sbd *sdp = rgd->rd_sbd; | 786 | struct gfs2_sbd *sdp = rgd->rd_sbd; |
746 | unsigned int length = rgd->rd_ri.ri_length; | 787 | unsigned int length = rgd->rd_length; |
747 | unsigned int x; | 788 | unsigned int x; |
748 | 789 | ||
749 | for (x = 0; x < length; x++) { | 790 | for (x = 0; x < length; x++) { |
@@ -826,7 +867,7 @@ static struct gfs2_rgrpd *recent_rgrp_first(struct gfs2_sbd *sdp, | |||
826 | goto first; | 867 | goto first; |
827 | 868 | ||
828 | list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) { | 869 | list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) { |
829 | if (rgd->rd_ri.ri_addr == rglast) | 870 | if (rgd->rd_addr == rglast) |
830 | goto out; | 871 | goto out; |
831 | } | 872 | } |
832 | 873 | ||
@@ -1037,7 +1078,7 @@ static int get_local_rgrp(struct gfs2_inode *ip) | |||
1037 | } | 1078 | } |
1038 | 1079 | ||
1039 | out: | 1080 | out: |
1040 | ip->i_last_rg_alloc = rgd->rd_ri.ri_addr; | 1081 | ip->i_last_rg_alloc = rgd->rd_addr; |
1041 | 1082 | ||
1042 | if (begin) { | 1083 | if (begin) { |
1043 | recent_rgrp_add(rgd); | 1084 | recent_rgrp_add(rgd); |
@@ -1128,8 +1169,8 @@ unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block) | |||
1128 | unsigned int buf; | 1169 | unsigned int buf; |
1129 | unsigned char type; | 1170 | unsigned char type; |
1130 | 1171 | ||
1131 | length = rgd->rd_ri.ri_length; | 1172 | length = rgd->rd_length; |
1132 | rgrp_block = block - rgd->rd_ri.ri_data0; | 1173 | rgrp_block = block - rgd->rd_data0; |
1133 | 1174 | ||
1134 | for (buf = 0; buf < length; buf++) { | 1175 | for (buf = 0; buf < length; buf++) { |
1135 | bi = rgd->rd_bits + buf; | 1176 | bi = rgd->rd_bits + buf; |
@@ -1171,7 +1212,7 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal, | |||
1171 | unsigned char old_state, unsigned char new_state) | 1212 | unsigned char old_state, unsigned char new_state) |
1172 | { | 1213 | { |
1173 | struct gfs2_bitmap *bi = NULL; | 1214 | struct gfs2_bitmap *bi = NULL; |
1174 | u32 length = rgd->rd_ri.ri_length; | 1215 | u32 length = rgd->rd_length; |
1175 | u32 blk = 0; | 1216 | u32 blk = 0; |
1176 | unsigned int buf, x; | 1217 | unsigned int buf, x; |
1177 | 1218 | ||
@@ -1247,9 +1288,9 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, | |||
1247 | return NULL; | 1288 | return NULL; |
1248 | } | 1289 | } |
1249 | 1290 | ||
1250 | length = rgd->rd_ri.ri_length; | 1291 | length = rgd->rd_length; |
1251 | 1292 | ||
1252 | rgrp_blk = bstart - rgd->rd_ri.ri_data0; | 1293 | rgrp_blk = bstart - rgd->rd_data0; |
1253 | 1294 | ||
1254 | while (blen--) { | 1295 | while (blen--) { |
1255 | for (buf = 0; buf < length; buf++) { | 1296 | for (buf = 0; buf < length; buf++) { |
@@ -1293,15 +1334,15 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip) | |||
1293 | u32 goal, blk; | 1334 | u32 goal, blk; |
1294 | u64 block; | 1335 | u64 block; |
1295 | 1336 | ||
1296 | if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_data)) | 1337 | if (rgrp_contains_block(rgd, ip->i_di.di_goal_data)) |
1297 | goal = ip->i_di.di_goal_data - rgd->rd_ri.ri_data0; | 1338 | goal = ip->i_di.di_goal_data - rgd->rd_data0; |
1298 | else | 1339 | else |
1299 | goal = rgd->rd_last_alloc_data; | 1340 | goal = rgd->rd_last_alloc_data; |
1300 | 1341 | ||
1301 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); | 1342 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); |
1302 | rgd->rd_last_alloc_data = blk; | 1343 | rgd->rd_last_alloc_data = blk; |
1303 | 1344 | ||
1304 | block = rgd->rd_ri.ri_data0 + blk; | 1345 | block = rgd->rd_data0 + blk; |
1305 | ip->i_di.di_goal_data = block; | 1346 | ip->i_di.di_goal_data = block; |
1306 | 1347 | ||
1307 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1348 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
@@ -1337,15 +1378,15 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip) | |||
1337 | u32 goal, blk; | 1378 | u32 goal, blk; |
1338 | u64 block; | 1379 | u64 block; |
1339 | 1380 | ||
1340 | if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_meta)) | 1381 | if (rgrp_contains_block(rgd, ip->i_di.di_goal_meta)) |
1341 | goal = ip->i_di.di_goal_meta - rgd->rd_ri.ri_data0; | 1382 | goal = ip->i_di.di_goal_meta - rgd->rd_data0; |
1342 | else | 1383 | else |
1343 | goal = rgd->rd_last_alloc_meta; | 1384 | goal = rgd->rd_last_alloc_meta; |
1344 | 1385 | ||
1345 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); | 1386 | blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); |
1346 | rgd->rd_last_alloc_meta = blk; | 1387 | rgd->rd_last_alloc_meta = blk; |
1347 | 1388 | ||
1348 | block = rgd->rd_ri.ri_data0 + blk; | 1389 | block = rgd->rd_data0 + blk; |
1349 | ip->i_di.di_goal_meta = block; | 1390 | ip->i_di.di_goal_meta = block; |
1350 | 1391 | ||
1351 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1392 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
@@ -1387,7 +1428,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation) | |||
1387 | 1428 | ||
1388 | rgd->rd_last_alloc_meta = blk; | 1429 | rgd->rd_last_alloc_meta = blk; |
1389 | 1430 | ||
1390 | block = rgd->rd_ri.ri_data0 + blk; | 1431 | block = rgd->rd_data0 + blk; |
1391 | 1432 | ||
1392 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); | 1433 | gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); |
1393 | rgd->rd_rg.rg_free--; | 1434 | rgd->rd_rg.rg_free--; |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index faccffd19907..f916b9740c75 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -95,8 +95,8 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent) | |||
95 | { | 95 | { |
96 | unsigned int x; | 96 | unsigned int x; |
97 | 97 | ||
98 | if (sb->sb_header.mh_magic != GFS2_MAGIC || | 98 | if (sb->sb_magic != GFS2_MAGIC || |
99 | sb->sb_header.mh_type != GFS2_METATYPE_SB) { | 99 | sb->sb_type != GFS2_METATYPE_SB) { |
100 | if (!silent) | 100 | if (!silent) |
101 | printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n"); | 101 | printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n"); |
102 | return -EINVAL; | 102 | return -EINVAL; |
@@ -174,10 +174,31 @@ static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error) | |||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | static void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf) | ||
178 | { | ||
179 | const struct gfs2_sb *str = buf; | ||
180 | |||
181 | sb->sb_magic = be32_to_cpu(str->sb_header.mh_magic); | ||
182 | sb->sb_type = be32_to_cpu(str->sb_header.mh_type); | ||
183 | sb->sb_format = be32_to_cpu(str->sb_header.mh_format); | ||
184 | sb->sb_fs_format = be32_to_cpu(str->sb_fs_format); | ||
185 | sb->sb_multihost_format = be32_to_cpu(str->sb_multihost_format); | ||
186 | sb->sb_bsize = be32_to_cpu(str->sb_bsize); | ||
187 | sb->sb_bsize_shift = be32_to_cpu(str->sb_bsize_shift); | ||
188 | sb->sb_master_dir.no_addr = be64_to_cpu(str->sb_master_dir.no_addr); | ||
189 | sb->sb_master_dir.no_formal_ino = be64_to_cpu(str->sb_master_dir.no_formal_ino); | ||
190 | sb->sb_root_dir.no_addr = be64_to_cpu(str->sb_root_dir.no_addr); | ||
191 | sb->sb_root_dir.no_formal_ino = be64_to_cpu(str->sb_root_dir.no_formal_ino); | ||
192 | |||
193 | memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN); | ||
194 | memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); | ||
195 | } | ||
196 | |||
177 | /** | 197 | /** |
178 | * gfs2_read_super - Read the gfs2 super block from disk | 198 | * gfs2_read_super - Read the gfs2 super block from disk |
179 | * @sb: The VFS super block | 199 | * @sdp: The GFS2 super block |
180 | * @sector: The location of the super block | 200 | * @sector: The location of the super block |
201 | * @error: The error code to return | ||
181 | * | 202 | * |
182 | * This uses the bio functions to read the super block from disk | 203 | * This uses the bio functions to read the super block from disk |
183 | * because we want to be 100% sure that we never read cached data. | 204 | * because we want to be 100% sure that we never read cached data. |
@@ -189,17 +210,19 @@ static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error) | |||
189 | * the master directory (contains pointers to journals etc) and the | 210 | * the master directory (contains pointers to journals etc) and the |
190 | * root directory. | 211 | * root directory. |
191 | * | 212 | * |
192 | * Returns: A page containing the sb or NULL | 213 | * Returns: 0 on success or error |
193 | */ | 214 | */ |
194 | 215 | ||
195 | struct page *gfs2_read_super(struct super_block *sb, sector_t sector) | 216 | int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector) |
196 | { | 217 | { |
218 | struct super_block *sb = sdp->sd_vfs; | ||
219 | struct gfs2_sb *p; | ||
197 | struct page *page; | 220 | struct page *page; |
198 | struct bio *bio; | 221 | struct bio *bio; |
199 | 222 | ||
200 | page = alloc_page(GFP_KERNEL); | 223 | page = alloc_page(GFP_KERNEL); |
201 | if (unlikely(!page)) | 224 | if (unlikely(!page)) |
202 | return NULL; | 225 | return -ENOBUFS; |
203 | 226 | ||
204 | ClearPageUptodate(page); | 227 | ClearPageUptodate(page); |
205 | ClearPageDirty(page); | 228 | ClearPageDirty(page); |
@@ -208,7 +231,7 @@ struct page *gfs2_read_super(struct super_block *sb, sector_t sector) | |||
208 | bio = bio_alloc(GFP_KERNEL, 1); | 231 | bio = bio_alloc(GFP_KERNEL, 1); |
209 | if (unlikely(!bio)) { | 232 | if (unlikely(!bio)) { |
210 | __free_page(page); | 233 | __free_page(page); |
211 | return NULL; | 234 | return -ENOBUFS; |
212 | } | 235 | } |
213 | 236 | ||
214 | bio->bi_sector = sector * (sb->s_blocksize >> 9); | 237 | bio->bi_sector = sector * (sb->s_blocksize >> 9); |
@@ -222,9 +245,13 @@ struct page *gfs2_read_super(struct super_block *sb, sector_t sector) | |||
222 | bio_put(bio); | 245 | bio_put(bio); |
223 | if (!PageUptodate(page)) { | 246 | if (!PageUptodate(page)) { |
224 | __free_page(page); | 247 | __free_page(page); |
225 | return NULL; | 248 | return -EIO; |
226 | } | 249 | } |
227 | return page; | 250 | p = kmap(page); |
251 | gfs2_sb_in(&sdp->sd_sb, p); | ||
252 | kunmap(page); | ||
253 | __free_page(page); | ||
254 | return 0; | ||
228 | } | 255 | } |
229 | 256 | ||
230 | /** | 257 | /** |
@@ -241,19 +268,13 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) | |||
241 | u32 tmp_blocks; | 268 | u32 tmp_blocks; |
242 | unsigned int x; | 269 | unsigned int x; |
243 | int error; | 270 | int error; |
244 | struct page *page; | ||
245 | char *sb; | ||
246 | 271 | ||
247 | page = gfs2_read_super(sdp->sd_vfs, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); | 272 | error = gfs2_read_super(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); |
248 | if (!page) { | 273 | if (error) { |
249 | if (!silent) | 274 | if (!silent) |
250 | fs_err(sdp, "can't read superblock\n"); | 275 | fs_err(sdp, "can't read superblock\n"); |
251 | return -EIO; | 276 | return error; |
252 | } | 277 | } |
253 | sb = kmap(page); | ||
254 | gfs2_sb_in(&sdp->sd_sb, sb); | ||
255 | kunmap(page); | ||
256 | __free_page(page); | ||
257 | 278 | ||
258 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); | 279 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); |
259 | if (error) | 280 | if (error) |
@@ -593,6 +614,24 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) | |||
593 | return error; | 614 | return error; |
594 | } | 615 | } |
595 | 616 | ||
617 | static void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf) | ||
618 | { | ||
619 | const struct gfs2_statfs_change *str = buf; | ||
620 | |||
621 | sc->sc_total = be64_to_cpu(str->sc_total); | ||
622 | sc->sc_free = be64_to_cpu(str->sc_free); | ||
623 | sc->sc_dinodes = be64_to_cpu(str->sc_dinodes); | ||
624 | } | ||
625 | |||
626 | static void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf) | ||
627 | { | ||
628 | struct gfs2_statfs_change *str = buf; | ||
629 | |||
630 | str->sc_total = cpu_to_be64(sc->sc_total); | ||
631 | str->sc_free = cpu_to_be64(sc->sc_free); | ||
632 | str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); | ||
633 | } | ||
634 | |||
596 | int gfs2_statfs_init(struct gfs2_sbd *sdp) | 635 | int gfs2_statfs_init(struct gfs2_sbd *sdp) |
597 | { | 636 | { |
598 | struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); | 637 | struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); |
@@ -772,7 +811,7 @@ static int statfs_slow_fill(struct gfs2_rgrpd *rgd, | |||
772 | struct gfs2_statfs_change_host *sc) | 811 | struct gfs2_statfs_change_host *sc) |
773 | { | 812 | { |
774 | gfs2_rgrp_verify(rgd); | 813 | gfs2_rgrp_verify(rgd); |
775 | sc->sc_total += rgd->rd_ri.ri_data; | 814 | sc->sc_total += rgd->rd_data; |
776 | sc->sc_free += rgd->rd_rg.rg_free; | 815 | sc->sc_free += rgd->rd_rg.rg_free; |
777 | sc->sc_dinodes += rgd->rd_rg.rg_dinodes; | 816 | sc->sc_dinodes += rgd->rd_rg.rg_dinodes; |
778 | return 0; | 817 | return 0; |
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index e590b2df11dc..60a870e430be 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h | |||
@@ -16,7 +16,7 @@ void gfs2_tune_init(struct gfs2_tune *gt); | |||
16 | 16 | ||
17 | int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent); | 17 | int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent); |
18 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); | 18 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); |
19 | struct page *gfs2_read_super(struct super_block *sb, sector_t sector); | 19 | int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector); |
20 | 20 | ||
21 | static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) | 21 | static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) |
22 | { | 22 | { |
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 3f5edc54e80a..424a0774eda8 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c | |||
@@ -137,7 +137,7 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, | |||
137 | "GFS2: fsid=%s: RG = %llu\n" | 137 | "GFS2: fsid=%s: RG = %llu\n" |
138 | "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", | 138 | "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", |
139 | sdp->sd_fsname, | 139 | sdp->sd_fsname, |
140 | sdp->sd_fsname, (unsigned long long)rgd->rd_ri.ri_addr, | 140 | sdp->sd_fsname, (unsigned long long)rgd->rd_addr, |
141 | sdp->sd_fsname, function, file, line); | 141 | sdp->sd_fsname, function, file, line); |
142 | return rv; | 142 | return rv; |
143 | } | 143 | } |